gui.cpp

changeset 17
5606eebd0b90
parent 14
6d9d8efae2f8
child 18
a6732098fed8
equal deleted inserted replaced
16:7e604baff022 17:5606eebd0b90
13 13
14 qObjList = new QTreeWidget; 14 qObjList = new QTreeWidget;
15 qObjList->setHeaderHidden (true); 15 qObjList->setHeaderHidden (true);
16 qObjList->setMaximumWidth (256); 16 qObjList->setMaximumWidth (256);
17 qObjList->setSelectionMode (QTreeWidget::MultiSelection); 17 qObjList->setSelectionMode (QTreeWidget::MultiSelection);
18 connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ()));
18 19
19 qMessageLog = new QTextEdit; 20 qMessageLog = new QTextEdit;
20 qMessageLog->setReadOnly (true); 21 qMessageLog->setReadOnly (true);
21 qMessageLog->setMaximumHeight (96); 22 qMessageLog->setMaximumHeight (96);
22 23
86 // things not implemented yet 87 // things not implemented yet
87 QAction* qaDisabledActions[] = { 88 QAction* qaDisabledActions[] = {
88 qAct_save, 89 qAct_save,
89 qAct_saveAs, 90 qAct_saveAs,
90 qAct_newSubfile, 91 qAct_newSubfile,
91 qAct_newLine,
92 qAct_newTriangle, 92 qAct_newTriangle,
93 qAct_newQuad, 93 qAct_newQuad,
94 qAct_newCondLine, 94 qAct_newCondLine,
95 qAct_newComment, 95 qAct_newComment,
96 qAct_newVector, 96 qAct_newVector,
218 void LDForgeWindow::slot_newSubfile () { 218 void LDForgeWindow::slot_newSubfile () {
219 219
220 } 220 }
221 221
222 void LDForgeWindow::slot_newLine () { 222 void LDForgeWindow::slot_newLine () {
223 223 LDLine* line = new LDLine;
224 const ulong ulSpot = getInsertionPoint ();
225
226 memset (line->vaCoords, 0, sizeof line->vaCoords);
227 line->dColor = 24;
228
229 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulSpot, line);
230
231 buildObjList ();
232 R->hardRefresh ();
224 } 233 }
225 234
226 void LDForgeWindow::slot_newTriangle () { 235 void LDForgeWindow::slot_newTriangle () {
227 236
228 } 237 }
415 424
416 qObjList->insertTopLevelItems (0, qaItems); 425 qObjList->insertTopLevelItems (0, qaItems);
417 } 426 }
418 427
419 void LDForgeWindow::slot_selectionChanged () { 428 void LDForgeWindow::slot_selectionChanged () {
420 429 // If the selection isn't 1 exact, disable setting contents
421 } 430 qAct_setContents->setEnabled (qObjList->selectedItems().size() == 1);
431 }
432
433 // =============================================================================
434 // ulong getInsertionPoint ()
435 //
436 // Returns the index of where a new item should be placed at.
437 // =============================================================================
438 ulong LDForgeWindow::getInsertionPoint () {
439 ulong ulIndex;
440
441 if (qObjList->selectedItems().size() == 1) {
442 // If we have a selection, put the item after it.
443 for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex)
444 if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0])
445 break;
446
447 if (ulIndex >= g_CurrentFile->objects.size())
448 return ulIndex + 1;
449 }
450
451 // Otherwise place the object at the end.
452 return g_CurrentFile->objects.size();
453 }

mercurial