forked from qt-creator/qt-creator
Replace virtual isModified method with a getter/setter/notifier
We have lacked the setter and dedicated notifier before. Change-Id: I58845a48259d260c5cc90ae94b173c79cddcfef9 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -76,17 +76,20 @@ DocumentController::DocumentController(QObject *parent) :
|
|||||||
{
|
{
|
||||||
// project controller
|
// project controller
|
||||||
connect(m_projectController, &ProjectController::changed, this, &DocumentController::changed);
|
connect(m_projectController, &ProjectController::changed, this, &DocumentController::changed);
|
||||||
|
connect(m_projectController, &ProjectController::modificationChanged, this, &DocumentController::modificationChanged);
|
||||||
|
|
||||||
// model controller
|
// model controller
|
||||||
m_modelController->setUndoController(m_undoController);
|
m_modelController->setUndoController(m_undoController);
|
||||||
connect(m_modelController, &ModelController::modified,
|
connect(m_modelController, &ModelController::modified, [this](){
|
||||||
m_projectController, &ProjectController::setModified);
|
m_projectController->setModified(true);
|
||||||
|
});
|
||||||
|
|
||||||
// diagram controller
|
// diagram controller
|
||||||
m_diagramController->setModelController(m_modelController);
|
m_diagramController->setModelController(m_modelController);
|
||||||
m_diagramController->setUndoController(m_undoController);
|
m_diagramController->setUndoController(m_undoController);
|
||||||
connect(m_diagramController, &DiagramController::modified,
|
connect(m_diagramController, &DiagramController::modified, [this](){
|
||||||
m_projectController, &ProjectController::setModified);
|
m_projectController->setModified(true);
|
||||||
|
});
|
||||||
|
|
||||||
// diagram scene controller
|
// diagram scene controller
|
||||||
m_diagramSceneController->setModelController(m_modelController);
|
m_diagramSceneController->setModelController(m_modelController);
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
void modificationChanged(bool modified);
|
||||||
void modelClipboardChanged(bool isEmpty);
|
void modelClipboardChanged(bool isEmpty);
|
||||||
void diagramClipboardChanged(bool isEmpty);
|
void diagramClipboardChanged(bool isEmpty);
|
||||||
|
|
||||||
|
@@ -43,8 +43,7 @@ ProjectIsModifiedException::ProjectIsModifiedException()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectController::ProjectController(QObject *parent)
|
ProjectController::ProjectController(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent)
|
||||||
m_isModified(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ void ProjectController::newProject(const QString &fileName)
|
|||||||
rootPackage->setName(tr("Model"));
|
rootPackage->setName(tr("Model"));
|
||||||
m_project->setRootPackage(rootPackage);
|
m_project->setRootPackage(rootPackage);
|
||||||
m_project->setFileName(fileName);
|
m_project->setFileName(fileName);
|
||||||
m_isModified = false;
|
setModified(false);
|
||||||
emit fileNameChanged(m_project->fileName());
|
emit fileNameChanged(m_project->fileName());
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
@@ -68,17 +67,18 @@ void ProjectController::setFileName(const QString &fileName)
|
|||||||
{
|
{
|
||||||
if (fileName != m_project->fileName()) {
|
if (fileName != m_project->fileName()) {
|
||||||
m_project->setFileName(fileName);
|
m_project->setFileName(fileName);
|
||||||
setModified();
|
setModified(true);
|
||||||
emit fileNameChanged(m_project->fileName());
|
emit fileNameChanged(m_project->fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectController::setModified()
|
void ProjectController::setModified(bool modified)
|
||||||
{
|
{
|
||||||
if (!m_isModified) {
|
if (m_isModified == modified)
|
||||||
m_isModified = true;
|
return;
|
||||||
emit changed();
|
|
||||||
}
|
m_isModified = modified;
|
||||||
|
emit modificationChanged(modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectController::load()
|
void ProjectController::load()
|
||||||
@@ -89,7 +89,7 @@ void ProjectController::load()
|
|||||||
throw NoFileNameException();
|
throw NoFileNameException();
|
||||||
ProjectSerializer serializer;
|
ProjectSerializer serializer;
|
||||||
serializer.load(m_project->fileName(), m_project.data());
|
serializer.load(m_project->fileName(), m_project.data());
|
||||||
m_isModified = false;
|
setModified(false);
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ void ProjectController::save()
|
|||||||
throw NoFileNameException();
|
throw NoFileNameException();
|
||||||
ProjectSerializer serializer;
|
ProjectSerializer serializer;
|
||||||
serializer.save(m_project->fileName(), m_project.data());
|
serializer.save(m_project->fileName(), m_project.data());
|
||||||
m_isModified = false;
|
setModified(false);
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void fileNameChanged(const QString &fileName);
|
void fileNameChanged(const QString &fileName);
|
||||||
|
void modificationChanged(bool modified);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Project *project() const { return m_project.data(); }
|
Project *project() const { return m_project.data(); }
|
||||||
@@ -65,7 +66,7 @@ public:
|
|||||||
|
|
||||||
void newProject(const QString &fileName);
|
void newProject(const QString &fileName);
|
||||||
void setFileName(const QString &fileName);
|
void setFileName(const QString &fileName);
|
||||||
void setModified();
|
void setModified(bool modified);
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
@@ -73,7 +74,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Project> m_project;
|
QScopedPointer<Project> m_project;
|
||||||
bool m_isModified;
|
bool m_isModified = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmt
|
} // namespace qmt
|
||||||
|
@@ -43,8 +43,12 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
|
|||||||
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
|
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
|
||||||
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||||
setSuspendAllowed(false);
|
setSuspendAllowed(false);
|
||||||
connect(editorWidget, &AndroidManifestEditorWidget::guiChanged,
|
connect(editorWidget, &AndroidManifestEditorWidget::modificationChanged,
|
||||||
this, &Core::IDocument::changed);
|
this, &Core::IDocument::setModified);
|
||||||
|
connect(this, &Core::IDocument::modificationChanged,
|
||||||
|
editorWidget, &AndroidManifestEditorWidget::setModified);
|
||||||
|
|
||||||
|
setModified(editorWidget->isModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
@@ -55,11 +59,6 @@ bool AndroidManifestDocument::save(QString *errorString, const QString &fileName
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestDocument::isModified() const
|
|
||||||
{
|
|
||||||
return TextDocument::isModified() || m_editorWidget->isModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AndroidManifestDocument::isSaveAsAllowed() const
|
bool AndroidManifestDocument::isSaveAsAllowed() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -39,7 +39,6 @@ public:
|
|||||||
bool save(QString *errorString, const QString &fileName = QString(),
|
bool save(QString *errorString, const QString &fileName = QString(),
|
||||||
bool autoSave = false) override;
|
bool autoSave = false) override;
|
||||||
|
|
||||||
bool isModified() const override;
|
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -101,7 +101,7 @@ Project *androidProject(const Utils::FileName &fileName)
|
|||||||
|
|
||||||
AndroidManifestEditorWidget::AndroidManifestEditorWidget()
|
AndroidManifestEditorWidget::AndroidManifestEditorWidget()
|
||||||
: QStackedWidget(),
|
: QStackedWidget(),
|
||||||
m_dirty(false),
|
m_modified(false),
|
||||||
m_stayClean(false)
|
m_stayClean(false)
|
||||||
{
|
{
|
||||||
m_textEditorWidget = new AndroidManifestTextEditorWidget(this);
|
m_textEditorWidget = new AndroidManifestTextEditorWidget(this);
|
||||||
@@ -138,7 +138,7 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
QGroupBox *packageGroupBox = new QGroupBox(mainWidget);
|
QGroupBox *packageGroupBox = new QGroupBox(mainWidget);
|
||||||
topLayout->addWidget(packageGroupBox);
|
topLayout->addWidget(packageGroupBox);
|
||||||
|
|
||||||
auto setDirtyFunc = [this] { setDirty(); };
|
auto setDirtyFunc = [this] { setModified(); };
|
||||||
packageGroupBox->setTitle(tr("Package"));
|
packageGroupBox->setTitle(tr("Package"));
|
||||||
{
|
{
|
||||||
QFormLayout *formLayout = new QFormLayout();
|
QFormLayout *formLayout = new QFormLayout();
|
||||||
@@ -206,7 +206,7 @@ void AndroidManifestEditorWidget::initializePage()
|
|||||||
connect(m_packageNameLineEdit, &QLineEdit::textEdited,
|
connect(m_packageNameLineEdit, &QLineEdit::textEdited,
|
||||||
this, &AndroidManifestEditorWidget::setPackageName);
|
this, &AndroidManifestEditorWidget::setPackageName);
|
||||||
connect(m_versionCode, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
connect(m_versionCode, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||||
this, &AndroidManifestEditorWidget::setDirty);
|
this, &AndroidManifestEditorWidget::setModified);
|
||||||
connect(m_versionNameLinedit, &QLineEdit::textEdited,
|
connect(m_versionNameLinedit, &QLineEdit::textEdited,
|
||||||
this, setDirtyFunc);
|
this, setDirtyFunc);
|
||||||
connect(m_androidMinSdkVersion,
|
connect(m_androidMinSdkVersion,
|
||||||
@@ -524,17 +524,17 @@ void AndroidManifestEditorWidget::updateAfterFileLoad()
|
|||||||
setActivePage(Source);
|
setActivePage(Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::setDirty(bool dirty)
|
void AndroidManifestEditorWidget::setModified(bool modified)
|
||||||
{
|
{
|
||||||
if (m_stayClean || dirty == m_dirty)
|
if (m_stayClean || modified == m_modified)
|
||||||
return;
|
return;
|
||||||
m_dirty = dirty;
|
m_modified = modified;
|
||||||
emit guiChanged();
|
emit modificationChanged(modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestEditorWidget::isModified() const
|
bool AndroidManifestEditorWidget::isModified() const
|
||||||
{
|
{
|
||||||
return m_dirty
|
return m_modified
|
||||||
|| !m_hIconPath.isEmpty()
|
|| !m_hIconPath.isEmpty()
|
||||||
|| !m_mIconPath.isEmpty()
|
|| !m_mIconPath.isEmpty()
|
||||||
|| !m_lIconPath.isEmpty();
|
|| !m_lIconPath.isEmpty();
|
||||||
@@ -819,7 +819,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
|||||||
updateAddRemovePermissionButtons();
|
updateAddRemovePermissionButtons();
|
||||||
|
|
||||||
m_stayClean = false;
|
m_stayClean = false;
|
||||||
m_dirty = false;
|
m_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int extractVersion(const QString &string)
|
int extractVersion(const QString &string)
|
||||||
@@ -862,7 +862,7 @@ void AndroidManifestEditorWidget::syncToEditor()
|
|||||||
m_textEditorWidget->setPlainText(result);
|
m_textEditorWidget->setPlainText(result);
|
||||||
m_textEditorWidget->document()->setModified(true);
|
m_textEditorWidget->document()->setModified(true);
|
||||||
|
|
||||||
m_dirty = false;
|
m_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -1253,7 +1253,7 @@ void AndroidManifestEditorWidget::setLDPIIcon()
|
|||||||
return;
|
return;
|
||||||
m_lIconPath = file;
|
m_lIconPath = file;
|
||||||
m_lIconButton->setIcon(QIcon(file));
|
m_lIconButton->setIcon(QIcon(file));
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::setMDPIIcon()
|
void AndroidManifestEditorWidget::setMDPIIcon()
|
||||||
@@ -1263,7 +1263,7 @@ void AndroidManifestEditorWidget::setMDPIIcon()
|
|||||||
return;
|
return;
|
||||||
m_mIconPath = file;
|
m_mIconPath = file;
|
||||||
m_mIconButton->setIcon(QIcon(file));
|
m_mIconButton->setIcon(QIcon(file));
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::setHDPIIcon()
|
void AndroidManifestEditorWidget::setHDPIIcon()
|
||||||
@@ -1273,12 +1273,12 @@ void AndroidManifestEditorWidget::setHDPIIcon()
|
|||||||
return;
|
return;
|
||||||
m_hIconPath = file;
|
m_hIconPath = file;
|
||||||
m_hIconButton->setIcon(QIcon(file));
|
m_hIconButton->setIcon(QIcon(file));
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::defaultPermissionOrFeatureCheckBoxClicked()
|
void AndroidManifestEditorWidget::defaultPermissionOrFeatureCheckBoxClicked()
|
||||||
{
|
{
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::updateAddRemovePermissionButtons()
|
void AndroidManifestEditorWidget::updateAddRemovePermissionButtons()
|
||||||
@@ -1293,7 +1293,7 @@ void AndroidManifestEditorWidget::addPermission()
|
|||||||
{
|
{
|
||||||
m_permissionsModel->addPermission(m_permissionsComboBox->currentText());
|
m_permissionsModel->addPermission(m_permissionsComboBox->currentText());
|
||||||
updateAddRemovePermissionButtons();
|
updateAddRemovePermissionButtons();
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::removePermission()
|
void AndroidManifestEditorWidget::removePermission()
|
||||||
@@ -1302,7 +1302,7 @@ void AndroidManifestEditorWidget::removePermission()
|
|||||||
if (idx.isValid())
|
if (idx.isValid())
|
||||||
m_permissionsModel->removePermission(idx.row());
|
m_permissionsModel->removePermission(idx.row());
|
||||||
updateAddRemovePermissionButtons();
|
updateAddRemovePermissionButtons();
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::setPackageName()
|
void AndroidManifestEditorWidget::setPackageName()
|
||||||
@@ -1312,7 +1312,7 @@ void AndroidManifestEditorWidget::setPackageName()
|
|||||||
bool valid = checkPackageName(packageName);
|
bool valid = checkPackageName(packageName);
|
||||||
m_packageNameWarning->setVisible(!valid);
|
m_packageNameWarning->setVisible(!valid);
|
||||||
m_packageNameWarningIcon->setVisible(!valid);
|
m_packageNameWarningIcon->setVisible(!valid);
|
||||||
setDirty(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -101,10 +101,10 @@ public:
|
|||||||
Core::IEditor *editor() const;
|
Core::IEditor *editor() const;
|
||||||
TextEditor::TextEditorWidget *textEditorWidget() const;
|
TextEditor::TextEditorWidget *textEditorWidget() const;
|
||||||
|
|
||||||
void setDirty(bool dirty = true);
|
void setModified(bool modified = true);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void guiChanged();
|
void modificationChanged(bool modified);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
@@ -150,7 +150,7 @@ private:
|
|||||||
QString parseComment(QXmlStreamReader &reader, QXmlStreamWriter &writer);
|
QString parseComment(QXmlStreamReader &reader, QXmlStreamWriter &writer);
|
||||||
void parseUnknownElement(QXmlStreamReader &reader, QXmlStreamWriter &writer);
|
void parseUnknownElement(QXmlStreamReader &reader, QXmlStreamWriter &writer);
|
||||||
|
|
||||||
bool m_dirty; // indicates that we need to call syncToEditor()
|
bool m_modified; // indicates that we need to call syncToEditor()
|
||||||
bool m_stayClean;
|
bool m_stayClean;
|
||||||
int m_errorLine;
|
int m_errorLine;
|
||||||
int m_errorColumn;
|
int m_errorColumn;
|
||||||
|
@@ -320,12 +320,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isModified() const override
|
|
||||||
{
|
|
||||||
return isTemporary()/*e.g. memory view*/ ? false
|
|
||||||
: m_widget->isModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFileReadOnly() const override {
|
bool isFileReadOnly() const override {
|
||||||
const FileName fn = filePath();
|
const FileName fn = filePath();
|
||||||
if (fn.isEmpty())
|
if (fn.isEmpty())
|
||||||
@@ -391,7 +385,12 @@ public:
|
|||||||
connect(m_addressEdit, &QLineEdit::editingFinished,
|
connect(m_addressEdit, &QLineEdit::editingFinished,
|
||||||
this, &BinEditor::jumpToAddress);
|
this, &BinEditor::jumpToAddress);
|
||||||
connect(widget, &BinEditorWidget::modificationChanged,
|
connect(widget, &BinEditorWidget::modificationChanged,
|
||||||
m_file, &IDocument::changed);
|
m_file, &IDocument::setModified);
|
||||||
|
connect(m_file, &IDocument::modificationChanged,
|
||||||
|
widget, &BinEditorWidget::setModified);
|
||||||
|
|
||||||
|
m_file->setModified(widget->isModified());
|
||||||
|
|
||||||
updateCursorPosition(widget->cursorPosition());
|
updateCursorPosition(widget->cursorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,6 +79,7 @@ public:
|
|||||||
bool hasWriteWarning = false;
|
bool hasWriteWarning = false;
|
||||||
bool restored = false;
|
bool restored = false;
|
||||||
bool isSuspendAllowed = false;
|
bool isSuspendAllowed = false;
|
||||||
|
bool isModified = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -200,7 +201,17 @@ bool IDocument::shouldAutoSave() const
|
|||||||
|
|
||||||
bool IDocument::isModified() const
|
bool IDocument::isModified() const
|
||||||
{
|
{
|
||||||
return false;
|
return d->isModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDocument::setModified(bool modified)
|
||||||
|
{
|
||||||
|
if (d->isModified == modified)
|
||||||
|
return;
|
||||||
|
|
||||||
|
d->isModified = modified;
|
||||||
|
emit modificationChanged(modified);
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDocument::isSaveAsAllowed() const
|
bool IDocument::isSaveAsAllowed() const
|
||||||
|
@@ -106,6 +106,9 @@ public:
|
|||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
void setTemporary(bool temporary);
|
void setTemporary(bool temporary);
|
||||||
|
|
||||||
|
bool isModified() const;
|
||||||
|
void setModified(bool modified);
|
||||||
|
|
||||||
virtual QString fallbackSaveAsPath() const;
|
virtual QString fallbackSaveAsPath() const;
|
||||||
virtual QString fallbackSaveAsFileName() const;
|
virtual QString fallbackSaveAsFileName() const;
|
||||||
|
|
||||||
@@ -113,7 +116,6 @@ public:
|
|||||||
void setMimeType(const QString &mimeType);
|
void setMimeType(const QString &mimeType);
|
||||||
|
|
||||||
virtual bool shouldAutoSave() const;
|
virtual bool shouldAutoSave() const;
|
||||||
virtual bool isModified() const;
|
|
||||||
virtual bool isSaveAsAllowed() const;
|
virtual bool isSaveAsAllowed() const;
|
||||||
bool isSuspendAllowed() const;
|
bool isSuspendAllowed() const;
|
||||||
void setSuspendAllowed(bool value);
|
void setSuspendAllowed(bool value);
|
||||||
@@ -136,6 +138,8 @@ signals:
|
|||||||
// For meta data changes: file name, modified state, ...
|
// For meta data changes: file name, modified state, ...
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
void modificationChanged(bool modified);
|
||||||
|
|
||||||
// For changes in the contents of the document
|
// For changes in the contents of the document
|
||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
|
|
||||||
|
@@ -59,6 +59,9 @@ FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *pare
|
|||||||
connect(m_formWindow->commandHistory(), &QUndoStack::indexChanged,
|
connect(m_formWindow->commandHistory(), &QUndoStack::indexChanged,
|
||||||
this, &FormWindowFile::setShouldAutoSave);
|
this, &FormWindowFile::setShouldAutoSave);
|
||||||
connect(m_formWindow.data(), &QDesignerFormWindowInterface::changed, this, &FormWindowFile::updateIsModified);
|
connect(m_formWindow.data(), &QDesignerFormWindowInterface::changed, this, &FormWindowFile::updateIsModified);
|
||||||
|
connect(this, &IDocument::modificationChanged, m_formWindow.data(), &QDesignerFormWindowInterface::setDirty);
|
||||||
|
|
||||||
|
setModified(m_formWindow->isDirty());
|
||||||
|
|
||||||
m_resourceHandler = new ResourceHandler(form);
|
m_resourceHandler = new ResourceHandler(form);
|
||||||
connect(this, &FormWindowFile::filePathChanged,
|
connect(this, &FormWindowFile::filePathChanged,
|
||||||
@@ -186,10 +189,7 @@ void FormWindowFile::updateIsModified()
|
|||||||
bool value = m_formWindow && m_formWindow->isDirty();
|
bool value = m_formWindow && m_formWindow->isDirty();
|
||||||
if (value)
|
if (value)
|
||||||
emit contentsChanged();
|
emit contentsChanged();
|
||||||
if (value == m_isModified)
|
setModified(value);
|
||||||
return;
|
|
||||||
m_isModified = value;
|
|
||||||
emit changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormWindowFile::shouldAutoSave() const
|
bool FormWindowFile::shouldAutoSave() const
|
||||||
@@ -197,11 +197,6 @@ bool FormWindowFile::shouldAutoSave() const
|
|||||||
return m_shouldAutoSave;
|
return m_shouldAutoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormWindowFile::isModified() const
|
|
||||||
{
|
|
||||||
return m_formWindow && m_formWindow->isDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FormWindowFile::isSaveAsAllowed() const
|
bool FormWindowFile::isSaveAsAllowed() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@@ -53,7 +53,6 @@ public:
|
|||||||
QByteArray contents() const override;
|
QByteArray contents() const override;
|
||||||
bool setContents(const QByteArray &contents) override;
|
bool setContents(const QByteArray &contents) override;
|
||||||
bool shouldAutoSave() const override;
|
bool shouldAutoSave() const override;
|
||||||
bool isModified() const override;
|
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
QString fallbackSaveAsFileName() const override;
|
QString fallbackSaveAsFileName() const override;
|
||||||
@@ -82,7 +81,6 @@ private:
|
|||||||
// Might actually go out of scope before the IEditor due
|
// Might actually go out of scope before the IEditor due
|
||||||
// to deleting the WidgetHost which owns it.
|
// to deleting the WidgetHost which owns it.
|
||||||
QPointer<QDesignerFormWindowInterface> m_formWindow;
|
QPointer<QDesignerFormWindowInterface> m_formWindow;
|
||||||
bool m_isModified = false;
|
|
||||||
ResourceHandler *m_resourceHandler = nullptr;
|
ResourceHandler *m_resourceHandler = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ void ExtPropertiesMView::onConfigPathChanged(const QString &path)
|
|||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
if (!project->configPath().isEmpty()) {
|
if (!project->configPath().isEmpty()) {
|
||||||
project->setConfigPath(QString());
|
project->setConfigPath(QString());
|
||||||
m_projectController->setModified();
|
m_projectController->setModified(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +103,7 @@ void ExtPropertiesMView::onConfigPathChanged(const QString &path)
|
|||||||
QString configPath = projectDir.relativeFilePath(absConfigPath.filePath());
|
QString configPath = projectDir.relativeFilePath(absConfigPath.filePath());
|
||||||
if (configPath != project->configPath()) {
|
if (configPath != project->configPath()) {
|
||||||
project->setConfigPath(configPath);
|
project->setConfigPath(configPath);
|
||||||
m_projectController->setModified();
|
m_projectController->setModified(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ bool ModelDocument::save(QString *errorString, const QString &name, bool autoSav
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (autoSave) {
|
if (autoSave) {
|
||||||
d->documentController->projectController()->setModified();
|
d->documentController->projectController()->setModified(true);
|
||||||
} else {
|
} else {
|
||||||
setFilePath(Utils::FileName::fromString(d->documentController->projectController()->project()->fileName()));
|
setFilePath(Utils::FileName::fromString(d->documentController->projectController()->project()->fileName()));
|
||||||
emit changed();
|
emit changed();
|
||||||
@@ -108,11 +108,6 @@ bool ModelDocument::shouldAutoSave() const
|
|||||||
return isModified();
|
return isModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelDocument::isModified() const
|
|
||||||
{
|
|
||||||
return d->documentController ? d->documentController->projectController()->isModified() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModelDocument::isSaveAsAllowed() const
|
bool ModelDocument::isSaveAsAllowed() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -140,6 +135,10 @@ Core::IDocument::OpenResult ModelDocument::load(QString *errorString, const QStr
|
|||||||
{
|
{
|
||||||
d->documentController = ModelEditorPlugin::modelsManager()->createModel(this);
|
d->documentController = ModelEditorPlugin::modelsManager()->createModel(this);
|
||||||
connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed);
|
connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed);
|
||||||
|
connect(d->documentController, &qmt::DocumentController::modificationChanged, this, &IDocument::setModified);
|
||||||
|
connect(this, &IDocument::modificationChanged,
|
||||||
|
d->documentController->projectController(), &qmt::ProjectController::setModified);
|
||||||
|
setModified(d->documentController->projectController()->isModified());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
d->documentController->loadProject(fileName);
|
d->documentController->loadProject(fileName);
|
||||||
|
@@ -52,7 +52,6 @@ public:
|
|||||||
const QString &realFileName) override;
|
const QString &realFileName) override;
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
||||||
bool shouldAutoSave() const override;
|
bool shouldAutoSave() const override;
|
||||||
bool isModified() const override;
|
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
|
|
||||||
|
@@ -63,10 +63,14 @@ ResourceEditorDocument::ResourceEditorDocument(QObject *parent) :
|
|||||||
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
||||||
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
|
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
|
||||||
connect(m_model, &RelativeResourceModel::dirtyChanged,
|
connect(m_model, &RelativeResourceModel::dirtyChanged,
|
||||||
this, &ResourceEditorDocument::dirtyChanged);
|
this, &ResourceEditorDocument::setModified);
|
||||||
|
connect(this, &IDocument::modificationChanged,
|
||||||
|
m_model, &RelativeResourceModel::setDirty);
|
||||||
connect(m_model, &ResourceModel::contentsChanged,
|
connect(m_model, &ResourceModel::contentsChanged,
|
||||||
this, &IDocument::contentsChanged);
|
this, &IDocument::contentsChanged);
|
||||||
|
|
||||||
|
setModified(m_model->dirty());
|
||||||
|
|
||||||
if (debugResourceEditorW)
|
if (debugResourceEditorW)
|
||||||
qDebug() << "ResourceEditorFile::ResourceEditorFile()";
|
qDebug() << "ResourceEditorFile::ResourceEditorFile()";
|
||||||
}
|
}
|
||||||
@@ -124,20 +128,16 @@ Core::IDocument::OpenResult ResourceEditorDocument::open(QString *errorString,
|
|||||||
if (debugResourceEditorW)
|
if (debugResourceEditorW)
|
||||||
qDebug() << "ResourceEditorW::open: " << fileName;
|
qDebug() << "ResourceEditorW::open: " << fileName;
|
||||||
|
|
||||||
setBlockDirtyChanged(true);
|
|
||||||
|
|
||||||
m_model->setFileName(realFileName);
|
m_model->setFileName(realFileName);
|
||||||
|
|
||||||
OpenResult openResult = m_model->reload();
|
OpenResult openResult = m_model->reload();
|
||||||
if (openResult != OpenResult::Success) {
|
if (openResult != OpenResult::Success) {
|
||||||
*errorString = m_model->errorMessage();
|
*errorString = m_model->errorMessage();
|
||||||
setBlockDirtyChanged(false);
|
|
||||||
emit loaded(false);
|
emit loaded(false);
|
||||||
return openResult;
|
return openResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilePath(FileName::fromString(fileName));
|
setFilePath(FileName::fromString(fileName));
|
||||||
setBlockDirtyChanged(false);
|
|
||||||
m_model->setDirty(fileName != realFileName);
|
m_model->setDirty(fileName != realFileName);
|
||||||
m_shouldAutoSave = false;
|
m_shouldAutoSave = false;
|
||||||
|
|
||||||
@@ -155,12 +155,10 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo
|
|||||||
if (actualName.isEmpty())
|
if (actualName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_blockDirtyChanged = true;
|
|
||||||
m_model->setFileName(actualName.toString());
|
m_model->setFileName(actualName.toString());
|
||||||
if (!m_model->save()) {
|
if (!m_model->save()) {
|
||||||
*errorString = m_model->errorMessage();
|
*errorString = m_model->errorMessage();
|
||||||
m_model->setFileName(oldFileName.toString());
|
m_model->setFileName(oldFileName.toString());
|
||||||
m_blockDirtyChanged = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,12 +166,10 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo
|
|||||||
if (autoSave) {
|
if (autoSave) {
|
||||||
m_model->setFileName(oldFileName.toString());
|
m_model->setFileName(oldFileName.toString());
|
||||||
m_model->setDirty(true);
|
m_model->setDirty(true);
|
||||||
m_blockDirtyChanged = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilePath(actualName);
|
setFilePath(actualName);
|
||||||
m_blockDirtyChanged = false;
|
|
||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
return true;
|
return true;
|
||||||
@@ -213,11 +209,6 @@ void ResourceEditorDocument::setFilePath(const FileName &newName)
|
|||||||
IDocument::setFilePath(newName);
|
IDocument::setFilePath(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceEditorDocument::setBlockDirtyChanged(bool value)
|
|
||||||
{
|
|
||||||
m_blockDirtyChanged = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
RelativeResourceModel *ResourceEditorDocument::model() const
|
RelativeResourceModel *ResourceEditorDocument::model() const
|
||||||
{
|
{
|
||||||
return m_model;
|
return m_model;
|
||||||
@@ -238,11 +229,6 @@ bool ResourceEditorDocument::shouldAutoSave() const
|
|||||||
return m_shouldAutoSave;
|
return m_shouldAutoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResourceEditorDocument::isModified() const
|
|
||||||
{
|
|
||||||
return m_model->dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ResourceEditorDocument::isSaveAsAllowed() const
|
bool ResourceEditorDocument::isSaveAsAllowed() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -264,16 +250,6 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceEditorDocument::dirtyChanged(bool dirty)
|
|
||||||
{
|
|
||||||
if (m_blockDirtyChanged)
|
|
||||||
return; // We emit changed() afterwards, unless it was an autosave
|
|
||||||
|
|
||||||
if (debugResourceEditorW)
|
|
||||||
qDebug() << " ResourceEditorW::dirtyChanged" << dirty;
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceEditorW::onUndoStackChanged(bool canUndo, bool canRedo)
|
void ResourceEditorW::onUndoStackChanged(bool canUndo, bool canRedo)
|
||||||
{
|
{
|
||||||
m_plugin->onUndoStackChanged(this, canUndo, canRedo);
|
m_plugin->onUndoStackChanged(this, canUndo, canRedo);
|
||||||
|
@@ -58,11 +58,9 @@ public:
|
|||||||
QByteArray contents() const override;
|
QByteArray contents() const override;
|
||||||
bool setContents(const QByteArray &contents) override;
|
bool setContents(const QByteArray &contents) override;
|
||||||
bool shouldAutoSave() const override;
|
bool shouldAutoSave() const override;
|
||||||
bool isModified() const override;
|
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
void setFilePath(const Utils::FileName &newName) override;
|
void setFilePath(const Utils::FileName &newName) override;
|
||||||
void setBlockDirtyChanged(bool value);
|
|
||||||
|
|
||||||
RelativeResourceModel *model() const;
|
RelativeResourceModel *model() const;
|
||||||
void setShouldAutoSave(bool save);
|
void setShouldAutoSave(bool save);
|
||||||
@@ -71,10 +69,8 @@ signals:
|
|||||||
void loaded(bool success);
|
void loaded(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void dirtyChanged(bool);
|
|
||||||
|
|
||||||
RelativeResourceModel *m_model;
|
RelativeResourceModel *m_model;
|
||||||
bool m_blockDirtyChanged = false;
|
|
||||||
bool m_shouldAutoSave = false;
|
bool m_shouldAutoSave = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -789,6 +789,11 @@ bool MainWidget::isDirty() const
|
|||||||
return m_document->changed();
|
return m_document->changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::setDirty(bool dirty)
|
||||||
|
{
|
||||||
|
m_document->setChanged(dirty);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::fitToView()
|
void MainWidget::fitToView()
|
||||||
{
|
{
|
||||||
StateView *view = m_views.last();
|
StateView *view = m_views.last();
|
||||||
|
@@ -87,6 +87,7 @@ public:
|
|||||||
QString contents() const;
|
QString contents() const;
|
||||||
QUndoStack *undoStack() const;
|
QUndoStack *undoStack() const;
|
||||||
bool isDirty() const;
|
bool isDirty() const;
|
||||||
|
void setDirty(bool dirty);
|
||||||
void newDocument();
|
void newDocument();
|
||||||
void refresh();
|
void refresh();
|
||||||
OutputPane::WarningModel *warningModel() const;
|
OutputPane::WarningModel *warningModel() const;
|
||||||
|
@@ -643,6 +643,14 @@ bool ScxmlDocument::changed() const
|
|||||||
return !m_undoStack->isClean();
|
return !m_undoStack->isClean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScxmlDocument::setChanged(bool modified)
|
||||||
|
{
|
||||||
|
if (modified)
|
||||||
|
; // we lack a setDirty method in QUndoStack
|
||||||
|
else
|
||||||
|
m_undoStack->setClean();
|
||||||
|
}
|
||||||
|
|
||||||
ScxmlTag *ScxmlDocument::scxmlRootTag() const
|
ScxmlTag *ScxmlDocument::scxmlRootTag() const
|
||||||
{
|
{
|
||||||
ScxmlTag *tag = rootTag();
|
ScxmlTag *tag = rootTag();
|
||||||
|
@@ -156,6 +156,7 @@ public:
|
|||||||
* @return - true if changed, false otherwise
|
* @return - true if changed, false otherwise
|
||||||
*/
|
*/
|
||||||
bool changed() const;
|
bool changed() const;
|
||||||
|
void setChanged(bool modified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief rootTag - return rootTag of the document
|
* @brief rootTag - return rootTag of the document
|
||||||
@@ -277,6 +278,7 @@ private:
|
|||||||
ScxmlTag *createScxmlTag();
|
ScxmlTag *createScxmlTag();
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
int m_cleanIndex;
|
||||||
QVector<ScxmlTag*> m_tags;
|
QVector<ScxmlTag*> m_tags;
|
||||||
QHash<QString, int> m_nextIdHash;
|
QHash<QString, int> m_nextIdHash;
|
||||||
QHash<QString, QString> m_idMap;
|
QHash<QString, QString> m_idMap;
|
||||||
|
@@ -52,9 +52,12 @@ ScxmlEditorDocument::ScxmlEditorDocument(MainWidget *designWidget, QObject *pare
|
|||||||
|
|
||||||
// Designer needs UTF-8 regardless of settings.
|
// Designer needs UTF-8 regardless of settings.
|
||||||
setCodec(QTextCodec::codecForName("UTF-8"));
|
setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
connect(m_designWidget.data(), &Common::MainWidget::dirtyChanged, this, [this]{
|
connect(m_designWidget.data(), &Common::MainWidget::dirtyChanged, this, [this](bool modified){
|
||||||
emit changed();
|
setModified(modified);
|
||||||
});
|
});
|
||||||
|
connect(this, &IDocument::modificationChanged, m_designWidget.data(), &Common::MainWidget::setDirty);
|
||||||
|
|
||||||
|
setModified(m_designWidget->isDirty());
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IDocument::OpenResult ScxmlEditorDocument::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
Core::IDocument::OpenResult ScxmlEditorDocument::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
@@ -129,11 +132,6 @@ MainWidget *ScxmlEditorDocument::designWidget() const
|
|||||||
return m_designWidget;
|
return m_designWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScxmlEditorDocument::isModified() const
|
|
||||||
{
|
|
||||||
return m_designWidget && m_designWidget->isDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScxmlEditorDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
bool ScxmlEditorDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
||||||
{
|
{
|
||||||
if (flag == FlagIgnore) {
|
if (flag == FlagIgnore) {
|
||||||
|
@@ -53,7 +53,6 @@ public:
|
|||||||
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
||||||
bool shouldAutoSave() const override;
|
bool shouldAutoSave() const override;
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
bool isModified() const override;
|
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
|
@@ -236,13 +236,16 @@ void TextDocumentPrivate::updateRevisions()
|
|||||||
TextDocument::TextDocument(Id id)
|
TextDocument::TextDocument(Id id)
|
||||||
: d(new TextDocumentPrivate)
|
: d(new TextDocumentPrivate)
|
||||||
{
|
{
|
||||||
QObject::connect(&d->m_document, &QTextDocument::modificationChanged, [this](bool modified) {
|
connect(&d->m_document, &QTextDocument::modificationChanged, [this](bool modified) {
|
||||||
// we only want to update the block revisions when going back to the saved version,
|
// we only want to update the block revisions when going back to the saved version,
|
||||||
// e.g. with undo
|
// e.g. with undo
|
||||||
if (!modified)
|
if (!modified)
|
||||||
d->updateRevisions();
|
d->updateRevisions();
|
||||||
emit changed();
|
setModified(modified);
|
||||||
});
|
});
|
||||||
|
connect(this, &IDocument::modificationChanged, &d->m_document, &QTextDocument::setModified);
|
||||||
|
|
||||||
|
setModified(d->m_document.isModified());
|
||||||
|
|
||||||
connect(&d->m_document, &QTextDocument::contentsChanged,
|
connect(&d->m_document, &QTextDocument::contentsChanged,
|
||||||
this, &Core::IDocument::contentsChanged);
|
this, &Core::IDocument::contentsChanged);
|
||||||
@@ -595,11 +598,6 @@ bool TextDocument::isFileReadOnly() const
|
|||||||
return d->m_fileIsReadOnly;
|
return d->m_fileIsReadOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextDocument::isModified() const
|
|
||||||
{
|
|
||||||
return d->m_document.isModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextDocument::checkPermissions()
|
void TextDocument::checkPermissions()
|
||||||
{
|
{
|
||||||
bool previousReadOnly = d->m_fileIsReadOnly;
|
bool previousReadOnly = d->m_fileIsReadOnly;
|
||||||
|
@@ -103,7 +103,6 @@ public:
|
|||||||
bool setContents(const QByteArray &contents) override;
|
bool setContents(const QByteArray &contents) override;
|
||||||
bool shouldAutoSave() const override;
|
bool shouldAutoSave() const override;
|
||||||
bool isFileReadOnly() const override;
|
bool isFileReadOnly() const override;
|
||||||
bool isModified() const override;
|
|
||||||
bool isSaveAsAllowed() const override;
|
bool isSaveAsAllowed() const override;
|
||||||
void checkPermissions() override;
|
void checkPermissions() override;
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
|
@@ -44,7 +44,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, VcsBaseSubmitEditor *parent) :
|
SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, VcsBaseSubmitEditor *parent) :
|
||||||
Core::IDocument(parent),
|
Core::IDocument(parent),
|
||||||
m_modified(false),
|
|
||||||
m_editor(parent)
|
m_editor(parent)
|
||||||
{
|
{
|
||||||
setId(parameters->id);
|
setId(parameters->id);
|
||||||
@@ -83,14 +82,6 @@ bool SubmitEditorFile::setContents(const QByteArray &contents)
|
|||||||
return m_editor->setFileContents(contents);
|
return m_editor->setFileContents(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubmitEditorFile::setModified(bool modified)
|
|
||||||
{
|
|
||||||
if (m_modified == modified)
|
|
||||||
return;
|
|
||||||
m_modified = modified;
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
{
|
{
|
||||||
const FileName fName = fileName.isEmpty() ? filePath() : FileName::fromString(fileName);
|
const FileName fName = fileName.isEmpty() ? filePath() : FileName::fromString(fileName);
|
||||||
|
@@ -45,14 +45,10 @@ public:
|
|||||||
QByteArray contents() const override;
|
QByteArray contents() const override;
|
||||||
bool setContents(const QByteArray &contents) override;
|
bool setContents(const QByteArray &contents) override;
|
||||||
|
|
||||||
bool isModified() const override { return m_modified; }
|
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
||||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
|
||||||
|
|
||||||
void setModified(bool modified = true);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_modified;
|
|
||||||
VcsBaseSubmitEditor *m_editor;
|
VcsBaseSubmitEditor *m_editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user