527 |
527 |
528 // ============================================================================= |
528 // ============================================================================= |
529 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
529 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
530 // ============================================================================= |
530 // ============================================================================= |
531 void ForgeWindow::slot_action () { |
531 void ForgeWindow::slot_action () { |
|
532 g_curfile->history ().open (); |
|
533 |
532 // Get the action that triggered this slot. |
534 // Get the action that triggered this slot. |
533 QAction* qAct = static_cast<QAction*> (sender ()); |
535 QAction* qAct = static_cast<QAction*> (sender ()); |
534 |
536 |
535 // Find the meta for the action. |
537 // Find the meta for the action. |
536 actionmeta* pMeta = null; |
538 actionmeta* pMeta = null; |
550 return; |
552 return; |
551 } |
553 } |
552 |
554 |
553 // We have the meta, now call the handler. |
555 // We have the meta, now call the handler. |
554 (*pMeta->handler) (); |
556 (*pMeta->handler) (); |
555 } |
557 |
556 |
558 g_curfile->history ().close (); |
557 // ============================================================================= |
559 } |
558 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
560 |
559 // ============================================================================= |
561 // ============================================================================= |
560 void ForgeWindow::deleteSelection (vector<ulong>* indicesPtr, vector<LDObject*>* objsPtr) { |
562 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
563 // ============================================================================= |
|
564 void ForgeWindow::deleteSelection () { |
561 if (m_sel.size () == 0) |
565 if (m_sel.size () == 0) |
562 return; |
566 return; |
563 |
567 |
564 vector<LDObject*> selCopy = m_sel; |
568 vector<LDObject*> selCopy = m_sel; |
565 |
569 |
566 // Delete the objects that were being selected |
570 // Delete the objects that were being selected |
567 for (LDObject* obj : selCopy) { |
571 for (LDObject* obj : selCopy) { |
568 if (objsPtr && indicesPtr) { |
|
569 *objsPtr << obj->clone (); |
|
570 *indicesPtr << obj->getIndex (g_curfile); |
|
571 } |
|
572 |
|
573 g_curfile->forgetObject (obj); |
572 g_curfile->forgetObject (obj); |
574 delete obj; |
573 delete obj; |
575 } |
574 } |
576 |
575 |
577 fullRefresh (); |
576 fullRefresh (); |
679 // Color gibberish orange on red so it stands out. |
678 // Color gibberish orange on red so it stands out. |
680 if (obj->getType() == LDObject::Gibberish) { |
679 if (obj->getType() == LDObject::Gibberish) { |
681 item->setBackground (QColor ("#AA0000")); |
680 item->setBackground (QColor ("#AA0000")); |
682 item->setForeground (QColor ("#FFAA00")); |
681 item->setForeground (QColor ("#FFAA00")); |
683 } else if (lv_colorize && obj->isColored () && |
682 } else if (lv_colorize && obj->isColored () && |
684 obj->color != maincolor && obj->color != edgecolor) |
683 obj->color () != maincolor && obj->color () != edgecolor) |
685 { |
684 { |
686 // If the object isn't in the main or edge color, draw this |
685 // If the object isn't in the main or edge color, draw this |
687 // list entry in said color. |
686 // list entry in said color. |
688 color* col = getColor (obj->color); |
687 color* col = getColor (obj->color ()); |
689 if (col) |
688 if (col) |
690 item->setForeground (col->faceColor); |
689 item->setForeground (col->faceColor); |
691 } |
690 } |
692 |
691 |
693 obj->qObjListEntry = item; |
692 obj->qObjListEntry = item; |
854 |
853 |
855 short ForgeWindow::getSelectedColor () { |
854 short ForgeWindow::getSelectedColor () { |
856 short result = -1; |
855 short result = -1; |
857 |
856 |
858 for (LDObject* obj : m_sel) { |
857 for (LDObject* obj : m_sel) { |
859 if (obj->color == -1) |
858 if (obj->isColored () == false) |
860 continue; // doesn't use color |
859 continue; // doesn't use color |
861 |
860 |
862 if (result != -1 && obj->color != result) |
861 if (result != -1 && obj->color () != result) |
863 return -1; // No consensus in object color |
862 return -1; // No consensus in object color |
864 |
863 |
865 if (result == -1) |
864 if (result == -1) |
866 result = obj->color; |
865 result = obj->color (); |
867 } |
866 } |
868 |
867 |
869 return result; |
868 return result; |
870 } |
869 } |
871 |
870 |
874 // ============================================================================= |
873 // ============================================================================= |
875 LDObject::Type ForgeWindow::uniformSelectedType () { |
874 LDObject::Type ForgeWindow::uniformSelectedType () { |
876 LDObject::Type result = LDObject::Unidentified; |
875 LDObject::Type result = LDObject::Unidentified; |
877 |
876 |
878 for (LDObject* obj : m_sel) { |
877 for (LDObject* obj : m_sel) { |
879 if (result != LDObject::Unidentified && obj->color != result) |
878 if (result != LDObject::Unidentified && obj->color () != result) |
880 return LDObject::Unidentified; |
879 return LDObject::Unidentified; |
881 |
880 |
882 if (result == LDObject::Unidentified) |
881 if (result == LDObject::Unidentified) |
883 result = obj->getType (); |
882 result = obj->getType (); |
884 } |
883 } |
941 |
940 |
942 contextMenu->exec (pos); |
941 contextMenu->exec (pos); |
943 } |
942 } |
944 |
943 |
945 // ======================================================================================================================================== |
944 // ======================================================================================================================================== |
946 DelHistory* ForgeWindow::deleteObjVector (vector<LDObject*> objs) { |
945 void ForgeWindow::deleteObjVector (vector<LDObject*> objs) { |
947 for (LDObject* obj : objs) { |
946 for (LDObject* obj : objs) { |
948 g_curfile->forgetObject (obj); |
947 g_curfile->forgetObject (obj); |
949 delete obj; |
948 delete obj; |
950 } |
949 } |
951 |
|
952 return null; |
|
953 } |
950 } |
954 |
951 |
955 // ======================================================================================================================================== |
952 // ======================================================================================================================================== |
956 DelHistory* ForgeWindow::deleteSelection () { |
953 void ForgeWindow::deleteByColor (const short colnum) { |
957 return deleteObjVector (sel ()); |
|
958 } |
|
959 |
|
960 // ======================================================================================================================================== |
|
961 DelHistory* ForgeWindow::deleteByColor (const short colnum) { |
|
962 vector<LDObject*> objs; |
954 vector<LDObject*> objs; |
963 for (LDObject* obj : g_curfile->objs ()) { |
955 for (LDObject* obj : g_curfile->objs ()) { |
964 if (!obj->isColored () || obj->color != colnum) |
956 if (!obj->isColored () || obj->color () != colnum) |
965 continue; |
957 continue; |
966 |
958 |
967 objs << obj; |
959 objs << obj; |
968 } |
960 } |
969 |
961 |
970 return deleteObjVector (objs); |
962 deleteObjVector (objs); |
971 } |
963 } |
972 |
964 |
973 // ======================================================================================================================================== |
965 // ======================================================================================================================================== |
974 void ForgeWindow::updateEditModeActions () { |
966 void ForgeWindow::updateEditModeActions () { |
975 const EditMode mode = R ()->editMode (); |
967 const EditMode mode = R ()->editMode (); |
1069 |
1061 |
1070 for (LDObject* obj : g_curfile->objs ()) { |
1062 for (LDObject* obj : g_curfile->objs ()) { |
1071 if (!obj->isColored ()) |
1063 if (!obj->isColored ()) |
1072 continue; |
1064 continue; |
1073 |
1065 |
1074 if (counts.find (obj->color) == counts.end ()) |
1066 if (counts.find (obj->color ()) == counts.end ()) |
1075 counts[obj->color] = 1; |
1067 counts[obj->color ()] = 1; |
1076 else |
1068 else |
1077 counts[obj->color]++; |
1069 counts[obj->color ()]++; |
1078 } |
1070 } |
1079 |
1071 |
1080 box->clear (); |
1072 box->clear (); |
1081 ulong row = 0; |
1073 ulong row = 0; |
1082 for (const auto& pair : counts) { |
1074 for (const auto& pair : counts) { |