mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Array cleanup.
This commit is contained in:
parent
6681986517
commit
b42e3b7e31
3 changed files with 25 additions and 44 deletions
|
@ -43,17 +43,6 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcArray<T>& operator+=(const lcArray<T>& Array)
|
|
||||||
{
|
|
||||||
AllocGrow(Array.mLength);
|
|
||||||
|
|
||||||
for (int i = 0; i < Array.mLength; i++)
|
|
||||||
mData[mLength + i] = Array.mData[i];
|
|
||||||
|
|
||||||
mLength += Array.mLength;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& operator[](int Index) const
|
const T& operator[](int Index) const
|
||||||
{
|
{
|
||||||
return mData[Index];
|
return mData[Index];
|
||||||
|
@ -148,20 +137,6 @@ public:
|
||||||
return mData[mLength++];
|
return mData[mLength++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddSorted(const T& Obj, lcArrayCompareFunc CompareFunc)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mLength; i++)
|
|
||||||
{
|
|
||||||
if (CompareFunc(Obj, mData[i]) < 0)
|
|
||||||
{
|
|
||||||
InsertAt(i, Obj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Add(Obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
T& InsertAt(int Index)
|
T& InsertAt(int Index)
|
||||||
{
|
{
|
||||||
if (Index >= mLength)
|
if (Index >= mLength)
|
||||||
|
|
|
@ -215,8 +215,12 @@ bool lcModel::IncludesModel(const lcModel* Model) const
|
||||||
|
|
||||||
void lcModel::DeleteHistory()
|
void lcModel::DeleteHistory()
|
||||||
{
|
{
|
||||||
mUndoHistory.DeleteAll();
|
for (lcModelHistoryEntry* Entry : mUndoHistory)
|
||||||
mRedoHistory.DeleteAll();
|
delete Entry;
|
||||||
|
mUndoHistory.clear();
|
||||||
|
for (lcModelHistoryEntry* Entry : mRedoHistory)
|
||||||
|
delete Entry;
|
||||||
|
mRedoHistory.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::DeleteModel()
|
void lcModel::DeleteModel()
|
||||||
|
@ -1487,13 +1491,15 @@ void lcModel::SaveCheckpoint(const QString& Description)
|
||||||
QTextStream Stream(&ModelHistoryEntry->File);
|
QTextStream Stream(&ModelHistoryEntry->File);
|
||||||
SaveLDraw(Stream, false);
|
SaveLDraw(Stream, false);
|
||||||
|
|
||||||
mUndoHistory.InsertAt(0, ModelHistoryEntry);
|
mUndoHistory.insert(mUndoHistory.begin(), ModelHistoryEntry);
|
||||||
mRedoHistory.DeleteAll();
|
for (lcModelHistoryEntry* Entry : mRedoHistory)
|
||||||
|
delete Entry;
|
||||||
|
mRedoHistory.clear();
|
||||||
|
|
||||||
if (!Description.isEmpty())
|
if (!Description.isEmpty())
|
||||||
{
|
{
|
||||||
gMainWindow->UpdateModified(IsModified());
|
gMainWindow->UpdateModified(IsModified());
|
||||||
gMainWindow->UpdateUndoRedo(mUndoHistory.GetSize() > 1 ? mUndoHistory[0]->Description : QString(), !mRedoHistory.IsEmpty() ? mRedoHistory[0]->Description : QString());
|
gMainWindow->UpdateUndoRedo(mUndoHistory.size() > 1 ? mUndoHistory[0]->Description : QString(), !mRedoHistory.empty() ? mRedoHistory[0]->Description : QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3653,32 +3659,32 @@ void lcModel::FindPiece(bool FindFirst, bool SearchForward)
|
||||||
|
|
||||||
void lcModel::UndoAction()
|
void lcModel::UndoAction()
|
||||||
{
|
{
|
||||||
if (mUndoHistory.GetSize() < 2)
|
if (mUndoHistory.size() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcModelHistoryEntry* Undo = mUndoHistory[0];
|
lcModelHistoryEntry* Undo = mUndoHistory.front();
|
||||||
mUndoHistory.RemoveIndex(0);
|
mUndoHistory.erase(mUndoHistory.begin());
|
||||||
mRedoHistory.InsertAt(0, Undo);
|
mRedoHistory.insert(mRedoHistory.begin(), Undo);
|
||||||
|
|
||||||
LoadCheckPoint(mUndoHistory[0]);
|
LoadCheckPoint(mUndoHistory[0]);
|
||||||
|
|
||||||
gMainWindow->UpdateModified(IsModified());
|
gMainWindow->UpdateModified(IsModified());
|
||||||
gMainWindow->UpdateUndoRedo(mUndoHistory.GetSize() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.IsEmpty() ? mRedoHistory[0]->Description : nullptr);
|
gMainWindow->UpdateUndoRedo(mUndoHistory.size() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.empty() ? mRedoHistory[0]->Description : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::RedoAction()
|
void lcModel::RedoAction()
|
||||||
{
|
{
|
||||||
if (mRedoHistory.IsEmpty())
|
if (mRedoHistory.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcModelHistoryEntry* Redo = mRedoHistory[0];
|
lcModelHistoryEntry* Redo = mRedoHistory.front();
|
||||||
mRedoHistory.RemoveIndex(0);
|
mRedoHistory.erase(mRedoHistory.begin());
|
||||||
mUndoHistory.InsertAt(0, Redo);
|
mUndoHistory.insert(mUndoHistory.begin(), Redo);
|
||||||
|
|
||||||
LoadCheckPoint(Redo);
|
LoadCheckPoint(Redo);
|
||||||
|
|
||||||
gMainWindow->UpdateModified(IsModified());
|
gMainWindow->UpdateModified(IsModified());
|
||||||
gMainWindow->UpdateUndoRedo(mUndoHistory.GetSize() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.IsEmpty() ? mRedoHistory[0]->Description : nullptr);
|
gMainWindow->UpdateUndoRedo(mUndoHistory.size() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.empty() ? mRedoHistory[0]->Description : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::BeginMouseTool()
|
void lcModel::BeginMouseTool()
|
||||||
|
@ -4202,7 +4208,7 @@ void lcModel::ShowMinifigDialog()
|
||||||
void lcModel::UpdateInterface()
|
void lcModel::UpdateInterface()
|
||||||
{
|
{
|
||||||
gMainWindow->UpdateTimeline(true, false);
|
gMainWindow->UpdateTimeline(true, false);
|
||||||
gMainWindow->UpdateUndoRedo(mUndoHistory.GetSize() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.IsEmpty() ? mRedoHistory[0]->Description : nullptr);
|
gMainWindow->UpdateUndoRedo(mUndoHistory.size() > 1 ? mUndoHistory[0]->Description : nullptr, !mRedoHistory.empty() ? mRedoHistory[0]->Description : nullptr);
|
||||||
gMainWindow->UpdatePaste(!gApplication->mClipboard.isEmpty());
|
gMainWindow->UpdatePaste(!gApplication->mClipboard.isEmpty());
|
||||||
gMainWindow->UpdateCategories();
|
gMainWindow->UpdateCategories();
|
||||||
gMainWindow->UpdateTitle();
|
gMainWindow->UpdateTitle();
|
||||||
|
|
|
@ -215,7 +215,7 @@ public:
|
||||||
|
|
||||||
void SetSaved()
|
void SetSaved()
|
||||||
{
|
{
|
||||||
if (mUndoHistory.IsEmpty())
|
if (mUndoHistory.empty())
|
||||||
SaveCheckpoint(QString());
|
SaveCheckpoint(QString());
|
||||||
|
|
||||||
mSavedHistory = mUndoHistory[0];
|
mSavedHistory = mUndoHistory[0];
|
||||||
|
@ -365,8 +365,8 @@ protected:
|
||||||
QStringList mFileLines;
|
QStringList mFileLines;
|
||||||
|
|
||||||
lcModelHistoryEntry* mSavedHistory;
|
lcModelHistoryEntry* mSavedHistory;
|
||||||
lcArray<lcModelHistoryEntry*> mUndoHistory;
|
std::vector<lcModelHistoryEntry*> mUndoHistory;
|
||||||
lcArray<lcModelHistoryEntry*> mRedoHistory;
|
std::vector<lcModelHistoryEntry*> mRedoHistory;
|
||||||
|
|
||||||
Q_DECLARE_TR_FUNCTIONS(lcModel);
|
Q_DECLARE_TR_FUNCTIONS(lcModel);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue