Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
ShortcutsModel Class Reference

Model that exposes the actions from one or more ActionCollections. More...

#include </tmp/quassel/src/qtui/settingspages/shortcutsmodel.h>

Classes

struct  Item

Public Types

enum  Role { ActionRole = Qt::UserRole, DefaultShortcutRole, ActiveShortcutRole, IsConfigurableRole }

Public Slots

void load ()
 Load shortcuts from the ActionCollections.
void defaults ()
 Load default shortcuts from the ActionCollections.
void commit ()
 Commit the model changes to the ActionCollections.
bool hasChanged () const

Signals

void hasChanged (bool changed)
 Reflects the difference between model contents and the ActionCollections we loaded this from.

Public Member Functions

 ShortcutsModel (const QHash< QString, ActionCollection * > &actionCollections, QObject *parent=0)
 ~ShortcutsModel ()
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex parent (const QModelIndex &child) const
int columnCount (const QModelIndex &parent=QModelIndex()) const
int rowCount (const QModelIndex &parent=QModelIndex()) const
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
bool setData (const QModelIndex &index, const QVariant &value, int role=ActiveShortcutRole)

Private Attributes

QList< Item * > _categoryItems
int _changedCount

Detailed Description

Model that exposes the actions from one or more ActionCollections.

This model takes one or more ActionCollections and exposes their actions as model items. Note that the ShortcutsModel will not react to changes in the ActionCollection (e.g. adding, removing actions), because it is supposed to be used after all actions being defined.

Definition at line 35 of file shortcutsmodel.h.

Member Enumeration Documentation

enum Role
Enumerator:
ActionRole 
DefaultShortcutRole 
ActiveShortcutRole 
IsConfigurableRole 

Definition at line 39 of file shortcutsmodel.h.

Constructor & Destructor Documentation

Definition at line 53 of file shortcutsmodel.cpp.

References _categoryItems.

Member Function Documentation

QModelIndex index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

Definition at line 74 of file shortcutsmodel.cpp.

References _categoryItems.

Referenced by defaults(), KeySequenceWidget::isKeySequenceAvailable(), and load().

QModelIndex parent ( const QModelIndex &  child) const
int columnCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 84 of file shortcutsmodel.cpp.

References ShortcutsModel::Item::parentItem.

int rowCount ( const QModelIndex &  parent = QModelIndex()) const
QVariant headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 115 of file shortcutsmodel.cpp.

void load ( )
slot

Load shortcuts from the ActionCollections.

Note that this will not rebuild the internal structure of the model, as we assume the ActionCollections to be static during the lifetime of the settingspage. This will merely re-read the shortcuts currently set in Quassel.

Definition at line 216 of file shortcutsmodel.cpp.

References _categoryItems, _changedCount, ShortcutsModel::Item::action, ShortcutsModel::Item::actionItems, hasChanged(), index(), rowCount(), Action::shortcut, and ShortcutsModel::Item::shortcut.

Referenced by ShortcutsSettingsPage::load().

void defaults ( )
slot

Load default shortcuts from the ActionCollections.

Note that this will not rebuild the internal structure of the model, as we assume the ActionCollections to be static during the lifetime of the settingspage. This will update the model's state from the ActionCollections' defaults.

Definition at line 245 of file shortcutsmodel.cpp.

References ActiveShortcutRole, DefaultShortcutRole, index(), rowCount(), and setData().

Referenced by ShortcutsSettingsPage::defaults().

void commit ( )
slot
bool hasChanged ( ) const
inlineslot

Definition at line 75 of file shortcutsmodel.h.

References _changedCount.

Referenced by commit(), load(), and setData().

void hasChanged ( bool  changed)
signal

Reflects the difference between model contents and the ActionCollections we loaded this from.

Member Data Documentation

QList<Item *> _categoryItems
private

Definition at line 93 of file shortcutsmodel.h.

Referenced by commit(), index(), load(), rowCount(), ShortcutsModel(), and ~ShortcutsModel().

int _changedCount
private

Definition at line 94 of file shortcutsmodel.h.

Referenced by commit(), hasChanged(), load(), and setData().


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