bluetoothengine/btui/inc/btsettingmodel.h
changeset 33 837dcc42fd6a
child 41 0b2439c3e397
equal deleted inserted replaced
19:43824b19ee35 33:837dcc42fd6a
       
     1 /*
       
     2 * Copyright (c) 2010 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 BTSETTINGMODEL_H
       
    19 #define BTSETTINGMODEL_H
       
    20 
       
    21 #include <qglobal.h>
       
    22 #include <QAbstractItemModel>
       
    23 #include <QSharedPointer>
       
    24 #include <btuimodeltypes.h>
       
    25 
       
    26 class BtLocalSetting;
       
    27 
       
    28 /*!
       
    29     \class BtSettingModel
       
    30     \brief The data model provided to Bluetooth UIs in QT
       
    31 
       
    32     BtSettingModel provides APIs for accessing BT local Bluetooth
       
    33     settings. In addition, signals from this
       
    34     model are provided for being informed of data update. 
       
    35     
       
    36     This model is in one dimension (n rows * 1 column), i.e.,
       
    37 
       
    38           row 0 (local device name)
       
    39           row 1 (power state)
       
    40           ...
       
    41     
       
    42     The data in this model is non-modifiable from the user interface, 
       
    43     determined by the characteristics of Bluetooth, the underline BT software 
       
    44     services and the BT application requirements. 
       
    45  */
       
    46 
       
    47 class BTUIMODEL_IMEXPORT BtSettingModel : public QAbstractItemModel
       
    48 {
       
    49     Q_OBJECT
       
    50     Q_ENUMS( LocalSettingRowId LocalSettingDataRole )
       
    51 
       
    52 public:
       
    53 
       
    54     //Q_DECLARE_FLAGS(Rows, BtSettingModelRow)
       
    55 
       
    56     /**
       
    57      * child row identifiers of the local setting row
       
    58      */
       
    59     enum LocalSettingRowId {
       
    60         LocalBtNameRow = 0,
       
    61         PowerStateRow ,
       
    62         VisibilityRow,
       
    63         SimAccessProfileRow,
       
    64         AllowedInOfflineRow,
       
    65         LocalSettingRowCount,
       
    66     };
       
    67     //Q_DECLARE_FLAGS(BtSettingModelLocalSettings, BtSettingModelLocalSettingColumn)
       
    68     
       
    69     /**
       
    70      * Data roles of the items in the local setting row
       
    71      */
       
    72     enum LocalSettingDataRole {
       
    73         SettingNameRole = Qt::WhatsThisRole,
       
    74         settingDisplayRole = Qt::DisplayRole,
       
    75         SettingValueRole = Qt::EditRole,
       
    76         SettingValueParamRole = Qt::UserRole + 1,  // e.g., temp visibility time     
       
    77     };
       
    78     
       
    79 public:
       
    80     
       
    81     explicit BtSettingModel( QObject *parent = 0 );
       
    82     
       
    83     explicit BtSettingModel( const BtSettingModel &model, QObject *parent = 0 );
       
    84     
       
    85     virtual ~BtSettingModel();
       
    86     
       
    87     // from QAbstractItemModel
       
    88     virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
       
    89     
       
    90     virtual QModelIndex parent( const QModelIndex &child ) const;
       
    91     
       
    92     virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
       
    93     
       
    94     virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
       
    95     
       
    96     virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
       
    97 
       
    98     virtual QMap<int, QVariant> itemData( const QModelIndex & index ) const;
       
    99     
       
   100 private:
       
   101     
       
   102     void emitDataChanged(int row, int column, void *parent );
       
   103     
       
   104     void emitDataChanged(const QModelIndex &top, const QModelIndex &bottom );
       
   105     
       
   106 private:
       
   107     QSharedPointer<BtLocalSetting> mLocalSetting;
       
   108     
       
   109     friend class BtLocalSetting;
       
   110 };
       
   111 
       
   112 #endif