BibleTime
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
BookshelfModel::Item Class Referenceabstract

#include <item.h>

Inheritance diagram for BookshelfModel::Item:

Public Types

enum  Type {
  ITEM_ROOT = 0 , ITEM_CATEGORY = 1 , ITEM_LANGUAGE = 2 , ITEM_MODULE = 3 ,
  ITEM_INDEXING = 4
}
 

Public Member Functions

Qt::CheckState checkState () const
 Returns the check state of this item.
 
int childIndex () const
 Returns the index of this item under its parent.
 
QList< Item * > & children ()
 Returns the list of child items of this node.
 
virtual QVariant data (int role=Qt::DisplayRole) const
 Returns data for this item.
 
virtual bool fitFor (CSwordModuleInfo const &module) const =0
 Returns whether this item is fit to contain the given module.
 
template<class T >
TgetGroupItem (CSwordModuleInfo const &module, int &outIndex)
 
int indexFor (Item const &newItem)
 Returns the position for where the given child item would be inserted.
 
void insertChild (int const index, Item *const newItem)
 Inserts the given item as a child at the given index.
 
 Item (Type const type)
 
virtual bool operator< (Item const &other) const
 Comparsion operator used sorting child items.
 
Itemparent () const
 Returns a pointer to the parent item of this item.
 
void setCheckState (Qt::CheckState const state)
 Sets the check state of this item.
 
Type type () const
 Returns the type of this item.
 
virtual ~Item ()
 

Private Member Functions

void setParent (Item *const parent) noexcept
 

Private Attributes

Qt::CheckState m_checkState
 
QList< Item * > m_children
 
Itemm_parent
 
Type m_type
 

Detailed Description

Definition at line 25 of file item.h.

Member Enumeration Documentation

◆ Type

Enumerator
ITEM_ROOT 
ITEM_CATEGORY 
ITEM_LANGUAGE 
ITEM_MODULE 
ITEM_INDEXING 

Definition at line 29 of file item.h.

Constructor & Destructor Documentation

◆ Item()

BookshelfModel::Item::Item ( Type const  type)
inline

Definition at line 39 of file item.h.

◆ ~Item()

BookshelfModel::Item::~Item ( )
virtual

Definition at line 23 of file item.cpp.

References m_children.

Member Function Documentation

◆ checkState()

Qt::CheckState BookshelfModel::Item::checkState ( ) const
inline

Returns the check state of this item.

Definition at line 113 of file item.h.

References m_checkState.

Referenced by BtBookshelfTreeModel::data(), BtBookshelfTreeModel::resetParentCheckStates(), and BtBookshelfTreeModel::setData().

◆ childIndex()

int BookshelfModel::Item::childIndex ( ) const
inline

Returns the index of this item under its parent.

Return values
-1if this item has no parent.

Definition at line 66 of file item.h.

References m_children, and m_parent.

Referenced by BtBookshelfTreeModel::getIndex(), and BtBookshelfTreeModel::parent().

◆ children()

QList< Item * > & BookshelfModel::Item::children ( )
inline

Returns the list of child items of this node.

Definition at line 60 of file item.h.

References m_children.

Referenced by BtBookshelfTreeModel::hasChildren(), BtBookshelfTreeModel::index(), BtBookshelfTreeModel::rowCount(), and BtBookshelfTreeModel::setData().

◆ data()

QVariant BookshelfModel::Item::data ( int  role = Qt::DisplayRole) const
virtual

◆ fitFor()

virtual bool BookshelfModel::Item::fitFor ( CSwordModuleInfo const &  module) const
pure virtual

Returns whether this item is fit to contain the given module.

Parameters
[in]moduleThe module to check with.
Return values
trueIf this item is a group and can contain the given module.
falseThis item is not a group or is a wrong group.

Implemented in BookshelfModel::RootItem, BookshelfModel::ModuleItem, BookshelfModel::CategoryItem, BookshelfModel::IndexingItem, and BookshelfModel::LanguageItem.

◆ getGroupItem()

template<class T >
T * BookshelfModel::Item::getGroupItem ( CSwordModuleInfo const &  module,
int &  outIndex 
)
inline

Definition at line 93 of file item.h.

References BT_ASSERT, m_children, and T.

◆ indexFor()

int BookshelfModel::Item::indexFor ( Item const &  newItem)

Returns the position for where the given child item would be inserted.

Parameters
[in]newItemPointer to the item that would be inserted.

Definition at line 27 of file item.cpp.

References BT_ASSERT, m_children, and type().

◆ insertChild()

void BookshelfModel::Item::insertChild ( int const  index,
Item *const  newItem 
)
inline

Inserts the given item as a child at the given index.

Precondition
The given index is a valid position for the item.
Parameters
[in]indexThe child index to insert the item at.
[in]newItemThe item to insert.

Definition at line 85 of file item.h.

References BT_ASSERT, m_children, and setParent().

◆ operator<()

bool BookshelfModel::Item::operator< ( Item const &  other) const
virtual

Comparsion operator used sorting child items.

Reimplemented in BookshelfModel::CategoryItem.

Definition at line 65 of file item.cpp.

References data(), m_type, and type().

◆ parent()

Item * BookshelfModel::Item::parent ( ) const
inline

Returns a pointer to the parent item of this item.

Return values
0if this item has no parent.

Definition at line 55 of file item.h.

References m_parent.

Referenced by BtBookshelfTreeModel::parent(), and setParent().

◆ setCheckState()

void BookshelfModel::Item::setCheckState ( Qt::CheckState const  state)
inline

Sets the check state of this item.

Parameters
[in]statenew check state.

Definition at line 119 of file item.h.

References m_checkState.

Referenced by BtBookshelfTreeModel::setData().

◆ setParent()

void BookshelfModel::Item::setParent ( Item *const  parent)
inlineprivatenoexcept

Definition at line 136 of file item.h.

References BT_ASSERT, m_parent, and parent().

Referenced by insertChild().

◆ type()

Type BookshelfModel::Item::type ( ) const
inline

Member Data Documentation

◆ m_checkState

Qt::CheckState BookshelfModel::Item::m_checkState
private

Definition at line 144 of file item.h.

Referenced by checkState(), data(), and setCheckState().

◆ m_children

QList<Item *> BookshelfModel::Item::m_children
private

Definition at line 143 of file item.h.

Referenced by childIndex(), children(), data(), getGroupItem(), indexFor(), insertChild(), and ~Item().

◆ m_parent

Item* BookshelfModel::Item::m_parent
private

Definition at line 142 of file item.h.

Referenced by childIndex(), parent(), and setParent().

◆ m_type

Type BookshelfModel::Item::m_type
private

Definition at line 141 of file item.h.

Referenced by operator<(), and type().


The documentation for this class was generated from the following files: