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

CDiagramArea is a widget displaying a list of chords. More...

#include <diagram-area.hh>

List of all members.

Public Slots

void newDiagram ()
void addDiagram (const QString &chord)
void editDiagram (QModelIndex index=QModelIndex())
void removeDiagram (QModelIndex index=QModelIndex())
void setTypeFilter (const CChord::Instrument &type)
void setNameFilter (const QString &name)
void setStringsFilter (const QString &strings)
void clearFilters ()

Signals

void contentsChanged ()
void layoutChanged ()
void readOnlyModeChanged ()
void diagramClicked (CChord *diagram)

Public Member Functions

 CDiagramArea (QWidget *parent=0)
 Constructor.
bool isReadOnly () const
void setReadOnly (bool value)
void setColumnCount (int value)
void setRowCount (int value)
QList< CChord * > chords ()

Detailed Description

CDiagramArea is a widget displaying a list of chords.

A CDiagramArea embeds a QTableView based upon a CChordTableModel model. A CDiagramArea can be defined as read-only or editable through setReadOnly() and is usually placed as a widget inside a scrolling area:

CDiagramArea *area = new CDiagramArea(this);
area->setRowCount(1);
area->setReadOnly(false);
QScrollArea *scroll = new QScrollArea;
scroll->setWidget(area);
scroll->setBackgroundRole(QPalette::Dark);
scroll->setWidgetResizable(true);

In the example above, the area is editable which means that chords can be edited or removed (from the contextMenu()). The area also features a "add" button that appends new chords to the model. An implementation may be found in song-header-editor.cc.

If the CDiagramArea is read-only, displayed chords can neither be edited nor removed. Thus, the area does not propose the "add" button to add a new chord to the list. The following example can be found in the dialog from diagram-editor.cc where it is used to display all the chords in songbook/tex/chords.tex as a list of common chords to pick from:

CDiagramArea *area = new CDiagramArea(this);
area->setReadOnly(true);
area->setColumnCount(8);
QScrollArea *scroll = new QScrollArea;
scroll->setWidget(area);
scroll->setBackgroundRole(QPalette::Base);
scroll->setWidgetResizable(true);

The list of chords in a CDiagramArea can be filtered by methods such as setTypeFilter(), setNameFilter() and setStringsFilter() that will only display rows that contain chords whose CChord::instrument(), CChord::name() and CChord::strings() match the filter. In the dialog from diagram-editor.cc, those slots are thus connected to the QLineEdit widgets:

QLineEdit *nameLineEdit = new QLineEdit;
QLineEdit *stringsLineEdit = new QLineEdit;
connect(nameLineEdit, SIGNAL(textChanged(const QString &)),
area, SLOT(setNameFilter(const QString &)));
connect(stringsLineEdit, SIGNAL(textChanged(const QString &)),
area, SLOT(setStringsFilter(const QString &)));

Member Function Documentation

void CDiagramArea::addDiagram ( const QString &  chord)
slot

Appends the chord chord to the list. The user is responsible for the correctness of the chord.

QList< CChord * > CDiagramArea::chords ( )

Returns all the chords. Note that it returns chords from the model, not the view; thus, filtered chords are also included.

void CDiagramArea::clearFilters ( )
slot

Removes all filters.

See also:
setTypeFilter, setNameFilter, setStringsFilter
void CDiagramArea::contentsChanged ( )
signal

This signal is emitted when the content of the list of chords changes such as when editing, removing or adding a new chord. This signal is never emitted in read-only mode.

See also:
editDiagram, removeDiagram, newDiagram
void CDiagramArea::diagramClicked ( CChord diagram)
signal

This signal is emitted when a chord from the list is clicked.

void CDiagramArea::editDiagram ( QModelIndex  index = QModelIndex())
slot

Triggers a CDiagramEditor associated to the chord at position index. This slot is only available in editable mode.

See also:
setReadOnly
bool CDiagramArea::isReadOnly ( ) const

Returns true if the diagram-area is in read-only mode; false otherwise.

See also:
setReadOnly
void CDiagramArea::layoutChanged ( )
signal

This signal is emitted when the contents of the model changes such as when removing, adding or filtering diagrams.

See also:
removeDiagram, newDiagram
void CDiagramArea::newDiagram ( )
slot

Adds a new chord to the list. This slot is connected to the "add" button and pops-up a CDiagramEditor.

void CDiagramArea::readOnlyModeChanged ( )
signal

This signal is emitted when the read-only property changes.

See also:
isReadOnly, setReadOnly
void CDiagramArea::removeDiagram ( QModelIndex  index = QModelIndex())
slot

Removes the chord at position index from the list. This slot is only available in editable mode.

See also:
setReadOnly
void CDiagramArea::setColumnCount ( int  value)

Forces the list of chords to be displayed on value columns.

See also:
setRowCount
void CDiagramArea::setNameFilter ( const QString &  name)
slot

Filters rows that contain chords whose name matches name.

See also:
setTypeFilter, setStringsFilter
void CDiagramArea::setReadOnly ( bool  value)

Set the diagram-area as editable (false) or read-only (true) according to value.

See also:
isReadOnly
void CDiagramArea::setRowCount ( int  value)

Forces the list of chords to be displayed on value rows.

See also:
setColumnCount
void CDiagramArea::setStringsFilter ( const QString &  strings)
slot

Filters rows that contain chords whose strings matches strings.

See also:
setTypeFilter, setNameFilter
void CDiagramArea::setTypeFilter ( const CChord::Instrument type)
slot

Filters rows that contain chords whose instrument matches type.

See also:
setNameFilter, setStringsFilter

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