Commit 93ccf4f2 authored by hjk's avatar hjk

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
......
......@@ -42,6 +42,7 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
QTC_CHECK(m_project);
QTC_CHECK(!fileName.isEmpty());
setId("Qml.ProjectFile");
setMimeType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
setFilePath(fileName);
}
......@@ -64,11 +65,6 @@ QString QmlProjectFile::suggestedFileName() const
return QString();
}
QString QmlProjectFile::mimeType() const
{
return QLatin1String(Constants::QMLPROJECT_MIMETYPE);
}
bool QmlProjectFile::isModified() const
{
return false;
......
......@@ -50,7 +50,6 @@ public:
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const;
virtual bool isSaveAsAllowed() const;
......
......@@ -49,6 +49,7 @@ BarDescriptorDocument::BarDescriptorDocument(QObject *parent)
: Core::TextDocument(parent)
{
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
setMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
// blackberry-nativepackager requires the XML file to be in UTF-8 encoding,
// force if possible
if (QTextCodec *defaultUTF8 = QTextCodec::codecForName("UTF-8"))
......@@ -102,11 +103,6 @@ QString BarDescriptorDocument::suggestedFileName() const
return fi.fileName();
}
QString BarDescriptorDocument::mimeType() const
{
return QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE);
}
bool BarDescriptorDocument::shouldAutoSave() const
{
return false;
......
......@@ -91,7 +91,6 @@ public:
QString defaultPath() const;
QString suggestedFileName() const;
QString mimeType() const;
bool shouldAutoSave() const;
bool isModified() const;
......
......@@ -62,22 +62,16 @@ enum { debugResourceEditorW = 0 };
ResourceEditorDocument::ResourceEditorDocument(ResourceEditorW *parent) :
IDocument(parent),
m_mimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE)),
m_blockDirtyChanged(false),
m_parent(parent)
{
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
setFilePath(parent->m_resourceEditor->fileName());
if (debugResourceEditorW)
qDebug() << "ResourceEditorFile::ResourceEditorFile()";
}
QString ResourceEditorDocument::mimeType() const
{
return m_mimeType;
}
ResourceEditorW::ResourceEditorW(const Core::Context &context,
ResourceEditorPlugin *plugin,
QWidget *parent)
......
......@@ -62,7 +62,6 @@ public:
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
QString defaultPath() const;
QString suggestedFileName() const;
QString mimeType() const;
void setFilePath(const QString &newName);
void setBlockDirtyChanged(bool value);
......@@ -70,7 +69,6 @@ public slots:
void dirtyChanged(bool);
private:
const QString m_mimeType;
bool m_blockDirtyChanged;
ResourceEditorW *m_parent;
};
......
......@@ -441,6 +441,7 @@ ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
: IDocument(node), m_node(node)
{
setId("ResourceNodeWatcher");
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
setFilePath(node->path());
}
......@@ -462,11 +463,6 @@ QString ResourceFileWatcher::suggestedFileName() const
return QString();
}
QString ResourceFileWatcher::mimeType() const
{
return QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE);
}
bool ResourceFileWatcher::isModified() const
{
return false;
......
......@@ -122,7 +122,6 @@ public:
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const;
virtual bool isSaveAsAllowed() const;
......
......@@ -64,11 +64,6 @@ QString TaskFile::suggestedFileName() const
return QString();
}
QString TaskFile::mimeType() const
{
return QString();
}
bool TaskFile::isModified() const
{
return false;
......
......@@ -47,7 +47,6 @@ public:
QString defaultPath() const;
QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const;
bool isSaveAsAllowed() const;
......
......@@ -80,7 +80,6 @@ public slots:
public:
QString m_defaultPath;
QString m_suggestedFileName;
QString m_mimeType;
TypingSettings m_typingSettings;
StorageSettings m_storageSettings;
TabSettings m_tabSettings;
......@@ -231,19 +230,6 @@ QChar BaseTextDocument::characterAt(int pos) const
return document()->characterAt(pos);
}
QString BaseTextDocument::mimeType() const
{
return d->m_mimeType;
}
void BaseTextDocument::setMimeType(const QString &mt)
{
if (d->m_mimeType != mt) {
d->m_mimeType = mt;
emit mimeTypeChanged();
}
}
void BaseTextDocument::setTypingSettings(const TypingSettings &typingSettings)
{
d->m_typingSettings = typingSettings;
......
......@@ -92,8 +92,6 @@ public:
bool isSaveAsAllowed() const;
void checkPermissions();
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
QString mimeType() const;
void setMimeType(const QString &mt);
void setFilePath(const QString &newName);
QString defaultPath() const;
......
......@@ -47,11 +47,11 @@ using namespace VcsBase::Internal;
SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, VcsBaseSubmitEditor *parent) :
Core::IDocument(parent),
m_mimeType(QLatin1String(parameters->mimeType)),
m_modified(false),
m_editor(parent)
{
setId(parameters->id);
setMimeType(QLatin1String(parameters->mimeType));
setTemporary(true);
}
......@@ -86,11 +86,6 @@ bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool
return true;
}
QString SubmitEditorFile::mimeType() const
{
return m_mimeType;
}
Core::IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state)
......
......@@ -51,7 +51,6 @@ public:
QString suggestedFileName() const { return QString(); }
bool isModified() const { return m_modified; }
QString mimeType() const;
bool isSaveAsAllowed() const { return false; }
bool save(QString *errorString, const QString &fileName, bool autoSave);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
......@@ -60,7 +59,6 @@ public:
void setModified(bool modified = true);
private:
const QString m_mimeType;
bool m_modified;
VcsBaseSubmitEditor *m_editor;
};
......
Markdown is supported
0% or .