homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappsettingsstate.cpp
changeset 69 87476091b3f5
parent 63 52b0f64eeb51
child 81 7dd137878ff8
equal deleted inserted replaced
67:474929a40a0f 69:87476091b3f5
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Menu Application Library state.
    14 * Description:  Menu Application Library state.
    15  *
    15  *
    16 */
    16 */
    17 
    17 #include <QScopedPointer>
    18 #include <hbmainwindow.h>
    18 #include <hbmainwindow.h>
    19 #include <hbview.h>
    19 #include <hbview.h>
    20 #include <hbinstance.h>
    20 #include <hbinstance.h>
    21 #include <qstatemachine.h>
    21 #include <qstatemachine.h>
    22 #include <hbaction.h>
    22 #include <hbaction.h>
    24 
    24 
    25 #include "hsdomainmodel_global.h"
    25 #include "hsdomainmodel_global.h"
    26 #include "hsapp_defs.h"
    26 #include "hsapp_defs.h"
    27 #include "hsmenuevent.h"
    27 #include "hsmenuevent.h"
    28 #include "hsviewappsettingsstate.h"
    28 #include "hsviewappsettingsstate.h"
       
    29 #include "hsmenuentryremovedhandler.h"
    29 #include "caentry.h"
    30 #include "caentry.h"
    30 #include "canotifier.h"
    31 #include "canotifier.h"
    31 #include "canotifierfilter.h"
    32 #include "canotifierfilter.h"
    32 
    33 
    33 #include "hsmenuservice.h"
    34 #include "hsmenuservice.h"
    62  */
    63  */
    63 HsViewAppSettingsState::HsViewAppSettingsState(QState *parent) :
    64 HsViewAppSettingsState::HsViewAppSettingsState(QState *parent) :
    64         QState(parent),
    65         QState(parent),
    65         mView(0), 
    66         mView(0), 
    66         mPreviousView(0), 
    67         mPreviousView(0), 
    67         mActionConfirm(0),
    68         mActionConfirm(0)
    68         mNotifier(0)
       
    69         
       
    70 {
    69 {
    71     construct();
    70     construct();
    72 }
    71 }
    73 
    72 
    74 /*!
    73 /*!
    85 /*!
    84 /*!
    86  Destructor.
    85  Destructor.
    87  */
    86  */
    88 HsViewAppSettingsState::~HsViewAppSettingsState()
    87 HsViewAppSettingsState::~HsViewAppSettingsState()
    89 {
    88 {
    90     if (mNotifier) {
       
    91         delete mNotifier;
       
    92     }    
       
    93 }
    89 }
    94 
    90 
    95 /*!
    91 /*!
    96  onEntry method invoked on entering the state
    92  onEntry method invoked on entering the state
    97  \param event: event
    93  \param event: event
   107     
   103     
   108     const int entryId = data.value(itemIdKey()).toInt();   
   104     const int entryId = data.value(itemIdKey()).toInt();   
   109     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);    
   105     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);    
   110     
   106     
   111     QString pluginPath;
   107     QString pluginPath;
   112     pluginPath = pluginPath.append("/resource/qt/plugins/appsettings/").append(entry->attribute(appSettingsPlugin())).append(".qtplugin");
   108     pluginPath = pluginPath.append("/resource/qt/plugins/appsettings/")
       
   109         .append(entry->attribute(appSettingsPlugin())).append(".qtplugin");
   113     QPluginLoader loader(pluginPath);
   110     QPluginLoader loader(pluginPath);
   114     mView = qobject_cast<HbView *>(loader.instance()); 
   111     mView = qobject_cast<HbView *>(loader.instance()); 
   115     
   112     
   116     mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView);
   113     mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView);
   117     connect(mActionConfirm, SIGNAL(triggered()),SLOT(settingsDone()));
   114     connect(mActionConfirm, SIGNAL(triggered()), SIGNAL(exit()));
   118     
   115     
   119     if (mView) {    
   116     if (mView) {    
   120         subscribeForMemoryCardRemove(entryId);
   117         QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
       
   118             new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit())));
       
   119         
       
   120         entryObserver.take()->setParent(mView);
       
   121         
   121         QObject::connect(this, SIGNAL(initialize(QString)), mView, SLOT(initialize(QString)));        
   122         QObject::connect(this, SIGNAL(initialize(QString)), mView, SLOT(initialize(QString)));        
   122         mView->setParent(this);
   123         mView->setParent(this);
   123         emit initialize(entry->attribute(applicationUidEntryKey()));        
   124         emit initialize(entry->attribute(applicationUidEntryKey()));        
   124         // Add View to main window
   125         // Add View to main window
   125         HbMainWindow *hbMainWindow = mainWindow();
   126         HbMainWindow *hbMainWindow = mainWindow();
   152 #ifdef COVERAGE_MEASUREMENT
   153 #ifdef COVERAGE_MEASUREMENT
   153 #pragma CTC ENDSKIP
   154 #pragma CTC ENDSKIP
   154 #endif //COVERAGE_MEASUREMENT
   155 #endif //COVERAGE_MEASUREMENT
   155 
   156 
   156 
   157 
   157 /*!
       
   158  Invoked when plugin view exits
       
   159  */
       
   160 void HsViewAppSettingsState::settingsDone()
       
   161 {
       
   162     emit exit();
       
   163 }
       
   164 
       
   165 /*!
       
   166  Subscribe for memory card remove.
       
   167  \param entryId: entry id.
       
   168  \retval void
       
   169  */
       
   170 void HsViewAppSettingsState::subscribeForMemoryCardRemove(int entryId)
       
   171 {
       
   172     CaNotifierFilter filter;
       
   173     QList<int> entryIds;
       
   174     entryIds.append(entryId);
       
   175     filter.setIds(entryIds);
       
   176     mNotifier = CaService::instance()->createNotifier(filter);
       
   177     mNotifier->setParent(this);
       
   178     connect(mNotifier,
       
   179             SIGNAL(entryChanged(CaEntry,ChangeType)),
       
   180             SLOT(settingsDone()));
       
   181 }
       
   182 
       
   183 void HsViewAppSettingsState::onExit(QEvent *event)
   158 void HsViewAppSettingsState::onExit(QEvent *event)
   184 {
   159 {
   185     
   160     
   186     QState::onExit(event);
   161     QState::onExit(event);
   187     // Remove mView from main window and restore previous view.
   162     // Remove mView from main window and restore previous view.
   188     HbMainWindow *hbMainWindow = mainWindow();
   163     HbMainWindow *hbMainWindow = mainWindow();
   189     hbMainWindow->setCurrentView(mPreviousView);
   164     hbMainWindow->setCurrentView(mPreviousView);
   190     hbMainWindow->removeView(mView);
   165     hbMainWindow->removeView(mView);
   191     disconnect(mNotifier,
   166 
   192                SIGNAL(entryChanged(CaEntry,ChangeType)),
       
   193                this,
       
   194                SLOT(settingsDone()));
       
   195     delete mNotifier;
       
   196     mNotifier = NULL;
       
   197     
   167     
   198     delete mActionConfirm;
   168     delete mActionConfirm;
   199     mActionConfirm = NULL;
   169     mActionConfirm = NULL;
   200     delete mView;
   170     delete mView;
   201     mView = NULL;
   171     mView = NULL;