radioapp/radiouiengine/inc/radiohistorymodel_p.h
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef RADIOHISTORYMODEL_P_H
       
    19 #define RADIOHISTORYMODEL_P_H
       
    20 
       
    21 // System includes
       
    22 #include <QList>
       
    23 #include <QString>
       
    24 #include <QScopedPointer>
       
    25 #include <QIcon>
       
    26 #include <QSqlQuery>
       
    27 
       
    28 // User includes
       
    29 #include "radiohistoryitem.h"
       
    30 
       
    31 // Forward declarations
       
    32 class RadioHistoryModel;
       
    33 class RadioUiEngine;
       
    34 class RadioHistoryItem;
       
    35 class QSqlDatabase;
       
    36 class RadioStation;
       
    37 class QStringList;
       
    38 class QSqlQueryModel;
       
    39 
       
    40 class RadioHistoryModelPrivate
       
    41 {
       
    42 public:
       
    43 
       
    44     explicit RadioHistoryModelPrivate( RadioHistoryModel* model, RadioUiEngine& uiEngine );
       
    45 
       
    46     ~RadioHistoryModelPrivate();
       
    47 
       
    48     bool connectToDatabase();
       
    49 
       
    50     void addItem( const QString& artist, const QString& title, const RadioStation& station, bool fromRds = true );
       
    51 
       
    52     int rowCount() const;
       
    53     QVariant data( const int row, const int role ) const;
       
    54 
       
    55     void removeAll( bool removeTagged );
       
    56 
       
    57     enum ViewMode{ ShowAll, ShowTagged };
       
    58     void setViewMode( ViewMode mode );
       
    59 
       
    60     void toggleTagging( const RadioHistoryItem& item, const int row );
       
    61 
       
    62     RadioHistoryItem itemAtIndex( const QModelIndex& index ) const;
       
    63 
       
    64 private:
       
    65 
       
    66     void refreshModel();
       
    67     QSqlQuery beginTransaction();
       
    68     enum Operation{ NoOp, InsertRows, RemoveRows, ChangeData };
       
    69     void commitTransaction( QSqlQuery& query, Operation operation, int start, int end = -1 );
       
    70 
       
    71 public: // data
       
    72 
       
    73     /**
       
    74      * Pointer to the public class
       
    75      * Not own.
       
    76      */
       
    77     RadioHistoryModel*              q_ptr;
       
    78 
       
    79     /**
       
    80      * Reference to the ui engine
       
    81      */
       
    82     RadioUiEngine&                  mUiEngine;
       
    83 
       
    84     QScopedPointer<QSqlDatabase>    mDatabase;
       
    85 
       
    86     QScopedPointer<QSqlQueryModel>  mQueryModel;
       
    87 
       
    88     QString                         mRtItemHolder;
       
    89     int                             mRtItemClass;
       
    90 
       
    91     bool                            mTopItemIsPlaying;
       
    92 
       
    93     bool                            mShowDetails;
       
    94 
       
    95     /**
       
    96      * Non Tagged icon
       
    97      */
       
    98     QIcon                           mNonTaggedIcon;
       
    99 
       
   100     /**
       
   101      * Tagged icon
       
   102      */
       
   103     QIcon                           mTaggedIcon;
       
   104 
       
   105     ViewMode                        mViewMode;
       
   106 
       
   107 };
       
   108 
       
   109 #endif // RADIOHISTORYMODEL_P_H