mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-24 15:43:54 -07:00
the original layout is actually more space efficient if using CardFrame instead of CardInfoWidget and reducing the size of the deck editor toolbar. this commit also removes the old search feature by removing the search button and the clear search button. the clear search menu item is left in place, however it now clears the filtertree. finally, the stretch factor for the right frame in the main layout was reduced to zero so that the card database gets priority for extra space. this makes more sense because the deck editor does not actually need very much horizontal space.
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#ifndef CARDDATABASEMODEL_H
|
|
#define CARDDATABASEMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QSortFilterProxyModel>
|
|
#include <QList>
|
|
#include <QSet>
|
|
#include "carddatabase.h"
|
|
|
|
class FilterTree;
|
|
|
|
class CardDatabaseModel : public QAbstractListModel {
|
|
Q_OBJECT
|
|
public:
|
|
CardDatabaseModel(CardDatabase *_db, QObject *parent = 0);
|
|
~CardDatabaseModel();
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
CardDatabase *getDatabase() const { return db; }
|
|
CardInfo *getCard(int index) const { return cardList[index]; }
|
|
private:
|
|
QList<CardInfo *> cardList;
|
|
CardDatabase *db;
|
|
private slots:
|
|
void updateCardList();
|
|
void cardAdded(CardInfo *card);
|
|
void cardRemoved(CardInfo *card);
|
|
void cardInfoChanged(CardInfo *card);
|
|
};
|
|
|
|
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
|
|
Q_OBJECT
|
|
public:
|
|
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
|
|
private:
|
|
FilterBool isToken;
|
|
QString cardNameBeginning, cardName, cardText;
|
|
QSet<QString> cardNameSet, cardTypes, cardColors;
|
|
FilterTree *filterTree;
|
|
public:
|
|
CardDatabaseDisplayModel(QObject *parent = 0);
|
|
void setFilterTree(FilterTree *filterTree);
|
|
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
|
|
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
|
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
|
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; invalidate(); }
|
|
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
|
|
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
|
|
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
|
void clearSearch();
|
|
protected:
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
private slots:
|
|
void filterTreeChanged();
|
|
};
|
|
|
|
#endif
|