Fixed selection marking files modified.

This commit is contained in:
Leonardo Zide
2026-02-23 22:42:33 -08:00
parent d1575c2ceb
commit a6c5cdde2b
2 changed files with 31 additions and 16 deletions
+24
View File
@@ -2010,6 +2010,30 @@ void lcModel::RevertActionSequence()
mActionSequence.clear();
}
bool lcModel::IsModified() const
{
const lcModelHistoryEntry* FirstModifyAction = GetFirstUndoChange();
if (!FirstModifyAction)
return mSavedHistory != nullptr;
else
return mSavedHistory != FirstModifyAction;
}
void lcModel::SetSaved()
{
mSavedHistory = GetFirstUndoChange();
}
const lcModelHistoryEntry* lcModel::GetFirstUndoChange() const
{
for (const std::unique_ptr<lcModelHistoryEntry>& UndoEntry : mUndoHistory)
if (UndoEntry->ModelActions.size() != 1 || !dynamic_cast<lcModelActionSelection*>(UndoEntry->ModelActions.front().get()))
return UndoEntry.get();
return nullptr;
}
void lcModel::SaveCheckpoint(const QString& )
{
/*
+7 -16
View File
@@ -131,19 +131,14 @@ public:
return mProject;
}
bool IsModified() const
{
if (mUndoHistory.empty())
return mSavedHistory != nullptr;
else
return mSavedHistory != mUndoHistory.front().get();
}
bool IsActive() const
{
return mActive;
}
bool IsModified() const;
void SetSaved();
bool GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& ParentWorldMatrix) const;
bool IncludesModel(const lcModel* Model) const;
void CreatePieceInfo(Project* Project);
@@ -271,12 +266,7 @@ public:
bool LoadInventory(const QByteArray& Inventory);
int SplitMPD(QIODevice& Device);
void Merge(std::unique_ptr<lcModel> Other);
void SetSaved()
{
mSavedHistory = mUndoHistory.empty() ? nullptr : mUndoHistory.front().get();
}
void SetMinifig(const lcMinifig& Minifig);
void SetPreviewPieceInfo(PieceInfo* Info, int ColorIndex);
@@ -422,6 +412,7 @@ protected:
void EndActionSequence(const QString& Description);
void DiscardActionSequence();
void RevertActionSequence();
const lcModelHistoryEntry* GetFirstUndoChange() const;
void SaveCheckpoint(const QString& Description);
void LoadCheckPoint(lcModelHistoryEntry* CheckPoint, bool Apply);
@@ -457,7 +448,7 @@ protected:
QStringList mFileLines;
std::vector<std::unique_ptr<lcModelAction>> mActionSequence;
lcModelHistoryEntry* mSavedHistory;
const lcModelHistoryEntry* mSavedHistory = nullptr;
std::vector<std::unique_ptr<lcModelHistoryEntry>> mUndoHistory;
std::vector<std::unique_ptr<lcModelHistoryEntry>> mRedoHistory;