Commit b604e91f authored by Svenn-Arne Dragly's avatar Svenn-Arne Dragly Committed by Tobias Hunger

Show folders as tree view for resources

This patch builds a tree view of the paths to files
in resource files.
Previously all files were shown in a flat structure
under prefixes with the entire path as part of their
displayed name.
Because folders based on prefixes are different from
folders in the paths, a new class, SimpleResourceFolderNode,
was introduced.

Change-Id: Ifc4773cff6a678b50e64b0d56713f80704e12f6f
Reviewed-by: default avatarSvenn-Arne Dragly <s@dragly.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent db16798e
This diff is collapsed.
......@@ -67,6 +67,32 @@ private:
};
namespace Internal {
class PrefixFolderLang
{
public:
PrefixFolderLang(QString prefix, QString folder, QString lang)
: m_prefix(prefix)
, m_folder(folder)
, m_lang(lang)
{}
bool operator<(const PrefixFolderLang &other) const
{
if (m_prefix != other.m_prefix)
return m_prefix < other.m_prefix;
if (m_folder != other.m_folder)
return m_folder < other.m_folder;
if (m_lang != other.m_lang)
return m_lang < other.m_lang;
return false;
}
private:
QString m_prefix;
QString m_folder;
QString m_lang;
};
class ResourceFolderNode : public ProjectExplorer::FolderNode
{
friend class ResourceEditor::ResourceTopLevelNode; // for updateFiles
......@@ -90,24 +116,56 @@ public:
QString lang() const;
ResourceTopLevelNode *resourceNode() const;
private:
void updateFolders(QList<ProjectExplorer::FolderNode *> newList);
void updateFiles(QList<ProjectExplorer::FileNode *> newList);
ResourceTopLevelNode *m_topLevelNode;
QString m_prefix;
QString m_lang;
};
class SimpleResourceFolderNode : public ProjectExplorer::FolderNode
{
friend class ResourceEditor::ResourceTopLevelNode;
public:
QString displayName() const;
SimpleResourceFolderNode(const QString &afolderName, const QString &displayName,
const QString &prefix, const QString &lang, Utils::FileName absolutePath,
ResourceTopLevelNode *topLevel, ResourceFolderNode *prefixNode);
QList<ProjectExplorer::ProjectAction> supportedActions(ProjectExplorer::Node *node) const;
void addFilesAndSubfolders(QMap<PrefixFolderLang, QList<ProjectExplorer::FileNode *>> filesToAdd,
QMap<PrefixFolderLang, QList<ProjectExplorer::FolderNode *>> foldersToAdd,
const QString &prefix, const QString &lang);
bool addFiles(const QStringList &filePaths, QStringList *notAdded);
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved);
bool renameFile(const QString &filePath, const QString &newFilePath);
QString prefix() const;
ResourceTopLevelNode *resourceNode() const;
ResourceFolderNode *prefixNode() const;
private:
void updateFiles(QList<ProjectExplorer::FileNode *> newList);
void updateFolders(QList<ProjectExplorer::FolderNode *> newList);
QString m_folderName;
QString m_displayName;
QString m_prefix;
QString m_lang;
ResourceTopLevelNode *m_topLevelNode;
ResourceFolderNode *m_prefixNode;
};
class ResourceFileNode : public ProjectExplorer::FileNode
{
public:
ResourceFileNode(const Utils::FileName &filePath, const QString &qrcPath, ResourceTopLevelNode *topLevel);
ResourceFileNode(const Utils::FileName &filePath, const QString &qrcPath, const QString &displayName);
QString displayName() const override;
QString qrcPath() const;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const override;
private:
QString m_displayName;
QString m_qrcPath;
QString m_displayName;
};
class ResourceFileWatcher : public Core::IDocument
......
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