diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:58:34 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:58:34 -0400 |
commit | 1ea03c0fce8066c1e22188447b4a6ca4dcef1201 (patch) | |
tree | 1ad46980fdca402062502b20b7e16468b89393f8 /src/backend/bookshelfmodel/item.cpp | |
parent | 579657c8cb4ecd8a313221e70bdbbc7267f20286 (diff) |
Imported Upstream version 2.10.1
Diffstat (limited to 'src/backend/bookshelfmodel/item.cpp')
-rw-r--r-- | src/backend/bookshelfmodel/item.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp index 02cd991..9d6e5af 100644 --- a/src/backend/bookshelfmodel/item.cpp +++ b/src/backend/bookshelfmodel/item.cpp @@ -4,7 +4,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2011 by the BibleTime developers. +* Copyright 1999-2014 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License * version 2.0. * @@ -17,56 +17,56 @@ namespace BookshelfModel { -Item::Item(Type type) - : m_type(type), m_parent(0), m_checkState(Qt::Unchecked) { - // Intentionally empty -} - Item::~Item() { qDeleteAll(m_children); } -int Item::indexFor(Item *newItem) { - Q_ASSERT(newItem != 0); +int Item::indexFor(Item * newItem) { + Q_ASSERT(newItem); - if (m_children.empty()) return 0; + if (m_children.empty()) + return 0; - int i(0); + int i = 0; for (;;) { - Item *nextItem(m_children.at(i)); + Item * const nextItem(m_children.at(i)); Q_ASSERT(nextItem->type() == newItem->type()); - if (*newItem < *nextItem) { + if (*newItem < *nextItem) return i; - } + i++; - if (i >= m_children.size()) { + if (i >= m_children.size()) return i; - } } } QVariant Item::data(int role) const { switch (role) { + case Qt::CheckStateRole: return m_checkState; + case BtBookshelfModel::ModuleHiddenRole: - if (m_children.empty()) return true; + if (m_children.empty()) + return true; - foreach (Item *child, m_children) { - if (!child->data(role).toBool()) return false; - } + Q_FOREACH (Item * child, m_children) + if (!child->data(role).toBool()) + return false; return true; + default: return QVariant(); + } } -bool Item::operator<(const Item &other) const { - if (m_type != other.type()) { +bool Item::operator<(const Item & other) const { + if (m_type != other.type()) return m_type < other.type(); - } - QString first(data(Qt::DisplayRole).toString().toLower()); - QString second(other.data(Qt::DisplayRole).toString().toLower()); + + const QString first(data(Qt::DisplayRole).toString().toLower()); + const QString second(other.data(Qt::DisplayRole).toString().toLower()); return first.localeAwareCompare(second) < 0; } |