forked from qt-creator/qt-creator
QmlProjectManager: Modernize
modernize-* Change-Id: Ic47c32c3fbf96d36f0d64e331eccc8c8e8aef6d2 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -37,9 +37,7 @@
|
|||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
FileFilterBaseItem::FileFilterBaseItem(QObject *parent) :
|
FileFilterBaseItem::FileFilterBaseItem(QObject *parent) :
|
||||||
QmlProjectContentItem(parent),
|
QmlProjectContentItem(parent)
|
||||||
m_recurse(RecurseDefault),
|
|
||||||
m_dirWatcher(0)
|
|
||||||
{
|
{
|
||||||
m_updateFileListTimer.setSingleShot(true);
|
m_updateFileListTimer.setSingleShot(true);
|
||||||
m_updateFileListTimer.setInterval(50);
|
m_updateFileListTimer.setInterval(50);
|
||||||
|
@@ -48,7 +48,7 @@ class FileFilterBaseItem : public QmlProjectContentItem {
|
|||||||
Q_PROPERTY(QStringList files READ files NOTIFY filesChanged DESIGNABLE false)
|
Q_PROPERTY(QStringList files READ files NOTIFY filesChanged DESIGNABLE false)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileFilterBaseItem(QObject *parent = 0);
|
FileFilterBaseItem(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString directory() const;
|
QString directory() const;
|
||||||
void setDirectory(const QString &directoryPath);
|
void setDirectory(const QString &directoryPath);
|
||||||
@@ -81,7 +81,7 @@ private:
|
|||||||
QString absoluteDir() const;
|
QString absoluteDir() const;
|
||||||
|
|
||||||
bool fileMatches(const QString &fileName) const;
|
bool fileMatches(const QString &fileName) const;
|
||||||
QSet<QString> filesInSubTree(const QDir &rootDir, const QDir &dir, QSet<QString> *parsedDirs = 0);
|
QSet<QString> filesInSubTree(const QDir &rootDir, const QDir &dir, QSet<QString> *parsedDirs = nullptr);
|
||||||
Utils::FileSystemWatcher *dirWatcher();
|
Utils::FileSystemWatcher *dirWatcher();
|
||||||
QStringList watchedDirectories() const;
|
QStringList watchedDirectories() const;
|
||||||
|
|
||||||
@@ -99,12 +99,12 @@ private:
|
|||||||
RecurseDefault // not set explicitly
|
RecurseDefault // not set explicitly
|
||||||
};
|
};
|
||||||
|
|
||||||
RecursiveOption m_recurse;
|
RecursiveOption m_recurse = RecurseDefault;
|
||||||
|
|
||||||
QStringList m_explicitFiles;
|
QStringList m_explicitFiles;
|
||||||
|
|
||||||
QSet<QString> m_files;
|
QSet<QString> m_files;
|
||||||
Utils::FileSystemWatcher *m_dirWatcher;
|
Utils::FileSystemWatcher *m_dirWatcher = nullptr;
|
||||||
QTimer m_updateFileListTimer;
|
QTimer m_updateFileListTimer;
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ class QmlFileFilterItem : public FileFilterBaseItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlFileFilterItem(QObject *parent = 0);
|
QmlFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class JsFileFilterItem : public FileFilterBaseItem {
|
class JsFileFilterItem : public FileFilterBaseItem {
|
||||||
@@ -128,7 +128,7 @@ signals:
|
|||||||
void filterChanged();
|
void filterChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JsFileFilterItem(QObject *parent = 0);
|
JsFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageFileFilterItem : public FileFilterBaseItem {
|
class ImageFileFilterItem : public FileFilterBaseItem {
|
||||||
@@ -141,7 +141,7 @@ signals:
|
|||||||
void filterChanged();
|
void filterChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageFileFilterItem(QObject *parent = 0);
|
ImageFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CssFileFilterItem : public FileFilterBaseItem {
|
class CssFileFilterItem : public FileFilterBaseItem {
|
||||||
@@ -154,7 +154,7 @@ signals:
|
|||||||
void filterChanged();
|
void filterChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CssFileFilterItem(QObject *parent = 0);
|
CssFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class OtherFileFilterItem : public FileFilterBaseItem {
|
class OtherFileFilterItem : public FileFilterBaseItem {
|
||||||
@@ -167,7 +167,7 @@ signals:
|
|||||||
void filterChanged();
|
void filterChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OtherFileFilterItem(QObject *parent = 0);
|
OtherFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -74,11 +74,11 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fi
|
|||||||
qWarning() << simpleQmlJSReader.errors();
|
qWarning() << simpleQmlJSReader.errors();
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = simpleQmlJSReader.errors().join(QLatin1String(", "));
|
*errorMessage = simpleQmlJSReader.errors().join(QLatin1String(", "));
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootNode->name() == QLatin1String("Project")) {
|
if (rootNode->name() == QLatin1String("Project")) {
|
||||||
QmlProjectItem *projectItem = new QmlProjectItem();
|
auto projectItem = new QmlProjectItem;
|
||||||
|
|
||||||
const QVariant mainFileProperty = rootNode->property(QLatin1String("mainFile"));
|
const QVariant mainFileProperty = rootNode->property(QLatin1String("mainFile"));
|
||||||
if (mainFileProperty.isValid())
|
if (mainFileProperty.isValid())
|
||||||
@@ -99,32 +99,32 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fi
|
|||||||
if (childNode->name() == QLatin1String("QmlFiles")) {
|
if (childNode->name() == QLatin1String("QmlFiles")) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "QmlFiles";
|
qDebug() << "QmlFiles";
|
||||||
QmlFileFilterItem *qmlFileFilterItem = new QmlFileFilterItem(projectItem);
|
auto qmlFileFilterItem = new QmlFileFilterItem(projectItem);
|
||||||
setupFileFilterItem(qmlFileFilterItem, childNode);
|
setupFileFilterItem(qmlFileFilterItem, childNode);
|
||||||
projectItem->appendContent(qmlFileFilterItem);
|
projectItem->appendContent(qmlFileFilterItem);
|
||||||
} else if (childNode->name() == QLatin1String("JavaScriptFiles")) {
|
} else if (childNode->name() == QLatin1String("JavaScriptFiles")) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "JavaScriptFiles";
|
qDebug() << "JavaScriptFiles";
|
||||||
JsFileFilterItem *jsFileFilterItem = new JsFileFilterItem(projectItem);
|
auto jsFileFilterItem = new JsFileFilterItem(projectItem);
|
||||||
setupFileFilterItem(jsFileFilterItem, childNode);
|
setupFileFilterItem(jsFileFilterItem, childNode);
|
||||||
projectItem->appendContent(jsFileFilterItem);
|
projectItem->appendContent(jsFileFilterItem);
|
||||||
} else if (childNode->name() == QLatin1String("ImageFiles")) {
|
} else if (childNode->name() == QLatin1String("ImageFiles")) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "ImageFiles";
|
qDebug() << "ImageFiles";
|
||||||
ImageFileFilterItem *imageFileFilterItem = new ImageFileFilterItem(projectItem);
|
auto imageFileFilterItem = new ImageFileFilterItem(projectItem);
|
||||||
setupFileFilterItem(imageFileFilterItem, childNode);
|
setupFileFilterItem(imageFileFilterItem, childNode);
|
||||||
projectItem->appendContent(imageFileFilterItem);
|
projectItem->appendContent(imageFileFilterItem);
|
||||||
|
|
||||||
} else if (childNode->name() == QLatin1String("CssFiles")) {
|
} else if (childNode->name() == QLatin1String("CssFiles")) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "CssFiles";
|
qDebug() << "CssFiles";
|
||||||
CssFileFilterItem *cssFileFilterItem = new CssFileFilterItem(projectItem);
|
auto cssFileFilterItem = new CssFileFilterItem(projectItem);
|
||||||
setupFileFilterItem(cssFileFilterItem, childNode);
|
setupFileFilterItem(cssFileFilterItem, childNode);
|
||||||
projectItem->appendContent(cssFileFilterItem);
|
projectItem->appendContent(cssFileFilterItem);
|
||||||
} else if (childNode->name() == QLatin1String("Files")) {
|
} else if (childNode->name() == QLatin1String("Files")) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Files";
|
qDebug() << "Files";
|
||||||
OtherFileFilterItem *otherFileFilterItem = new OtherFileFilterItem(projectItem);
|
auto otherFileFilterItem = new OtherFileFilterItem(projectItem);
|
||||||
setupFileFilterItem(otherFileFilterItem, childNode);
|
setupFileFilterItem(otherFileFilterItem, childNode);
|
||||||
projectItem->appendContent(otherFileFilterItem);
|
projectItem->appendContent(otherFileFilterItem);
|
||||||
} else if (childNode->name() == "Environment") {
|
} else if (childNode->name() == "Environment") {
|
||||||
@@ -144,7 +144,7 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fi
|
|||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = tr("Invalid root element: %1").arg(rootNode->name());
|
*errorMessage = tr("Invalid root element: %1").arg(rootNode->name());
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -39,7 +39,8 @@ class QmlProjectFileFormat
|
|||||||
Q_DECLARE_TR_FUNCTIONS(QmlProjectManager::QmlProjectFileFormat)
|
Q_DECLARE_TR_FUNCTIONS(QmlProjectManager::QmlProjectFileFormat)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QmlProjectItem *parseProjectFile(const Utils::FileName &fileName, QString *errorMessage = 0);
|
static QmlProjectItem *parseProjectFile(const Utils::FileName &fileName,
|
||||||
|
QString *errorMessage = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -38,9 +38,8 @@ void QmlProjectItem::setSourceDirectory(const QString &directoryPath)
|
|||||||
|
|
||||||
m_sourceDirectory = directoryPath;
|
m_sourceDirectory = directoryPath;
|
||||||
|
|
||||||
for (int i = 0; i < m_content.size(); ++i) {
|
for (auto contentElement : qAsConst(m_content)) {
|
||||||
QmlProjectContentItem *contentElement = m_content.at(i);
|
auto fileFilter = qobject_cast<FileFilterBaseItem*>(contentElement);
|
||||||
FileFilterBaseItem *fileFilter = qobject_cast<FileFilterBaseItem*>(contentElement);
|
|
||||||
if (fileFilter) {
|
if (fileFilter) {
|
||||||
fileFilter->setDefaultDirectory(directoryPath);
|
fileFilter->setDefaultDirectory(directoryPath);
|
||||||
connect(fileFilter, &FileFilterBaseItem::filesChanged,
|
connect(fileFilter, &FileFilterBaseItem::filesChanged,
|
||||||
|
@@ -38,7 +38,7 @@ class QmlProjectContentItem : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlProjectContentItem(QObject *parent = 0) : QObject(parent) {}
|
QmlProjectContentItem(QObject *parent = nullptr) : QObject(parent) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlProjectItem : public QObject
|
class QmlProjectItem : public QObject
|
||||||
|
@@ -47,7 +47,7 @@ Environment QmlProjectEnvironmentAspect::baseEnvironment() const
|
|||||||
? Environment::systemEnvironment()
|
? Environment::systemEnvironment()
|
||||||
: Environment();
|
: Environment();
|
||||||
|
|
||||||
if (QmlProject *project = qobject_cast<QmlProject *>(m_target->project()))
|
if (auto project = qobject_cast<const QmlProject *>(m_target->project()))
|
||||||
env.modify(project->environment());
|
env.modify(project->environment());
|
||||||
|
|
||||||
return env;
|
return env;
|
||||||
|
@@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
bool showInSimpleTree() const override;
|
bool showInSimpleTree() const override;
|
||||||
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
|
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
|
||||||
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
|
bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr) override;
|
||||||
bool deleteFiles(const QStringList &filePaths) override;
|
bool deleteFiles(const QStringList &filePaths) override;
|
||||||
bool renameFile(const QString &filePath, const QString &newFilePath) override;
|
bool renameFile(const QString &filePath, const QString &newFilePath) override;
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ class MainQmlFileAspect : public ProjectConfigurationAspect
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MainQmlFileAspect(QmlProject *project);
|
explicit MainQmlFileAspect(QmlProject *project);
|
||||||
~MainQmlFileAspect() { delete m_fileListCombo; }
|
~MainQmlFileAspect() override { delete m_fileListCombo; }
|
||||||
|
|
||||||
enum MainScriptSource {
|
enum MainScriptSource {
|
||||||
FileInEditor,
|
FileInEditor,
|
||||||
@@ -107,9 +107,8 @@ public:
|
|||||||
|
|
||||||
MainQmlFileAspect::MainQmlFileAspect(QmlProject *project)
|
MainQmlFileAspect::MainQmlFileAspect(QmlProject *project)
|
||||||
: m_project(project)
|
: m_project(project)
|
||||||
|
, m_scriptFile(M_CURRENT_FILE)
|
||||||
{
|
{
|
||||||
m_scriptFile = M_CURRENT_FILE;
|
|
||||||
|
|
||||||
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
||||||
this, &MainQmlFileAspect::changeCurrentFile);
|
this, &MainQmlFileAspect::changeCurrentFile);
|
||||||
connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged,
|
connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged,
|
||||||
@@ -189,7 +188,7 @@ void MainQmlFileAspect::updateFileComboBox()
|
|||||||
if (fileInfo.suffix() != QLatin1String("qml"))
|
if (fileInfo.suffix() != QLatin1String("qml"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QStandardItem *item = new QStandardItem(fn);
|
auto item = new QStandardItem(fn);
|
||||||
m_fileListModel.appendRow(item);
|
m_fileListModel.appendRow(item);
|
||||||
|
|
||||||
if (mainScriptPath == fn)
|
if (mainScriptPath == fn)
|
||||||
|
Reference in New Issue
Block a user