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