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

Private Member Functions

void setParent (Item *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  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(), BtBookshelfTreeModel::parent(), and BtBookshelfTreeModel::removeModule().

◆ children()

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

◆ data()

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

◆ fitFor()

virtual bool BookshelfModel::Item::fitFor ( const CSwordModuleInfo 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::LanguageItem, BookshelfModel::IndexingItem, BookshelfModel::CategoryItem, BookshelfModel::ModuleItem, and BookshelfModel::RootItem.

◆ getGroupItem()

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

Definition at line 93 of file item.h.

References BT_ASSERT, m_children, and T.

Referenced by BtBookshelfTreeModel::getGroup().

◆ 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().

Referenced by BtBookshelfTreeModel::addModule(), and BtBookshelfTreeModel::getGroup().

◆ insertChild()

void BookshelfModel::Item::insertChild ( int  index,
Item 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().

Referenced by BtBookshelfTreeModel::addModule(), and BtBookshelfTreeModel::getGroup().

◆ operator<()

bool BookshelfModel::Item::operator< ( const Item 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::getIndex(), BtBookshelfTreeModel::parent(), BtBookshelfTreeModel::removeModule(), and setParent().

◆ setCheckState()

void BookshelfModel::Item::setCheckState ( const Qt::CheckState  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::addModule(), BtBookshelfTreeModel::resetParentCheckStates(), and BtBookshelfTreeModel::setData().

◆ setParent()

void BookshelfModel::Item::setParent ( Item 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: