Commit 93ccf4f2 authored by hjk's avatar hjk
Browse files

IDocument: Make mimeType a value member



Change-Id: I2e90ccf0a45ae8d00bcd00ec77fe0d9776f2f119
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 777b9e88
...@@ -41,6 +41,7 @@ AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QStr ...@@ -41,6 +41,7 @@ AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QStr
m_project(project) m_project(project)
{ {
setId("Autotools.ProjectFile"); setId("Autotools.ProjectFile");
setMimeType(QLatin1String(Constants::MAKEFILE_MIMETYPE));
setFilePath(fileName); setFilePath(fileName);
} }
...@@ -63,11 +64,6 @@ QString AutotoolsProjectFile::suggestedFileName() const ...@@ -63,11 +64,6 @@ QString AutotoolsProjectFile::suggestedFileName() const
return QString(); return QString();
} }
QString AutotoolsProjectFile::mimeType() const
{
return QLatin1String(Constants::MAKEFILE_MIMETYPE);
}
bool AutotoolsProjectFile::isModified() const bool AutotoolsProjectFile::isModified() const
{ {
return false; return false;
......
...@@ -59,7 +59,6 @@ public: ...@@ -59,7 +59,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave); bool save(QString *errorString, const QString &fileName, bool autoSave);
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type); bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
......
...@@ -206,17 +206,13 @@ public: ...@@ -206,17 +206,13 @@ public:
Core::IDocument(parent) Core::IDocument(parent)
{ {
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
setMimeType(QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE));
m_widget = parent; m_widget = parent;
connect(m_widget, SIGNAL(dataRequested(quint64)), connect(m_widget, SIGNAL(dataRequested(quint64)),
this, SLOT(provideData(quint64))); this, SLOT(provideData(quint64)));
connect(m_widget, SIGNAL(newRangeRequested(quint64)), connect(m_widget, SIGNAL(newRangeRequested(quint64)),
this, SLOT(provideNewRange(quint64))); this, SLOT(provideNewRange(quint64)));
} }
~BinEditorDocument() {}
QString mimeType() const {
return QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE);
}
bool setContents(const QByteArray &contents) bool setContents(const QByteArray &contents)
{ {
......
...@@ -767,6 +767,7 @@ CMakeFile::CMakeFile(CMakeProject *parent, QString fileName) ...@@ -767,6 +767,7 @@ CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
: Core::IDocument(parent), m_project(parent) : Core::IDocument(parent), m_project(parent)
{ {
setId("Cmake.ProjectFile"); setId("Cmake.ProjectFile");
setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
setFilePath(fileName); setFilePath(fileName);
} }
...@@ -790,12 +791,6 @@ QString CMakeFile::suggestedFileName() const ...@@ -790,12 +791,6 @@ QString CMakeFile::suggestedFileName() const
return QString(); return QString();
} }
QString CMakeFile::mimeType() const
{
return QLatin1String(Constants::CMAKEMIMETYPE);
}
bool CMakeFile::isModified() const bool CMakeFile::isModified() const
{ {
return false; return false;
......
...@@ -194,7 +194,6 @@ public: ...@@ -194,7 +194,6 @@ public:
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
......
...@@ -142,6 +142,14 @@ void IDocument::setTemporary(bool temporary) ...@@ -142,6 +142,14 @@ void IDocument::setTemporary(bool temporary)
m_temporary = temporary; m_temporary = temporary;
} }
void IDocument::setMimeType(const QString &mimeType)
{
if (m_mimeType != mimeType) {
m_mimeType = mimeType;
emit mimeTypeChanged();
}
}
bool IDocument::autoSave(QString *errorString, const QString &fileName) bool IDocument::autoSave(QString *errorString, const QString &fileName)
{ {
if (!save(errorString, fileName, true)) if (!save(errorString, fileName, true))
......
...@@ -94,7 +94,9 @@ public: ...@@ -94,7 +94,9 @@ public:
virtual QString defaultPath() const = 0; virtual QString defaultPath() const = 0;
virtual QString suggestedFileName() const = 0; virtual QString suggestedFileName() const = 0;
virtual QString mimeType() const = 0;
QString mimeType() const { return m_mimeType; }
void setMimeType(const QString &mimeType);
virtual bool shouldAutoSave() const; virtual bool shouldAutoSave() const;
virtual bool isModified() const = 0; virtual bool isModified() const = 0;
...@@ -116,6 +118,7 @@ public: ...@@ -116,6 +118,7 @@ public:
signals: signals:
void changed(); void changed();
void mimeTypeChanged();
void aboutToReload(); void aboutToReload();
void reloadFinished(bool success); void reloadFinished(bool success);
...@@ -124,6 +127,7 @@ signals: ...@@ -124,6 +127,7 @@ signals:
private: private:
Id m_id; Id m_id;
QString m_mimeType;
QString m_filePath; QString m_filePath;
QString m_displayName; QString m_displayName;
bool m_temporary; bool m_temporary;
......
...@@ -52,11 +52,11 @@ namespace Designer { ...@@ -52,11 +52,11 @@ namespace Designer {
namespace Internal { namespace Internal {
FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent) FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent)
: m_mimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE)), : m_shouldAutoSave(false),
m_shouldAutoSave(false),
m_formWindow(form), m_formWindow(form),
m_isModified(false) m_isModified(false)
{ {
setMimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE));
setParent(parent); setParent(parent);
setId(Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID)); setId(Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID));
// Designer needs UTF-8 regardless of settings. // Designer needs UTF-8 regardless of settings.
...@@ -210,11 +210,6 @@ QString FormWindowFile::suggestedFileName() const ...@@ -210,11 +210,6 @@ QString FormWindowFile::suggestedFileName() const
return m_suggestedName; return m_suggestedName;
} }
QString FormWindowFile::mimeType() const
{
return m_mimeType;
}
bool FormWindowFile::writeFile(const QString &fn, QString *errorString) const bool FormWindowFile::writeFile(const QString &fn, QString *errorString) const
{ {
if (Designer::Constants::Internal::debug) if (Designer::Constants::Internal::debug)
......
...@@ -59,7 +59,6 @@ public: ...@@ -59,7 +59,6 @@ public:
bool reload(QString *errorString, ReloadFlag flag, ChangeType type); bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
// Internal // Internal
void setSuggestedFileName(const QString &fileName); void setSuggestedFileName(const QString &fileName);
...@@ -83,8 +82,6 @@ private slots: ...@@ -83,8 +82,6 @@ private slots:
void slotFormWindowRemoved(QDesignerFormWindowInterface *w); void slotFormWindowRemoved(QDesignerFormWindowInterface *w);
private: private:
const QString m_mimeType;
QString m_suggestedName; QString m_suggestedName;
bool m_shouldAutoSave; bool m_shouldAutoSave;
// Might actually go out of scope before the IEditor due // Might actually go out of scope before the IEditor due
......
...@@ -67,11 +67,6 @@ bool DiffEditorDocument::save(QString *errorString, const QString &fileName, boo ...@@ -67,11 +67,6 @@ bool DiffEditorDocument::save(QString *errorString, const QString &fileName, boo
return false; return false;
} }
QString DiffEditorDocument::mimeType() const
{
return QString();
}
Core::IDocument::ReloadBehavior DiffEditorDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior DiffEditorDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
......
...@@ -52,7 +52,6 @@ public: ...@@ -52,7 +52,6 @@ public:
QString suggestedFileName() const { return QString(); } QString suggestedFileName() const { return QString(); }
bool isModified() const { return false; } bool isModified() const { return false; }
QString mimeType() const;
bool isSaveAsAllowed() const { return false; } bool isSaveAsAllowed() const { return false; }
bool save(QString *errorString, const QString &fileName, bool autoSave); bool save(QString *errorString, const QString &fileName, bool autoSave);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
......
...@@ -409,6 +409,7 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, ...@@ -409,6 +409,7 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName,
m_options(options) m_options(options)
{ {
setId("Generic.ProjectFile"); setId("Generic.ProjectFile");
setMimeType(QLatin1String(Constants::GENERICMIMETYPE));
setFilePath(fileName); setFilePath(fileName);
} }
...@@ -427,11 +428,6 @@ QString GenericProjectFile::suggestedFileName() const ...@@ -427,11 +428,6 @@ QString GenericProjectFile::suggestedFileName() const
return QString(); return QString();
} }
QString GenericProjectFile::mimeType() const
{
return QLatin1String(Constants::GENERICMIMETYPE);
}
bool GenericProjectFile::isModified() const bool GenericProjectFile::isModified() const
{ {
return false; return false;
......
...@@ -123,7 +123,6 @@ public: ...@@ -123,7 +123,6 @@ public:
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
......
...@@ -42,6 +42,7 @@ ImageViewerFile::ImageViewerFile(ImageViewer *parent) ...@@ -42,6 +42,7 @@ ImageViewerFile::ImageViewerFile(ImageViewer *parent)
{ {
setId(Constants::IMAGEVIEWER_ID); setId(Constants::IMAGEVIEWER_ID);
m_editor = parent; m_editor = parent;
connect(this, SIGNAL(mimeTypeChanged()), this, SIGNAL(changed()));
} }
Core::IDocument::ReloadBehavior ImageViewerFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior ImageViewerFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
...@@ -90,11 +91,6 @@ QString ImageViewerFile::suggestedFileName() const ...@@ -90,11 +91,6 @@ QString ImageViewerFile::suggestedFileName() const
return QString(); return QString();
} }
QString ImageViewerFile::mimeType() const
{
return m_mimeType;
}
bool ImageViewerFile::isModified() const bool ImageViewerFile::isModified() const
{ {
return false; return false;
...@@ -105,11 +101,5 @@ bool ImageViewerFile::isSaveAsAllowed() const ...@@ -105,11 +101,5 @@ bool ImageViewerFile::isSaveAsAllowed() const
return false; return false;
} }
void ImageViewerFile::setMimetype(const QString &mimetype)
{
m_mimeType = mimetype;
emit changed();
}
} // namespace Internal } // namespace Internal
} // namespace ImageViewer } // namespace ImageViewer
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
...@@ -58,10 +57,7 @@ public: ...@@ -58,10 +57,7 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type); bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void setMimetype(const QString &mimetype);
private: private:
QString m_mimeType;
ImageViewer *m_editor; ImageViewer *m_editor;
}; };
......
...@@ -39,6 +39,7 @@ QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDo ...@@ -39,6 +39,7 @@ QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDo
m_project(parent) m_project(parent)
{ {
setId("Qbs.ProjectFile"); setId("Qbs.ProjectFile");
setMimeType(QLatin1String(Constants::MIME_TYPE));
setFilePath(fileName); setFilePath(fileName);
} }
...@@ -65,11 +66,6 @@ QString QbsProjectFile::suggestedFileName() const ...@@ -65,11 +66,6 @@ QString QbsProjectFile::suggestedFileName() const
return QString(); return QString();
} }
QString QbsProjectFile::mimeType() const
{
return QLatin1String(Constants::MIME_TYPE);
}
bool QbsProjectFile::isModified() const bool QbsProjectFile::isModified() const
{ {
return false; return false;
......
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
......
...@@ -184,6 +184,7 @@ QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile) ...@@ -184,6 +184,7 @@ QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile)
: IDocument(qmakePriFile), m_priFile(qmakePriFile) : IDocument(qmakePriFile), m_priFile(qmakePriFile)
{ {
setId("Qmake.PriFile"); setId("Qmake.PriFile");
setMimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE));
setFilePath(m_priFile->path()); setFilePath(m_priFile->path());
} }
...@@ -205,11 +206,6 @@ QString QmakePriFile::suggestedFileName() const ...@@ -205,11 +206,6 @@ QString QmakePriFile::suggestedFileName() const
return QString(); return QString();
} }
QString QmakePriFile::mimeType() const
{
return QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
}
bool QmakePriFile::isModified() const bool QmakePriFile::isModified() const
{ {
return false; return false;
......
...@@ -242,7 +242,6 @@ public: ...@@ -242,7 +242,6 @@ public:
virtual QString defaultPath() const; virtual QString defaultPath() const;
virtual QString suggestedFileName() const; virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const; virtual bool isModified() const;
virtual bool isSaveAsAllowed() const; virtual bool isSaveAsAllowed() const;
......
...@@ -128,16 +128,12 @@ public: ...@@ -128,16 +128,12 @@ public:
QString defaultPath() const; QString defaultPath() const;
QString suggestedFileName() const; QString suggestedFileName() const;
virtual QString mimeType() const;
bool isModified() const; bool isModified() const;
bool isSaveAsAllowed() const; bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type); bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
const QString m_mimeType;
}; };
/// Watches folders for QmakePriFile nodes /// Watches folders for QmakePriFile nodes
...@@ -274,10 +270,10 @@ void ProjectFilesVisitor::visitFolderNode(FolderNode *folderNode) ...@@ -274,10 +270,10 @@ void ProjectFilesVisitor::visitFolderNode(FolderNode *folderNode)
// ----------- QmakeProjectFile // ----------- QmakeProjectFile
namespace Internal { namespace Internal {
QmakeProjectFile::QmakeProjectFile(const QString &filePath, QObject *parent) QmakeProjectFile::QmakeProjectFile(const QString &filePath, QObject *parent)
: Core::IDocument(parent), : Core::IDocument(parent)
m_mimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE))
{ {
setId("Qmake.ProFile"); setId("Qmake.ProFile");
setMimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE));
setFilePath(filePath); setFilePath(filePath);
} }
...@@ -297,11 +293,6 @@ QString QmakeProjectFile::suggestedFileName() const ...@@ -297,11 +293,6 @@ QString QmakeProjectFile::suggestedFileName() const
return QString(); return QString();
} }
QString QmakeProjectFile::mimeType() const
{
return m_mimeType;
}
bool QmakeProjectFile::isModified() const bool QmakeProjectFile::isModified() const
{ {
return false; // we save after changing anyway return false; // we save after changing anyway
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment