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 "carddatabasemodel.h"
|
||||||
|
#include "filterlist.h"
|
||||||
|
|
||||||
CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, QObject *parent)
|
CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, QObject *parent)
|
||||||
: QAbstractListModel(parent), db(_db)
|
: QAbstractListModel(parent), db(_db)
|
||||||
|
@ -109,6 +110,7 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent),
|
: QSortFilterProxyModel(parent),
|
||||||
isToken(ShowAll)
|
isToken(ShowAll)
|
||||||
{
|
{
|
||||||
|
filterList = NULL;
|
||||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
@ -144,6 +146,9 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
||||||
if (!cardTypes.contains(info->getMainCardType()))
|
if (!cardTypes.contains(info->getMainCardType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (filterList != NULL)
|
||||||
|
return filterList->acceptsCard(info);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,3 +160,18 @@ void CardDatabaseDisplayModel::clearSearch()
|
||||||
cardColors.clear();
|
cardColors.clear();
|
||||||
invalidateFilter();
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
|
|
||||||
|
class FilterList;
|
||||||
|
|
||||||
class CardDatabaseModel : public QAbstractListModel {
|
class CardDatabaseModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -36,8 +38,10 @@ private:
|
||||||
FilterBool isToken;
|
FilterBool isToken;
|
||||||
QString cardNameBeginning, cardName, cardText;
|
QString cardNameBeginning, cardName, cardText;
|
||||||
QSet<QString> cardNameSet, cardTypes, cardColors;
|
QSet<QString> cardNameSet, cardTypes, cardColors;
|
||||||
|
const FilterList *filterList;
|
||||||
public:
|
public:
|
||||||
CardDatabaseDisplayModel(QObject *parent = 0);
|
CardDatabaseDisplayModel(QObject *parent = 0);
|
||||||
|
void setFilterList(const FilterList *filterList);
|
||||||
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
|
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
|
||||||
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
||||||
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
||||||
|
@ -48,6 +52,8 @@ public:
|
||||||
void clearSearch();
|
void clearSearch();
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
private slots:
|
||||||
|
void filterListChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,12 @@ const char *CardFilter::attrName(Attr a)
|
||||||
return "type";
|
return "type";
|
||||||
case AttrColor:
|
case AttrColor:
|
||||||
return "color";
|
return "color";
|
||||||
|
case AttrText:
|
||||||
|
return "text";
|
||||||
|
case AttrSet:
|
||||||
|
return "set";
|
||||||
|
case AttrManaCost:
|
||||||
|
return "mana cost";
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,15 @@ public:
|
||||||
TypeEnd
|
TypeEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* if you add an atribute here you also need to
|
||||||
|
* add its string representation in attrName */
|
||||||
enum Attr {
|
enum Attr {
|
||||||
AttrName = 0,
|
AttrName = 0,
|
||||||
AttrType,
|
AttrType,
|
||||||
AttrColor,
|
AttrColor,
|
||||||
|
AttrText,
|
||||||
|
AttrSet,
|
||||||
|
AttrManaCost,
|
||||||
AttrEnd
|
AttrEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "filterlist.h"
|
#include "filterlist.h"
|
||||||
#include "CardFilter.h"
|
#include "cardfilter.h"
|
||||||
|
#include "carddatabase.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
@ -9,6 +10,17 @@ LogicMap::~LogicMap()
|
||||||
delete takeFirst();
|
delete takeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FilterItemList *LogicMap::findTypeList(CardFilter::Type type) const
|
||||||
|
{
|
||||||
|
LogicMap::const_iterator i;
|
||||||
|
|
||||||
|
for(i = constBegin(); i != constEnd(); i++)
|
||||||
|
if ((*i)->type == type)
|
||||||
|
return *i;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FilterItemList *LogicMap::typeList(CardFilter::Type type)
|
FilterItemList *LogicMap::typeList(CardFilter::Type type)
|
||||||
{
|
{
|
||||||
LogicMap::iterator i;
|
LogicMap::iterator i;
|
||||||
|
@ -158,3 +170,168 @@ int FilterList::count(const CardFilter *f)
|
||||||
{
|
{
|
||||||
return count(f->attr(), f->type());
|
return count(f->attr(), f->type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptName(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
return info->getName().contains(term, Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptType(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
return info->getCardType().contains(term, Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptColor(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
QStringList::const_iterator i;
|
||||||
|
bool status;
|
||||||
|
|
||||||
|
status = false;
|
||||||
|
for(i = info->getColors().constBegin(); i != info->getColors().constEnd(); i++)
|
||||||
|
if ((*i).contains(term, Qt::CaseInsensitive)) {
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptText(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
return info->getText().contains(term, Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptSet(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
SetList::const_iterator i;
|
||||||
|
bool status;
|
||||||
|
|
||||||
|
status = false;
|
||||||
|
for(i = info->getSets().constBegin(); i != info->getSets().constEnd(); i++)
|
||||||
|
if ((*i)->getShortName() == term
|
||||||
|
|| (*i)->getLongName().contains(term, Qt::CaseInsensitive)) {
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptManaCost(const CardInfo *info, const QString &term) const
|
||||||
|
{
|
||||||
|
return (info->getManaCost() == term);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptCardAttr(const CardInfo *info, const QString &term,
|
||||||
|
CardFilter::Attr attr) const
|
||||||
|
{
|
||||||
|
bool status;
|
||||||
|
|
||||||
|
switch(attr) {
|
||||||
|
case CardFilter::AttrName:
|
||||||
|
status = acceptName(info, term);
|
||||||
|
break;
|
||||||
|
case CardFilter::AttrType:
|
||||||
|
status = acceptType(info, term);
|
||||||
|
break;
|
||||||
|
case CardFilter::AttrColor:
|
||||||
|
status = acceptColor(info, term);
|
||||||
|
break;
|
||||||
|
case CardFilter::AttrText:
|
||||||
|
status = acceptText(info, term);
|
||||||
|
break;
|
||||||
|
case CardFilter::AttrSet:
|
||||||
|
status = acceptSet(info, term);
|
||||||
|
break;
|
||||||
|
case CardFilter::AttrManaCost:
|
||||||
|
status = acceptManaCost(info, term);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = true; /* ignore this attribute */
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::testTypeAnd(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *fil) const
|
||||||
|
{
|
||||||
|
FilterItemList::const_iterator i;
|
||||||
|
|
||||||
|
for(i = fil->constBegin(); i != fil->constEnd(); i++)
|
||||||
|
if(!acceptCardAttr(info, (*i)->term, attr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::testTypeAndNot(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *fil) const
|
||||||
|
{
|
||||||
|
FilterItemList::const_iterator i;
|
||||||
|
|
||||||
|
for(i = fil->constBegin(); i != fil->constEnd(); i++)
|
||||||
|
if(acceptCardAttr(info, (*i)->term, attr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::testTypeOr(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *filOr,
|
||||||
|
const FilterItemList *filOrNot) const
|
||||||
|
{
|
||||||
|
FilterItemList::const_iterator i;
|
||||||
|
bool status;
|
||||||
|
|
||||||
|
if(filOr == NULL && filOrNot == NULL)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
status = false;
|
||||||
|
if (filOr != NULL)
|
||||||
|
for(i = filOr->constBegin(); i != filOr->constEnd(); i++)
|
||||||
|
if(acceptCardAttr(info, (*i)->term, attr)) {
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (status != true && filOrNot != NULL)
|
||||||
|
for(i = filOrNot->constBegin(); i != filOrNot->constEnd(); i++)
|
||||||
|
if(!acceptCardAttr(info, (*i)->term, attr)) {
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::testAttr(const CardInfo *info, const LogicMap *lm) const
|
||||||
|
{
|
||||||
|
bool status;
|
||||||
|
const FilterItemList *fil, *fil2;
|
||||||
|
|
||||||
|
fil = lm->findTypeList(CardFilter::TypeAnd);
|
||||||
|
if (fil != NULL && !testTypeAnd(info, lm->attr, fil))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fil = lm->findTypeList(CardFilter::TypeAndNot);
|
||||||
|
if (fil != NULL && !testTypeAndNot(info, lm->attr, fil))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fil = lm->findTypeList(CardFilter::TypeOr);
|
||||||
|
fil2 = lm->findTypeList(CardFilter::TypeOrNot);
|
||||||
|
if (!testTypeOr(info, lm->attr, fil, fil2))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilterList::acceptsCard(const CardInfo *info) const
|
||||||
|
{
|
||||||
|
QList<LogicMap *>::const_iterator i;
|
||||||
|
|
||||||
|
for(i = logicAttrs.constBegin(); i != logicAttrs.constEnd(); i++)
|
||||||
|
if(!testAttr(info, *i))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "cardfilter.h"
|
#include "cardfilter.h"
|
||||||
|
|
||||||
|
class CardInfo;
|
||||||
|
|
||||||
class FilterListNode {
|
class FilterListNode {
|
||||||
private:
|
private:
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
@ -38,6 +40,7 @@ public:
|
||||||
LogicMap(CardFilter::Attr a, FilterList *parent)
|
LogicMap(CardFilter::Attr a, FilterList *parent)
|
||||||
: attr(a), p(parent) {}
|
: attr(a), p(parent) {}
|
||||||
~LogicMap();
|
~LogicMap();
|
||||||
|
const FilterItemList *findTypeList(CardFilter::Type type) const;
|
||||||
FilterItemList *typeList(CardFilter::Type type);
|
FilterItemList *typeList(CardFilter::Type type);
|
||||||
virtual FilterListNode *parent() const;
|
virtual FilterListNode *parent() const;
|
||||||
virtual FilterListNode *nodeAt(int i) const;
|
virtual FilterListNode *nodeAt(int i) const;
|
||||||
|
@ -55,6 +58,7 @@ private:
|
||||||
LogicMap *const p;
|
LogicMap *const p;
|
||||||
public:
|
public:
|
||||||
const CardFilter::Type type;
|
const CardFilter::Type type;
|
||||||
|
|
||||||
FilterItemList(CardFilter::Type t, LogicMap *parent)
|
FilterItemList(CardFilter::Type t, LogicMap *parent)
|
||||||
: type(t), p(parent) {}
|
: type(t), p(parent) {}
|
||||||
~FilterItemList();
|
~FilterItemList();
|
||||||
|
@ -90,6 +94,7 @@ class FilterList : public QObject, public FilterListNode {
|
||||||
signals:
|
signals:
|
||||||
void preInsertRow(const FilterListNode *parent, int i) const;
|
void preInsertRow(const FilterListNode *parent, int i) const;
|
||||||
void postInsertRow(const FilterListNode *parent, int i) const;
|
void postInsertRow(const FilterListNode *parent, int i) const;
|
||||||
|
void changed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<LogicMap *> logicAttrs;
|
QList<LogicMap *> logicAttrs;
|
||||||
|
@ -98,6 +103,24 @@ private:
|
||||||
FilterItemList *attrTypeList(CardFilter::Attr attr,
|
FilterItemList *attrTypeList(CardFilter::Attr attr,
|
||||||
CardFilter::Type type);
|
CardFilter::Type type);
|
||||||
|
|
||||||
|
bool acceptName(const CardInfo *info, const QString &term) const;
|
||||||
|
bool acceptType(const CardInfo *info, const QString &term) const;
|
||||||
|
bool acceptColor(const CardInfo *info, const QString &term) const;
|
||||||
|
bool acceptCardAttr(const CardInfo *info, const QString &term,
|
||||||
|
CardFilter::Attr attr) const;
|
||||||
|
bool acceptText(const CardInfo *info, const QString &term) const;
|
||||||
|
bool acceptSet(const CardInfo *info, const QString &term) const;
|
||||||
|
bool acceptManaCost(const CardInfo *info, const QString &term) const;
|
||||||
|
|
||||||
|
bool testTypeAnd(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *fil) const;
|
||||||
|
bool testTypeAndNot(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *fil) const;
|
||||||
|
bool testTypeOr(const CardInfo *info, CardFilter::Attr attr,
|
||||||
|
const FilterItemList *filOr,
|
||||||
|
const FilterItemList *filOrNot) const;
|
||||||
|
|
||||||
|
bool testAttr(const CardInfo *info, const LogicMap *lm) const;
|
||||||
public:
|
public:
|
||||||
~FilterList();
|
~FilterList();
|
||||||
int indexOf(const LogicMap *val) const { return logicAttrs.indexOf((LogicMap *) val); }
|
int indexOf(const LogicMap *val) const { return logicAttrs.indexOf((LogicMap *) val); }
|
||||||
|
@ -117,7 +140,10 @@ public:
|
||||||
virtual QString text() const { return QString("root"); }
|
virtual QString text() const { return QString("root"); }
|
||||||
virtual int index() const { return 0; }
|
virtual int index() const { return 0; }
|
||||||
void preInsertChild(const FilterListNode *p, int i) const { emit preInsertRow(p, i); }
|
void preInsertChild(const FilterListNode *p, int i) const { emit preInsertRow(p, i); }
|
||||||
void postInsertChild(const FilterListNode *p, int i) const { emit postInsertRow(p, i); }
|
void postInsertChild(const FilterListNode *p, int i) const { emit postInsertRow(p, i); emit changed(); }
|
||||||
|
void emitChanged() const { emit changed(); }
|
||||||
|
|
||||||
|
bool acceptsCard(const CardInfo *info) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
FilterListModel::FilterListModel(QObject *parent)
|
FilterListModel::FilterListModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
filterList = new FilterList;
|
fList = new FilterList;
|
||||||
connect(filterList,
|
connect(fList,
|
||||||
SIGNAL(preInsertRow(const FilterListNode *, int)),
|
SIGNAL(preInsertRow(const FilterListNode *, int)),
|
||||||
this, SLOT(proxyBeginInsertRow(const FilterListNode *, int)));
|
this, SLOT(proxyBeginInsertRow(const FilterListNode *, int)));
|
||||||
connect(filterList,
|
connect(fList,
|
||||||
SIGNAL(postInsertRow(const FilterListNode *, int)),
|
SIGNAL(postInsertRow(const FilterListNode *, int)),
|
||||||
this, SLOT(proxyEndInsertRow(const FilterListNode *, int)));
|
this, SLOT(proxyEndInsertRow(const FilterListNode *, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterListModel::~FilterListModel()
|
FilterListModel::~FilterListModel()
|
||||||
{
|
{
|
||||||
delete filterList;
|
delete fList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterListModel::proxyBeginInsertRow(const FilterListNode *node, int i)
|
void FilterListModel::proxyBeginInsertRow(const FilterListNode *node, int i)
|
||||||
|
@ -44,11 +44,11 @@ FilterListNode *FilterListModel::indexToNode(const QModelIndex &idx) const
|
||||||
FilterListNode *node;
|
FilterListNode *node;
|
||||||
|
|
||||||
if(!idx.isValid())
|
if(!idx.isValid())
|
||||||
return filterList;
|
return fList;
|
||||||
|
|
||||||
ip = idx.internalPointer();
|
ip = idx.internalPointer();
|
||||||
if(ip == NULL)
|
if(ip == NULL)
|
||||||
return filterList;
|
return fList;
|
||||||
|
|
||||||
node = static_cast<FilterListNode *>(ip);
|
node = static_cast<FilterListNode *>(ip);
|
||||||
return node;
|
return node;
|
||||||
|
@ -57,7 +57,7 @@ FilterListNode *FilterListModel::indexToNode(const QModelIndex &idx) const
|
||||||
void FilterListModel::addFilter(const CardFilter *f)
|
void FilterListModel::addFilter(const CardFilter *f)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
filterList->termNode(f);
|
fList->termNode(f);
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ bool FilterListModel::setData(const QModelIndex &index,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node = indexToNode(index);
|
node = indexToNode(index);
|
||||||
if(node == NULL || node == filterList)
|
if(node == NULL || node == fList)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
|
Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
|
||||||
|
@ -161,7 +161,7 @@ Qt::ItemFlags FilterListModel::flags(const QModelIndex &index) const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
result = Qt::ItemIsEnabled;
|
result = Qt::ItemIsEnabled;
|
||||||
if(node == filterList)
|
if(node == fList)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result |= Qt::ItemIsSelectable;
|
result |= Qt::ItemIsSelectable;
|
||||||
|
@ -207,7 +207,7 @@ QModelIndex FilterListModel::parent(const QModelIndex &ind) const
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
node = indexToNode(ind);
|
node = indexToNode(ind);
|
||||||
if(node == NULL || node == filterList)
|
if(node == NULL || node == fList)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
parent = node->parent();
|
parent = node->parent();
|
||||||
|
@ -239,8 +239,9 @@ bool FilterListModel::removeRows(int row, int count, const QModelIndex & parent)
|
||||||
for(i = 0; i < count; i++)
|
for(i = 0; i < count; i++)
|
||||||
node->deleteAt(row);
|
node->deleteAt(row);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
fList->emitChanged();
|
||||||
|
|
||||||
if(node != filterList && node->childCount() < 1)
|
if(node != fList && node->childCount() < 1)
|
||||||
return removeRow(parent.row(), parent.parent());
|
return removeRow(parent.row(), parent.parent());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -10,7 +10,7 @@ class FilterListNode;
|
||||||
class FilterListModel : public QAbstractItemModel {
|
class FilterListModel : public QAbstractItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
FilterList *filterList;
|
FilterList *fList;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addFilter(const CardFilter *f);
|
void addFilter(const CardFilter *f);
|
||||||
|
@ -26,6 +26,7 @@ private:
|
||||||
public:
|
public:
|
||||||
FilterListModel(QObject *parent = 0);
|
FilterListModel(QObject *parent = 0);
|
||||||
~FilterListModel();
|
~FilterListModel();
|
||||||
|
const FilterList *filterList() const { return fList; }
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const;
|
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
|
@ -170,6 +170,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
botFrame->addLayout(searchAndButtons);
|
botFrame->addLayout(searchAndButtons);
|
||||||
|
|
||||||
filterModel = new FilterListModel();
|
filterModel = new FilterListModel();
|
||||||
|
databaseDisplayModel->setFilterList(filterModel->filterList());
|
||||||
filterView = new QTreeView;
|
filterView = new QTreeView;
|
||||||
filterView->setModel(filterModel);
|
filterView->setModel(filterModel);
|
||||||
filterView->setMaximumWidth(250);
|
filterView->setMaximumWidth(250);
|
||||||
|
|
Loading…
Reference in a new issue