src/gui.cpp

changeset 283
c5401af41685
parent 276
a21e49914264
child 286
7a562bf3d829
equal deleted inserted replaced
282:c890f42c8054 283:c5401af41685
37 #include "config.h" 37 #include "config.h"
38 #include "misc.h" 38 #include "misc.h"
39 #include "colors.h" 39 #include "colors.h"
40 #include "history.h" 40 #include "history.h"
41 #include "widgets.h" 41 #include "widgets.h"
42 #include "addObjectDialog.h"
42 #include "config.h" 43 #include "config.h"
43 44
44 actionmeta g_actionMeta[MAX_ACTIONS]; 45 actionmeta g_actionMeta[MAX_ACTIONS];
45 static ushort g_metacursor = 0; 46 static ushort g_metacursor = 0;
46 47
69 70
70 m_objList = new ObjectList; 71 m_objList = new ObjectList;
71 m_objList->setSelectionMode (QListWidget::ExtendedSelection); 72 m_objList->setSelectionMode (QListWidget::ExtendedSelection);
72 m_objList->setAlternatingRowColors (true); 73 m_objList->setAlternatingRowColors (true);
73 connect (m_objList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); 74 connect (m_objList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ()));
75 connect (m_objList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*)));
74 76
75 m_splitter = new QSplitter; 77 m_splitter = new QSplitter;
76 m_splitter->addWidget (m_renderer); 78 m_splitter->addWidget (m_renderer);
77 m_splitter->addWidget (m_objList); 79 m_splitter->addWidget (m_objList);
78 setCentralWidget (m_splitter); 80 setCentralWidget (m_splitter);
942 } 944 }
943 945
944 contextMenu->exec (pos); 946 contextMenu->exec (pos);
945 } 947 }
946 948
947 // ======================================================================================================================================== 949 // =============================================================================
948 void ForgeWindow::deleteObjVector (vector<LDObject*> objs) { 950 void ForgeWindow::deleteObjVector (vector<LDObject*> objs) {
949 for (LDObject* obj : objs) { 951 for (LDObject* obj : objs) {
950 g_curfile->forgetObject (obj); 952 g_curfile->forgetObject (obj);
951 delete obj; 953 delete obj;
952 } 954 }
953 } 955 }
954 956
955 // ======================================================================================================================================== 957 // =============================================================================
956 void ForgeWindow::deleteByColor (const short colnum) { 958 void ForgeWindow::deleteByColor (const short colnum) {
957 vector<LDObject*> objs; 959 vector<LDObject*> objs;
958 for (LDObject* obj : g_curfile->objs ()) { 960 for (LDObject* obj : g_curfile->objs ()) {
959 if (!obj->isColored () || obj->color () != colnum) 961 if (!obj->isColored () || obj->color () != colnum)
960 continue; 962 continue;
963 } 965 }
964 966
965 deleteObjVector (objs); 967 deleteObjVector (objs);
966 } 968 }
967 969
968 // ======================================================================================================================================== 970 // =============================================================================
969 void ForgeWindow::updateEditModeActions () { 971 void ForgeWindow::updateEditModeActions () {
970 const EditMode mode = R ()->editMode (); 972 const EditMode mode = R ()->editMode ();
971 const size_t numModeActions = (sizeof g_modeActionNames / sizeof *g_modeActionNames); 973 const size_t numModeActions = (sizeof g_modeActionNames / sizeof *g_modeActionNames);
972 assert ((size_t) mode < numModeActions); 974 assert ((size_t) mode < numModeActions);
973 975
980 if (i != Select) 982 if (i != Select)
981 act->setEnabled (R ()->camera () != GL::Free); 983 act->setEnabled (R ()->camera () != GL::Free);
982 } 984 }
983 } 985 }
984 986
985 // ======================================================================================================================================== 987 void ForgeWindow::slot_editObject (QListWidgetItem* listitem) {
988 LDObject* obj = null;
989 for (LDObject* it : *g_curfile) {
990 if (it->qObjListEntry == listitem) {
991 obj = it;
992 break;
993 }
994 }
995
996 AddObjectDialog::staticDialog (obj->getType (), obj);
997 }
998
999 // ============================================================================
986 void ObjectList::contextMenuEvent (QContextMenuEvent* ev) { 1000 void ObjectList::contextMenuEvent (QContextMenuEvent* ev) {
987 g_win->spawnContextMenu (ev->globalPos ()); 1001 g_win->spawnContextMenu (ev->globalPos ());
988 } 1002 }
989 1003
990 // ============================================================================= 1004 // =============================================================================

mercurial