![]() |
Songbook-Client
0.7
This application is a manager of customguitar songbooks
|
CChordTableModel is a table model that contains CChord objects. More...
#include <chord-table-model.hh>
Public Types | |
| enum | ChordRoles { NameRole = Qt::UserRole + 1, StringsRole = Qt::UserRole + 2, InstrumentRole = Qt::UserRole + 3, ImportantRole = Qt::UserRole + 4, MaxRole = ImportantRole } |
Public Slots | |
| void | insertItem (const QModelIndex &index, const QString &value) |
| void | removeItem (const QModelIndex &index) |
| void | addItem (const QString &value) |
Public Member Functions | |
| CChordTableModel (QObject *parent=0) | |
| Constructor. | |
| ~CChordTableModel () | |
| Destructor. | |
| virtual int | columnCount (const QModelIndex &index=QModelIndex()) const |
| virtual void | setColumnCount (int value) |
| virtual int | rowCount (const QModelIndex &index=QModelIndex()) const |
| virtual void | setRowCount (int value) |
| Qt::DropActions | supportedDropActions () const |
| Qt::DropActions | supportedDragActions () const |
| Qt::ItemFlags | flags (const QModelIndex &index) const |
| QStringList | mimeTypes () const |
| QMimeData * | mimeData (const QModelIndexList &indexes) const |
| bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
| CChord * | getChord (const QModelIndex &index) const |
CChordTableModel is a table model that contains CChord objects.
A CChordTableModel presents data on a grid where the number of rows or columns is specified with setRowCount() or setColumnCount(). Adding a new data element (CChord) to the model does not require indicating its position on the grid as this is automatically computed.
The following example defines a model that may have several columns but a single row:
Intuitively, the example above behaves like a QHBoxLayout whereas in this second example, the model presents data on 3 columns but any number of rows (thus, the D chord is displayed on the second row):
Each CChord object the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs.
|
virtual |
Returns the number of columns.
| QVariant CChordTableModel::data | ( | const QModelIndex & | index, |
| int | role = Qt::DisplayRole |
||
| ) | const |
| CChord * CChordTableModel::getChord | ( | const QModelIndex & | index | ) | const |
|
virtual |
Returns the number of rows.
|
virtual |
Sets the number of columns to value. Calling this method defines a "fixed" column count mode which means that any item that is added afterwards will start a new row if necessary.
| bool CChordTableModel::setData | ( | const QModelIndex & | index, |
| const QVariant & | value, | ||
| int | role = Qt::EditRole |
||
| ) |
|
virtual |
Sets the number of rows to value. Calling this method defines a "fixed" row count mode which means that any item that is added afterwards will start a new column if necessary.
1.8.1.1