stateproviders/ftustateprovider/src/ftuwizardmenustate.cpp
changeset 2 66c26770985f
parent 0 c464cd7e2753
child 5 1c5fe9af5d39
equal deleted inserted replaced
0:c464cd7e2753 2:66c26770985f
    24 #include <hbview.h>
    24 #include <hbview.h>
    25 #include <hblabel.h>
    25 #include <hblabel.h>
    26 #include <hbicon.h>
    26 #include <hbicon.h>
    27 #include <hbinstance.h>
    27 #include <hbinstance.h>
    28 #include <hblistview.h>
    28 #include <hblistview.h>
    29 
       
    30 #include <hbdocumentloader.h>
    29 #include <hbdocumentloader.h>
    31 
    30 
    32 #include <QStandardItemModel>
    31 #include <QStandardItemModel>
    33 #include <QDate>
    32 #include <QDate>
    34 #include <hbaction.h>
    33 
       
    34 #include <xqsettingsmanager.h>
       
    35 
       
    36 #include "ftustatecenrephandler.h"
    35 
    37 
    36 const int progressCompelete = 100;
    38 const int progressCompelete = 100;
    37 const char* emptyLine = " ";
    39 const char* emptyLine = " ";
    38 
    40 
    39 #define WMS_LOG qDebug() << "ftu:FtuWizardMenuState"
    41 #define WMS_LOG qDebug() << "ftu:FtuWizardMenuState"
    40 
    42 
    41 const char *FTUSTATEPROVIDER_DOCML = ":/xml/ftustateprovider.docml";
    43 const char *FTUSTATEPROVIDER_DOCML = ":/xml/ftustateprovider.docml";
    42 const char *TOC_VIEW = "tocView";
    44 const char *TOC_VIEW = "tocView";
    43 const char *TOC_INFOTEXT_LABEL = "tocInfoTextLabel";
    45 const char *TOC_INFOTEXT_LABEL = "tocInfoTextLabel";
    44 const char *TOC_LIST_VIEW = "tocListView";
    46 const char *TOC_LIST_VIEW = "tocListView";
    45 
       
    46 
    47 
    47 
    48 
    48 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    49 // FtuWizardMenuState::FtuWizardMenuState
    50 // FtuWizardMenuState::FtuWizardMenuState
    50 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    54     mMainWindow(NULL),
    55     mMainWindow(NULL),
    55     mTocView(NULL),
    56     mTocView(NULL),
    56     mInfoText(NULL),
    57     mInfoText(NULL),
    57     mListView(NULL),
    58     mListView(NULL),
    58 	mDocumentLoader(NULL),
    59 	mDocumentLoader(NULL),
    59     mModel(NULL)   
    60     mModel(NULL)
    60 {
    61 {
    61     mMainWindow = hbInstance->allMainWindows().at(0);
    62     mMainWindow = hbInstance->allMainWindows().at(0);
    62     mModel = new QStandardItemModel(this);
    63     mModel = new QStandardItemModel(this);
       
    64     
       
    65     //TODO Read number of wizards supported and init the following list
       
    66     //mCompletedWizardList << false << false << false << false << false <<false;
    63 
    67 
    64 	mDocumentLoader = new HbDocumentLoader();
    68 	mDocumentLoader = new HbDocumentLoader();
    65 	bool ok = false;
    69 	bool ok = false;
    66 	mDocumentLoader->load(FTUSTATEPROVIDER_DOCML, &ok);
    70 	mDocumentLoader->load(FTUSTATEPROVIDER_DOCML, &ok);
    67 	QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW);
    71 	QGraphicsWidget *widget = mDocumentLoader->findWidget(TOC_VIEW);
    71     mTocView->setTitle(qtTrId("txt_ftu_title_setup"));
    75     mTocView->setTitle(qtTrId("txt_ftu_title_setup"));
    72 
    76 
    73 	mMainWindow->addView(mTocView);
    77 	mMainWindow->addView(mTocView);
    74     // Set as initial view.
    78     // Set as initial view.
    75     mMainWindow->setCurrentView(mTocView);
    79     mMainWindow->setCurrentView(mTocView);
    76     mExitAction = new HbAction(Hb::QuitNaviAction, this);
    80     mCenrepHandler = new FtuStateCenrepHandler(NULL);
    77     mTocView->setNavigationAction(mExitAction);
    81     int registeredPlugins = mCenrepHandler->registeredPluginCount();
    78     QObject::connect( mExitAction, SIGNAL(triggered()), this, SLOT(exitApp()));
    82     for(int counter = 0; counter < registeredPlugins; counter ++){
       
    83         mCompletedWizardList << mCenrepHandler->getPluginInfo(counter);
       
    84     }
       
    85         
    79 }
    86 }
    80 
    87 
    81 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    82 // FtuWizardMenuState::~FtuWizardMenuState
    89 // FtuWizardMenuState::~FtuWizardMenuState
    83 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    87 	if(mModel)
    94 	if(mModel)
    88 	{
    95 	{
    89 		delete mModel;
    96 		delete mModel;
    90 	}
    97 	}
    91 	delete mDocumentLoader;
    98 	delete mDocumentLoader;
       
    99 	delete mCenrepHandler;
    92 }
   100 }
    93 
   101 
    94 // ---------------------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
    95 // FtuWizardMenuState::onEntry
   103 // FtuWizardMenuState::onEntry
    96 // ---------------------------------------------------------------------------
   104 // ---------------------------------------------------------------------------
   122 // FtuWizardMenuState::onExit
   130 // FtuWizardMenuState::onExit
   123 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   124 //
   132 //
   125 void FtuWizardMenuState::onExit(QEvent *event)
   133 void FtuWizardMenuState::onExit(QEvent *event)
   126 {
   134 {
       
   135     //remove the options menu so that plugin can perform the cleanup
       
   136     mMainWindow->currentView()->takeMenu();
   127     QState::onExit(event);
   137     QState::onExit(event);
   128 }
   138 }
   129 
   139 
   130 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   131 // FtuWizardMenuState::content
   141 // FtuWizardMenuState::content
   227 // FtuWizardMenuState::activateWizard
   237 // FtuWizardMenuState::activateWizard
   228 // ---------------------------------------------------------------------------
   238 // ---------------------------------------------------------------------------
   229 //
   239 //
   230 void FtuWizardMenuState::activateWizard(const QModelIndex index)
   240 void FtuWizardMenuState::activateWizard(const QModelIndex index)
   231 {
   241 {
       
   242     //remove the main menu 
       
   243     mMainWindow->currentView()->takeMenu();
   232     // Set the active wizard index
   244     // Set the active wizard index
   233     content()->setActiveWizard(index.row());
   245     content()->setActiveWizard(index.row());
       
   246     FtuWizard * wizard=content()->wizard(index.row());
       
   247     
   234     // signal to activated state
   248     // signal to activated state
   235     emit wizardSelected();
   249     emit wizardSelected();
   236 }
   250 }
   237 
   251 
   238 // ---------------------------------------------------------------------------
   252 // ---------------------------------------------------------------------------
   270         }
   284         }
   271         else
   285         else
   272         {         
   286         {         
   273             QDate date = wizards[index]->wizardCompletedDate();
   287             QDate date = wizards[index]->wizardCompletedDate();
   274             data << updatedAsString(date);            
   288             data << updatedAsString(date);            
       
   289 
       
   290             XQSettingsManager settingsManager;
       
   291             
       
   292             if(false == mCompletedWizardList[index])
       
   293             {
       
   294             mCompletedWizardList[index] = true; 
       
   295             mCenrepHandler->updatePluginInfo(index);
       
   296             }
       
   297 
   275         }
   298         }
   276         mModel->item(index)->setData(QVariant(data), Qt::DisplayRole);
   299         mModel->item(index)->setData(QVariant(data), Qt::DisplayRole);
   277     }
   300     }
   278 }
   301 }
   279 
       
   280 void FtuWizardMenuState::exitApp()
       
   281     {
       
   282     qApp->exit();
       
   283     }