homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp
changeset 69 87476091b3f5
parent 63 52b0f64eeb51
child 81 7dd137878ff8
equal deleted inserted replaced
67:474929a40a0f 69:87476091b3f5
    14 * Description:  Menu Application Library state.
    14 * Description:  Menu Application Library state.
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 #include <QDebug>
    18 #include <QDebug>
       
    19 #include <QScopedPointer>
    19 #include <HbDialog>
    20 #include <HbDialog>
    20 #include <HbDocumentLoader>
    21 #include <HbDocumentLoader>
    21 #include <HbLabel>
    22 #include <HbLabel>
    22 #include <HbAction>
    23 #include <HbAction>
    23 
    24 
    28 #include "canotifierfilter.h"
    29 #include "canotifierfilter.h"
    29 
    30 
    30 #include "hsviewappdetailsstate.h"
    31 #include "hsviewappdetailsstate.h"
    31 #include "hsmenuevent.h"
    32 #include "hsmenuevent.h"
    32 #include "hsmenuitemmodel.h"
    33 #include "hsmenuitemmodel.h"
       
    34 #include "hsmenuentryremovedhandler.h"
    33 
    35 
    34 static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME=
    36 static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME=
    35         "detailsDialogForJavaApplication";
    37         "detailsDialogForJavaApplication";
    36 
    38 
    37 /*!
    39 /*!
    38  Constructor.
    40  Constructor.
    39  /param parent Parent state.
    41  /param parent Parent state.
    40  */
    42  */
    41 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    43 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
    42     QState(parent), mDialog(0), mNotifier(0)
    44     QState(parent), mDialog(0)
    43 {
    45 {
    44     construct();
    46     construct();
    45 }
    47 }
    46 
    48 
    47 /*!
    49 /*!
    48  Destructor
    50  Destructor
    49  */
    51  */
    50 HsViewAppDetailsState::~HsViewAppDetailsState()
    52 HsViewAppDetailsState::~HsViewAppDetailsState()
    51 {
    53 {
    52     if (mDialog) {
    54     delete mDialog;
    53         delete mDialog;
       
    54     }
       
    55 }
    55 }
    56 
    56 
    57 /*!
    57 /*!
    58  Construction
    58  Construction
    59  */
    59  */
    90     QString appType = entry->attribute(swTypeKey());
    90     QString appType = entry->attribute(swTypeKey());
    91 
    91 
    92     
    92     
    93     //TODO: Should we display something In that case?
    93     //TODO: Should we display something In that case?
    94     if (detailMap.size() < 1){
    94     if (detailMap.size() < 1){
       
    95         stateExited();
    95         return;
    96         return;
    96     }
    97     }
    97     
    98     
    98     HbDocumentLoader loader;
    99     HbDocumentLoader loader;
    99     bool loadStatusOk = false;
   100     bool loadStatusOk = false;
   112 
   113 
   113     if (mDialog != NULL) {
   114     if (mDialog != NULL) {
   114         mDialog->setTimeout(HbPopup::NoTimeout);
   115         mDialog->setTimeout(HbPopup::NoTimeout);
   115         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   116         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
   116         mDialog->actions()[0]->setParent(mDialog);
   117         mDialog->actions()[0]->setParent(mDialog);
   117 
   118         
   118         subscribeForMemoryCardRemove(entryId);
       
   119       
       
   120         setFieldPresentation(CaSoftwareRegistry::componentNameKey(),
   119         setFieldPresentation(CaSoftwareRegistry::componentNameKey(),
   121             detailMap, loader);
   120             detailMap, loader);
   122         setFieldPresentation(CaSoftwareRegistry::componentVersionKey(),
   121         setFieldPresentation(CaSoftwareRegistry::componentVersionKey(),
   123             detailMap, loader);
   122             detailMap, loader);
   124         setFieldPresentation(CaSoftwareRegistry::componentVendorKey(),
   123         setFieldPresentation(CaSoftwareRegistry::componentVendorKey(),
   134             setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(),
   133             setFieldPresentation(CaSoftwareRegistry::componentDescriptionKey(),
   135                 detailMap, loader);
   134                 detailMap, loader);
   136             setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(),
   135             setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(),
   137                 detailMap, loader);
   136                 detailMap, loader);
   138         }
   137         }
   139         mDialog->open(this, SLOT(stateExited())); 
   138         
       
   139         QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
       
   140             new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit())));
       
   141         
       
   142         entryObserver.take()->setParent(mDialog);
       
   143         
       
   144         mDialog->open(this, SLOT(stateExited()));
       
   145     } else {
       
   146         stateExited();
   140     }
   147     }
   141     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");
   148     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");
   142 }
   149 }
   143 
   150 
   144 /*!
   151 /*!
   172  Slot invoked when a state is exited.
   179  Slot invoked when a state is exited.
   173  */
   180  */
   174 void HsViewAppDetailsState::stateExited()
   181 void HsViewAppDetailsState::stateExited()
   175 {
   182 {
   176     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited");
   183     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited");
   177     mDialog = NULL;
       
   178     emit exit();
   184     emit exit();
   179     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited");
   185     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited");
   180     qDebug("HsViewAppDetailsState::stateExited()");
   186     qDebug("HsViewAppDetailsState::stateExited()");
   181 }
   187 }
   182 
   188 
   186 void HsViewAppDetailsState::onExit(QEvent *event)
   192 void HsViewAppDetailsState::onExit(QEvent *event)
   187 {
   193 {
   188     QState::onExit(event);
   194     QState::onExit(event);
   189     // Close popups if App key was pressed or
   195     // Close popups if App key was pressed or
   190     // memory card removed
   196     // memory card removed
   191     if (mDialog) {
   197     if (mDialog != NULL) {
   192         mDialog->close();
   198         mDialog->close();
   193     }
   199         mDialog = NULL;
   194     mDialog = NULL;
   200     }
   195 }
   201 }
   196 
   202 
   197 /*!
       
   198  Subscribe for memory card remove.
       
   199  \param entryId: entry id.
       
   200  \retval void
       
   201  */
       
   202 void HsViewAppDetailsState::subscribeForMemoryCardRemove(int entryId)
       
   203 {
       
   204     CaNotifierFilter filter;
       
   205     QList<int> entryIds;
       
   206     entryIds.append(entryId);
       
   207     filter.setIds(entryIds);
       
   208     mNotifier = CaService::instance()->createNotifier(filter);
       
   209     mNotifier->setParent(this);
       
   210     connect(mNotifier,
       
   211             SIGNAL(entryChanged(CaEntry,ChangeType)),
       
   212             SIGNAL(exit()));
       
   213 }