homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp
changeset 62 341166945d65
parent 55 03646e8da489
child 63 52b0f64eeb51
child 77 4b195f3bea29
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
    29 
    29 
    30 #include "hsviewappdetailsstate.h"
    30 #include "hsviewappdetailsstate.h"
    31 #include "hsmenuevent.h"
    31 #include "hsmenuevent.h"
    32 #include "hsmenuitemmodel.h"
    32 #include "hsmenuitemmodel.h"
    33 
    33 
       
    34 
       
    35 /*!
       
    36  Constructor.
       
    37  @param parent Parent state.
       
    38  */
    34 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    39 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    35     QState(parent), mDialog(0), mNotifier(0)
    40     QState(parent), mDialog(0), mNotifier(0)
    36 {
    41 {
    37     construct();
    42     construct();
    38 }
    43 }
    39 
    44 
       
    45 /*!
       
    46  Destructor
       
    47  */
    40 HsViewAppDetailsState::~HsViewAppDetailsState()
    48 HsViewAppDetailsState::~HsViewAppDetailsState()
    41 {
    49 {
    42     if (mDialog) {
    50     if (mDialog) {
    43         delete mDialog;
    51         delete mDialog;
    44     }
    52     }
    45 }
    53 }
    46 
    54 
       
    55 /*!
       
    56  Construction
       
    57  */
    47 void HsViewAppDetailsState::construct()
    58 void HsViewAppDetailsState::construct()
    48 {
    59 {
    49     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct");
    60     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct");
    50     setObjectName(this->parent()->objectName()
    61         
    51                   + "/ViewAppDetailsState");
    62     setObjectName("/ViewAppDetailsState");
       
    63     if (this->parent()) {
       
    64         setObjectName(this->parent()->objectName() + objectName());
       
    65     }
    52     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct");
    66     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct");
    53 }
    67 }
    54 
    68 
       
    69 /*!
       
    70  Invoked on entering state
       
    71  */
    55 void HsViewAppDetailsState::onEntry(QEvent *event)
    72 void HsViewAppDetailsState::onEntry(QEvent *event)
    56 {
    73 {
    57     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry");
    74     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry");
    58     QState::onEntry(event);
    75     QState::onEntry(event);
    59     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    76     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    60     QVariantMap data = menuEvent->data();
    77     QVariantMap data = menuEvent->data();
    61     
    78     
    62     const int entryId = data.value(itemIdKey()).toInt();
    79     const int entryId = data.value(itemIdKey()).toInt();
    63     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);
    80     QSharedPointer<const CaEntry> entry 
    64     const int componentId = entry->attribute(componentIdAttributeName()).toInt();
    81         = CaService::instance()->getEntry(entryId);
       
    82     const int componentId = entry->attribute(
       
    83         componentIdAttributeName()).toInt();
    65     
    84     
    66     QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
    85     QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
    67     CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
    86     CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
    68     
    87     
    69     HbDocumentLoader loader;
    88     HbDocumentLoader loader;
    70     bool loadStatusOk = false;
    89     bool loadStatusOk = false;
    71     mObjectList = 
    90     mObjectList = loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk);
    72         loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk);
    91     Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT,
    73     Q_ASSERT_X(loadStatusOk,
       
    74         HS_DETAILS_DIALOG_LAYOUT,
       
    75            "Error while loading docml file.");
    92            "Error while loading docml file.");
    76 
    93 
    77     mDialog = qobject_cast<HbDialog*>(loader.findWidget(HS_DETAILS_DIALOG_NAME));
    94     mDialog = qobject_cast<HbDialog*>(
       
    95         loader.findWidget(HS_DETAILS_DIALOG_NAME));
    78     mDialog->actions()[0]->setParent(mDialog);
    96     mDialog->actions()[0]->setParent(mDialog);
    79     
    97     
    80     subscribeForMemoryCardRemove(entryId);
    98     subscribeForMemoryCardRemove(entryId);
    81     
    99     
    82     HbLabel* nameLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentNameKey()));
   100     HbLabel* nameLabel = qobject_cast<HbLabel*>(
    83     HbLabel* versionLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentVersionKey()));
   101         loader.findWidget(CaSoftwareRegistry::componentNameKey()));
    84     HbLabel* supplierLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentVendorKey()));
   102     HbLabel* versionLabel = qobject_cast<HbLabel*>(
    85     HbLabel* memoryLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentDriveInfoKey()));
   103         loader.findWidget(CaSoftwareRegistry::componentVersionKey()));
    86     HbLabel* sizeLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentSizeKey()));
   104     HbLabel* supplierLabel = qobject_cast<HbLabel*>(
    87     HbLabel* typeLabel = qobject_cast<HbLabel*>(loader.findWidget(CaSoftwareRegistry::componentTypeKey()));    
   105         loader.findWidget(CaSoftwareRegistry::componentVendorKey()));
       
   106     HbLabel* memoryLabel = qobject_cast<HbLabel*>(
       
   107         loader.findWidget(CaSoftwareRegistry::componentDriveInfoKey()));
       
   108     HbLabel* sizeLabel = qobject_cast<HbLabel*>(
       
   109         loader.findWidget(CaSoftwareRegistry::componentSizeKey()));
       
   110     HbLabel* typeLabel = qobject_cast<HbLabel*>(
       
   111         loader.findWidget(CaSoftwareRegistry::componentTypeKey()));    
    88     
   112     
    89     nameLabel->setPlainText(detailMap[CaSoftwareRegistry::componentNameKey()]);
   113     nameLabel->setPlainText(
    90     versionLabel->setPlainText(detailMap[CaSoftwareRegistry::componentVersionKey()]);
   114         detailMap[CaSoftwareRegistry::componentNameKey()]);
    91     supplierLabel->setPlainText(detailMap[CaSoftwareRegistry::componentVendorKey()]);
   115     versionLabel->setPlainText(
    92     memoryLabel->setPlainText(detailMap[CaSoftwareRegistry::componentDriveInfoKey()]);
   116         detailMap[CaSoftwareRegistry::componentVersionKey()]);
    93     sizeLabel->setPlainText(detailMap[CaSoftwareRegistry::componentSizeKey()]);
   117     supplierLabel->setPlainText(
    94     typeLabel->setPlainText(detailMap[CaSoftwareRegistry::componentTypeKey()]);
   118         detailMap[CaSoftwareRegistry::componentVendorKey()]);
       
   119     memoryLabel->setPlainText(
       
   120             detailMap[CaSoftwareRegistry::componentDriveInfoKey()]);
       
   121     sizeLabel->setPlainText(
       
   122         detailMap[CaSoftwareRegistry::componentSizeKey()]);
       
   123 
       
   124     typeLabel->setPlainText(
       
   125         detailMap[CaSoftwareRegistry::componentTypeKey()]);
    95     
   126     
    96     if (mDialog != NULL) {
   127     if (mDialog != NULL) {
    97         mDialog->setTimeout(HbPopup::NoTimeout);
   128         mDialog->setTimeout(HbPopup::NoTimeout);
    98         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   129         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
    99         mDialog->open(this, SLOT(stateExited())); 
   130         mDialog->open(this, SLOT(stateExited())); 
   100     }
   131     }
   101     
       
   102     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");    
   132     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");    
   103 }
   133 }
   104 #ifdef COVERAGE_MEASUREMENT
   134 
   105 #pragma CTC SKIP
       
   106 #endif //COVERAGE_MEASUREMENT
       
   107 /*!
   135 /*!
   108  Slot invoked when a state is exited.
   136  Slot invoked when a state is exited.
   109  */
   137  */
   110 void HsViewAppDetailsState::stateExited()
   138 void HsViewAppDetailsState::stateExited()
   111 {
   139 {
   113     mDialog = NULL;
   141     mDialog = NULL;
   114     emit exit();
   142     emit exit();
   115     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited");
   143     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited");
   116     qDebug("HsViewAppDetailsState::stateExited()");
   144     qDebug("HsViewAppDetailsState::stateExited()");
   117 }
   145 }
   118 #ifdef COVERAGE_MEASUREMENT
       
   119 #pragma CTC ENDSKIP
       
   120 #endif //COVERAGE_MEASUREMENT
       
   121 
   146 
   122 
   147 /*!
   123 #ifdef COVERAGE_MEASUREMENT
   148  Invoked on exiting state
   124 #pragma CTC SKIP
   149  */
   125 #endif //COVERAGE_MEASUREMENT
       
   126 void HsViewAppDetailsState::onExit(QEvent *event)
   150 void HsViewAppDetailsState::onExit(QEvent *event)
   127 {
   151 {
   128     QState::onExit(event);
   152     QState::onExit(event);
   129     // Close popups if App key was pressed
   153     // Close popups if App key was pressed or
       
   154     // memory card removed
   130     if (mDialog) {
   155     if (mDialog) {
   131         mDialog->close();
   156         mDialog->close();
   132     }
   157     }
   133     mDialog = NULL;
   158     mDialog = NULL;
   134 }
   159 }
   135 #ifdef COVERAGE_MEASUREMENT
       
   136 #pragma CTC ENDSKIP
       
   137 #endif //COVERAGE_MEASUREMENT
       
   138 
   160 
   139 /*!
   161 /*!
   140  Subscribe for memory card remove.
   162  Subscribe for memory card remove.
   141  \param entryId: entry id.
   163  \param entryId: entry id.
   142  \retval void
   164  \retval void
   149     filter.setIds(entryIds);
   171     filter.setIds(entryIds);
   150     mNotifier = CaService::instance()->createNotifier(filter);
   172     mNotifier = CaService::instance()->createNotifier(filter);
   151     mNotifier->setParent(this);
   173     mNotifier->setParent(this);
   152     connect(mNotifier,
   174     connect(mNotifier,
   153             SIGNAL(entryChanged(CaEntry,ChangeType)),
   175             SIGNAL(entryChanged(CaEntry,ChangeType)),
   154             SLOT(memoryCardRemoved()));
   176             SIGNAL(exit()));
   155 }
   177 }
   156 
       
   157 #ifdef COVERAGE_MEASUREMENT
       
   158 #pragma CTC SKIP
       
   159 #endif //COVERAGE_MEASUREMENT
       
   160 /*!
       
   161  Memory card with instaled widget was removed.
       
   162  \retval void
       
   163  */
       
   164 void HsViewAppDetailsState::memoryCardRemoved()
       
   165 {
       
   166     if (mDialog) {
       
   167     mDialog->close();
       
   168     }
       
   169     // exit not needed, it is called after dialog closed
       
   170 
       
   171 }
       
   172 #ifdef COVERAGE_MEASUREMENT
       
   173 #pragma CTC ENDSKIP
       
   174 #endif //COVERAGE_MEASUREMENT
       
   175