stationlistmodel.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008  Tim Fechtner < urwald at users dot sourceforge dot net >
00003 
00004     This program is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU General Public License as
00006     published by the Free Software Foundation; either version 2 of
00007     the License or (at your option) version 3 or any later version
00008     accepted by the membership of KDE e.V. (or its successor approved
00009     by the membership of KDE e.V.), which shall act as a proxy
00010     defined in Section 14 of version 3 of the license.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef STATIONLISTMODEL_H
00022 #define STATIONLISTMODEL_H
00023 
00024 #include <QAbstractTableModel>
00025 #include <QPointer>
00026 #include <QList>
00027 #include <phonon/mediaobject.h>
00028 #include <phonon/path.h>
00029 #include <phonon/audiooutput.h>
00030 #include "listensupport.h"
00031 #include "radiostation.h"
00032 
00033 class stationlistWidget;
00034 
00054 class stationlistModel : public QAbstractTableModel
00055 {
00056 
00057      Q_OBJECT
00058 
00071      Q_PROPERTY(quint64 bandwidth READ bandwidth)
00072 
00073      
00083      Q_PROPERTY(int numberOfActiveStreams READ numberOfActiveStreams)
00084 
00085   public:
00090      explicit stationlistModel(stationlistWidget *parent,
00091                                QWidget *mainWidget = 0);
00092 
00094      virtual ~stationlistModel();
00095 
00128      enum columnInfoType{
00129                           columnHeaderTitle,
00130                           columnHeaderToolTip,
00131                           columnHeaderWhatsThis,
00132                           columnWidth,
00133                           setColumnWidth,
00134                           columnVisibility,
00135                           setColumnVisibility,
00136                           columnData
00137                         };
00138 
00144      QModelIndex addNewStation();
00145 
00147      quint64 bandwidth() const;
00148 
00153      virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
00154 
00184      QVariant columnInfo(const columnInfoType type,
00185                          const int column,
00186                          const qint64 row = (-1),
00187                          const quint64 value = (-1),
00188                          QList<radioStation *> listOfStations = QList<radioStation *>()) const;
00189 
00205      virtual QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
00206 
00208      virtual bool dropMimeData(const QMimeData *data,
00209                                Qt::DropAction action,
00210                                int row,
00211                                int column,
00212                                const QModelIndex & parent);
00213 
00216      virtual Qt::ItemFlags flags(const QModelIndex & index) const;
00217 
00221      virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
00222 
00225      virtual QStringList mimeTypes () const;
00226 
00228      int numberOfActiveStreams() const;
00229 
00235      virtual bool queryClose();
00236 
00241      virtual void readProperties(const KConfigGroup & m_configGroup);
00242 
00252      virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
00253 
00258      virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
00259 
00266      virtual void saveProperties(KConfigGroup & m_configGroup);
00267 
00271      virtual void sort (int column, Qt::SortOrder order = Qt::AscendingOrder);
00272 
00273   signals:
00275      void bandwidthChanged();
00277      void numberOfActiveStreamsChanged();
00279      void numberOfActiveStreamsIsZero();
00280 
00281   public slots:
00285      void enableListeningIn();
00287      void disableListeningIn();
00289      void paste();
00291      void pasteSelection();
00295      void record(const int index);
00298      void showConfigDialog(const int index);
00303      void stopRecording(const int index);
00304 
00305   protected:
00308      QPointer<stationlistWidget> view;
00309 
00310   private:
00316      void helper_connectSignalsAndSlots(radioStation *m_stream);
00318      QList<QUrl> helper_convertToUrl(const QMimeData *data);
00330      bool helper_firstIsAfterSecond(const PropertyValue & firstValue,
00331                                     const PropertyValue & secondValue,
00332                                     Qt::SortOrder order);
00337      bool helper_isNumericValue(const QVariant & value);
00341      qlonglong helper_toLongLong(const PropertyValue & value);
00343      void helper_writeStationListToGeneralSettings();
00345      quint64 internal_bandwidth;
00347      int internal_numberOfActiveStreams;
00349      listenSupport listen;
00361      QStringList *m_listOfStreamsOfWhichTheUserWantsThatTheyRip;
00364      QPointer<QWidget> m_mainWidget;
00367      QList<radioStation *> m_stationlist;  /* we need a pointer as list member
00368                                                       instead of radioStation itself
00369                                                       because we need the construct
00370                                                       radioStation with the constructor
00371                                                       (no other way to set the config file),
00372                                                       and when radioStation's
00373                                                       constructor is called, the config file
00374                                                       is opened and so on. I
00375                                                       don't think it's save to copy this
00376                                                       class - what's necessary
00377                                                       when not using a pointer. */
00378 
00379   private slots:
00396      void recalculate_numberOfActiveStreams_and_bandwidth();
00398      void reloadBitrate(const qlonglong stationIndex);
00400      void reloadDataSize(const qlonglong stationIndex);
00402      void reloadMetaInterval(const qlonglong stationIndex);
00404      void reloadMetaInterval_milliSeconds(const qlonglong stationIndex);
00406      void reloadRelayPort(const qlonglong stationIndex);
00408      void reloadServerName(const qlonglong stationIndex);
00410      void reloadSong(const qlonglong stationIndex);
00412      void reloadStatus(const qlonglong stationIndex);
00414      void reloadStreamName(const qlonglong stationIndex);
00416      void reloadUri(const qlonglong stationIndex);
00436      void rememberListOfStreamsWhichTheUserWantsToRip_ifNotYetDone();
00437 
00438 };
00439 
00440 #endif

doxygen