diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-26 20:48:38 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:14 +0100 |
| commit | be0d6aef00891286f33242073627611413ad79c4 (patch) | |
| tree | 037f2c69d8d11adba6be428704bb4612fd7f79fc /src/modlistbypriorityproxy.h | |
| parent | 71055e373de639d9654361084f39d81211d08819 (diff) | |
Start working on collapsible separators.
Diffstat (limited to 'src/modlistbypriorityproxy.h')
| -rw-r--r-- | src/modlistbypriorityproxy.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/modlistbypriorityproxy.h b/src/modlistbypriorityproxy.h new file mode 100644 index 00000000..6ec04b9b --- /dev/null +++ b/src/modlistbypriorityproxy.h @@ -0,0 +1,56 @@ +#ifndef MODLISBYPRIORITYPROXY_H +#define MODLISBYPRIORITYPROXY_H + +#include <optional> +#include <vector> + +#include <QAbstractProxyModel> +#include <QModelIndex> +#include <QMultiHash> +#include <QStringList> +#include <QIcon> +#include <QSet> + +#include "modinfo.h" + +class ModList; + +class ModListByPriorityProxy : public QAbstractProxyModel +{ + Q_OBJECT + +public: + explicit ModListByPriorityProxy(ModList* modList, QObject* parent = nullptr); + ~ModListByPriorityProxy(); + + void setSourceModel(QAbstractItemModel* sourceModel) override; + + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& child) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& index) const override; + bool hasChildren(const QModelIndex& parent) const override; + + QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; + QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; + +private: + + void buildTree(); + + struct ModInfoWithPriority { + const ModInfo::Ptr mod; + const int priority; + }; + + std::vector<ModInfoWithPriority> topLevelItems() const; + std::vector<ModInfoWithPriority> childItems(int priority) const; + std::optional<ModInfoWithPriority> separator(int priority) const; + +private: + + ModList* m_ModList; + +}; + +#endif //GROUPINGPROXY_H |
