forked from qt-creator/qt-creator
SessionFile does not need to be a IFile
Remove useless inheritage
This commit is contained in:
@@ -76,8 +76,6 @@ Core::IFile *ProjectFileFactory::open(const QString &fileName)
|
|||||||
SessionManager *session = pe->session();
|
SessionManager *session = pe->session();
|
||||||
if (session->projects().count() == 1)
|
if (session->projects().count() == 1)
|
||||||
fIFace = session->projects().first()->file();
|
fIFace = session->projects().first()->file();
|
||||||
else if (session->projects().count() > 1)
|
|
||||||
fIFace = session->file(); // TODO: Why return session file interface here ???
|
|
||||||
}
|
}
|
||||||
return fIFace;
|
return fIFace;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -973,7 +973,7 @@ void ProjectExplorerPlugin::savePersistentSettings()
|
|||||||
|
|
||||||
QSettings *s = Core::ICore::instance()->settings();
|
QSettings *s = Core::ICore::instance()->settings();
|
||||||
if (s) {
|
if (s) {
|
||||||
s->setValue("ProjectExplorer/StartupSession", d->m_session->file()->fileName());
|
s->setValue("ProjectExplorer/StartupSession", d->m_session->currentSession());
|
||||||
s->remove("ProjectExplorer/RecentProjects/Files");
|
s->remove("ProjectExplorer/RecentProjects/Files");
|
||||||
|
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace {
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class SessionFile : public Core::IFile
|
class SessionFile : QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -81,23 +81,10 @@ public:
|
|||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
void setFileName(const QString &fileName);
|
void setFileName(const QString &fileName);
|
||||||
|
|
||||||
QString defaultPath() const;
|
|
||||||
QString suggestedFileName() const;
|
|
||||||
virtual QString mimeType() const;
|
|
||||||
|
|
||||||
bool isModified() const;
|
|
||||||
bool isReadOnly() const;
|
|
||||||
bool isSaveAsAllowed() const;
|
|
||||||
|
|
||||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
|
||||||
void reload(ReloadFlag flag, ChangeType type);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sessionLoadingProgress();
|
void sessionLoadingProgress();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_mimeType;
|
|
||||||
Core::ICore *m_core;
|
Core::ICore *m_core;
|
||||||
|
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
@@ -125,17 +112,11 @@ void SessionFile::sessionLoadingProgress()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SessionFile::SessionFile()
|
SessionFile::SessionFile()
|
||||||
: m_mimeType(QLatin1String(ProjectExplorer::Constants::SESSIONFILE_MIMETYPE)),
|
: m_core(Core::ICore::instance()),
|
||||||
m_core(Core::ICore::instance()),
|
|
||||||
m_startupProject(0)
|
m_startupProject(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SessionFile::mimeType() const
|
|
||||||
{
|
|
||||||
return m_mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SessionFile::load(const QString &fileName)
|
bool SessionFile::load(const QString &fileName)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!fileName.isEmpty());
|
Q_ASSERT(!fileName.isEmpty());
|
||||||
@@ -306,53 +287,8 @@ void SessionFile::setFileName(const QString &fileName)
|
|||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionFile::isModified() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SessionFile::isReadOnly() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SessionFile::isSaveAsAllowed() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IFile::ReloadBehavior SessionFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(state)
|
|
||||||
Q_UNUSED(type)
|
|
||||||
return BehaviorSilent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionFile::reload(ReloadFlag flag, ChangeType type)
|
|
||||||
{
|
|
||||||
Q_UNUSED(flag)
|
|
||||||
Q_UNUSED(type)
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SessionFile::defaultPath() const
|
|
||||||
{
|
|
||||||
if (!m_projects.isEmpty()) {
|
|
||||||
const QFileInfo fi(m_projects.first()->file()->fileName());
|
|
||||||
return fi.absolutePath();
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SessionFile::suggestedFileName() const
|
|
||||||
{
|
|
||||||
if (m_startupProject)
|
|
||||||
return m_startupProject->displayName();
|
|
||||||
|
|
||||||
return tr("Untitled", "default file name to display");
|
|
||||||
}
|
|
||||||
|
|
||||||
Internal::SessionNodeImpl::SessionNodeImpl(SessionManager *manager)
|
Internal::SessionNodeImpl::SessionNodeImpl(SessionManager *manager)
|
||||||
: ProjectExplorer::SessionNode(manager->file()->fileName(), manager)
|
: ProjectExplorer::SessionNode(manager->currentSession(), manager)
|
||||||
{
|
{
|
||||||
setFileName("session");
|
setFileName("session");
|
||||||
}
|
}
|
||||||
@@ -894,9 +830,9 @@ void SessionManager::setEditorCodec(Core::IEditor *editor, const QString &fileNa
|
|||||||
textEditor->setTextCodec(project->editorConfiguration()->defaultTextCodec());
|
textEditor->setTextCodec(project->editorConfiguration()->defaultTextCodec());
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IFile *SessionManager::file() const
|
QString SessionManager::currentSession() const
|
||||||
{
|
{
|
||||||
return m_file;
|
return m_file->fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::handleCurrentEditorChange(Core::IEditor *editor)
|
void SessionManager::handleCurrentEditorChange(Core::IEditor *editor)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
bool addDependency(Project *project, Project *depProject);
|
bool addDependency(Project *project, Project *depProject);
|
||||||
void removeDependency(Project *project, Project *depProject);
|
void removeDependency(Project *project, Project *depProject);
|
||||||
|
|
||||||
Core::IFile *file() const;
|
QString currentSession() const;
|
||||||
Project *startupProject() const;
|
Project *startupProject() const;
|
||||||
|
|
||||||
const QList<Project *> &projects() const;
|
const QList<Project *> &projects() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user