Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
Public Types | Public Slots | Public Member Functions
CChordTableModel Class Reference

CChordTableModel is a table model that contains CChord objects. More...

#include <chord-table-model.hh>

List of all members.

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)
CChordgetChord (const QModelIndex &index) const

Detailed Description

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:

model->setRowCount(1);
model->addItem("\gtab{C}{X32010}");
model->addItem("\gtab{Am}{X02210}");
model->addItem("\gtab{G}{X02210}");
model->addItem("\gtab{D}{XX0232}");

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):

model->setRowCount(3);
model->addItem("\gtab{C}{X32010}");
model->addItem("\gtab{Am}{X02210}");
model->addItem("\gtab{G}{X02210}");
model->addItem("\gtab{D}{XX0232}");

Member Enumeration Documentation

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.

Enumerator:
NameRole 

the name of the chord.

StringsRole 

the strings sequence of the chord.

InstrumentRole 

the instrument of the chord.

ImportantRole 

whether the chord is important.


Member Function Documentation

int CChordTableModel::columnCount ( const QModelIndex &  index = QModelIndex()) const
virtual

Returns the number of columns.

See also:
setColumnCount, rowCount, setRowCount
QVariant CChordTableModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Reimplements QAbstractTableModel::data(). Returns the item (CChord object) at position index according to the role role.

See also:
setData
CChord * CChordTableModel::getChord ( const QModelIndex &  index) const

Returns the CChord object at position index.

See also:
data, setData
int CChordTableModel::rowCount ( const QModelIndex &  index = QModelIndex()) const
virtual

Returns the number of rows.

See also:
setRowCount, columnCount, setColumnCount
void CChordTableModel::setColumnCount ( int  value)
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.

See also:
columnCount, rowCount, setRowCount
bool CChordTableModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

Reimplements QAbstractTableModel::setData(). Sets the value value of the item (CChord object) at position index for the role role.

See also:
data
void CChordTableModel::setRowCount ( int  value)
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.

See also:
rowCount, columnCount, setColumnCount

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