Commit 3ba511c6 authored by Daniel Teske's avatar Daniel Teske

Add watching of .files/.config/.creator to generic project

Strangely absent.

Task-Number: QTCREATORBUG-6478

Change-Id: I35dd03a7d5b34c01dc668e5ed222d10088f77f15
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 0ce5017d
......@@ -49,6 +49,7 @@
#include <utils/fileutils.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/filemanager.h>
#include <QtCore/QDir>
#include <QtCore/QProcessEnvironment>
......@@ -85,8 +86,18 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
m_file = new GenericProjectFile(this, fileName);
m_rootNode = new GenericProjectNode(this, m_file);
m_creatorIFile = new GenericProjectFile(this, m_fileName, GenericProject::Everything);
m_filesIFile = new GenericProjectFile(this, m_filesFileName, GenericProject::Files);
m_includesIFile = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration);
m_configIFile = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration);
Core::FileManager *fm = Core::FileManager::instance();
fm->addFile(m_creatorIFile);
fm->addFile(m_filesIFile);
fm->addFile(m_includesIFile);
fm->addFile(m_configIFile);
m_rootNode = new GenericProjectNode(this, m_creatorIFile);
m_manager->registerProject(this);
}
......@@ -407,7 +418,7 @@ QString GenericProject::id() const
Core::IFile *GenericProject::file() const
{
return m_file;
return m_creatorIFile;
}
IProjectManager *GenericProject::projectManager() const
......@@ -589,10 +600,11 @@ void GenericBuildSettingsWidget::updateToolChainList()
// GenericProjectFile
////////////////////////////////////////////////////////////////////////////////////
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName)
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options)
: Core::IFile(parent),
m_project(parent),
m_fileName(fileName)
m_fileName(fileName),
m_options(options)
{ }
GenericProjectFile::~GenericProjectFile()
......@@ -656,6 +668,8 @@ bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeTyp
{
Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
if (type == TypePermissions)
return true;
m_project->refresh(m_options);
return true;
}
......@@ -137,9 +137,11 @@ private:
QString m_filesFileName;
QString m_includesFileName;
QString m_configFileName;
GenericProjectFile *m_file;
QString m_projectName;
GenericProjectFile *m_creatorIFile;
GenericProjectFile *m_filesIFile;
GenericProjectFile *m_includesIFile;
GenericProjectFile *m_configIFile;
QStringList m_rawFileList;
QStringList m_files;
QHash<QString, QString> m_rawListEntries;
......@@ -158,7 +160,7 @@ class GenericProjectFile : public Core::IFile
Q_OBJECT
public:
GenericProjectFile(GenericProject *parent, QString fileName);
GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options);
virtual ~GenericProjectFile();
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
......@@ -179,6 +181,7 @@ public:
private:
GenericProject *m_project;
QString m_fileName;
GenericProject::RefreshOptions m_options;
};
class GenericBuildSettingsWidget : public ProjectExplorer::BuildConfigWidget
......
......@@ -50,7 +50,6 @@ using namespace GenericProjectManager::Internal;
ProjectFilesFactory::ProjectFilesFactory(Manager *manager,
TextEditor::TextEditorActionHandler *handler)
: Core::IEditorFactory(manager),
m_manager(manager),
m_actionHandler(handler)
{
m_mimeTypes.append(QLatin1String(Constants::FILES_MIMETYPE));
......@@ -58,11 +57,6 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager,
m_mimeTypes.append(QLatin1String(Constants::CONFIG_MIMETYPE));
}
Manager *ProjectFilesFactory::manager() const
{
return m_manager;
}
Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent)
{
ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget(parent, this, m_actionHandler);
......@@ -135,8 +129,7 @@ ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent, ProjectFiles
m_factory(factory),
m_actionHandler(handler)
{
Manager *manager = factory->manager();
ProjectFilesDocument *doc = new ProjectFilesDocument(manager);
TextEditor::BaseTextDocument *doc = new TextEditor::BaseTextDocument();
setBaseTextDocument(doc);
handler->setupActions(this);
......@@ -159,26 +152,3 @@ TextEditor::BaseTextEditor *ProjectFilesEditorWidget::createEditor()
{
return new ProjectFilesEditor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
// ProjectFilesDocument
////////////////////////////////////////////////////////////////////////////////////////
ProjectFilesDocument::ProjectFilesDocument(Manager *manager)
: m_manager(manager)
{
setMimeType(QLatin1String(Constants::FILES_MIMETYPE));
}
ProjectFilesDocument::~ProjectFilesDocument()
{ }
bool ProjectFilesDocument::save(QString *errorString, const QString &name, bool autoSave)
{
if (!BaseTextDocument::save(errorString, name, autoSave))
return false;
if (!autoSave)
m_manager->notifyChanged(name.isEmpty() ? fileName() : name);
return true;
}
......@@ -48,7 +48,6 @@ namespace Internal {
class Manager;
class ProjectFilesEditor;
class ProjectFilesEditorWidget;
class ProjectFilesDocument;
class ProjectFilesFactory;
class ProjectFilesFactory: public Core::IEditorFactory
......@@ -58,8 +57,6 @@ class ProjectFilesFactory: public Core::IEditorFactory
public:
ProjectFilesFactory(Manager *manager, TextEditor::TextEditorActionHandler *handler);
Manager *manager() const;
virtual Core::IEditor *createEditor(QWidget *parent);
virtual QStringList mimeTypes() const;
......@@ -68,7 +65,6 @@ public:
virtual Core::IFile *open(const QString &fileName);
private:
Manager *m_manager;
TextEditor::TextEditorActionHandler *m_actionHandler;
QStringList m_mimeTypes;
};
......@@ -105,20 +101,6 @@ private:
TextEditor::TextEditorActionHandler *m_actionHandler;
};
class ProjectFilesDocument: public TextEditor::BaseTextDocument
{
Q_OBJECT
public:
ProjectFilesDocument(Manager *manager);
virtual ~ProjectFilesDocument();
virtual bool save(QString *errorString, const QString &name, bool autoSave);
private:
Manager *m_manager;
};
} // namespace Internal
} // namespace GenericProjectManager
......
......@@ -79,15 +79,3 @@ void Manager::unregisterProject(GenericProject *project)
{
m_projects.removeAll(project);
}
void Manager::notifyChanged(const QString &fileName)
{
foreach (GenericProject *project, m_projects) {
if (fileName == project->filesFileName()) {
project->refresh(GenericProject::Files);
} else if (fileName == project->includesFileName()
|| fileName == project->configFileName()) {
project->refresh(GenericProject::Configuration);
}
}
}
......@@ -50,8 +50,6 @@ public:
virtual QString mimeType() const;
virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
void notifyChanged(const QString &fileName);
void registerProject(GenericProject *project);
void unregisterProject(GenericProject *project);
......
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