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