2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef SESSION_H
|
|
|
|
|
#define SESSION_H
|
|
|
|
|
|
|
|
|
|
#include "projectexplorer_export.h"
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
#include <QtCore/QStringList>
|
2012-02-06 17:14:52 +01:00
|
|
|
#include <QtCore/QMap>
|
2012-02-06 17:26:31 +01:00
|
|
|
#include <QtCore/QFutureInterface>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-29 11:39:55 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QAbstractItemModel;
|
2010-11-01 11:18:27 +01:00
|
|
|
class QTimer;
|
2009-09-29 11:39:55 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Core {
|
|
|
|
|
class IMode;
|
|
|
|
|
class IEditor;
|
2009-09-29 11:39:55 +02:00
|
|
|
class IFile;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
class Project;
|
|
|
|
|
class Node;
|
|
|
|
|
class SessionNode;
|
|
|
|
|
class SessionManager;
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
class SessionFile;
|
2010-11-01 11:18:27 +01:00
|
|
|
class SessionNodeImpl;
|
2008-12-02 12:01:29 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
|
2009-01-20 17:14:00 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT SessionManager : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2009-01-20 17:14:00 +01:00
|
|
|
explicit SessionManager(QObject *parent = 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
~SessionManager();
|
|
|
|
|
|
|
|
|
|
// higher level session management
|
|
|
|
|
QString activeSession() const;
|
|
|
|
|
QString lastSession() const;
|
|
|
|
|
QStringList sessions() const;
|
|
|
|
|
|
|
|
|
|
bool createSession(const QString &session);
|
|
|
|
|
|
|
|
|
|
bool deleteSession(const QString &session);
|
|
|
|
|
|
|
|
|
|
bool cloneSession(const QString &original, const QString &clone);
|
2010-04-21 16:08:13 +02:00
|
|
|
bool renameSession(const QString &original, const QString &newName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
bool loadSession(const QString &session);
|
|
|
|
|
|
|
|
|
|
bool save();
|
|
|
|
|
bool clear();
|
|
|
|
|
|
|
|
|
|
void addProject(Project *project);
|
|
|
|
|
void addProjects(const QList<Project*> &projects);
|
|
|
|
|
void removeProject(Project *project);
|
|
|
|
|
void removeProjects(QList<Project *> remove);
|
|
|
|
|
|
|
|
|
|
void setStartupProject(Project *startupProject);
|
|
|
|
|
|
2009-01-16 16:30:22 +01:00
|
|
|
QList<Project *> dependencies(const Project *project) const;
|
|
|
|
|
bool hasDependency(const Project *project, const Project *depProject) const;
|
|
|
|
|
bool canAddDependency(const Project *project, const Project *depProject) const;
|
2009-08-06 15:31:32 +02:00
|
|
|
bool addDependency(Project *project, Project *depProject);
|
|
|
|
|
void removeDependency(Project *project, Project *depProject);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-07-11 20:25:00 +02:00
|
|
|
QString sessionNameToFileName(const QString &session) const;
|
2011-11-09 17:03:00 +01:00
|
|
|
QString sessionNameFromFileName(const QString &fileName) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
Project *startupProject() const;
|
|
|
|
|
|
2008-12-05 15:58:19 +01:00
|
|
|
const QList<Project *> &projects() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
bool isDefaultVirgin() const;
|
|
|
|
|
bool isDefaultSession(const QString &session) const;
|
|
|
|
|
|
|
|
|
|
// Let other plugins store persistent values within the session file
|
|
|
|
|
void setValue(const QString &name, const QVariant &value);
|
|
|
|
|
QVariant value(const QString &name);
|
|
|
|
|
|
|
|
|
|
// NBS rewrite projectOrder (dependency management)
|
|
|
|
|
QList<Project *> projectOrder(Project *project = 0) const;
|
|
|
|
|
|
|
|
|
|
SessionNode *sessionNode() const;
|
|
|
|
|
|
|
|
|
|
Project *projectForNode(ProjectExplorer::Node *node) const;
|
2009-03-11 17:36:17 +01:00
|
|
|
Node *nodeForFile(const QString &fileName, Project *project = 0) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
Project *projectForFile(const QString &fileName) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void reportProjectLoadingProgress();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void projectAdded(ProjectExplorer::Project *project);
|
|
|
|
|
void singleProjectAdded(ProjectExplorer::Project *project);
|
|
|
|
|
void aboutToRemoveProject(ProjectExplorer::Project *project);
|
|
|
|
|
|
|
|
|
|
void projectRemoved(ProjectExplorer::Project *project);
|
|
|
|
|
|
|
|
|
|
void startupProjectChanged(ProjectExplorer::Project *project);
|
|
|
|
|
|
2011-11-09 17:03:00 +01:00
|
|
|
void aboutToLoadSession(QString sessionName);
|
2008-12-02 12:01:29 +01:00
|
|
|
void sessionLoaded();
|
2009-08-13 17:10:53 +02:00
|
|
|
void aboutToUnloadSession();
|
2008-12-02 12:01:29 +01:00
|
|
|
void aboutToSaveSession();
|
2009-08-06 15:31:32 +02:00
|
|
|
void dependencyChanged(ProjectExplorer::Project *a, ProjectExplorer::Project *b);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void saveActiveMode(Core::IMode *mode);
|
|
|
|
|
void clearProjectFileCache();
|
2011-02-01 14:13:54 +01:00
|
|
|
void configureEditor(Core::IEditor *editor, const QString &fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
void updateWindowTitle();
|
|
|
|
|
|
2010-03-18 13:42:09 +01:00
|
|
|
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
|
2012-02-06 16:45:03 +01:00
|
|
|
void sessionLoadingProgress();
|
2010-03-03 15:54:32 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
bool loadImpl(const QString &fileName);
|
|
|
|
|
bool createImpl(const QString &fileName);
|
2008-12-05 15:58:19 +01:00
|
|
|
bool projectContainsFile(Project *p, const QString &fileName) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const;
|
|
|
|
|
QStringList dependencies(const QString &proName) const;
|
|
|
|
|
QStringList dependenciesOrder() const;
|
|
|
|
|
|
|
|
|
|
Internal::SessionFile *m_file;
|
2012-01-31 13:40:59 +01:00
|
|
|
SessionNode *m_sessionNode;
|
2008-12-02 12:01:29 +01:00
|
|
|
QString m_sessionName;
|
2010-03-29 13:43:41 +02:00
|
|
|
bool m_virginSession;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-18 11:36:39 +02:00
|
|
|
mutable QStringList m_sessions;
|
|
|
|
|
|
|
|
|
|
mutable QHash<Project *, QStringList> m_projectFileCache;
|
2010-03-03 15:54:32 +01:00
|
|
|
QTimer *m_autoSaveSessionTimer;
|
2012-02-06 16:52:15 +01:00
|
|
|
|
|
|
|
|
Project *m_startupProject;
|
2012-02-06 16:58:31 +01:00
|
|
|
QList<Project *> m_projects;
|
2012-02-06 17:08:01 +01:00
|
|
|
QStringList m_failedProjects;
|
2012-02-06 17:14:52 +01:00
|
|
|
QMap<QString, QStringList> m_depMap;
|
2012-02-06 17:19:36 +01:00
|
|
|
QMap<QString, QVariant> m_values;
|
2012-02-06 17:26:31 +01:00
|
|
|
QFutureInterface<void> future;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
#endif // SESSION_H
|