taskswitcherapp/tsdevicedialogplugin/inc/tsmodel.h
changeset 62 341166945d65
parent 57 2e2dc3d30ca8
child 63 52b0f64eeb51
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
     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: tsmodel.h
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef TSMODEL_H
       
    19 #define TSMODEL_H
       
    20 
       
    21 #include <QAbstractItemModel>
       
    22 #include <QList>
       
    23 #include <QSize>
       
    24 #include <QSharedPointer>
       
    25 #include <tstaskmonitor.h>
       
    26 #ifdef Q_OS_SYMBIAN
       
    27 #include <apgcli.h>
       
    28 #endif
       
    29 
       
    30 class TsTaskMonitor;
       
    31 class ActivityManager;
       
    32 class CaNotifier;
       
    33 class TsModelItem;
       
    34 
       
    35 class TsModel : public QAbstractListModel
       
    36 {
       
    37     Q_OBJECT
       
    38 
       
    39 public:
       
    40     explicit TsModel(TsTaskMonitor &applicationSrv,
       
    41                      QObject &activitySrv,
       
    42                      QObject *parent = 0);
       
    43     ~TsModel();
       
    44 
       
    45     int rowCount(const QModelIndex &parent = QModelIndex()) const;
       
    46     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
       
    47     int maxRowCount()const;
       
    48 
       
    49 public slots:
       
    50     void openApplication(const QModelIndex &index);
       
    51     void closeApplication(const QModelIndex &index);
       
    52     void updateModel();
       
    53     void entryChanged(TsModelItem *);
       
    54 private:
       
    55     TsModelItem *entry(const QModelIndex &index) const;
       
    56     void getApplications();
       
    57     void getActivities();
       
    58     void prepareActivityEntry(QVariantHash &activity);
       
    59     QString getApplicationName(int id);
       
    60 
       
    61 private:
       
    62     /*
       
    63      * List containing result
       
    64      */
       
    65     QList<TsModelItem *> mEntries;
       
    66 
       
    67     TsTaskMonitor &mApplicationService;
       
    68 
       
    69     /*
       
    70      * Activity Service
       
    71      */
       
    72     QObject &mActivityService;
       
    73     
       
    74 #ifdef Q_OS_SYMBIAN
       
    75     RApaLsSession iAppArcSession;
       
    76 #endif
       
    77 
       
    78     /*
       
    79      * Icon size in model
       
    80      */
       
    81     QSize mSize;
       
    82     
       
    83     /*
       
    84      * Maximum number of items (only for running apps + activities)
       
    85      */ 
       
    86     int mMaxItems;
       
    87 };
       
    88 
       
    89 #endif // TSMODEL_H