stationlistModel Class Reference

A model (for model-view-programming) handling radio streams. More...

#include <stationlistmodel.h>

Collaboration diagram for stationlistModel:

Collaboration graph
[legend]

List of all members.

Public Types

enum  columnInfoType {
  columnHeaderTitle, columnHeaderToolTip,
  columnHeaderWhatsThis, columnWidth,
  setColumnWidth, columnVisibility,
  setColumnVisibility, columnData
}

Public Slots

void addNewFolder ()
void addNewFolderInFolder ()
void addNewStation ()
void addNewStationInFolder ()
void enableListeningIn ()
void disableListeningIn ()
void paste ()
void pasteSelection (const QModelIndex &index)
void record ()
void showConfigDialog ()
void stopRecording ()

Signals

void bandwidthChanged ()
void numberOfActiveStreamsChanged ()
void numberOfActiveStreamsIsZero ()
void relayportChanged ()
void selectedStreamsChanged ()
void statusChanged ()

Public Member Functions

 stationlistModel (stationlistWidget *parent, 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 radioStation *stream=0, const quint64 value=(-1)) const
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
virtual Qt::ItemFlags flags (const QModelIndex &index) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual QStringList mimeTypes () const
int numberOfActiveStreams () const
virtual QModelIndex parent (const QModelIndex &index) const
virtual bool queryClose ()
virtual void readProperties (const KConfigGroup &m_configGroup)
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
virtual void saveProperties (KConfigGroup &m_configGroup)
QList< radioStation * > selectedStreams () const
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)

Public Attributes

listenSupport listen

Protected Attributes

QPointer< stationlistWidgetview

Properties

quint64 bandwidth
QList radioStation
int numberOfActiveStreams

Private Types

enum  mode { add, move }

Private Slots

void recalculate_numberOfActiveStreams_and_bandwidth ()
void recalculateSelectedStreams ()
void reloadBitrate (void *stationIndex)
void reloadDataSize (void *stationIndex)
void reloadMetaInterval (void *stationIndex)
void reloadMetaInterval_milliSeconds (void *stationIndex)
void reloadRelayPort (void *stationIndex)
void reloadServerName (void *stationIndex)
void reloadSong (void *stationIndex)
void reloadStatus (void *stationIndex)
void reloadStreamName (void *stationIndex)
void reloadUri (void *stationIndex)
void rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone ()

Private Member Functions

void helper_addNewFolder (const QModelIndex &index)
void helper_addNewStation (const QModelIndex &index)
void helper_connectSignalsAndSlots (radioStation *m_stream)
QList< QUrl > helper_convertToUrl (const QMimeData *data)
stationlistItemhelper_createStreamItem (radioStation *stream)
void helper_deleteRadiostationobjectAndRemoveConfigfiles (radioStation *station)
void helper_deleteRadiostationobjectAndRemoveConfigfiles (stationlistItem *item)
bool helper_firstIsAfterSecond (stationlistItem *firstItem, stationlistItem *secondItem, int column, Qt::SortOrder order)
bool helper_firstIsAfterSecond (const PropertyValue &firstValue, const PropertyValue &secondValue, Qt::SortOrder order)
bool helper_hasStreams (stationlistItem *item)
QList< radioStation * > helper_listOfAllStreams (stationlistItem *parentItem)
void helper_insertItems (QList< stationlistItem * > itemList, const QModelIndex &parent, int row)
void helper_insertItem (stationlistItem *item, const QModelIndex &parent, int row)
bool helper_isInTree (stationlistItem *child, stationlistItem *parent)
bool helper_isNumericValue (const QVariant &value)
void helper_moveItems (const QModelIndex &oldParent, int first, int last, const QModelIndex &newParent, int newRow)
QList< stationlistItem * > helper_removeItems (const QModelIndex &parent, int first, int last)
void helper_selectAndScrollTo (const QModelIndexList &modelIndexList)
QString helper_stationlistXmlFilepath ()
qlonglong helper_toLongLong (const PropertyValue &value)
void helper_writeStationList ()
stationlistItemitem (const QModelIndex &index) const
QModelIndex modelindexOfItem (stationlistItem *item, int column)
void sortChildItems (stationlistItem *parent, int column, Qt::SortOrder order)
void writeItemToFile (stationlistItem *item, QXmlStreamWriter &file)

Private Attributes

quint64 internal_bandwidth
int internal_numberOfActiveStreams
QList< radioStation * > internal_selectedStreams
QStringList * m_listOfStreamsOfWhichTheUserWantsThatTheyRip
QPointer< QWidget > m_mainWidget
stationlistItemrootItem


Detailed Description

A model (for model-view-programming) handling radio streams.

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.

Warning:
Use only one instance of this class at the same time! (Otherwise, the same stream could be recorded by more than one instance at the same time - and written by all instances to the same file! That's bad! Also this class uses the config files - and it is bad when more than one instance uses them...)

You can use only one view to show the content of this model!

Definition at line 57 of file stationlistmodel.h.


Member Enumeration Documentation

This enum is used in columnInfo() to determinate which action will be performed:

  • stationlistModel::columnHeaderTitle: Get the header title of the given column (QString).
  • stationlistModel::columnHeaderToolTip: Get the tooltip of the header of the given column (QString).
  • stationlistModel::columnHeaderWhatsThis: Get the "What's this"-help of the header of the given column (QString).
  • stationlistModel::columnWidth: Get the width of the given column from settings_general (quint64). A view for this model should take care of this value and read it and apply it in his constructor. In the config file the values aren't saved as a simple list of values (ordered by column number), but each column has an individual entry name for the width. This way it is guaranteed that, also when the model changes the order of columns, each column guards its width. Furthermore, no changes at the "view" widget are necessary as this system works without that the view widget knows about the order of the columns and of there content.
  • stationlistModel::setColumnWidth: Set the width of the given column in settings_general. A view for this model should write this value back in his contructor to guarantee that the last state of the UI is saved.
  • stationlistModel::columnVisibility: Get the visibility of the given column from settings_general (bool). A view for this model should take care of this value and read it and apply it in his constructor. Like stationlistmodel::columnWidth, it is saved individually for each column.
  • stationlistModel::setColumnVisibility: Set the visibility of the given column in settings_general. A view for this model should write this value back in his contructor to guarantee that the last state of the UI is saved.
  • stationlistModel::columnData: Get the data of the field specified by column and row (PropertyValue).
Enumerator:
columnHeaderTitle 
columnHeaderToolTip 
columnHeaderWhatsThis 
columnWidth 
setColumnWidth 
columnVisibility 
setColumnVisibility 
columnData 

Definition at line 148 of file stationlistmodel.h.

enum stationlistModel::mode [private]

Internal enum.

Enumerator:
add 
move 

Definition at line 362 of file stationlistmodel.h.


Constructor & Destructor Documentation

stationlistModel::stationlistModel ( stationlistWidget parent,
QWidget *  mainWidget = 0 
) [explicit]

The constructor.

Parameters:
parent The parent of this object. This is important for the necessary interaction between model and view (for example: selection handling).
mainWidget The widget to which configuration dialogs will be centered.
Note:
This model sets itself with setModel() in parent.

Definition at line 43 of file stationlistmodel.cpp.

References stationlistItem::appendChild(), helper_createStreamItem(), helper_stationlistXmlFilepath(), helper_writeStationList(), m_listOfStreamsOfWhichTheUserWantsThatTheyRip, m_mainWidget, modelindexOfItem(), stationlistItem::parent(), radioStation, recalculate_numberOfActiveStreams_and_bandwidth(), recalculateSelectedStreams(), rootItem, and view.

Here is the call graph for this function:

stationlistModel::~stationlistModel (  )  [virtual]

The destructor.

Definition at line 110 of file stationlistmodel.cpp.

References rootItem.


Member Function Documentation

void stationlistModel::addNewFolder (  )  [slot]

This function adds a new folder: It displays a configuration dialog for the new folder. If accepted by the user (= clicking OK), the new folder is inserted in the root folder.)

Definition at line 1071 of file stationlistmodel.cpp.

References helper_addNewFolder().

Here is the call graph for this function:

void stationlistModel::addNewFolderInFolder (  )  [slot]

This function adds a new folder: It displays a configuration dialog for the new folder. If accepted by the user (= clicking OK), the new folder is inserted in the actually selected folder. (Works only if actually exactly one item is selected and this item is a folder. Otherwise, the new folder is simply inserted in the root folder.)

Definition at line 1056 of file stationlistmodel.cpp.

References helper_addNewFolder(), and view.

Here is the call graph for this function:

void stationlistModel::addNewStation (  )  [slot]

This function 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 in the root folder.

Definition at line 1066 of file stationlistmodel.cpp.

References helper_addNewStation().

Here is the call graph for this function:

void stationlistModel::addNewStationInFolder (  )  [slot]

This function 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 in the actually selected folder. (Works only if actually exactly one item is selected and this item is a folder. Otherwise, the new stream is simply inserted in the root folder.)

Definition at line 1046 of file stationlistmodel.cpp.

References helper_addNewStation(), and view.

Here is the call graph for this function:

quint64 stationlistModel::bandwidth (  )  const

See property bandwidth.

void stationlistModel::bandwidthChanged (  )  [signal]

See property bandwidth.

Referenced by recalculate_numberOfActiveStreams_and_bandwidth().

Here is the caller graph for this function:

int stationlistModel::columnCount ( const QModelIndex &  parent = QModelIndex()  )  const [virtual]

Reimplemented from QAbstractTableModel.

Parameters:
parent As this is a table model (non-hirarchical!), this parameter is ignored.
Returns:
the number of columns

Definition at line 164 of file stationlistmodel.cpp.

Referenced by sort().

Here is the caller graph for this function:

QVariant stationlistModel::columnInfo ( const columnInfoType  type,
const int  column,
const radioStation stream = 0,
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...).

Warning:
This function has the const qualifier, but this doesn't mean that nothing changes. You have not only read access, but also write access (to some values).
Parameters:
type Specifies the type of action that will be performed. See columnInfoType for details.
column The column to access.
stream The stream to access. Is ignored if the action is independent from the stream.
value The value to write. Is ignored if the action is not a writing action.
Returns:
The requested data as QVariant. If the passed arguments were invalid or if it was a write operation, than an invalid QVariant is returned.

Definition at line 169 of file stationlistmodel.cpp.

References ripping::bitrate, columnData, columnHeaderTitle, columnHeaderToolTip, columnHeaderWhatsThis, columnVisibility, columnWidth, ripping::dataSize, PropertyValue::error, ripping::error, PropertyValue::formatedValue, PropertyValue::internalValue, ripping::metaInterval, ripping::metaInterval_milliSeconds, ripping::relayPort, ripping::serverName, setColumnVisibility, setColumnWidth, ripping::song, ripping::status, ripping::streamName, PropertyValue::toolTip, PropertyValue::type, PropertyValue::unset, radioStation::uri, PropertyValue::value, and PropertyValue::whatsThis.

Referenced by data(), headerData(), and helper_firstIsAfterSecond().

Here is the caller graph for this function:

QVariant stationlistModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const [virtual]

Reimplemented from QAbstractTableModel.

Uses columnInfo() to deliver the data.

Parameters:
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
  • Qt::DisplayRole (the data itself)
  • Qt::ToolTipRole
  • Qt::WhatsThisRole.
For other values, an invalid QVariant is returned.
Returns:
the data of a the spezified item.

Definition at line 666 of file stationlistmodel.cpp.

References AND, columnData, columnInfo(), EQUAL, stationlistItem::folderName(), stationlistItem::stream, stationlistItem::streamObject(), and stationlistItem::type().

Here is the call graph for this function:

void stationlistModel::disableListeningIn (  )  [slot]

Disables listening in.

Definition at line 1436 of file stationlistmodel.cpp.

References listen, and listenSupport::setStation().

Here is the call graph for this function:

bool stationlistModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
) [virtual]

Reimplemented function that provides support for dropping URL lists via "drag and drop.

Definition at line 1353 of file stationlistmodel.cpp.

References stationlistItem::childCount(), stationlistItem::folder, helper_convertToUrl(), helper_createStreamItem(), helper_insertItems(), helper_selectAndScrollTo(), helper_writeStationList(), index(), item(), m_mainWidget, modelindexOfItem(), and radioStation.

Referenced by paste(), and pasteSelection().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::enableListeningIn (  )  [slot]

Enables the listening in to the actually selected stream.

Note:
If there is no stream selected of more than 1 stream are selected, than listening in is disabled.

Definition at line 1422 of file stationlistmodel.cpp.

References listen, listenSupport::setStation(), stationlistItem::stream, stationlistItem::streamObject(), stationlistItem::type(), and view.

Here is the call graph for this function:

Qt::ItemFlags stationlistModel::flags ( const QModelIndex &  index  )  const [virtual]

Reimplemented function that says that dropping streams via "drag and drop" is accepted at each place in the view widget.

Definition at line 1410 of file stationlistmodel.cpp.

QVariant stationlistModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const [virtual]

Reimplemented from QAbstractTableModel.

Uses columnInfo() if orientation is horizontal.

Definition at line 641 of file stationlistmodel.cpp.

References columnHeaderTitle, columnHeaderToolTip, columnHeaderWhatsThis, columnInfo(), and EQUAL.

Here is the call graph for this function:

void stationlistModel::helper_addNewFolder ( const QModelIndex &  index  )  [private]

Helps to create a new folder. Displays a settings dialog for the folder that will be created. If accepted, the folder will be inserted. If index is a folder, it will be added in this folder. If not, it will be added in the root folder.

Definition at line 978 of file stationlistmodel.cpp.

References folderPropertiesDialog::centralWidget, stationlistItem::childCount(), stationlistItem::folder, helper_insertItem(), helper_selectAndScrollTo(), helper_writeStationList(), modelindexOfItem(), rootItem, and folderProperties::text().

Referenced by addNewFolder(), and addNewFolderInFolder().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_addNewStation ( const QModelIndex &  index  )  [private]

Helps to create a new station. Displays a settings dialog for the station that will be created. If accepted, the station will be inserted. If index is a folder, it will be added in this folder. If not, it will be added in the root folder.

Definition at line 1005 of file stationlistmodel.cpp.

References stationlistItem::childCount(), radioStation::execSettingsDialogWithoutApplyButton(), stationlistItem::folder, helper_createStreamItem(), helper_deleteRadiostationobjectAndRemoveConfigfiles(), helper_insertItem(), helper_selectAndScrollTo(), helper_writeStationList(), m_mainWidget, modelindexOfItem(), radioStation, and rootItem.

Referenced by addNewStation(), and addNewStationInFolder().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_connectSignalsAndSlots ( 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.

Warning:
Call this function only once for each station.
Parameters:
m_stream a pointer to the station for which you want to set up the connection

Definition at line 115 of file stationlistmodel.cpp.

References recalculate_numberOfActiveStreams_and_bandwidth(), reloadBitrate(), reloadDataSize(), reloadMetaInterval(), reloadMetaInterval_milliSeconds(), reloadRelayPort(), reloadServerName(), reloadSong(), reloadStatus(), reloadStreamName(), reloadUri(), and statusChanged().

Referenced by helper_createStreamItem().

Here is the call graph for this function:

Here is the caller graph for this function:

QList< QUrl > stationlistModel::helper_convertToUrl ( const QMimeData *  data  )  [private]

Extracts a list of URLs from mime data.

Definition at line 1309 of file stationlistmodel.cpp.

Referenced by dropMimeData().

Here is the caller graph for this function:

stationlistItem * stationlistModel::helper_createStreamItem ( radioStation stream  )  [private]

Creates an item for a given stream, adjusts radioStation::index, and connects the signals of radioStation to the slots of this class.

Parameters:
stream A radioStation object
Returns:
A pointer to a newly created item.

Definition at line 966 of file stationlistmodel.cpp.

References helper_connectSignalsAndSlots(), and streamripper_base::setIndex().

Referenced by dropMimeData(), helper_addNewStation(), and stationlistModel().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_deleteRadiostationobjectAndRemoveConfigfiles ( stationlistItem item  )  [private]

Deletes the radioStation objects of this respective of all its direct and indirect child items.

Note:
The stationlistItem obejcts themself are not deleted.
Parameters:
item A pointer to the item
Warning:
Execute this function only on items that are not part of the tree!

Definition at line 1076 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::childCount(), helper_deleteRadiostationobjectAndRemoveConfigfiles(), stationlistItem::stream, stationlistItem::streamObject(), and stationlistItem::type().

Here is the call graph for this function:

void stationlistModel::helper_deleteRadiostationobjectAndRemoveConfigfiles ( radioStation station  )  [private]

Deletes the radioStation object and removes its config files from disk.

Parameters:
station A pointer to the station (must be on the heap)

Definition at line 1087 of file stationlistmodel.cpp.

References radioStation::fullConfigFileName.

Referenced by helper_addNewStation(), helper_deleteRadiostationobjectAndRemoveConfigfiles(), and removeRows().

Here is the caller graph for this function:

bool stationlistModel::helper_firstIsAfterSecond ( const PropertyValue firstValue,
const PropertyValue secondValue,
Qt::SortOrder  order 
) [private]

This function compares 2 values for sorting. It uses the following sort order:

  1. PropertyValue::unset
  2. PropertyValue::error
  3. PropertyValue::value in order (following PropertyValue.internalValue interpretated as integer if possible, otherwise case-insensitive string sorting of PropertyValue.formatedValue)

If both values have the same order, it returns always true.

Returns:
If the first item should be after the second item when sorting.

Definition at line 847 of file stationlistmodel.cpp.

References PropertyValue::error, PropertyValue::formatedValue, helper_isNumericValue(), helper_toLongLong(), PropertyValue::internalValue, PropertyValue::type, PropertyValue::unset, and PropertyValue::value.

Here is the call graph for this function:

bool stationlistModel::helper_firstIsAfterSecond ( stationlistItem firstItem,
stationlistItem secondItem,
int  column,
Qt::SortOrder  order 
) [private]

Overloaded function that supports to compare items directly. See the other function for details. This one, as it permits folders to be compared, always says that folder are before streams when comparing a folder with a stream. When comparing two folders than it uses alphabetical order, following the argument order.

Definition at line 816 of file stationlistmodel.cpp.

References columnData, columnInfo(), stationlistItem::folderName(), stationlistItem::stream, stationlistItem::streamObject(), and stationlistItem::type().

Referenced by sortChildItems().

Here is the call graph for this function:

Here is the caller graph for this function:

bool stationlistModel::helper_hasStreams ( stationlistItem item  )  [private]

Returns:
If the item is a stream or has at least one stream as direct or indirect child.

Definition at line 1475 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::folder, and stationlistItem::type().

Here is the call graph for this function:

void stationlistModel::helper_insertItem ( stationlistItem item,
const QModelIndex &  parent,
int  row 
) [private]

See also:
helper_insertItems(QList<stationlistItem *> itemList, const QModelIndex &parent, int row)

Definition at line 942 of file stationlistmodel.cpp.

References helper_insertItems().

Referenced by helper_addNewFolder(), and helper_addNewStation().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_insertItems ( QList< stationlistItem * >  itemList,
const QModelIndex &  parent,
int  row 
) [private]

Inserts items to the model, handling also beginInsertRows and endInsertRows.

Parameters:
itemList The list of the items that will be added. These items can not be yet part of the model!
parent The parent in which the items will be inserted. If invalid, that the function will insert to the root item.
row The row number within the parent where the new items will be inserted.
Note:
This function does not call helper_writeStationList. You have to do this manually!
Warning:
This function is very fast, but does no checks. 'row' must be a valid row numbers within the parent.
See also:
helper_removeItems()

Definition at line 951 of file stationlistmodel.cpp.

References stationlistItem::insertChild(), and item().

Referenced by dropMimeData(), helper_insertItem(), and helper_moveItems().

Here is the call graph for this function:

Here is the caller graph for this function:

bool stationlistModel::helper_isInTree ( stationlistItem child,
stationlistItem parent 
) [private]

Parameters:
child The child item to test
parent The parent item to test
Returns:
true if child is a direct or indirect child of parent, otherwise false

Definition at line 909 of file stationlistmodel.cpp.

References OR, and stationlistItem::parent().

Here is the call graph for this function:

bool stationlistModel::helper_isNumericValue ( const QVariant &  value  )  [private]

Returns:
Whether the value is of numeric type (either an integer number or an floating point number) or can be converted to a numeric type (ripping::statusType).
See also:
helper_toLongLong

Definition at line 783 of file stationlistmodel.cpp.

Referenced by helper_firstIsAfterSecond().

Here is the caller graph for this function:

QList< radioStation * > stationlistModel::helper_listOfAllStreams ( stationlistItem parentItem  )  [private]

Parameters:
parentItem The base item
Returns:
If parentItem is a stream, it returns a list that just contains this item. If parentItem is a folder, it returns a list that contains all its direct and indirect child items that are streams.
Warning:
This function will crash if the item is invalid.

Definition at line 522 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::childCount(), stationlistItem::stream, stationlistItem::streamObject(), and stationlistItem::type().

Referenced by queryClose(), readProperties(), recalculate_numberOfActiveStreams_and_bandwidth(), recalculateSelectedStreams(), and rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_moveItems ( const QModelIndex &  oldParent,
int  first,
int  last,
const QModelIndex &  newParent,
int  newRow 
) [private]

Moves the respective items within the tree model.

Parameters:
oldParent The parent of the items that will be moved.
first The row number of the first child that will be moved.
last The row number of the last child that will be moved.
newParent The parent to which the items will be moved.
newRow The row number where the items will be inserted.
Warning:
This function does not any checks! Be careful with the parameters. For details:
See also:
helper_removeItems

helper_insertItem

Definition at line 750 of file stationlistmodel.cpp.

References helper_insertItems(), and helper_removeItems().

Referenced by sortChildItems().

Here is the call graph for this function:

Here is the caller graph for this function:

QList< stationlistItem * > stationlistModel::helper_removeItems ( const QModelIndex &  parent,
int  first,
int  last 
) [private]

Removes items from the model, handling also beginRemoveRows and endRemoveRows.

Parameters:
parent The parent of the items that will be removed.
first The row number of the first item to be removed (within the parent)
last The row number of the last item to be removed (within the parent)
Returns:
A list of pointers to the item objects. The item objects still exist, but are no longer part of the model.
Warning:
This function is very fast, but does no checks. 'first' and 'last' must be a valid row numbers within the parent, and 'last' must be >= 'first'. Otherwise, the results are undefined.
See also:
helper_insertItems()

Definition at line 924 of file stationlistmodel.cpp.

References stationlistItem::child(), and item().

Referenced by helper_moveItems(), and removeRows().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::helper_selectAndScrollTo ( const QModelIndexList &  modelIndexList  )  [private]

If modelIndexList is not empty, than this function deletes the actual selection, selects the given rows, if necessary expands it's parents and scrolls to them.

Parameters:
modelIndexList The list of rows. (One index per row is enough.)

Definition at line 1034 of file stationlistmodel.cpp.

References view.

Referenced by dropMimeData(), helper_addNewFolder(), and helper_addNewStation().

Here is the caller graph for this function:

QString stationlistModel::helper_stationlistXmlFilepath (  )  [inline, private]

Returns:
The full path to the XML file that contains the station list.

Definition at line 147 of file stationlistmodel.cpp.

Referenced by helper_writeStationList(), and stationlistModel().

Here is the caller graph for this function:

qlonglong stationlistModel::helper_toLongLong ( const PropertyValue value  )  [private]

Converts a PropertyValue.internalValue to a qlonglong if possible (integer values or ripping::statusType).

See also:
helper_isNumericValue

Definition at line 806 of file stationlistmodel.cpp.

References PropertyValue::internalValue.

Referenced by helper_firstIsAfterSecond().

Here is the caller graph for this function:

void stationlistModel::helper_writeStationList (  )  [inline, private]

Writes the actual list of streams back to the configuration file "stationlist.xml".

Definition at line 1152 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::childCount(), helper_stationlistXmlFilepath(), rootItem, and writeItemToFile().

Referenced by dropMimeData(), helper_addNewFolder(), helper_addNewStation(), queryClose(), removeRows(), saveProperties(), and stationlistModel().

Here is the call graph for this function:

Here is the caller graph for this function:

QModelIndex stationlistModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

Reimplemented from base class.

Definition at line 1456 of file stationlistmodel.cpp.

References stationlistItem::child(), and item().

Referenced by dropMimeData(), modelindexOfItem(), and recalculateSelectedStreams().

Here is the call graph for this function:

Here is the caller graph for this function:

stationlistItem * stationlistModel::item ( const QModelIndex &  index  )  const [private]

Parameters:
index A model index
Returns:
A pointer to the corresponding item.
Warning:
This function will return invalid data if you execute it with indexes that are not part of this model.

Definition at line 1097 of file stationlistmodel.cpp.

References rootItem.

Referenced by dropMimeData(), helper_insertItems(), helper_removeItems(), index(), removeRows(), rowCount(), and showConfigDialog().

Here is the caller graph for this function:

QStringList stationlistModel::mimeTypes (  )  const [virtual]

Reimplemented from Qt. Provides a list of the mime types that are accepted for dropping streams via "drag and drop".

Definition at line 1415 of file stationlistmodel.cpp.

QModelIndex stationlistModel::modelindexOfItem ( stationlistItem item,
int  column 
) [private]

Parameters:
item An item of our tree structure
column The column of the item
Returns:
A QModelIndex for the respective column in the item

Definition at line 570 of file stationlistmodel.cpp.

References index(), stationlistItem::parent(), rootItem, and stationlistItem::row().

Referenced by dropMimeData(), helper_addNewFolder(), helper_addNewStation(), reloadBitrate(), reloadDataSize(), reloadMetaInterval(), reloadMetaInterval_milliSeconds(), reloadRelayPort(), reloadServerName(), reloadSong(), reloadStatus(), reloadStreamName(), reloadUri(), sortChildItems(), stationlistModel(), and writeItemToFile().

Here is the call graph for this function:

Here is the caller graph for this function:

int stationlistModel::numberOfActiveStreams (  )  const

See property numberOfActiveStreams.

Referenced by queryClose().

Here is the caller graph for this function:

void stationlistModel::numberOfActiveStreamsChanged (  )  [signal]

See property numberOfActiveStreams.

Referenced by recalculate_numberOfActiveStreams_and_bandwidth().

Here is the caller graph for this function:

void stationlistModel::numberOfActiveStreamsIsZero (  )  [signal]

See property numberOfActiveStreams.

Referenced by queryClose(), and recalculate_numberOfActiveStreams_and_bandwidth().

Here is the caller graph for this function:

QModelIndex stationlistModel::parent ( const QModelIndex &  index  )  const [virtual]

Reimplemented from base class.

Definition at line 1441 of file stationlistmodel.cpp.

References stationlistItem::parent(), rootItem, and stationlistItem::row().

Here is the call graph for this function:

void stationlistModel::paste (  )  [slot]

Pastes the content of the clipboard (using dropMimeData()).

Definition at line 1335 of file stationlistmodel.cpp.

References dropMimeData().

Here is the call graph for this function:

void stationlistModel::pasteSelection ( const QModelIndex &  index  )  [slot]

Pastes the content of the mouse selection (using dropMimeData()).

Parameters:
index The position where the mouse selection will be inserted.

Definition at line 1344 of file stationlistmodel.cpp.

References dropMimeData().

Here is the call graph for this function:

bool stationlistModel::queryClose (  )  [virtual]

  • Remembers a list of running streams (which is necessary if we do session management)

  • Shuts them down. As this can take a while, a "busy" dialog is displayed.

See also:
saveProperties()

rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone()

Definition at line 1241 of file stationlistmodel.cpp.

References helper_listOfAllStreams(), helper_writeStationList(), m_mainWidget, numberOfActiveStreams(), numberOfActiveStreamsIsZero(), rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone(), and rootItem.

Here is the call graph for this function:

void stationlistModel::readProperties ( const KConfigGroup &  m_configGroup  )  [virtual]

Reads properties for restoring the previous session (using session management).

Parameters:
m_configGroup The location where to read the properties from
See also:
saveProperties()

Definition at line 1292 of file stationlistmodel.cpp.

References helper_listOfAllStreams(), and rootItem.

Here is the call graph for this function:

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 535 of file stationlistmodel.cpp.

References bandwidthChanged(), helper_listOfAllStreams(), ripping::idle, internal_bandwidth, internal_numberOfActiveStreams, numberOfActiveStreamsChanged(), numberOfActiveStreamsIsZero(), rootItem, and PropertyValue::value.

Referenced by helper_connectSignalsAndSlots(), and stationlistModel().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::recalculateSelectedStreams (  )  [private, slot]

Recalculates the value of the property selectedStreams.

Definition at line 1490 of file stationlistmodel.cpp.

References helper_listOfAllStreams(), index(), internal_selectedStreams, selectedStreamsChanged(), and view.

Referenced by stationlistModel().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::record (  )  [slot]

This slot tries to start the recording of all selected stream. Selected streams means: directly selected or one of its parent folders is selected. Trying means: when the stream is actually shutting down, than the call will be ignored by radioStation.

Definition at line 1177 of file stationlistmodel.cpp.

References internal_selectedStreams, and ripping::startStreamripper().

Here is the call graph for this function:

void stationlistModel::relayportChanged (  )  [signal]

Is emitted always when one of the streams changes its relay port.

Referenced by reloadRelayPort().

Here is the caller graph for this function:

void stationlistModel::reloadBitrate ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 610 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadDataSize ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 604 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadMetaInterval ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 616 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadMetaInterval_milliSeconds ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 622 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadRelayPort ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 634 of file stationlistmodel.cpp.

References modelindexOfItem(), and relayportChanged().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadServerName ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 628 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadSong ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 598 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadStatus ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 591 of file stationlistmodel.cpp.

References modelindexOfItem(), and statusChanged().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadStreamName ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 579 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots(), and showConfigDialog().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::reloadUri ( void *  stationIndex  )  [private, slot]

Used internally to emit the signal dataChanged.

Definition at line 585 of file stationlistmodel.cpp.

References modelindexOfItem().

Referenced by helper_connectSignalsAndSlots().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone (  )  [private, slot]

If the application is closed using session management, it is undefined, if saveProperties() or queryClose() is executed first. Because queryClose() shuts the streams down, if saveProperties() is executed later it would not be able to know which streams were running.

To solve this problem, queryClose() and saveProperties() call this function (in the case of queryClose() of course before shutting down streams). This function writes a list of running streams to the member m_listOfStreamsOfWhichTheUserWantsThatTheyRip - but only if there is not yet a list. This way, saveProperties() can call this function and be sure to have now a correct list of running streams at m_listOfStreamsOfWhichTheUserWantsThatTheyRip, indepentently from the execution order of saveProperties() and readProperties().

See also:
saveProperties()

queryClose()

m_listOfStreamsOfWhichTheUserWantsThatTheyRip

Definition at line 1225 of file stationlistmodel.cpp.

References helper_listOfAllStreams(), m_listOfStreamsOfWhichTheUserWantsThatTheyRip, and rootItem.

Referenced by queryClose(), and saveProperties().

Here is the call graph for this function:

Here is the caller graph for this function:

bool stationlistModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
) [virtual]

Reimplemented from QAbstractItemModel.

Removes count radio stations starting with the given row (radio station) from this model and deletes the corresponding config files.

Parameters:
row You must pass the index (= the row) of the first stream which you want to delete. When you pass an invalid index, nothing happens.
count number of streams that will be deleted.
parent is ignored.
Returns:
whether the removing was sucessful

Definition at line 1106 of file stationlistmodel.cpp.

References stationlistItem::childCount(), helper_deleteRadiostationobjectAndRemoveConfigfiles(), helper_removeItems(), helper_writeStationList(), and item().

Here is the call graph for this function:

int stationlistModel::rowCount ( const QModelIndex &  parent = QModelIndex()  )  const [virtual]

Reimplemented from QAbstractTableModel.

Parameters:
parent As this is a table model (non-hirarchical!), this parameter is ignored.
Returns:
the number of rows

Definition at line 152 of file stationlistmodel.cpp.

References stationlistItem::childCount(), and item().

Here is the call graph for this function:

void stationlistModel::saveProperties ( KConfigGroup &  m_configGroup  )  [virtual]

Saves properties for restoring this session later (using session management).

Parameters:
m_configGroup The location where to save the properties
See also:
readProperties()

rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone()

m_listOfStreamsOfWhichTheUserWantsThatTheyRip

Definition at line 1283 of file stationlistmodel.cpp.

References helper_writeStationList(), m_listOfStreamsOfWhichTheUserWantsThatTheyRip, and rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone().

Here is the call graph for this function:

QList< radioStation * > stationlistModel::selectedStreams (  )  const

See property selectedStreams.

Definition at line 1511 of file stationlistmodel.cpp.

References internal_selectedStreams.

void stationlistModel::selectedStreamsChanged (  )  [signal]

See property selectedStreams.

Referenced by recalculateSelectedStreams().

Here is the caller graph for this function:

void stationlistModel::showConfigDialog (  )  [slot]

If exactly one stream or folder is selected, then this slot shows the config dialog. Else nothing happens.

Definition at line 1191 of file stationlistmodel.cpp.

References stationlistItem::folderName(), item(), reloadStreamName(), stationlistItem::setFolderName(), radioStation::showSettingsDialogWithApplyButton(), stationlistItem::stream, stationlistItem::streamObject(), stationlistItem::type(), and view.

Here is the call graph for this function:

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 718 of file stationlistmodel.cpp.

References columnCount(), rootItem, and sortChildItems().

Here is the call graph for this function:

void stationlistModel::sortChildItems ( stationlistItem parent,
int  column,
Qt::SortOrder  order 
) [private]

Sorts the child items of a given parent.

Parameters:
parent The parent.
column The column following to which we will sort the children.
order The sort order.

Definition at line 760 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::childCount(), helper_firstIsAfterSecond(), helper_moveItems(), and modelindexOfItem().

Referenced by sort().

Here is the call graph for this function:

Here is the caller graph for this function:

void stationlistModel::statusChanged (  )  [signal]

Is emitted always when one of the streams changes its status or its error.

Referenced by helper_connectSignalsAndSlots(), and reloadStatus().

Here is the caller graph for this function:

void stationlistModel::stopRecording (  )  [slot]

This slot stops the recording of all selected stream. Selected streams means: directly selected or one of its parent folders is selected.

Definition at line 1184 of file stationlistmodel.cpp.

References internal_selectedStreams, and ripping::shutDown().

Here is the call graph for this function:

void stationlistModel::writeItemToFile ( stationlistItem item,
QXmlStreamWriter &  file 
) [private]

Writes the XML elements for a given item.

Parameters:
item The item that has to be saved
file The file to which the XML data will be written

Definition at line 1135 of file stationlistmodel.cpp.

References stationlistItem::child(), stationlistItem::childCount(), radioStation::configFileName, stationlistItem::folderName(), modelindexOfItem(), stationlistItem::stream, stationlistItem::streamObject(), stationlistItem::type(), and view.

Referenced by helper_writeStationList().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Used internally to cache the value of the property bandwidth.

Definition at line 498 of file stationlistmodel.h.

Referenced by recalculate_numberOfActiveStreams_and_bandwidth().

Used internally to cache the value of the property numberOfActiveStreams.

Definition at line 500 of file stationlistmodel.h.

Referenced by recalculate_numberOfActiveStreams_and_bandwidth().

Used internally to cache the value of the property selectedStreams.

Definition at line 502 of file stationlistmodel.h.

Referenced by recalculateSelectedStreams(), record(), selectedStreams(), and stopRecording().

With this object, we can listen in streams.

Note:
This object is handled automatically. So don't make changes to this object. However, it may make sense to connect to its signals to obtain information.

Definition at line 236 of file stationlistmodel.h.

Referenced by disableListeningIn(), and enableListeningIn().

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.

Warning:
Keep this pointer always valid and set it back to null when deleting the QStringList. The destructor will delete a possibly remaining QStringlist, and this will lead to a crash when the pointer is invalid.
See also:
rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone() has details.

Definition at line 512 of file stationlistmodel.h.

Referenced by rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone(), saveProperties(), 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 515 of file stationlistmodel.h.

Referenced by dropMimeData(), helper_addNewStation(), queryClose(), and stationlistModel().

A pointer to the view that shows this model.

Warning:
This pointer can be 0! Test this before using it!

Definition at line 358 of file stationlistmodel.h.

Referenced by addNewFolderInFolder(), addNewStationInFolder(), enableListeningIn(), helper_selectAndScrollTo(), recalculateSelectedStreams(), showConfigDialog(), stationlistModel(), and writeItemToFile().


Property Documentation

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

Warning:
The formated version contains the value in kbit/s (with SI prefix which means 1000 bit/s, not 1024 bit/s).
See also:

Definition at line 74 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).

See also:

Definition at line 102 of file stationlistmodel.h.

QList stationlistModel::radioStation [read]

This property gives access to a duplicate-free list of all actually selected streams (either selected directly or because one of its parent folders is selected).

The value is always keept up to date.

Note:
You should connect to selectedStreamsChanged() instead of connecting to the signals of QItemSelectionModel because this makes sure that at the time of the slot call, all properties are yet updated.
See also:

 QList<radioStation *> internal_selectedStreams 

Definition at line 90 of file stationlistmodel.h.

Referenced by dropMimeData(), helper_addNewStation(), and stationlistModel().


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

doxygen