KTutorial  0.5.1
Public Member Functions
ktutorial::view::TutorialListModel Class Reference

A ListModel that fetchs its data from a TutorialManager. More...

#include <TutorialListModel.h>

List of all members.

Public Member Functions

 TutorialListModel (const TutorialManager *tutorialManager, QObject *parent=0)
 Creates a new TutoriaListModel.
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 Returns the number of available tutorials.
virtual QVariant data (const QModelIndex &index, int role) const
 Returns the name of the tutorial with the specified index.
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Returns the data for the given role and section in the header.
const TutorialInformationgetTutorialInformationForIndex (const QModelIndex &index) const
 Returns the TutorialInformation associated with the specified index.

Detailed Description

A ListModel that fetchs its data from a TutorialManager.

This is a very basic read-only model. It just shows the TutorialInformations registered in a TutorialManager as a list where each element is the name of a TutorialInformation.

To know the TutorialInformation associated with an index, use getTutorialInformationForIndex(const QModelIndex&).

Definition at line 43 of file TutorialListModel.h.


Constructor & Destructor Documentation

ktutorial::view::TutorialListModel::TutorialListModel ( const TutorialManager tutorialManager,
QObject *  parent = 0 
) [inline, explicit]

Creates a new TutoriaListModel.

It gets the data from the specified TutorialManager.

Parameters:
tutorialManagerThe TutorialManager to get the data from.
parentThe parent QObject, defaults to null.

Definition at line 54 of file TutorialListModel.h.


Member Function Documentation

QVariant ktutorial::view::TutorialListModel::data ( const QModelIndex &  index,
int  role 
) const [virtual]

Returns the name of the tutorial with the specified index.

If the index isn't valid or the role isn't DisplayRole, an empty message is returned.

Parameters:
indexThe index to get its data.
roleThe role of the data.
Returns:
The name of the tutorial with the specified index.

Definition at line 37 of file TutorialListModel.cpp.

References getTutorialInformationForIndex(), and ktutorial::TutorialInformation::name().

Returns the TutorialInformation associated with the specified index.

If the index is invalid, a null pointer is returned.

Parameters:
indexThe index to get its associatted TutorialInformation.
Returns:
The TutorialInformation associated with the specified index.

Definition at line 64 of file TutorialListModel.cpp.

References ktutorial::TutorialManager::tutorialInformations().

Referenced by data().

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

Returns the data for the given role and section in the header.

"Tutorials name" is returned for first section of DisplayRole, and an empty message for other sections and roles.

Parameters:
sectionThe section of the header data.
orientationIgnored.
roleThe role of the header data.
Returns:
The data for the given role and section in the header.

Definition at line 51 of file TutorialListModel.cpp.

int ktutorial::view::TutorialListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Returns the number of available tutorials.

Parameters:
parentIgnored.
Returns:
The number of available tutorials.

Definition at line 33 of file TutorialListModel.cpp.

References ktutorial::TutorialManager::tutorialInformations().


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