diff options
Diffstat (limited to 'src/backend/bookshelfmodel/item.cpp')
-rw-r--r-- | src/backend/bookshelfmodel/item.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp index ec2dcab..809021b 100644 --- a/src/backend/bookshelfmodel/item.cpp +++ b/src/backend/bookshelfmodel/item.cpp @@ -12,9 +12,7 @@ #include "backend/bookshelfmodel/item.h" -#include "backend/bookshelfmodel/categoryitem.h" -#include "backend/bookshelfmodel/distributionitem.h" -#include "backend/bookshelfmodel/languageitem.h" +#include "backend/bookshelfmodel/btbookshelfmodel.h" namespace BookshelfModel { @@ -47,19 +45,29 @@ int Item::indexFor(Item *newItem) { } } -bool Item::operator<(const Item &other) const { - if (m_type != other.type()) { - return m_type < other.type(); +QVariant Item::data(int role) const { + switch (role) { + case Qt::CheckStateRole: + return m_checkState; + case BtBookshelfModel::ModuleHiddenRole: + if (m_children.empty()) return true; + + foreach (Item *child, m_children) { + if (!child->data(role).toBool()) return false; + } + return true; + default: + return QVariant(); } - return name().localeAwareCompare(other.name()) < 0; } -bool Item::isHidden() const { - if (m_children.empty()) return true; - Q_FOREACH(Item *child, m_children) { - if (!child->isHidden()) return false; +bool Item::operator<(const Item &other) const { + if (m_type != other.type()) { + return m_type < other.type(); } - return true; + QString first(data(Qt::DisplayRole).toString().toLower()); + QString second(other.data(Qt::DisplayRole).toString().toLower()); + return first.localeAwareCompare(second) < 0; } } // namespace BookshelfModel |