taskswitcherapp/tsdevicedialogplugin/src/tsentrymodelitem.cpp
changeset 51 4785f57bf3d4
parent 39 4e8ebe173323
child 55 03646e8da489
equal deleted inserted replaced
46:23b5d6a29cce 51:4785f57bf3d4
    15 *
    15 *
    16 */
    16 */
    17 #include "tsentrymodelitem.h"
    17 #include "tsentrymodelitem.h"
    18 #include "tsdataroles.h"
    18 #include "tsdataroles.h"
    19 
    19 
       
    20 #include <tstask.h>
    20 #include <HbIcon>
    21 #include <HbIcon>
    21 
    22 
    22 /*!
    23 /*!
    23     \class TsEntryModelItem
    24     \class TsEntryModelItem
    24     \ingroup group_tsdevicedialogplugin
    25     \ingroup group_tsdevicedialogplugin
    25     \brief Item presenting running apps in the grid.
    26     \brief Item presenting running apps in the grid.
    26 */
    27 */
    27 
    28 
    28 /*!
    29 /*!
    29     Standard C++ constructor
    30     Standard C++ constructor
    30     /param service - reference to initialized Content Aresnal client instance
       
    31     /param entry - Content Arsenal data
    31     /param entry - Content Arsenal data
    32     /param size - icon size
       
    33 */
    32 */
    34 TsEntryModelItem::TsEntryModelItem(CaService& service, QSharedPointer<CaEntry> entry, QSize size)
    33 TsEntryModelItem::TsEntryModelItem(QSharedPointer<TsTask> entry)
    35     :
    34     :
    36     mService(service),
    35     mEntry(entry)
    37     mEntry(entry),
       
    38     mSize(size)
       
    39 {
    36 {
    40     //no implementation required
    37     //no implementation required
    41 }
    38 }
    42 
    39 
    43 /*!
    40 /*!
    54 */
    51 */
    55 QVariant TsEntryModelItem::data(int role) const
    52 QVariant TsEntryModelItem::data(int role) const
    56 {
    53 {
    57     switch (role) {
    54     switch (role) {
    58         case Qt::DisplayRole:
    55         case Qt::DisplayRole:
    59             return QVariant(mEntry->text());
    56             return QVariant(mEntry->name());
    60         case Qt::DecorationRole:
    57         case Qt::DecorationRole:
    61             return QVariant(mEntry->makeIcon(mSize));
    58             {
       
    59                 QPixmap icon = mEntry->icon();
       
    60                 if (icon.isNull()) {
       
    61                     return HbIcon("qtg_large_application");
       
    62                 } else {
       
    63                     return QVariant::fromValue<HbIcon>(HbIcon(icon));
       
    64                 }
       
    65             }
    62         case TsDataRoles::Closable:
    66         case TsDataRoles::Closable:
    63             return QVariant(closable());
    67             return QVariant(mEntry->isClosable());
    64         case TsDataRoles::Visible:
    68         case TsDataRoles::Visible:
    65             return QVariant(true);
    69             return QVariant(true);
    66         default:
    70         default:
    67             return QVariant(QVariant::Invalid);
    71             return QVariant(QVariant::Invalid);
    68     }
    72     }
    71 /*!
    75 /*!
    72     Close running application repesented by entry
    76     Close running application repesented by entry
    73 */
    77 */
    74 void TsEntryModelItem::close()
    78 void TsEntryModelItem::close()
    75 {
    79 {
    76     mService.executeCommand(mEntry->id(), QString("close"));
    80     mEntry->close();
    77 }
    81 }
    78 
    82 
    79 /*!
    83 /*!
    80     Open or move to foreground application repesented by entry
    84     Open or move to foreground application repesented by entry
    81 */
    85 */
    82 void TsEntryModelItem::open()
    86 void TsEntryModelItem::open()
    83 {
    87 {
    84     mService.executeCommand(mEntry->id(), QString("open"));
    88     mEntry->open();
    85 }
    89 }
    86 
    90 
    87 /*!
       
    88     Check if application represented by entry is running.
       
    89     /return true if application is running, false otherwise
       
    90 */
       
    91 bool TsEntryModelItem::closable() const
       
    92 {
       
    93     return (mEntry->flags().testFlag(RunningEntryFlag) &&
       
    94             !mEntry->flags().testFlag(SystemEntryFlag));
       
    95 }