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

A list widget that can group the items. More...

#include <grouplistwidget.h>

+ Inheritance diagram for GroupListWidget:

Public Slots

void setViewMode (QListView::ViewMode value)
 Place text to the right ("list") or to the bottom ("icon")
 
void setFlow (QListView::Flow value)
 Arrange items from left to right or from top to bottom.
 
void setPixmapSize (int value)
 Change the size of the icons.
 
void increasePixSize ()
 Change the size of the icons.
 
void decreasePixSize ()
 Change the size of the icons.
 

Signals

void currentLVItemChanged (int row)
 Informs that current item has changed.
 
void currentLVItemChangedEx (int row_in_base, int row_in_list, int gsm)
 Informs that current item has changed.
 

Public Member Functions

 GroupListWidget (QWidget *parent=NULL)
 Default constructor. More...
 
virtual ~GroupListWidget ()
 Destructor. More...
 
void setBaseModel (QAbstractItemModel *model)
 Sets the user model in underlying model and updates the view. More...
 
QAbstractItemModel * baseModel () const
 Retreive user model from underlying model. More...
 
void setUnderModel (GroupModel *model)
 Sets the underlying model and updates the view. More...
 
GroupModelunderModel () const
 Retreive underlying model.
 
GroupModeltakeUnderModel (GroupModel *other=NULL)
 Take ownership of underlying model. More...
 
void appendToMenu (QMenu *menu)
 Adds actions for sorting, grouping to the menu. More...
 
void appendGroupToMenu (QMenu *menu)
 Adds actions for grouping to the menu.
 
void appendSortToMenu (QMenu *menu)
 Adds actions for sorting to the menu.
 
void appendLayoutToMenu (QMenu *menu)
 Adds actions for arranging the items to the menu.
 
QListView::ViewMode viewMode () const
 Place text to the right ("list") or to the bottom ("icon")
 
QListView::Flow flow () const
 Arrange items from left to right or from top to bottom.
 
int pixmapSize () const
 Arrange items from left to right or from top to bottom.
 
QSize gridCell ()
 Arrange items from left to right or from top to bottom.
 
QSize computeGridCell () const
 Arrange items from left to right or from top to bottom.
 
QAbstractItemDelegate * listDelegate () const
 The delegate used with list items, if any.
 
void setListDelegate (QAbstractItemDelegate *value)
 Set the delegate to be used with list items. More...
 
QAbstractItemDelegate * takeListDelegate (QAbstractItemDelegate *value=NULL)
 Set the delegate to be used with list items. More...
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event)
 Implement a default contextual menu.
 
void resizeEvent (QResizeEvent *e)
 The widget is being resized.
 
void wheelEvent (QWheelEvent *)
 Change the size of the image using the wheels.
 

Friends

class GrpTreeDeleg
 

Detailed Description

A list widget that can group the items.

For simplest use case the user must install at least a base model using setBaseModel().

The instance will always have an internal model accesible by using underModel(). At construction time and if the user calls takeUnderModel() with no arguments a default GroupModel is created and used. setUnderModel() will refuse to install a NULL model.

The instance owns the internal GroupModel that is destroyed in the destructor. To avoid the destructor the user may choose to takeUnderModel() before the destructor kicks in.

Constructor & Destructor Documentation

GroupListWidget::GroupListWidget ( QWidget *  parent = NULL)

Default constructor.

For the instance to be usable a model needs to be installed.

GroupListWidget::~GroupListWidget ( )
virtual

Destructor.

The destructr will also destruct internal model.

Member Function Documentation

void GroupListWidget::appendToMenu ( QMenu *  menu)

Adds actions for sorting, grouping to the menu.

The method simply uses more specialized methods to insert actions for grouping, sorting and laying out the items (in this order).

All actions are constructed on the fly and are parented in their respective menu. As a result, when menu gets destroyed the same happens to all actions and menus created by this method.

Parameters
menuThe menu where new components will be appended.
QAbstractItemModel * GroupListWidget::baseModel ( ) const

Retreive user model from underlying model.

This is a convenience function that inquires internal model for base model that it uses. It is equivalent to:

model()->baseModel ();
void GroupListWidget::setBaseModel ( QAbstractItemModel *  model)

Sets the user model in underlying model and updates the view.

This is a convenience function that installs the base model into internal model. It is equivalent to:

model()->setBaseModel (model);
Parameters
modelThe model that provides the data to sort, group and present.
void GroupListWidget::setListDelegate ( QAbstractItemDelegate *  value)

Set the delegate to be used with list items.

The widget takes ownership of the provided pointer and it will destroy it in its own destructor. Use takeListDelegate to avoid this behaviour.

Parameters
valuenew delegate to use or NULL to revert to using default delegate.
void GroupListWidget::setUnderModel ( GroupModel model)

Sets the underlying model and updates the view.

Please note that - most of the tme - you do not need to derive a class from GroupModel. Instead, install your own model inside the default GroupModel instance and provide a customizer.

This instance takes ownership of provided pointer. Currently installed model will be deleted by this method. To avoid this use takeUnderModel() prior to calling this method.

Parameters
modelThe instance to use as internal model.
QAbstractItemDelegate * GroupListWidget::takeListDelegate ( QAbstractItemDelegate *  value = NULL)

Set the delegate to be used with list items.

The widget takes ownership of the provided pointer and it will destroy it in its own destructor. Use takeListDelegate to avoid this behaviour.

Parameters
valuenew delegate to use or NULL to revert to using default delegate.
GroupModel * GroupListWidget::takeUnderModel ( GroupModel other = NULL)

Take ownership of underlying model.

Parameters
otherA replacement to be installed in this instance; if NULL is provided a default instance will be constructed.
Returns
previously installed model

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