mirror of
https://github.com/leozide/leocad
synced 2025-01-28 19:58:12 +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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return mData[Index];
|
||||
|
@ -148,20 +137,6 @@ public:
|
|||
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)
|
||||
{
|
||||
if (Index >= mLength)
|
||||
|
|
|
@ -215,8 +215,12 @@ bool lcModel::IncludesModel(const lcModel* Model) const
|
|||
|
||||
void lcModel::DeleteHistory()
|
||||
{
|
||||
mUndoHistory.DeleteAll();
|
||||
mRedoHistory.DeleteAll();
|
||||
for (lcModelHistoryEntry* Entry : mUndoHistory)
|
||||
delete Entry;
|
||||
mUndoHistory.clear();
|
||||
for (lcModelHistoryEntry* Entry : mRedoHistory)
|
||||
delete Entry;
|
||||
mRedoHistory.clear();
|
||||
}
|
||||
|
||||
void lcModel::DeleteModel()
|
||||
|
@ -1487,13 +1491,15 @@ void lcModel::SaveCheckpoint(const QString& Description)
|
|||
QTextStream Stream(&ModelHistoryEntry->File);
|
||||
SaveLDraw(Stream, false);
|
||||
|
||||
mUndoHistory.InsertAt(0, ModelHistoryEntry);
|
||||
mRedoHistory.DeleteAll();
|
||||
mUndoHistory.insert(mUndoHistory.begin(), ModelHistoryEntry);
|
||||
for (lcModelHistoryEntry* Entry : mRedoHistory)
|
||||
delete Entry;
|
||||
mRedoHistory.clear();
|
||||
|
||||
if (!Description.isEmpty())
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (mUndoHistory.GetSize() < 2)
|
||||
if (mUndoHistory.size() < 2)
|
||||
return;
|
||||
|
||||
lcModelHistoryEntry* Undo = mUndoHistory[0];
|
||||
mUndoHistory.RemoveIndex(0);
|
||||
mRedoHistory.InsertAt(0, Undo);
|
||||
lcModelHistoryEntry* Undo = mUndoHistory.front();
|
||||
mUndoHistory.erase(mUndoHistory.begin());
|
||||
mRedoHistory.insert(mRedoHistory.begin(), Undo);
|
||||
|
||||
LoadCheckPoint(mUndoHistory[0]);
|
||||
|
||||
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()
|
||||
{
|
||||
if (mRedoHistory.IsEmpty())
|
||||
if (mRedoHistory.empty())
|
||||
return;
|
||||
|
||||
lcModelHistoryEntry* Redo = mRedoHistory[0];
|
||||
mRedoHistory.RemoveIndex(0);
|
||||
mUndoHistory.InsertAt(0, Redo);
|
||||
lcModelHistoryEntry* Redo = mRedoHistory.front();
|
||||
mRedoHistory.erase(mRedoHistory.begin());
|
||||
mUndoHistory.insert(mUndoHistory.begin(), Redo);
|
||||
|
||||
LoadCheckPoint(Redo);
|
||||
|
||||
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()
|
||||
|
@ -4202,7 +4208,7 @@ void lcModel::ShowMinifigDialog()
|
|||
void lcModel::UpdateInterface()
|
||||
{
|
||||
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->UpdateCategories();
|
||||
gMainWindow->UpdateTitle();
|
||||
|
|
|
@ -215,7 +215,7 @@ public:
|
|||
|
||||
void SetSaved()
|
||||
{
|
||||
if (mUndoHistory.IsEmpty())
|
||||
if (mUndoHistory.empty())
|
||||
SaveCheckpoint(QString());
|
||||
|
||||
mSavedHistory = mUndoHistory[0];
|
||||
|
@ -365,8 +365,8 @@ protected:
|
|||
QStringList mFileLines;
|
||||
|
||||
lcModelHistoryEntry* mSavedHistory;
|
||||
lcArray<lcModelHistoryEntry*> mUndoHistory;
|
||||
lcArray<lcModelHistoryEntry*> mRedoHistory;
|
||||
std::vector<lcModelHistoryEntry*> mUndoHistory;
|
||||
std::vector<lcModelHistoryEntry*> mRedoHistory;
|
||||
|
||||
Q_DECLARE_TR_FUNCTIONS(lcModel);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue