44 const QStringList g_specialSubdirectories ({ "s", "48", "8" }); |
44 const QStringList g_specialSubdirectories ({ "s", "48", "8" }); |
45 |
45 |
46 LDDocument::LDDocument (QObject* parent) : |
46 LDDocument::LDDocument (QObject* parent) : |
47 QObject (parent), |
47 QObject (parent), |
48 HierarchyElement (parent), |
48 HierarchyElement (parent), |
49 m_history (new History), |
49 m_history (new EditHistory (this)), |
50 m_isCache (true), |
50 m_isCache (true), |
51 m_verticesOutdated (true), |
51 m_verticesOutdated (true), |
52 m_needVertexMerge (true), |
52 m_needVertexMerge (true), |
53 m_beingDestroyed (false), |
53 m_beingDestroyed (false), |
54 m_gldata (new LDGLData) |
54 m_gldata (new LDGLData) |
55 { |
55 { |
56 setSavePosition (-1); |
56 setSavePosition (-1); |
57 setTabIndex (-1); |
57 setTabIndex (-1); |
58 m_history->setDocument (this); |
|
59 m_needsReCache = true; |
58 m_needsReCache = true; |
60 } |
59 } |
61 |
60 |
62 LDDocument::~LDDocument() |
61 LDDocument::~LDDocument() |
63 { |
62 { |
959 |
958 |
960 // ============================================================================= |
959 // ============================================================================= |
961 // |
960 // |
962 int LDDocument::addObject (LDObject* obj) |
961 int LDDocument::addObject (LDObject* obj) |
963 { |
962 { |
964 history()->add (new AddHistory (objects().size(), obj)); |
963 history()->add (new AddHistoryEntry (objects().size(), obj)); |
965 m_objects << obj; |
964 m_objects << obj; |
966 addKnownVertices (obj); |
965 addKnownVertices (obj); |
967 obj->setDocument (this); |
966 obj->setDocument (this); |
968 m_window->renderer()->compileObject (obj); |
967 m_window->renderer()->compileObject (obj); |
969 return getObjectCount() - 1; |
968 return getObjectCount() - 1; |
982 |
981 |
983 // ============================================================================= |
982 // ============================================================================= |
984 // |
983 // |
985 void LDDocument::insertObj (int pos, LDObject* obj) |
984 void LDDocument::insertObj (int pos, LDObject* obj) |
986 { |
985 { |
987 history()->add (new AddHistory (pos, obj)); |
986 history()->add (new AddHistoryEntry (pos, obj)); |
988 m_objects.insert (pos, obj); |
987 m_objects.insert (pos, obj); |
989 obj->setDocument (this); |
988 obj->setDocument (this); |
990 m_window->renderer()->compileObject (obj); |
989 m_window->renderer()->compileObject (obj); |
991 |
990 |
992 |
991 |
1021 { |
1020 { |
1022 obj->deselect(); |
1021 obj->deselect(); |
1023 |
1022 |
1024 if (not isCache() and not m_beingDestroyed) |
1023 if (not isCache() and not m_beingDestroyed) |
1025 { |
1024 { |
1026 history()->add (new DelHistory (idx, obj)); |
1025 history()->add (new DelHistoryEntry (idx, obj)); |
1027 m_objectVertices.remove (obj); |
1026 m_objectVertices.remove (obj); |
1028 } |
1027 } |
1029 |
1028 |
1030 m_objects.removeAt (idx); |
1029 m_objects.removeAt (idx); |
1031 obj->setDocument (nullptr); |
1030 obj->setDocument (nullptr); |
1055 // Mark this change to history |
1054 // Mark this change to history |
1056 if (not m_history->isIgnoring()) |
1055 if (not m_history->isIgnoring()) |
1057 { |
1056 { |
1058 QString oldcode = getObject (idx)->asText(); |
1057 QString oldcode = getObject (idx)->asText(); |
1059 QString newcode = obj->asText(); |
1058 QString newcode = obj->asText(); |
1060 *m_history << new EditHistory (idx, oldcode, newcode); |
1059 m_history->add (new EditHistoryEntry (idx, oldcode, newcode)); |
1061 } |
1060 } |
1062 |
1061 |
1063 m_objectVertices.remove (m_objects[idx]); |
1062 m_objectVertices.remove (m_objects[idx]); |
1064 m_objects[idx]->deselect(); |
1063 m_objects[idx]->deselect(); |
1065 m_objects[idx]->setDocument (nullptr); |
1064 m_objects[idx]->setDocument (nullptr); |