CategoryItemModel Class Reference

The CategoryItemModel class provides a model that can be used to browse through collections and classes in a Digest Database (DigestDb). More...

#include <categoryitemmodel.h>

Inheritance diagram for CategoryItemModel:

AbstractDigestDbView AbstractView MvcBase List of all members.

Public Types

enum  IndexType { RootIndex, LibraryIndex, ClassIndex, CollectionIndex }
enum  ModelFlag { ItemsAreSelectable = 0x1, ItemsAreEditable = 0x2, ItemsAreCheckable = 0x4, ItemsAreDropEnabled = 0x8 }

Public Member Functions

 Q_DECLARE_FLAGS (ModelFlags, ModelFlag)
 CategoryItemModel (QObject *parent=0)
 CategoryItemModel (DigestDbController *controller, QObject *parent=0)
virtual ~CategoryItemModel ()
ModelFlags modelFlags ()
void setModelFlags (ModelFlags flags)
CategoryItemModel::IndexType indexType (const QModelIndex &index) const
int indexDatabaseId (const QModelIndex &index) const
QModelIndex libraryIndex () const
virtual Qt::ItemFlags flags (const QModelIndex &index) const
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual QModelIndex parent (const QModelIndex &index) const
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Qt::DropActions supportedDropActions () const
virtual QStringList mimeTypes () const
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &index)
QModelIndexList checkedIndexes () const
QString gestureQueryForIndexes (const QModelIndexList &indexes) const
QString gestureQueryForCheckedIndexes () const
bool isReady () const

Protected Member Functions

virtual DEFINE_CUSTOM_VIEWEVENT_HANDLER
void 
resetEvent (VEvent *)
virtual void classesEvent (VClassesEvent *)
virtual void collectionsEvent (VCollectionsEvent *)
void resetModel ()
QModelIndex index (CategoryItem *item) const
QModelIndexList checkedIndexes (CategoryItem *parent) const

Classes

struct  CategoryItem

Detailed Description

The CategoryItemModel class provides a model that can be used to browse through collections and classes in a Digest Database (DigestDb).


Member Enumeration Documentation

enum CategoryItemModel::IndexType

Enumerator:
RootIndex 
LibraryIndex 
ClassIndex 
CollectionIndex 

enum CategoryItemModel::ModelFlag

Enumerator:
ItemsAreSelectable 
ItemsAreEditable  Visually indicates that an item is selected.
ItemsAreCheckable  Enables the editing of item labels.
ItemsAreDropEnabled  Note: Not affected by ItemsAreEditable.


Constructor & Destructor Documentation

CategoryItemModel::CategoryItemModel ( QObject *  parent = 0  ) 

Constructs a category item model with the given parent.

CategoryItemModel::CategoryItemModel ( DigestDbController controller,
QObject *  parent = 0 
)

Constructs a category item model with the given parent and attaches itself to the controller.

CategoryItemModel::~CategoryItemModel (  )  [virtual]

Destroys the category item model.


Member Function Documentation

CategoryItemModel::Q_DECLARE_FLAGS ( ModelFlags  ,
ModelFlag   
)

CategoryItemModel::ModelFlags CategoryItemModel::modelFlags (  )  [inline]

Retruns the category item model's flags.

Not to be confused with the version for individual items, flags(const QModelIndex&).

Defaults to: ItemsAreSelectable | ItemsAreEditable

void CategoryItemModel::setModelFlags ( ModelFlags  flags  ) 

Sets the category item model's flags.

Defaults to: ItemsAreSelectable | ItemsAreEditable

CategoryItemModel::IndexType CategoryItemModel::indexType ( const QModelIndex &  index  )  const

int CategoryItemModel::indexDatabaseId ( const QModelIndex &  index  )  const

This is specific to the SQL table that the index lives in.

Use indexType() to determine which table the index lives in.

QModelIndex CategoryItemModel::libraryIndex (  )  const [inline]

Qt::ItemFlags CategoryItemModel::flags ( const QModelIndex &  index  )  const [virtual]

int CategoryItemModel::rowCount ( const QModelIndex &  parent = QModelIndex()  )  const [virtual]

int CategoryItemModel::columnCount ( const QModelIndex &  parent = QModelIndex()  )  const [virtual]

QVariant CategoryItemModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const [virtual]

QModelIndex CategoryItemModel::parent ( const QModelIndex &  index  )  const [virtual]

QModelIndex CategoryItemModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

QVariant CategoryItemModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const [virtual]

bool CategoryItemModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

Qt::DropActions CategoryItemModel::supportedDropActions (  )  const

QStringList CategoryItemModel::mimeTypes (  )  const [virtual]

bool CategoryItemModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  index 
) [virtual]

Warning: index has been renamed from parent, because the latter lead to much confusion, as it really is the index of the item that the MIME data was dropped onto.

QModelIndexList CategoryItemModel::checkedIndexes (  )  const

QString CategoryItemModel::gestureQueryForIndexes ( const QModelIndexList &  indexes  )  const

QString CategoryItemModel::gestureQueryForCheckedIndexes (  )  const

Convenience method.

Equivalent to gestureQueryForIndexes( checkedIndexes() );

bool CategoryItemModel::isReady (  )  const [inline]

void CategoryItemModel::resetEvent ( VEvent  )  [protected, virtual]

Resets the model.

Calls resetModel(), followed by reset() (which resets the views).

Reimplemented from AbstractDigestDbView.

void CategoryItemModel::classesEvent ( VClassesEvent event  )  [protected, virtual]

Note: "Classes" live in the Library, which I believe is logical.

Reimplemented from AbstractDigestDbView.

void CategoryItemModel::collectionsEvent ( VCollectionsEvent  )  [protected, virtual]

Reimplemented from AbstractDigestDbView.

void CategoryItemModel::resetModel (  )  [protected]

QModelIndex CategoryItemModel::index ( CategoryItem item  )  const [protected]

We employ caching in this method, as it called very often by the views and contains a very expensive line of code that includes createIndex() and the very costly indexOf() (which performs a linear search).

Asserts that the item is non-null.

QModelIndexList CategoryItemModel::checkedIndexes ( CategoryItem parent  )  const [protected]

Light-weight, recursive method - used by checkedIndexes().

Asserts m_ready and that parent is non-null.


The documentation for this class was generated from the following files:
Generated on Mon Jul 30 09:46:51 2007 for Digest by  doxygen 1.5.2