homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappsettingsstate.cpp
changeset 46 23b5d6a29cce
parent 39 4e8ebe173323
child 60 30f14686fb04
equal deleted inserted replaced
39:4e8ebe173323 46:23b5d6a29cce
    31 #include "canotifierfilter.h"
    31 #include "canotifierfilter.h"
    32 
    32 
    33 #include "hsmenuservice.h"
    33 #include "hsmenuservice.h"
    34 
    34 
    35 /*!
    35 /*!
    36  \class HsCollectionNameDialog
    36  \class HsViewAppSettingsState
    37  \ingroup HsViewAppSettingsState
    37  \ingroup HsViewAppSettingsState
    38  \brief State for showing Application Settings HbView from provided plugin
    38  \brief State for showing Application Settings HbView from provided plugin
       
    39  */
       
    40 
       
    41 /*!
       
    42  \var HsViewAppSettingsState::mView
       
    43  View.
       
    44  Owned.
       
    45  */
       
    46 
       
    47 /*!
       
    48  \var HsViewAppSettingsState::mPreviousView
       
    49  Previous view.
       
    50  Not owned.
       
    51  */
       
    52 
       
    53 /*!
       
    54  \var HsViewAppSettingsState::mActionConfirm
       
    55  Confirm action. Owned.
    39  */
    56  */
    40 
    57 
    41 /*!
    58 /*!
    42  Constructor
    59  Constructor
    43  \param parent: parent state
    60  \param parent: parent state
    52         
    69         
    53 {
    70 {
    54         construct();
    71         construct();
    55 }
    72 }
    56 
    73 
    57 // ---------------------------------------------------------------------------
    74 /*!
    58 // ---------------------------------------------------------------------------
    75  Constructs contained objects.
    59 //
    76  */
    60 void HsViewAppSettingsState::construct()
    77 void HsViewAppSettingsState::construct()
    61 {
    78 {
    62     setObjectName(this->parent()->objectName()
    79     setObjectName(this->parent()->objectName()
    63                   + "/ViewAppSettingsState");
    80                   + "/ViewAppSettingsState");
    64 }
    81 }
    86     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
   103     HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
    87     QVariantMap data = menuEvent->data();
   104     QVariantMap data = menuEvent->data();
    88     
   105     
    89     const int entryId = data.value(itemIdKey()).toInt();   
   106     const int entryId = data.value(itemIdKey()).toInt();   
    90     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);    
   107     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);    
    91     
       
    92     if(mView)
       
    93         {
       
    94     
       
    95         delete mActionConfirm;  
       
    96         mActionConfirm = NULL;    
       
    97     
       
    98         delete mView;  
       
    99         mView = NULL;
       
   100 
       
   101         }
       
   102     
   108     
   103     QString pluginPath(entry->attribute(appSettingsPlugin()));
   109     QString pluginPath(entry->attribute(appSettingsPlugin()));
   104     QPluginLoader loader(pluginPath);
   110     QPluginLoader loader(pluginPath);
   105     mView = qobject_cast<HbView *>(loader.instance()); 
   111     mView = qobject_cast<HbView *>(loader.instance()); 
   106     
   112     
   131 
   137 
   132 
   138 
   133 #ifdef COVERAGE_MEASUREMENT
   139 #ifdef COVERAGE_MEASUREMENT
   134 #pragma CTC SKIP
   140 #pragma CTC SKIP
   135 #endif //COVERAGE_MEASUREMENT
   141 #endif //COVERAGE_MEASUREMENT
       
   142 /*!
       
   143  Returns pointer to tha main window.
       
   144  \return Pointer to the main window.
       
   145  */
   136 HbMainWindow *HsViewAppSettingsState::mainWindow() const
   146 HbMainWindow *HsViewAppSettingsState::mainWindow() const
   137 {
   147 {
   138     return HbInstance::instance()->allMainWindows().value(0);
   148     return HbInstance::instance()->allMainWindows().value(0);
   139 }
   149 }
   140 #ifdef COVERAGE_MEASUREMENT
   150 #ifdef COVERAGE_MEASUREMENT
   143 
   153 
   144 
   154 
   145 #ifdef COVERAGE_MEASUREMENT
   155 #ifdef COVERAGE_MEASUREMENT
   146 #pragma CTC SKIP
   156 #pragma CTC SKIP
   147 #endif //COVERAGE_MEASUREMENT
   157 #endif //COVERAGE_MEASUREMENT
       
   158 /*!
       
   159  Invoked when plugin view exits
       
   160  */
   148 void HsViewAppSettingsState::settingsDone()
   161 void HsViewAppSettingsState::settingsDone()
   149 {
   162 {
   150     // Remove mView from main window and restore previous view.
   163     emit exit();
   151     HbMainWindow *hbMainWindow = mainWindow();
       
   152     hbMainWindow->setCurrentView(mPreviousView);
       
   153     hbMainWindow->removeView(mView);
       
   154     delete mActionConfirm;
       
   155     mActionConfirm = NULL;
       
   156     delete mView;
       
   157     mView = NULL;
       
   158 }
   164 }
   159 #ifdef COVERAGE_MEASUREMENT
   165 #ifdef COVERAGE_MEASUREMENT
   160 #pragma CTC ENDSKIP
   166 #pragma CTC ENDSKIP
   161 #endif //COVERAGE_MEASUREMENT
   167 #endif //COVERAGE_MEASUREMENT
   162 
   168 
   176     connect(mNotifier,
   182     connect(mNotifier,
   177             SIGNAL(entryChanged(CaEntry,ChangeType)),
   183             SIGNAL(entryChanged(CaEntry,ChangeType)),
   178             SLOT(settingsDone()));
   184             SLOT(settingsDone()));
   179 }
   185 }
   180 
   186 
       
   187 void HsViewAppSettingsState::onExit(QEvent *event)
       
   188 {
       
   189     
       
   190     QState::onExit(event);
       
   191     // Remove mView from main window and restore previous view.
       
   192     HbMainWindow *hbMainWindow = mainWindow();
       
   193     hbMainWindow->setCurrentView(mPreviousView);
       
   194     hbMainWindow->removeView(mView);
       
   195     disconnect(mNotifier,
       
   196                SIGNAL(entryChanged(CaEntry,ChangeType)),
       
   197                this,
       
   198                SLOT(settingsDone()));
       
   199     delete mNotifier;
       
   200     mNotifier = NULL;
       
   201     
       
   202     delete mActionConfirm;
       
   203     mActionConfirm = NULL;
       
   204     delete mView;
       
   205     mView = NULL;
       
   206 }