mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
connect filter list functionality to the CardDatabaseDisplayModel class
enable/disable check boxes still not functional
This commit is contained in:
parent
863e437d4c
commit
3202243ed0
9 changed files with 258 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "carddatabasemodel.h"
|
||||
#include "filterlist.h"
|
||||
|
||||
CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, QObject *parent)
|
||||
: QAbstractListModel(parent), db(_db)
|
||||
|
|
@ -109,6 +110,7 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
|||
: QSortFilterProxyModel(parent),
|
||||
isToken(ShowAll)
|
||||
{
|
||||
filterList = NULL;
|
||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
}
|
||||
|
|
@ -116,7 +118,7 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
|||
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||
{
|
||||
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||
|
||||
|
||||
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
|
||||
return false;
|
||||
|
||||
|
|
@ -144,6 +146,9 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
if (!cardTypes.contains(info->getMainCardType()))
|
||||
return false;
|
||||
|
||||
if (filterList != NULL)
|
||||
return filterList->acceptsCard(info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -155,3 +160,18 @@ void CardDatabaseDisplayModel::clearSearch()
|
|||
cardColors.clear();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void CardDatabaseDisplayModel::setFilterList(const FilterList *filterList)
|
||||
{
|
||||
if(this->filterList != NULL)
|
||||
disconnect(this->filterList, 0, this, 0);
|
||||
|
||||
this->filterList = filterList;
|
||||
connect(this->filterList, SIGNAL(changed()), this, SLOT(filterListChanged()));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void CardDatabaseDisplayModel::filterListChanged()
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue