mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
* Untangle the card_info.cpp mess and split into individual files. Took 53 minutes * Auto-lint was disabled and my pre-commit hook didn't fire. Oh well. Took 3 minutes * Fix oracle. Took 35 seconds * Lint! Took 20 seconds * Fix tests. Took 3 minutes * CMakeLists.txt: The reason why I have to disable auto-lint. Took 2 minutes * dbconverter. Took 3 minutes * Oracle again. Took 3 minutes * dbconverter again. Took 3 minutes * dbconverter again again. Took 2 minutes * More fixes. Took 4 minutes Took 21 seconds * Everything needs everything. Took 3 minutes * Everything means everything. Took 4 minutes * All the tests. Took 4 minutes * I hate everything about this. Took 3 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
106 lines
2.7 KiB
C++
106 lines
2.7 KiB
C++
/**
|
|
* @file sets_model.h
|
|
* @ingroup CardDatabaseModels
|
|
* @brief TODO: Document this.
|
|
*/
|
|
|
|
#ifndef SETSMODEL_H
|
|
#define SETSMODEL_H
|
|
|
|
#include "../../database/card_database.h"
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QMimeData>
|
|
#include <QSet>
|
|
#include <QSortFilterProxyModel>
|
|
|
|
class SetsProxyModel;
|
|
|
|
class SetsMimeData : public QMimeData
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
int oldRow;
|
|
|
|
public:
|
|
SetsMimeData(int _oldRow) : oldRow(_oldRow)
|
|
{
|
|
}
|
|
int getOldRow() const
|
|
{
|
|
return oldRow;
|
|
}
|
|
QStringList formats() const
|
|
{
|
|
return QStringList() << "application/x-cockatricecardset";
|
|
}
|
|
};
|
|
|
|
class SetsModel : public QAbstractTableModel
|
|
{
|
|
Q_OBJECT
|
|
friend class SetsProxyModel;
|
|
|
|
private:
|
|
static const int NUM_COLS = 7;
|
|
CardSetList sets;
|
|
QSet<CardSetPtr> enabledSets;
|
|
|
|
public:
|
|
enum SetsColumns
|
|
{
|
|
SortKeyCol,
|
|
IsKnownCol,
|
|
EnabledCol,
|
|
LongNameCol,
|
|
ShortNameCol,
|
|
SetTypeCol,
|
|
ReleaseDateCol,
|
|
PriorityCol
|
|
};
|
|
enum Role
|
|
{
|
|
SortRole = Qt::UserRole
|
|
};
|
|
|
|
explicit SetsModel(CardDatabase *_db, QObject *parent = nullptr);
|
|
~SetsModel() override;
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override
|
|
{
|
|
Q_UNUSED(parent);
|
|
return NUM_COLS;
|
|
}
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
Qt::DropActions supportedDropActions() const override;
|
|
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
|
bool
|
|
dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
|
QStringList mimeTypes() const override;
|
|
void swapRows(int oldRow, int newRow);
|
|
void toggleRow(int row, bool enable);
|
|
void toggleRow(int row);
|
|
void toggleAll(bool);
|
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
|
void save(CardDatabase *db);
|
|
void restore(CardDatabase *db);
|
|
void restoreOriginalOrder();
|
|
};
|
|
|
|
class SetsDisplayModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit SetsDisplayModel(QObject *parent = nullptr);
|
|
|
|
protected:
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
|
void fetchMore(const QModelIndex &index) override;
|
|
};
|
|
|
|
#endif
|