stationlistmodel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef STATIONLISTMODEL_H
00022 #define STATIONLISTMODEL_H
00023
00024 #include <QAbstractItemModel>
00025 #include <QList>
00026 #include <QPointer>
00027 #include <QXmlStreamWriter>
00028 #include <phonon/mediaobject.h>
00029 #include <phonon/path.h>
00030 #include <phonon/audiooutput.h>
00031 #include "folderpropertiesdialog.h"
00032 #include "listensupport.h"
00033 #include "radiostation.h"
00034 #include "stationlistitem.h"
00035
00036 class stationlistWidget;
00037
00057 class stationlistModel : public QAbstractItemModel
00058 {
00059
00060 Q_OBJECT
00061
00074 Q_PROPERTY(quint64 bandwidth READ bandwidth)
00075
00076
00090 Q_PROPERTY(QList<radioStation *> selectedStreams READ selectedStreams)
00091
00102 Q_PROPERTY(int numberOfActiveStreams READ numberOfActiveStreams)
00103
00104 public:
00110 explicit stationlistModel(stationlistWidget *parent,
00111 QWidget *mainWidget = 0);
00112
00114 virtual ~stationlistModel();
00115
00148 enum columnInfoType{
00149 columnHeaderTitle,
00150 columnHeaderToolTip,
00151 columnHeaderWhatsThis,
00152 columnWidth,
00153 setColumnWidth,
00154 columnVisibility,
00155 setColumnVisibility,
00156 columnData
00157 };
00158
00160 quint64 bandwidth() const;
00161
00166 virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
00167
00190 QVariant columnInfo(const columnInfoType type,
00191 const int column,
00192 const radioStation *stream = 0,
00193 const quint64 value = (-1)) const;
00194
00210 virtual QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
00211
00213 virtual bool dropMimeData(const QMimeData *data,
00214 Qt::DropAction action,
00215 int row,
00216 int column,
00217 const QModelIndex & parent);
00218
00221 virtual Qt::ItemFlags flags(const QModelIndex & index) const;
00222
00226 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
00227
00229 virtual QModelIndex index (int row,
00230 int column,
00231 const QModelIndex & parent = QModelIndex()) const;
00232
00236 listenSupport listen;
00237
00240 virtual QStringList mimeTypes () const;
00241
00243 int numberOfActiveStreams() const;
00244
00246 virtual QModelIndex parent(const QModelIndex & index) const;
00247
00255 virtual bool queryClose();
00256
00261 virtual void readProperties(const KConfigGroup & m_configGroup);
00262
00272 virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
00273
00278 virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
00279
00286 virtual void saveProperties(KConfigGroup & m_configGroup);
00287
00289 QList<radioStation *> selectedStreams() const;
00290
00294 virtual void sort (int column, Qt::SortOrder order = Qt::AscendingOrder);
00295
00296 signals:
00298 void bandwidthChanged();
00300 void numberOfActiveStreamsChanged();
00302 void numberOfActiveStreamsIsZero();
00304 void relayportChanged();
00306 void selectedStreamsChanged();
00308 void statusChanged();
00309
00310 public slots:
00314 void addNewFolder();
00320 void addNewFolderInFolder();
00324 void addNewStation();
00330 void addNewStationInFolder();
00334 void enableListeningIn();
00336 void disableListeningIn();
00338 void paste();
00341 void pasteSelection(const QModelIndex & index);
00346 void record();
00349 void showConfigDialog();
00353 void stopRecording();
00354
00355 protected:
00358 QPointer<stationlistWidget> view;
00359
00360 private:
00362 enum mode {
00363 add,
00364 move
00365 };
00369 void helper_addNewFolder(const QModelIndex & index);
00373 void helper_addNewStation(const QModelIndex & index);
00379 void helper_connectSignalsAndSlots(radioStation *m_stream);
00381 QList<QUrl> helper_convertToUrl(const QMimeData *data);
00386 stationlistItem *helper_createStreamItem(radioStation *stream);
00389 void helper_deleteRadiostationobjectAndRemoveConfigfiles(radioStation *station);
00394 void helper_deleteRadiostationobjectAndRemoveConfigfiles(stationlistItem *item);
00399 bool helper_firstIsAfterSecond(stationlistItem *firstItem,
00400 stationlistItem *secondItem,
00401 int column,
00402 Qt::SortOrder order);
00414 bool helper_firstIsAfterSecond(const PropertyValue & firstValue,
00415 const PropertyValue & secondValue,
00416 Qt::SortOrder order);
00419 bool helper_hasStreams(stationlistItem *item);
00425 QList<radioStation *> helper_listOfAllStreams(stationlistItem *parentItem);
00437 void helper_insertItems(QList<stationlistItem *> itemList,
00438 const QModelIndex &parent,
00439 int row);
00442 void helper_insertItem(stationlistItem * item, const QModelIndex &parent, int row);
00447 bool helper_isInTree(stationlistItem *child, stationlistItem *parent);
00452 bool helper_isNumericValue(const QVariant & value);
00463 void helper_moveItems(const QModelIndex &oldParent,
00464 int first,
00465 int last,
00466 const QModelIndex &newParent,
00467 int newRow);
00479 QList<stationlistItem *> helper_removeItems(const QModelIndex &parent, int first, int last);
00483 void helper_selectAndScrollTo(const QModelIndexList & modelIndexList);
00485 QString helper_stationlistXmlFilepath();
00489 qlonglong helper_toLongLong(const PropertyValue & value);
00491 void helper_writeStationList();
00496 stationlistItem *item(const QModelIndex & index) const;
00498 quint64 internal_bandwidth;
00500 int internal_numberOfActiveStreams;
00502 QList<radioStation *> internal_selectedStreams;
00512 QStringList *m_listOfStreamsOfWhichTheUserWantsThatTheyRip;
00515 QPointer<QWidget> m_mainWidget;
00519 QModelIndex modelindexOfItem(stationlistItem *item, int column);
00521 stationlistItem *rootItem;
00526 void sortChildItems(stationlistItem *parent, int column, Qt::SortOrder order);
00530 void writeItemToFile(stationlistItem *item, QXmlStreamWriter &file);
00531
00532 private slots:
00549 void recalculate_numberOfActiveStreams_and_bandwidth();
00551 void recalculateSelectedStreams();
00553 void reloadBitrate(void *stationIndex);
00555 void reloadDataSize(void *stationIndex);
00557 void reloadMetaInterval(void *stationIndex);
00559 void reloadMetaInterval_milliSeconds(void *stationIndex);
00561 void reloadRelayPort(void *stationIndex);
00563 void reloadServerName(void *stationIndex);
00565 void reloadSong(void *stationIndex);
00567 void reloadStatus(void *stationIndex);
00569 void reloadStreamName(void *stationIndex);
00571 void reloadUri(void *stationIndex);
00591 void rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone();
00592
00593 };
00594
00595 #endif