#include <stationlistmodel.h>
Public Types | |
enum | columnInfoType { columnHeaderTitle, columnHeaderToolTip, columnHeaderWhatsThis, columnWidth, setColumnWidth, columnVisibility, setColumnVisibility, columnData, columnDataToolTip, columnDataWhatsThis } |
Public Slots | |
void | addNewStation () |
void | deleteStation (const int index) |
void | record (const int index) |
void | showConfigDialog (const int index) |
void | stopRecording (const int index) |
Signals | |
void | bandwidthChanged () |
void | numberOfActiveStreamsChanged () |
void | numberOfActiveStreamsIsZero () |
Public Member Functions | |
stationlistModel (const QPointer< QObject > parent=0, const QPointer< QWidget > mainWidget=0) | |
virtual | ~stationlistModel () |
quint64 | bandwidth () const |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const |
QVariant | columnInfo (const columnInfoType type, const int column, const qint64 row=(-1), const quint64 value=(-1)) const |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role) const |
int | numberOfActiveStreams () const |
virtual bool | queryClose () |
virtual void | readProperties (const KConfigGroup &m_configGroup) |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
virtual void | saveProperties (KConfigGroup &m_configGroup) |
virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
Properties | |
quint64 | bandwidth |
int | numberOfActiveStreams |
Private Slots | |
void | recalculate_numberOfActiveStreams_and_bandwidth () |
void | reloadBitrate (const qlonglong stationIndex) |
void | reloadDataSize (const qlonglong stationIndex) |
void | reloadMetaInterval (const qlonglong stationIndex) |
void | reloadRelayPort (const qlonglong stationIndex) |
void | reloadServerName (const qlonglong stationIndex) |
void | reloadSong (const qlonglong stationIndex) |
void | reloadStatus (const qlonglong stationIndex) |
void | reloadStreamName (const qlonglong stationIndex) |
void | rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone () |
Private Member Functions | |
void | helper_connectSignalsAndSlots (QPointer< radioStation > m_stream) |
void | helper_writeStationListToGeneralSettings () |
Private Attributes | |
quint64 | internal_bandwidth |
int | internal_numberOfActiveStreams |
QStringList * | m_listOfStreamsOfWhichTheUserWantsThatTheyRip |
QPointer< QWidget > | m_mainWidget |
QList< QPointer< radioStation > > | m_stationlist |
This class handels radio stations. It reads the list of configuration files of radio stations from settings_general and represents these radio stations. Internally, it uses objects of the class radioStation to handle the stations. This class can also create new radio stations or delete existing ones - and takes care of creating/changing/removing the corresponding config files.
This class inherits from QAbstractTableModel (and this way indirectly from QAbstractItemModel). So it can be used as model for Qt's model-view-programming. Use a QTableView object to watch the data of this model.
Definition at line 46 of file stationlistmodel.h.
This enum is used in columnInfo() to determinate which action will be performed:
columnHeaderTitle | |
columnHeaderToolTip | |
columnHeaderWhatsThis | |
columnWidth | |
setColumnWidth | |
columnVisibility | |
setColumnVisibility | |
columnData | |
columnDataToolTip | |
columnDataWhatsThis |
Definition at line 123 of file stationlistmodel.h.
stationlistModel::stationlistModel | ( | const QPointer< QObject > | parent = 0 , |
|
const QPointer< QWidget > | mainWidget = 0 | |||
) | [explicit] |
The constructor.
parent | the parent of this object | |
mainWidget | the widget to which configuration dialogs will be centered. |
Definition at line 31 of file stationlistmodel.cpp.
References helper_connectSignalsAndSlots(), helper_writeStationListToGeneralSettings(), m_listOfStreamsOfWhichTheUserWantsThatTheyRip, m_mainWidget, m_stationlist, and recalculate_numberOfActiveStreams_and_bandwidth().
stationlistModel::~stationlistModel | ( | ) | [virtual] |
The destructor.
Definition at line 59 of file stationlistmodel.cpp.
References m_listOfStreamsOfWhichTheUserWantsThatTheyRip.
quint64 stationlistModel::bandwidth | ( | ) | const |
See property bandwidth.
int stationlistModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Reimplemented from QAbstractTableModel.
parent | As this is a table model (non-hirarchical!), this parameter is ignored. |
Definition at line 97 of file stationlistmodel.cpp.
QVariant stationlistModel::columnInfo | ( | const columnInfoType | type, | |
const int | column, | |||
const qint64 | row = (-1) , |
|||
const quint64 | value = (-1) | |||
) | const |
This function is the central place to access all information about the data in the model and also about related things (column width, visibility, header title...).
type | Specifies the type of action that will be performed. See columnInfoType for details. | |
column | The column to access. | |
row | The row to access. Is ignored if the action is independent from the row. | |
value | The value to write. Is ignored if the action is not a writing action. |
Definition at line 102 of file stationlistmodel.cpp.
References columnData, columnDataToolTip, columnDataWhatsThis, columnHeaderTitle, columnHeaderToolTip, columnHeaderWhatsThis, columnVisibility, columnWidth, m_stationlist, OR, rowCount(), setColumnVisibility, and setColumnWidth.
Referenced by data(), and headerData().
QVariant stationlistModel::data | ( | const QModelIndex & | index, | |
int | role = Qt::DisplayRole | |||
) | const [virtual] |
Reimplemented from QAbstractTableModel.
Uses columnInfo() to deliver the data.
index | As this is a table model (non-hirarchical!), only rows and columns of the index are relevant. The parent is ignored. If the index doesn't belong to this model, an invalid QVariant is returned. | |
role | The type of information that is requested. Supported are
|
Definition at line 503 of file stationlistmodel.cpp.
References columnData, columnDataToolTip, columnDataWhatsThis, columnInfo(), and EQUAL.
QVariant stationlistModel::headerData | ( | int | section, | |
Qt::Orientation | orientation, | |||
int | role | |||
) | const [virtual] |
Reimplemented from QAbstractTableModel.
Uses columnInfo() if orientation is horizontal.
Definition at line 478 of file stationlistmodel.cpp.
References columnHeaderTitle, columnHeaderToolTip, columnHeaderWhatsThis, columnInfo(), and EQUAL.
int stationlistModel::numberOfActiveStreams | ( | ) | const |
See property numberOfActiveStreams.
Referenced by queryClose().
bool stationlistModel::queryClose | ( | ) | [virtual] |
TODO
Definition at line 664 of file stationlistmodel.cpp.
References m_mainWidget, m_stationlist, numberOfActiveStreams(), numberOfActiveStreamsIsZero(), and rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone().
void stationlistModel::readProperties | ( | const KConfigGroup & | m_configGroup | ) | [virtual] |
TODO
Definition at line 712 of file stationlistmodel.cpp.
References m_stationlist, and rowCount().
int stationlistModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() |
) | const [virtual] |
Reimplemented from QAbstractTableModel.
parent | As this is a table model (non-hirarchical!), this parameter is ignored. |
Definition at line 92 of file stationlistmodel.cpp.
References m_stationlist.
Referenced by columnInfo(), readProperties(), and rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone().
void stationlistModel::saveProperties | ( | KConfigGroup & | m_configGroup | ) | [virtual] |
TODO
Definition at line 704 of file stationlistmodel.cpp.
References m_listOfStreamsOfWhichTheUserWantsThatTheyRip, and rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone().
void stationlistModel::sort | ( | int | column, | |
Qt::SortOrder | order = Qt::AscendingOrder | |||
) | [virtual] |
Reimplemented from QAbstractTableModel.
This is just a dummy function. It (still) does nothing.
Definition at line 530 of file stationlistmodel.cpp.
void stationlistModel::bandwidthChanged | ( | ) | [signal] |
See property bandwidth.
Referenced by recalculate_numberOfActiveStreams_and_bandwidth().
void stationlistModel::numberOfActiveStreamsChanged | ( | ) | [signal] |
See property numberOfActiveStreams.
Referenced by recalculate_numberOfActiveStreams_and_bandwidth().
void stationlistModel::numberOfActiveStreamsIsZero | ( | ) | [signal] |
See property numberOfActiveStreams.
Referenced by queryClose(), and recalculate_numberOfActiveStreams_and_bandwidth().
void stationlistModel::addNewStation | ( | ) | [slot] |
This slot adds a new radio station: It displays a configuration dialog for the new stream. If accepted by the user (= clicking OK), the new stream is inserted at the end of the list.
Definition at line 535 of file stationlistmodel.cpp.
References helper_connectSignalsAndSlots(), helper_writeStationListToGeneralSettings(), m_mainWidget, and m_stationlist.
void stationlistModel::deleteStation | ( | const int | index | ) | [slot] |
Removes the specified radio station from this model and deletes the corresponding config file.
index | You must pass the index (= the row) of the stream which you want to delete. When you pass an invalid index, nothing happens. |
Definition at line 564 of file stationlistmodel.cpp.
References AND, helper_writeStationListToGeneralSettings(), and m_stationlist.
void stationlistModel::record | ( | const int | index | ) | [slot] |
This slot starts the recording of a stream.
index | You must pass the index (= the row) of the stream which you want to record. When you pass an invalid index, nothing happens. |
Definition at line 613 of file stationlistmodel.cpp.
References AND, and m_stationlist.
void stationlistModel::showConfigDialog | ( | const int | index | ) | [slot] |
If exactly one stream is selected, then this slot shows the config dialog. Else nothing happens.
Definition at line 629 of file stationlistmodel.cpp.
References AND, and m_stationlist.
void stationlistModel::stopRecording | ( | const int | index | ) | [slot] |
This slot stops the recording of a stream.
index | You must pass the index (= the row) of the stream which you want to stop the recording. When you pass an invalid index, nothing happens. |
Definition at line 621 of file stationlistmodel.cpp.
References AND, and m_stationlist.
void stationlistModel::helper_connectSignalsAndSlots | ( | QPointer< radioStation > | m_stream | ) | [private] |
This helper function sets up all the necessary connection of signals and slots which are needed to keep this model up to date.
m_stream | a pointer to the station for which you want to set up the connection |
Definition at line 64 of file stationlistmodel.cpp.
References recalculate_numberOfActiveStreams_and_bandwidth(), reloadBitrate(), reloadDataSize(), reloadMetaInterval(), reloadRelayPort(), reloadServerName(), reloadSong(), reloadStatus(), and reloadStreamName().
Referenced by addNewStation(), and stationlistModel().
void stationlistModel::helper_writeStationListToGeneralSettings | ( | ) | [inline, private] |
Writes the actual list of streams back to the configuration file.
Definition at line 599 of file stationlistmodel.cpp.
References m_stationlist.
Referenced by addNewStation(), deleteStation(), and stationlistModel().
void stationlistModel::recalculate_numberOfActiveStreams_and_bandwidth | ( | ) | [private, slot] |
This slot recalculates the values for the properties bandwidth and numberOfActiveStreams from scratch. It caches them in the corresponding member. If for one of the properties or for both of them, the new value differs from the old value, the corresponding signal(s) is/are emitted.
We recalculate the value each time from scratch. We could have implemented a solution the reacts on signals of the radiostation objects that the status has changed, and than increment or decrement our properties. This solution would be more efficient, but also more complicate: We would have to worry about a correct initialization, about session management.... The situation would be confusing and complicate. So it's better to have a clean solution, also when it's not so efficient.
Definition at line 404 of file stationlistmodel.cpp.
References bandwidthChanged(), ripping::idle, internal_bandwidth, internal_numberOfActiveStreams, m_stationlist, numberOfActiveStreamsChanged(), numberOfActiveStreamsIsZero(), and PropertyValue::value.
Referenced by helper_connectSignalsAndSlots(), and stationlistModel().
void stationlistModel::reloadBitrate | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 458 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadDataSize | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 453 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadMetaInterval | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 463 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadRelayPort | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 473 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadServerName | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 468 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadSong | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 448 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadStatus | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 443 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::reloadStreamName | ( | const qlonglong | stationIndex | ) | [private, slot] |
Used internally to emit the signal dataChanged
.
Definition at line 438 of file stationlistmodel.cpp.
Referenced by helper_connectSignalsAndSlots().
void stationlistModel::rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone | ( | ) | [private, slot] |
TODO
Definition at line 647 of file stationlistmodel.cpp.
References m_listOfStreamsOfWhichTheUserWantsThatTheyRip, m_stationlist, and rowCount().
Referenced by queryClose(), and saveProperties().
quint64 stationlistModel::internal_bandwidth [private] |
Used internally to cache the value of the property bandwidth.
Definition at line 260 of file stationlistmodel.h.
Referenced by recalculate_numberOfActiveStreams_and_bandwidth().
int stationlistModel::internal_numberOfActiveStreams [private] |
Used internally to cache the value of the property numberOfActiveStreams.
Definition at line 262 of file stationlistmodel.h.
Referenced by recalculate_numberOfActiveStreams_and_bandwidth().
QStringList* stationlistModel::m_listOfStreamsOfWhichTheUserWantsThatTheyRip [private] |
Here you can save a list of the streams for which radioStation::doesTheUserWantsThatTheStreamIsRipping() is true. Used for session management handling.
By initialization, this pointer is null.
Definition at line 273 of file stationlistmodel.h.
Referenced by rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone(), saveProperties(), stationlistModel(), and ~stationlistModel().
QPointer<QWidget> stationlistModel::m_mainWidget [private] |
A pointer to the widget to which configuration dialogs should be centered. This member is initialized in the constructor.
Definition at line 276 of file stationlistmodel.h.
Referenced by addNewStation(), queryClose(), and stationlistModel().
QList< QPointer<radioStation> > stationlistModel::m_stationlist [private] |
This is a QList of objects of the radiostation class used internally to handle the stations.
Definition at line 279 of file stationlistmodel.h.
Referenced by addNewStation(), columnInfo(), deleteStation(), helper_writeStationListToGeneralSettings(), queryClose(), readProperties(), recalculate_numberOfActiveStreams_and_bandwidth(), record(), rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone(), rowCount(), showConfigDialog(), stationlistModel(), and stopRecording().
quint64 stationlistModel::bandwidth [read] |
This property holds the total bandwidth that is actually really used by the streams (summation of the bitrate of all streams which are not ripping::idle).
quint64 bandwidth() const
void bandwidthChanged()
quint64 internal_bandwidth
Definition at line 63 of file stationlistmodel.h.
int stationlistModel::numberOfActiveStreams [read] |
This property holds the number of active streams (number of all streams which are not ripping::idle).
int numberOfActiveStreams() const
void numberOfActiveStreamsChanged()
void numberOfActiveIsZero()
Definition at line 75 of file stationlistmodel.h.