Files
qt-creator/src/plugins/qt4projectmanager/qt4project.h

263 lines
7.7 KiB
C
Raw Normal View History

/**************************************************************************
2008-12-02 12:01:29 +01:00
**
** This file is part of Qt Creator
**
2011-01-11 16:28:15 +01:00
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
2008-12-02 12:01:29 +01:00
**
2011-04-13 08:42:33 +02:00
** Contact: Nokia Corporation (info@qt.nokia.com)
2008-12-02 12:01:29 +01:00
**
**
** GNU Lesser General Public License Usage
**
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.
**
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
** Nokia at qt-info@nokia.com.
2008-12-02 12:01:29 +01:00
**
**************************************************************************/
2008-12-02 16:19:05 +01:00
2008-12-02 12:01:29 +01:00
#ifndef QT4PROJECT_H
#define QT4PROJECT_H
#include "qt4nodes.h"
#include "qt4target.h"
2008-12-02 12:01:29 +01:00
#include <projectexplorer/project.h>
2008-12-02 12:01:29 +01:00
#include <projectexplorer/projectnodes.h>
#include <coreplugin/ifile.h>
2008-12-02 12:01:29 +01:00
#include <QtCore/QStringList>
#include <QtCore/QMap>
2010-02-26 12:50:11 +01:00
#include <QtCore/QFutureInterface>
#include <QtCore/QTimer>
#include <QtCore/QFuture>
2008-12-02 12:01:29 +01:00
QT_BEGIN_NAMESPACE
2009-12-09 16:56:01 +01:00
struct ProFileOption;
2008-12-02 12:01:29 +01:00
QT_END_NAMESPACE
namespace Qt4ProjectManager {
namespace Internal {
class ProFileReader;
class DeployHelperRunStep;
class FileItem;
class Qt4ProFileNode;
class Qt4PriFileNode;
2008-12-02 12:01:29 +01:00
class GCCPreprocessor;
struct Qt4ProjectFiles;
class Qt4ProjectConfigWidget;
class Qt4NodesWatcher;
2008-12-02 12:01:29 +01:00
}
class QMakeStep;
class MakeStep;
class Qt4Manager;
class Qt4Project;
class Qt4RunStep;
class Qt4ProjectFile : public Core::IFile
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
public:
Qt4ProjectFile(Qt4Project *project, const QString &filePath, QObject *parent = 0);
bool save(QString *errorString, const QString &fileName = QString());
2008-12-02 12:01:29 +01:00
QString fileName() const;
virtual void rename(const QString &newName);
2008-12-02 12:01:29 +01:00
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);
2008-12-02 12:01:29 +01:00
private:
const QString m_mimeType;
Qt4Project *m_project;
QString m_filePath;
};
/// Watches folders for Qt4PriFile nodes
/// use one file system watcher to watch all folders
/// such minimizing system ressouce usage
namespace Internal {
class CentralizedFolderWatcher : public QObject
{
Q_OBJECT
public:
CentralizedFolderWatcher();
~CentralizedFolderWatcher();
void watchFolders(const QList<QString> &folders, Qt4PriFileNode *node);
void unwatchFolders(const QList<QString> &folders, Qt4PriFileNode *node);
private slots:
void folderChanged(const QString &folder);
void onTimer();
void delayedFolderChanged(const QString &folder);
private:
QSet<QString> recursiveDirs(const QString &folder);
QFileSystemWatcher m_watcher;
QMultiMap<QString, Qt4PriFileNode *> m_map;
QSet<QString> m_recursiveWatchedFolders;
QTimer m_compressTimer;
QSet<QString> m_changedFolders;
};
}
class Qt4Project : public ProjectExplorer::Project
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
public:
Qt4Project(Qt4Manager *manager, const QString &proFile);
2008-12-02 12:01:29 +01:00
virtual ~Qt4Project();
QString displayName() const;
QString id() const;
2008-12-02 12:01:29 +01:00
Core::IFile *file() const;
ProjectExplorer::IProjectManager *projectManager() const;
Qt4Manager *qt4ProjectManager() const;
Qt4BaseTarget *activeTarget() const;
2008-12-02 12:01:29 +01:00
QList<Core::IFile *> dependencies(); //NBS remove
QList<ProjectExplorer::Project *>dependsOn();
Internal::Qt4ProFileNode *rootProjectNode() const;
bool validParse(const QString &proFilePath) const;
2008-12-02 12:01:29 +01:00
virtual QStringList files(FilesMode fileMode) const;
virtual QString generatedUiHeader(const QString &formFile) const;
2008-12-02 12:01:29 +01:00
QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
2008-12-02 12:01:29 +01:00
QList<Internal::Qt4ProFileNode *> allProFiles() const;
2008-12-02 12:01:29 +01:00
QList<Internal::Qt4ProFileNode *> applicationProFiles() const;
bool hasApplicationProFile(const QString &path) const;
QStringList applicationProFilePathes(const QString &prepend = QString()) const;
2008-12-02 12:01:29 +01:00
void notifyChanged(const QString &name);
/// \internal
Internal::ProFileReader *createProFileReader(Internal::Qt4ProFileNode *qt4ProFileNode, Qt4BuildConfiguration *bc = 0);
/// \internal
void destroyProFileReader(Internal::ProFileReader *reader);
/// \internal
void scheduleAsyncUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
/// \internal
void incrementPendingEvaluateFutures();
/// \internal
void decrementPendingEvaluateFutures();
/// \internal
bool wasEvaluateCanceled();
Internal::CentralizedFolderWatcher *centralizedFolderWatcher();
// For Qt4ProFileNode after a on disk change
void updateFileList();
signals:
void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node, bool);
void proFileInvalidated(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
void buildDirectoryInitialized();
void fromMapFinished();
2008-12-02 12:01:29 +01:00
public slots:
void proFileParseError(const QString &errorMessage);
void update();
protected:
virtual bool fromMap(const QVariantMap &map);
2008-12-02 12:01:29 +01:00
private slots:
void proFileEvaluateNeeded(Qt4ProjectManager::Qt4BaseTarget *target);
void asyncUpdate();
void onAddedTarget(ProjectExplorer::Target *t);
void activeTargetWasChanged();
private:
void scheduleAsyncUpdate();
2008-12-02 12:01:29 +01:00
void updateCodeModels();
void updateCppCodeModel();
void updateQmlJSCodeModel();
2008-12-02 12:01:29 +01:00
static void collectAllfProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node);
2008-12-02 12:01:29 +01:00
static void collectApplicationProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node);
static void findProFile(const QString& fileName, Internal::Qt4ProFileNode *root, QList<Internal::Qt4ProFileNode *> &list);
static bool hasSubNode(Internal::Qt4PriFileNode *root, const QString &path);
2008-12-02 12:01:29 +01:00
static bool equalFileList(const QStringList &a, const QStringList &b);
2008-12-02 12:01:29 +01:00
void addDefaultBuild();
static QString qmakeVarName(ProjectExplorer::FileType type);
Qt4Manager *m_manager;
Internal::Qt4ProFileNode *m_rootProjectNode;
Internal::Qt4NodesWatcher *m_nodesWatcher;
Qt4ProjectFile *m_fileInfo;
// Current configuration
QString m_oldQtIncludePath;
QString m_oldQtLibsPath;
// cached lists of all of files
Internal::Qt4ProjectFiles *m_projectFiles;
// cached data during project rescan
ProFileOption *m_proFileOption;
int m_proFileOptionRefCnt;
QTimer m_asyncUpdateTimer;
QFutureInterface<void> *m_asyncUpdateFutureInterface;
int m_pendingEvaluateFuturesCount;
enum AsyncUpdateState { NoState, Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
AsyncUpdateState m_asyncUpdateState;
bool m_cancelEvaluate;
QList<Internal::Qt4ProFileNode *> m_partialEvaluate;
2010-03-02 12:51:47 +01:00
QFuture<void> m_codeModelFuture;
Internal::CentralizedFolderWatcher m_centralizedFolderWatcher;
2008-12-02 12:01:29 +01:00
friend class Qt4ProjectFile;
friend class Internal::Qt4ProjectConfigWidget;
2008-12-02 12:01:29 +01:00
};
} // namespace Qt4ProjectManager
2008-12-02 12:01:29 +01:00
#endif // QT4PROJECT_H