1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00
vcmi/launcher/modManager/cmodlistmodel_moc.h
2015-12-04 01:17:43 +02:00

87 lines
2.0 KiB
C++

#pragma once
#include "cmodlist.h"
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
namespace ModFields
{
enum EModFields
{
NAME,
STATUS_ENABLED,
STATUS_UPDATE,
TYPE,
VERSION,
SIZE,
AUTHOR,
COUNT
};
}
namespace ModRoles
{
enum EModRoles
{
ValueRole = Qt::UserRole,
ModNameRole
};
}
class CModListModel : public QAbstractItemModel, public CModList
{
Q_OBJECT
QVector<QString> modNameToID;
// contains mapping mod -> numbered list of submods
// mods that have no parent located under "" key (empty string)
QMap<QString, QVector<QString>> modIndex;
void endResetModel();
QString modIndexToName(const QModelIndex & index) const;
QVariant getTextAlign(int field) const;
QVariant getValue(const CModEntry & mod, int field) const;
QVariant getText(const CModEntry & mod, int field) const;
QVariant getIcon(const CModEntry & mod, int field) const;
public:
explicit CModListModel(QObject *parent = 0);
/// CModListContainer overrides
void resetRepositories() override;
void addRepository(QVariantMap data) override;
void modChanged(QString modID) override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
signals:
public slots:
};
class CModFilterModel : public QSortFilterProxyModel
{
CModListModel * base;
int filteredType;
int filterMask;
bool filterMatchesThis(const QModelIndex & source) const;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
public:
void setTypeFilter(int filteredType, int filterMask);
CModFilterModel(CModListModel * model, QObject *parent = 0);
};