radioapp/radiouiengine/inc/radiostationmodel.h
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 32 189d20c34778
--- a/radioapp/radiouiengine/inc/radiostationmodel.h	Fri Jun 11 16:24:13 2010 +0100
+++ b/radioapp/radiouiengine/inc/radiostationmodel.h	Thu Jul 22 16:33:45 2010 +0100
@@ -20,6 +20,7 @@
 
 // System includes
 #include <QAbstractListModel>
+#include <QScopedPointer>
 #include <QMap>
 
 // User includes
@@ -39,21 +40,24 @@
 // Constants
 typedef QMap<uint,RadioStation> Stations;
 
+namespace FindCriteria
+{
+    enum Criteria
+    {
+        OnlySavedStations,
+        IncludeManualStation
+    };
+}
+
 // Class declaration
 class UI_ENGINE_DLL_EXPORT RadioStationModel : public QAbstractListModel
 {
     Q_OBJECT
-    Q_DECLARE_PRIVATE_D( d_ptr, RadioStationModel )
+    Q_DECLARE_PRIVATE_D( d_ptr.data(), RadioStationModel )
     Q_DISABLE_COPY( RadioStationModel )
 
 public:
 
-    enum RadioRole
-    {
-        RadioStationRole = Qt::UserRole + 1,
-        ToggleFavoriteRole
-    };
-
     enum DetailFlag
     {
         Minimal     = 1 << 0,
@@ -102,9 +106,15 @@
     RadioStation stationAt( int index ) const;
 
     /*!
-     * Functions to find stations by frequency
+     * Finds a station by frequency
      */
-    bool findFrequency( uint frequency, RadioStation& station );
+    bool findFrequency( uint frequency, RadioStation& station, FindCriteria::Criteria criteria = FindCriteria::OnlySavedStations ) const;
+
+    /*!
+     * Convenience function to find a radio station.
+     * Internally uses findFrequency() and returns an invalid station if the given frequency is not found
+     */
+    RadioStation findStation( uint frequency, FindCriteria::Criteria criteria = FindCriteria::OnlySavedStations ) const;
 
     /*!
      * Functions to find stations by preset index
@@ -118,6 +128,11 @@
     RadioStation findClosest( const uint frequency, StationSkip::Mode mode );
 
     /*!
+     * Checks if the model contains the given frequency
+     */
+    bool contains( const uint frequency ) const;
+
+    /*!
      * Functions to remove stations
      */
     void removeByFrequency( uint frequency );
@@ -168,7 +183,7 @@
     /*!
      * Returns the model index corresponding to the given frequency
      */
-    QModelIndex modelIndexFromFrequency( uint frequency );
+    int indexFromFrequency( uint frequency );
 
 signals:
 
@@ -201,18 +216,12 @@
      */
     int findUnusedPresetIndex();
 
-    /**
-     * Used by the RDS data setters to find the correct station where the data is set
-     * First tries the currentStation variable and if the frequency doesn't match, finds the right one
-     */
-    RadioStation findCurrentStation( uint frequency );
-
 private: // data
 
     /**
      * Unmodifiable pointer to the private implementation
      */
-    RadioStationModelPrivate* const d_ptr;
+    const QScopedPointer<RadioStationModelPrivate> d_ptr;
 
 };