GroupListWidget Pile   version 0.0.1
The pile attempts to provide a widget that is capable of presenting
GroupSubModel Class Reference

A model representing a group that is used by the embedded lists. More...

#include <groupsubmodel.h>

+ Inheritance diagram for GroupSubModel:

Public Member Functions

 GroupSubModel (GroupModel *model=NULL, const QVariant &key=QVariant(), const QString &lbl=QString())
 Default constructor.
 
virtual ~GroupSubModel ()
 Destructor.
 
int listIndex () const
 Retreive the index of this model inside the main model.
 
void setParentModel (GroupModel *model)
 Sets the parent model.
 
GroupModelparentModel () const
 Retreive the parent model.
 
void appendRecord (int original_row)
 Insert a new record at the end of the list.
 
void insertSortedRecord (int row)
 Insert a new record in the proper place. More...
 
virtual void setGroupKey (const QVariant &value)
 Sets the key for the grouping algorithm.
 
virtual const QVariant & groupKey () const
 Retreive the key for the grouping algorithm.
 
virtual void setLabel (const QString &value)
 Sets the user visible label for this group.
 
virtual const QString & label () const
 Retreive the user visible label for this group.
 
void performSorting ()
 Sort internal rows acording to the rules of the parent. More...
 
void performUnsorting ()
 Sort internal rows acording to their values. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Number of rows.
 
QVariant data (const QModelIndex &index, int role) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
int mapRowToBaseModel (int row) const
 Retrieve the row in base model given the row in this model. More...
 
const QList< int > & mapping () const
 Maps rows in this model to rows in base model.
 

Protected Member Functions

void signalReset ()
 
void setListIndex (int value)
 
void baseModelDataChange (int index_in_group, const QVector< int > &roles)
 Will emit dataChange for this row.
 

Friends

class GroupModel
 
class GroupListWidget
 

Detailed Description

A model representing a group that is used by the embedded lists.

This is a simple proxy that can be installed in a common QListView. It holds a mapping between the rows in this model and the rows in GroupModel's base model. The rows are sorted according cu the rule set for sorting in GroupModel.

Inside the GroupModel each group is represented by one instance of this class as it provides both the user-visible label() and the groupKey() for grouping.

Member Function Documentation

QVariant GroupSubModel::data ( const QModelIndex &  index,
int  role 
) const

As this is a list model it is expected that column will always be 0. Nonetheless mosst of the time the column is forwarded to the user model.

The method filters the decoration role for column 0 that is handled by requesting the decoration from parent model.

void GroupSubModel::insertSortedRecord ( int  row)

Insert a new record in the proper place.

Makes sure that the inserted row is placed at appropriate index.

int GroupSubModel::mapRowToBaseModel ( int  row) const

Retrieve the row in base model given the row in this model.

Parameters
rowa zero-based index in the list of items this model manages
Returns
-1 if the row is outside valid range, a row in base model otherwise
void GroupSubModel::performSorting ( )

Sort internal rows acording to the rules of the parent.

Retreives the values for all rows and, based on those, arranges the internal list of rows in ascending order.

void GroupSubModel::performUnsorting ( )

Sort internal rows acording to their values.

This would restore the original sorting from base model.


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