forked from qt-creator/qt-creator
QmlProject: cleanup the code
Change-Id: I10ce1fcba253e006b26864066510f3334893ce4c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -293,24 +293,6 @@ QSet<QString> FileFilterBaseItem::filesInSubTree(const QDir &rootDir, const QDir
|
|||||||
return fileSet;
|
return fileSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlFileFilterItem::QmlFileFilterItem(QObject *parent)
|
|
||||||
: FileFilterBaseItem(parent)
|
|
||||||
{
|
|
||||||
setFilter(QLatin1String("*.qml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
JsFileFilterItem::JsFileFilterItem(QObject *parent)
|
|
||||||
: FileFilterBaseItem(parent)
|
|
||||||
{
|
|
||||||
setFilter(QLatin1String("*.js"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void JsFileFilterItem::setFilter(const QString &filter)
|
|
||||||
{
|
|
||||||
FileFilterBaseItem::setFilter(filter);
|
|
||||||
emit filterChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageFileFilterItem::ImageFileFilterItem(QObject *parent)
|
ImageFileFilterItem::ImageFileFilterItem(QObject *parent)
|
||||||
: FileFilterBaseItem(parent)
|
: FileFilterBaseItem(parent)
|
||||||
{
|
{
|
||||||
@@ -323,33 +305,10 @@ ImageFileFilterItem::ImageFileFilterItem(QObject *parent)
|
|||||||
setFilter(filter);
|
setFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageFileFilterItem::setFilter(const QString &filter)
|
FileFilterItem::FileFilterItem(const QString &fileFilter, QObject *parent)
|
||||||
{
|
|
||||||
FileFilterBaseItem::setFilter(filter);
|
|
||||||
emit filterChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
CssFileFilterItem::CssFileFilterItem(QObject *parent)
|
|
||||||
: FileFilterBaseItem(parent)
|
: FileFilterBaseItem(parent)
|
||||||
{
|
{
|
||||||
setFilter(QLatin1String("*.css"));
|
setFilter(fileFilter);
|
||||||
}
|
|
||||||
|
|
||||||
void CssFileFilterItem::setFilter(const QString &filter)
|
|
||||||
{
|
|
||||||
FileFilterBaseItem::setFilter(filter);
|
|
||||||
emit filterChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
OtherFileFilterItem::OtherFileFilterItem(QObject *parent)
|
|
||||||
: FileFilterBaseItem(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OtherFileFilterItem::setFilter(const QString &filter)
|
|
||||||
{
|
|
||||||
FileFilterBaseItem::setFilter(filter);
|
|
||||||
emit filterChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -107,67 +107,17 @@ private:
|
|||||||
Utils::FileSystemWatcher *m_dirWatcher = nullptr;
|
Utils::FileSystemWatcher *m_dirWatcher = nullptr;
|
||||||
QTimer m_updateFileListTimer;
|
QTimer m_updateFileListTimer;
|
||||||
|
|
||||||
|
|
||||||
friend class ProjectItem;
|
friend class ProjectItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlFileFilterItem : public FileFilterBaseItem {
|
class FileFilterItem : public FileFilterBaseItem {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlFileFilterItem(QObject *parent = nullptr);
|
FileFilterItem(const QString &fileFilter, QObject *parent = nullptr);
|
||||||
};
|
|
||||||
|
|
||||||
class JsFileFilterItem : public FileFilterBaseItem {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
|
||||||
|
|
||||||
void setFilter(const QString &filter);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void filterChanged();
|
|
||||||
|
|
||||||
public:
|
|
||||||
JsFileFilterItem(QObject *parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageFileFilterItem : public FileFilterBaseItem {
|
class ImageFileFilterItem : public FileFilterBaseItem {
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
|
||||||
|
|
||||||
void setFilter(const QString &filter);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void filterChanged();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageFileFilterItem(QObject *parent = nullptr);
|
ImageFileFilterItem(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CssFileFilterItem : public FileFilterBaseItem {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
|
||||||
|
|
||||||
void setFilter(const QString &filter);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void filterChanged();
|
|
||||||
|
|
||||||
public:
|
|
||||||
CssFileFilterItem(QObject *parent = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OtherFileFilterItem : public FileFilterBaseItem {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
|
|
||||||
|
|
||||||
void setFilter(const QString &filter);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void filterChanged();
|
|
||||||
|
|
||||||
public:
|
|
||||||
OtherFileFilterItem(QObject *parent = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -37,7 +37,7 @@ enum {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void setupFileFilterItem(QmlProjectManager::FileFilterBaseItem *fileFilterItem, const QmlJS::SimpleReaderNode::Ptr &node)
|
QmlProjectManager::FileFilterBaseItem *setupFileFilterItem(QmlProjectManager::FileFilterBaseItem *fileFilterItem, const QmlJS::SimpleReaderNode::Ptr &node)
|
||||||
{
|
{
|
||||||
const QVariant directoryProperty = node->property(QLatin1String("directory"));
|
const QVariant directoryProperty = node->property(QLatin1String("directory"));
|
||||||
if (directoryProperty.isValid())
|
if (directoryProperty.isValid())
|
||||||
@@ -57,6 +57,7 @@ void setupFileFilterItem(QmlProjectManager::FileFilterBaseItem *fileFilterItem,
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "directory:" << directoryProperty << "recursive" << recursiveProperty << "paths" << pathsProperty;
|
qDebug() << "directory:" << directoryProperty << "recursive" << recursiveProperty << "paths" << pathsProperty;
|
||||||
|
return fileFilterItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
@@ -100,37 +101,19 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
|
|||||||
qDebug() << "importPath:" << importPathsProperty << "mainFile:" << mainFileProperty;
|
qDebug() << "importPath:" << importPathsProperty << "mainFile:" << mainFileProperty;
|
||||||
|
|
||||||
foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, rootNode->children()) {
|
foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, rootNode->children()) {
|
||||||
if (childNode->name() == QLatin1String("QmlFiles")) {
|
if (debug)
|
||||||
if (debug)
|
qDebug() << "reading type:" << childNode->name();
|
||||||
qDebug() << "QmlFiles";
|
|
||||||
auto qmlFileFilterItem = new QmlFileFilterItem(projectItem);
|
|
||||||
setupFileFilterItem(qmlFileFilterItem, childNode);
|
|
||||||
projectItem->appendContent(qmlFileFilterItem);
|
|
||||||
} else if (childNode->name() == QLatin1String("JavaScriptFiles")) {
|
|
||||||
if (debug)
|
|
||||||
qDebug() << "JavaScriptFiles";
|
|
||||||
auto jsFileFilterItem = new JsFileFilterItem(projectItem);
|
|
||||||
setupFileFilterItem(jsFileFilterItem, childNode);
|
|
||||||
projectItem->appendContent(jsFileFilterItem);
|
|
||||||
} else if (childNode->name() == QLatin1String("ImageFiles")) {
|
|
||||||
if (debug)
|
|
||||||
qDebug() << "ImageFiles";
|
|
||||||
auto imageFileFilterItem = new ImageFileFilterItem(projectItem);
|
|
||||||
setupFileFilterItem(imageFileFilterItem, childNode);
|
|
||||||
projectItem->appendContent(imageFileFilterItem);
|
|
||||||
|
|
||||||
|
if (childNode->name() == QLatin1String("QmlFiles")) {
|
||||||
|
projectItem->appendContent(setupFileFilterItem(new FileFilterItem("*.qml"), childNode));
|
||||||
|
} else if (childNode->name() == QLatin1String("JavaScriptFiles")) {
|
||||||
|
projectItem->appendContent(setupFileFilterItem(new FileFilterItem("*.js"), childNode));
|
||||||
|
} else if (childNode->name() == QLatin1String("ImageFiles")) {
|
||||||
|
projectItem->appendContent(setupFileFilterItem(new ImageFileFilterItem(projectItem), childNode));
|
||||||
} else if (childNode->name() == QLatin1String("CssFiles")) {
|
} else if (childNode->name() == QLatin1String("CssFiles")) {
|
||||||
if (debug)
|
projectItem->appendContent(setupFileFilterItem(new FileFilterItem("*.css"), childNode));
|
||||||
qDebug() << "CssFiles";
|
|
||||||
auto cssFileFilterItem = new CssFileFilterItem(projectItem);
|
|
||||||
setupFileFilterItem(cssFileFilterItem, childNode);
|
|
||||||
projectItem->appendContent(cssFileFilterItem);
|
|
||||||
} else if (childNode->name() == QLatin1String("Files")) {
|
} else if (childNode->name() == QLatin1String("Files")) {
|
||||||
if (debug)
|
projectItem->appendContent(setupFileFilterItem(new FileFilterBaseItem(), childNode));
|
||||||
qDebug() << "Files";
|
|
||||||
auto otherFileFilterItem = new OtherFileFilterItem(projectItem);
|
|
||||||
setupFileFilterItem(otherFileFilterItem, childNode);
|
|
||||||
projectItem->appendContent(otherFileFilterItem);
|
|
||||||
} else if (childNode->name() == "Environment") {
|
} else if (childNode->name() == "Environment") {
|
||||||
const auto properties = childNode->properties();
|
const auto properties = childNode->properties();
|
||||||
auto i = properties.constBegin();
|
auto i = properties.constBegin();
|
||||||
|
Reference in New Issue
Block a user