homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
equal deleted inserted replaced
62:341166945d65 63:52b0f64eeb51
    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 static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME=
       
    35         "detailsDialogForJavaApplication";
    34 
    36 
    35 /*!
    37 /*!
    36  Constructor.
    38  Constructor.
    37  @param parent Parent state.
    39  /param parent Parent state.
    38  */
    40  */
    39 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    41 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    40     QState(parent), mDialog(0), mNotifier(0)
    42     QState(parent), mDialog(0), mNotifier(0)
    41 {
    43 {
    42     construct();
    44     construct();
    56  Construction
    58  Construction
    57  */
    59  */
    58 void HsViewAppDetailsState::construct()
    60 void HsViewAppDetailsState::construct()
    59 {
    61 {
    60     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct");
    62     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::construct");
    61         
    63 
    62     setObjectName("/ViewAppDetailsState");
    64     setObjectName("/ViewAppDetailsState");
    63     if (this->parent()) {
    65     if (this->parent()) {
    64         setObjectName(this->parent()->objectName() + objectName());
    66         setObjectName(this->parent()->objectName() + objectName());
    65     }
    67     }
    66     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct");
    68     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::construct");
    73 {
    75 {
    74     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry");
    76     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::onEntry");
    75     QState::onEntry(event);
    77     QState::onEntry(event);
    76     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    78     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    77     QVariantMap data = menuEvent->data();
    79     QVariantMap data = menuEvent->data();
    78     
    80 
    79     const int entryId = data.value(itemIdKey()).toInt();
    81     const int entryId = data.value(itemIdKey()).toInt();
    80     QSharedPointer<const CaEntry> entry 
    82     QSharedPointer<const CaEntry> entry
    81         = CaService::instance()->getEntry(entryId);
    83         = CaService::instance()->getEntry(entryId);
    82     const int componentId = entry->attribute(
    84     const int componentId = entry->attribute(
    83         componentIdAttributeName()).toInt();
    85         componentIdAttributeName()).toInt();
    84     
    86     
    85     QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
    87     QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
    86     CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
    88     CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
       
    89 
       
    90     QString appType = entry->attribute(swTypeKey());
       
    91 
       
    92     
       
    93     //TODO: Should we display something In that case?
       
    94     if (detailMap.size() < 1){
       
    95         return;
       
    96     }
    87     
    97     
    88     HbDocumentLoader loader;
    98     HbDocumentLoader loader;
    89     bool loadStatusOk = false;
    99     bool loadStatusOk = false;
    90     mObjectList = loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk);
   100     loader.load(HS_DETAILS_DIALOG_LAYOUT, &loadStatusOk);
    91     Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT,
   101     Q_ASSERT_X(loadStatusOk, HS_DETAILS_DIALOG_LAYOUT,
    92            "Error while loading docml file.");
   102            "Error while loading docml file.");
    93 
   103 
       
   104     if (!appType.compare(javaSwType())) {
       
   105         QString section = QString(HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME);
       
   106         loader.load(HS_DETAILS_DIALOG_LAYOUT,
       
   107                                   section, &loadStatusOk);
       
   108     }
       
   109 
    94     mDialog = qobject_cast<HbDialog*>(
   110     mDialog = qobject_cast<HbDialog*>(
    95         loader.findWidget(HS_DETAILS_DIALOG_NAME));
   111         loader.findWidget(HS_DETAILS_DIALOG_NAME));
    96     mDialog->actions()[0]->setParent(mDialog);
   112 
    97     
       
    98     subscribeForMemoryCardRemove(entryId);
       
    99     
       
   100     HbLabel* nameLabel = qobject_cast<HbLabel*>(
       
   101         loader.findWidget(CaSoftwareRegistry::componentNameKey()));
       
   102     HbLabel* versionLabel = qobject_cast<HbLabel*>(
       
   103         loader.findWidget(CaSoftwareRegistry::componentVersionKey()));
       
   104     HbLabel* supplierLabel = qobject_cast<HbLabel*>(
       
   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()));    
       
   112     
       
   113     nameLabel->setPlainText(
       
   114         detailMap[CaSoftwareRegistry::componentNameKey()]);
       
   115     versionLabel->setPlainText(
       
   116         detailMap[CaSoftwareRegistry::componentVersionKey()]);
       
   117     supplierLabel->setPlainText(
       
   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()]);
       
   126     
       
   127     if (mDialog != NULL) {
   113     if (mDialog != NULL) {
   128         mDialog->setTimeout(HbPopup::NoTimeout);
   114         mDialog->setTimeout(HbPopup::NoTimeout);
   129         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   115         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
       
   116         mDialog->actions()[0]->setParent(mDialog);
       
   117 
       
   118         subscribeForMemoryCardRemove(entryId);
       
   119       
       
   120         setFieldPresentation(CaSoftwareRegistry::componentNameKey(),
       
   121             detailMap, loader);
       
   122         setFieldPresentation(CaSoftwareRegistry::componentVersionKey(),
       
   123             detailMap, loader);
       
   124         setFieldPresentation(CaSoftwareRegistry::componentVendorKey(),
       
   125             detailMap, loader);
       
   126         setFieldPresentation(CaSoftwareRegistry::componentDriveInfoKey(),
       
   127             detailMap, loader);
       
   128         setFieldPresentation(CaSoftwareRegistry::componentSizeKey(),
       
   129             detailMap, loader);
       
   130         setFieldPresentation(CaSoftwareRegistry::componentTypeKey(),
       
   131             detailMap, loader);
       
   132 
       
   133         if (!appType.compare(javaSwType())) {
       
   134             setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(),
       
   135                 detailMap, loader);
       
   136             setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(),
       
   137                 detailMap, loader);
       
   138         }
   130         mDialog->open(this, SLOT(stateExited())); 
   139         mDialog->open(this, SLOT(stateExited())); 
   131     }
   140     }
   132     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");    
   141     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");
       
   142 }
       
   143 
       
   144 /*!
       
   145  Extracting label from loader and set content of data field.
       
   146  Hide label if the is no data to display.
       
   147  \param key detail key.
       
   148  \param detailMap detail map.
       
   149  \param loader session to document loader
       
   150  \retval void
       
   151  */
       
   152 void HsViewAppDetailsState::setFieldPresentation(QString key,
       
   153         CaSoftwareRegistry::DetailMap &detailMap,
       
   154         HbDocumentLoader &loader)
       
   155 {
       
   156     HbLabel* dataLabel = qobject_cast<HbLabel*>(
       
   157                 loader.findWidget(key));
       
   158     QString data = detailMap[key];
       
   159     if (data.isEmpty()) {
       
   160         dataLabel->setVisible(false);
       
   161         dataLabel->setMaximumHeight(0);
       
   162         HbLabel* titleLabel = qobject_cast<HbLabel*>(
       
   163             loader.findWidget(QString("_") + key));
       
   164         titleLabel->setVisible(false);
       
   165         titleLabel->setMaximumHeight(0);
       
   166     } else {
       
   167         dataLabel->setPlainText(data);
       
   168     }
   133 }
   169 }
   134 
   170 
   135 /*!
   171 /*!
   136  Slot invoked when a state is exited.
   172  Slot invoked when a state is exited.
   137  */
   173  */