@@ -24,9 +24,11 @@ TabMMState::TabMMState(MMStateList *stateList, QWidget *parent) :
24
24
treeView = new QTreeView (this );
25
25
26
26
layoutMain = new QVBoxLayout ();
27
+ layoutButtonsTree = new QHBoxLayout ();
27
28
28
29
createToolBar ();
29
30
typeSelected (0 );
31
+ createLateralButtons ();
30
32
31
33
treeView->setModel (m_stateList);
32
34
treeView->setTextElideMode (Qt::ElideLeft);
@@ -35,10 +37,120 @@ TabMMState::TabMMState(MMStateList *stateList, QWidget *parent) :
35
37
treeView->show ();
36
38
37
39
layoutMain->addLayout (layoutBar);
38
- layoutMain->addWidget (treeView);
40
+ layoutButtonsTree->addLayout (layoutButton);
41
+ layoutButtonsTree->addWidget (treeView);
42
+ layoutMain->addLayout (layoutButtonsTree);
39
43
this ->setLayout (layoutMain);
40
44
41
45
setAutoFillBackground (true );
46
+ resizeColumns ();
47
+
48
+ connect (treeView, SIGNAL (expanded (QModelIndex)), this , SLOT (resizeColumns ()));
49
+ }
50
+
51
+ void TabMMState::createToolBar ()
52
+ {
53
+ layoutBar = new QHBoxLayout ();
54
+
55
+ typeBox = new QComboBox (this );
56
+ typeBox->addItem (" Paint" );
57
+ typeBox->addItem (" Mapping" );
58
+ typeBox->setCurrentIndex (0 );
59
+ idLabel = new QLabel (" Id" , this );
60
+ idBox = new QSpinBox (this );
61
+ idBox->setMinimum (1 );
62
+ nameLine = new QLineEdit (" paint" , this );
63
+ paintTypeBox = new QComboBox (this );
64
+ paintTypeBox->addItem (" Media" );
65
+ paintTypeBox->addItem (" Color" );
66
+ paintTypeBox->addItem (" Camera" );
67
+ paintTypeBox->setCurrentIndex (0 );
68
+ uriLabel = new QLabel (" Choose->" , this );
69
+ uriButton = new QPushButton (" File" , this );
70
+ colorLabel = new QLabel (" Choose->" , this );
71
+ colorButton = new QPushButton (" Color" , this );
72
+ cameraLabel = new QLabel (" Choose->" , this );
73
+ cameraButton = new QPushButton (" Camera" , this );
74
+ opacityLabel = new QLabel (" opacity" , this );
75
+ opacityBox = new QSpinBox (this );
76
+ opacityBox->setMinimum (0 );
77
+ opacityBox->setMaximum (100 );
78
+ rateLabel = new QLabel (" rate" , this );
79
+ rateBox = new QSpinBox (this );
80
+ rateBox->setMaximum (1000 );
81
+ rateBox->setMinimum (-1000 );
82
+ volumeLabel = new QLabel (" volume" , this );
83
+ volumeBox = new QSpinBox (this );
84
+ volumeBox->setMaximum (100 );
85
+ volumeBox->setMinimum (0 );
86
+ visibleBox = new QCheckBox (" Visible" , this );
87
+ soloBox = new QCheckBox (" Solo" , this );
88
+ lockBox = new QCheckBox (" Locked" , this );
89
+ depthLabel = new QLabel (" depth" , this );
90
+ depthBox = new QSpinBox (this );
91
+ depthBox->setMinimum (1 );
92
+ addToStateButton = new QPushButton (" Add to State" , this );
93
+ addToStateButton->setToolTip (" Add to Initial Sate" );
94
+ addToStateButton->setToolTipDuration (2000 );
95
+
96
+ layoutBar->addWidget (typeBox);
97
+ layoutBar->addWidget (idLabel);
98
+ layoutBar->addWidget (idBox);
99
+ layoutBar->addWidget (nameLine);
100
+ layoutBar->addWidget (paintTypeBox);
101
+ layoutBar->addWidget (uriLabel);
102
+ layoutBar->addWidget (uriButton);
103
+ layoutBar->addWidget (colorLabel);
104
+ layoutBar->addWidget (colorButton);
105
+ layoutBar->addWidget (cameraLabel);
106
+ layoutBar->addWidget (cameraButton);
107
+ layoutBar->addWidget (opacityLabel);
108
+ layoutBar->addWidget (opacityBox);
109
+ layoutBar->addWidget (rateLabel);
110
+ layoutBar->addWidget (rateBox);
111
+ layoutBar->addWidget (volumeLabel);
112
+ layoutBar->addWidget (volumeBox);
113
+ layoutBar->addWidget (visibleBox);
114
+ layoutBar->addWidget (soloBox);
115
+ layoutBar->addWidget (lockBox);
116
+ layoutBar->addWidget (depthLabel);
117
+ layoutBar->addWidget (depthBox);
118
+ layoutBar->addStretch ();
119
+ layoutBar->addWidget (addToStateButton);
120
+
121
+ connect (typeBox, SIGNAL (currentIndexChanged (int )), this , SLOT (typeSelected (int )));
122
+ connect (paintTypeBox, SIGNAL (currentIndexChanged (int )), this , SLOT (paintTypeSelected (int )));
123
+ connect (addToStateButton, SIGNAL (clicked ()), this , SLOT (addToState ()));
124
+ connect (uriButton, SIGNAL (clicked ()), this , SLOT (setUriLabel ()));
125
+ connect (colorButton, SIGNAL (clicked ()), this , SLOT (setColorLabel ()));
126
+ connect (cameraButton, SIGNAL (clicked ()), this , SLOT (setCameraLabel ()));
127
+ }
128
+
129
+ void TabMMState::createLateralButtons ()
130
+ {
131
+ layoutButton = new QVBoxLayout ();
132
+
133
+ deleteButton = new QPushButton (" Delete" , this );
134
+ deleteButton->setToolTip (" Delete Paint or Mapping Selected" );
135
+ deleteButton->setToolTipDuration (2000 );
136
+ saveState1Button = new QPushButton (" Save State1" , this );
137
+ saveState1Button->setToolTip (" Save State 1 to File" );
138
+ saveState1Button->setToolTipDuration (2000 );
139
+ loadState1Button = new QPushButton (" Load State1" , this );
140
+ loadState1Button->setToolTip (" Load State 1 From File" );
141
+ loadState1Button->setToolTipDuration (2000 );
142
+ generateStatesButton = new QPushButton (" Generate states" , this );
143
+ generateStatesButton->setToolTip ((" generate States from Cues" ));
144
+
145
+ layoutButton->addWidget (deleteButton);
146
+ layoutButton->addWidget (saveState1Button);
147
+ layoutButton->addWidget (loadState1Button);
148
+ layoutButton->addWidget (generateStatesButton);
149
+
150
+ connect (deleteButton, SIGNAL (clicked ()), this , SLOT (deleteRow ()));
151
+ connect (saveState1Button, SIGNAL (clicked ()), this , SLOT (saveAs ()));
152
+ connect (loadState1Button, SIGNAL (clicked ()), this , SLOT (loadFile ()));
153
+ connect (generateStatesButton, SIGNAL (clicked ()), this , SLOT (generateStates ()));
42
154
}
43
155
44
156
void TabMMState::typeSelected (const int index)
@@ -351,95 +463,31 @@ void TabMMState::loadFile()
351
463
lineindex++;
352
464
}
353
465
file.close ();
354
- // hideShowColumns ();
466
+ resizeColumns ();
355
467
}
356
468
357
- void TabMMState::createToolBar ()
469
+ void TabMMState::deleteRow ()
358
470
{
359
- layoutBar = new QHBoxLayout ();
471
+ QModelIndex indexSelected = treeView->currentIndex ();
472
+ QModelIndex parentIndex = m_stateList->parent (indexSelected);
473
+ if (!indexSelected.isValid () || parentIndex == QModelIndex ()) return ;
474
+ QObject *item = m_stateList->getItem (indexSelected);
475
+ QString className = item->metaObject ()->className ();
476
+ if (className == " MMPaint" )
477
+ m_stateList->removePaint (0 , indexSelected.row ());
478
+ if (className == " MMMapping" ) m_stateList->removeMapping (0 , parentIndex.row (), indexSelected.row ());
479
+ return ;
480
+ }
360
481
361
- typeBox = new QComboBox (this );
362
- typeBox->addItem (" Paint" );
363
- typeBox->addItem (" Mapping" );
364
- typeBox->setCurrentIndex (0 );
365
- idLabel = new QLabel (" Id" , this );
366
- idBox = new QSpinBox (this );
367
- idBox->setMinimum (1 );
368
- nameLine = new QLineEdit (" paint" , this );
369
- paintTypeBox = new QComboBox (this );
370
- paintTypeBox->addItem (" Media" );
371
- paintTypeBox->addItem (" Color" );
372
- paintTypeBox->addItem (" Camera" );
373
- paintTypeBox->setCurrentIndex (0 );
374
- uriLabel = new QLabel (" Choose->" , this );
375
- uriButton = new QPushButton (" File" , this );
376
- colorLabel = new QLabel (" Choose->" , this );
377
- colorButton = new QPushButton (" Color" , this );
378
- cameraLabel = new QLabel (" Choose->" , this );
379
- cameraButton = new QPushButton (" Camera" , this );
380
- opacityLabel = new QLabel (" opacity" , this );
381
- opacityBox = new QSpinBox (this );
382
- opacityBox->setMinimum (0 );
383
- opacityBox->setMaximum (100 );
384
- rateLabel = new QLabel (" rate" , this );
385
- rateBox = new QSpinBox (this );
386
- rateBox->setMaximum (1000 );
387
- rateBox->setMinimum (-1000 );
388
- volumeLabel = new QLabel (" volume" , this );
389
- volumeBox = new QSpinBox (this );
390
- volumeBox->setMaximum (100 );
391
- volumeBox->setMinimum (0 );
392
- visibleBox = new QCheckBox (" Visible" , this );
393
- soloBox = new QCheckBox (" Solo" , this );
394
- lockBox = new QCheckBox (" Locked" , this );
395
- depthLabel = new QLabel (" depth" , this );
396
- depthBox = new QSpinBox (this );
397
- depthBox->setMinimum (1 );
398
- addToStateButton = new QPushButton (" Add to State" , this );
399
- addToStateButton->setToolTip (" Add to Initial Sate" );
400
- addToStateButton->setToolTipDuration (2000 );
401
- saveState1Button = new QPushButton (" Save State1" , this );
402
- saveState1Button->setToolTip (" Save State 1 to File" );
403
- saveState1Button->setToolTipDuration (2000 );
404
- loadState1Button = new QPushButton (" Load State1" , this );
405
- loadState1Button->setToolTip (" Load State 1 From File" );
406
- loadState1Button->setToolTipDuration (2000 );
482
+ void TabMMState::generateStates ()
483
+ {
407
484
408
- layoutBar->addWidget (typeBox);
409
- layoutBar->addWidget (idLabel);
410
- layoutBar->addWidget (idBox);
411
- layoutBar->addWidget (nameLine);
412
- layoutBar->addWidget (paintTypeBox);
413
- layoutBar->addWidget (uriLabel);
414
- layoutBar->addWidget (uriButton);
415
- layoutBar->addWidget (colorLabel);
416
- layoutBar->addWidget (colorButton);
417
- layoutBar->addWidget (cameraLabel);
418
- layoutBar->addWidget (cameraButton);
419
- layoutBar->addWidget (opacityLabel);
420
- layoutBar->addWidget (opacityBox);
421
- layoutBar->addWidget (rateLabel);
422
- layoutBar->addWidget (rateBox);
423
- layoutBar->addWidget (volumeLabel);
424
- layoutBar->addWidget (volumeBox);
425
- layoutBar->addWidget (visibleBox);
426
- layoutBar->addWidget (soloBox);
427
- layoutBar->addWidget (lockBox);
428
- layoutBar->addWidget (depthLabel);
429
- layoutBar->addWidget (depthBox);
430
- layoutBar->addStretch ();
431
- layoutBar->addWidget (addToStateButton);
432
- layoutBar->addWidget (saveState1Button);
433
- layoutBar->addWidget (loadState1Button);
485
+ }
434
486
435
- connect (typeBox, SIGNAL (currentIndexChanged (int )), this , SLOT (typeSelected (int )));
436
- connect (paintTypeBox, SIGNAL (currentIndexChanged (int )), this , SLOT (paintTypeSelected (int )));
437
- connect (addToStateButton, SIGNAL (clicked ()), this , SLOT (addToState ()));
438
- connect (uriButton, SIGNAL (clicked ()), this , SLOT (setUriLabel ()));
439
- connect (colorButton, SIGNAL (clicked ()), this , SLOT (setColorLabel ()));
440
- connect (cameraButton, SIGNAL (clicked ()), this , SLOT (setCameraLabel ()));
441
- connect (saveState1Button, SIGNAL (clicked ()), this , SLOT (saveAs ()));
442
- connect (loadState1Button, SIGNAL (clicked ()), this , SLOT (loadFile ()));
487
+ void TabMMState::resizeColumns ()
488
+ {
489
+ for (int i = Name; i < columnStateCount; i++) treeView->resizeColumnToContents (i);
443
490
}
444
491
445
492
493
+
0 commit comments