diff options
author | Petr Mrázek <peterix@gmail.com> | 2018-04-06 21:04:34 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-04-06 21:04:34 +0200 |
commit | 6323aae56ff8bd1fb06da9044f9dd5e0df983bdc (patch) | |
tree | 73cbd610cfd5fb3fea1a1fe43d5be44a245409f3 /application/pages/modplatform/FtbListModel.h | |
parent | c9c6037f50a97084ca60b98514bea047765910e9 (diff) | |
download | MultiMC-6323aae56ff8bd1fb06da9044f9dd5e0df983bdc.tar MultiMC-6323aae56ff8bd1fb06da9044f9dd5e0df983bdc.tar.gz MultiMC-6323aae56ff8bd1fb06da9044f9dd5e0df983bdc.tar.lz MultiMC-6323aae56ff8bd1fb06da9044f9dd5e0df983bdc.tar.xz MultiMC-6323aae56ff8bd1fb06da9044f9dd5e0df983bdc.zip |
NOISSUE move FtbListModel to where it is actually used
Diffstat (limited to 'application/pages/modplatform/FtbListModel.h')
-rw-r--r-- | application/pages/modplatform/FtbListModel.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/application/pages/modplatform/FtbListModel.h b/application/pages/modplatform/FtbListModel.h new file mode 100644 index 00000000..12b26be1 --- /dev/null +++ b/application/pages/modplatform/FtbListModel.h @@ -0,0 +1,65 @@ +#pragma once + +#include <QAbstractListModel> +#include <QSortFilterProxyModel> +#include <modplatform/ftb/PackHelpers.h> +#include <QThreadPool> + +#include <RWStorage.h> + +#include <QIcon> + +typedef QMap<QString, QIcon> FtbLogoMap; + +class FtbFilterModel : public QSortFilterProxyModel +{ +public: + FtbFilterModel(QObject* parent = Q_NULLPTR); + enum Sorting { + ByName, + ByGameVersion + }; + const QMap<QString, Sorting> getAvailableSortings(); + QString translateCurrentSorting(); + void setSorting(Sorting sorting); + Sorting getCurrentSorting(); + +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; + +private: + QMap<QString, Sorting> sortings; + Sorting currentSorting; + +}; + +class FtbListModel : public QAbstractListModel +{ + Q_OBJECT +private: + FtbModpackList modpacks; + QStringList m_failedLogos; + QStringList m_loadingLogos; + FtbLogoMap m_logoMap; + + void requestLogo(QString file); + QString translatePackType(FtbPackType type) const; + + +private slots: + void logoFailed(QString logo); + void logoLoaded(QString logo, QIcon out); + +public: + FtbListModel(QObject *parent); + ~FtbListModel(); + int rowCount(const QModelIndex &parent) const override; + int columnCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + + void fill(FtbModpackList modpacks); + + FtbModpack at(int row); + +}; |