searchui/runtimeproviders/searchruntimeprovider/src/searchruntime.cpp
changeset 12 993ab30e92fc
parent 11 773be20e0a25
child 17 7d8c8d8f5eab
equal deleted inserted replaced
11:773be20e0a25 12:993ab30e92fc
    31 // states
    31 // states
    32 const char wizardProgressiveStateUri[] =
    32 const char wizardProgressiveStateUri[] =
    33         "search.nokia.com/state/wizardprogressivestate";
    33         "search.nokia.com/state/wizardprogressivestate";
    34 const char wizardSettingStateUri[] =
    34 const char wizardSettingStateUri[] =
    35         "search.nokia.com/state/wizardsettingstate";
    35         "search.nokia.com/state/wizardsettingstate";
    36 
    36 const char wizardOnlineStateUri[] =
       
    37         "search.nokia.com/state/wizardonlinestate";
    37 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    38 // searchRuntime::SearchRuntime
    39 // searchRuntime::SearchRuntime
    39 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    40 //
    41 //
    41 SearchRuntime::SearchRuntime(QObject* aParent) :
    42 SearchRuntime::SearchRuntime(QObject* aParent) :
    42 QStateMachine(aParent),mWindow(0)
    43     QStateMachine(aParent), mWindow(0)
    43     {
    44     {
    44     createGuiServiceParts();
    45     createGuiServiceParts();
    45     createStates();
    46     createStates();
    46     }
    47     }
    47 
    48 
    50 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    51 //
    52 //
    52 SearchRuntime::~SearchRuntime()
    53 SearchRuntime::~SearchRuntime()
    53     {
    54     {
    54     delete mWindow;
    55     delete mWindow;
    55   //  delete mStateMachine;
    56     //  delete mStateMachine;
    56     }
    57     }
    57 
    58 
    58 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    59 // SearchRuntime::handleStateMachineStarted()
    60 // SearchRuntime::handleStateMachineStarted()
    60 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    61 //
    62 //
    62 void SearchRuntime::handleStateMachineStarted()
    63 void SearchRuntime::handleStateMachineStarted()
    63     {
    64     {
    64    // emit started();
    65     // emit started();
    65     }
    66     }
    66 
    67 
    67 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    68 // SearchRuntime::handleStateMachineStopped()
    69 // SearchRuntime::handleStateMachineStopped()
    69 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    89 //
    90 //
    90 void SearchRuntime::createStates()
    91 void SearchRuntime::createStates()
    91     {
    92     {
    92 
    93 
    93     SearchStateProvider stateProvider;
    94     SearchStateProvider stateProvider;
    94     
    95 
    95     QFinalState* finalState = new QFinalState();
    96     QFinalState* finalState = new QFinalState();
    96     this->addState(finalState);
    97     this->addState(finalState);
    97 
    98 
    98     // parallel state activates all children states
    99     // parallel state activates all children states
    99     QState* parallel = new QState(QState::ParallelStates);
   100     QState* parallel = new QState(QState::ParallelStates);
   103     // root GUI state
   104     // root GUI state
   104     QState* guiRootState = new QState(parallel);
   105     QState* guiRootState = new QState(parallel);
   105 
   106 
   106     QState* searchRootState = new QState(guiRootState);
   107     QState* searchRootState = new QState(guiRootState);
   107 
   108 
   108 
   109     QState* wizardProgressiveState = stateProvider.createState(
   109     QState* wizardProgressiveState = stateProvider.createState(wizardProgressiveStateUri);
   110             wizardProgressiveStateUri);
   110     // set state specific data
   111     // set state specific data
   111     wizardProgressiveState->setParent(searchRootState);
   112     wizardProgressiveState->setParent(searchRootState);
   112     wizardProgressiveState->setObjectName(wizardProgressiveStateUri);
   113     wizardProgressiveState->setObjectName(wizardProgressiveStateUri);
   113 
   114 
   114 
   115     QState* wizardSettingState = stateProvider.createState(
   115     QState* wizardSettingState = stateProvider.createState(wizardSettingStateUri);
   116             wizardSettingStateUri);
   116     wizardSettingState->setParent(searchRootState);
   117     wizardSettingState->setParent(searchRootState);
   117     wizardSettingState->setObjectName(wizardSettingStateUri);
   118     wizardSettingState->setObjectName(wizardSettingStateUri);
   118 
   119 
       
   120     QState* wizardOnlineState = stateProvider.createState(
       
   121             wizardOnlineStateUri);
       
   122     wizardOnlineState->setParent(searchRootState);
       
   123     wizardOnlineState->setObjectName(wizardOnlineStateUri);
       
   124 
       
   125     // progressive to settings
   119     wizardProgressiveState->addTransition(wizardProgressiveState,
   126     wizardProgressiveState->addTransition(wizardProgressiveState,
   120             SIGNAL(settingsState()), wizardSettingState);
   127             SIGNAL(switchProToSettingsState()), wizardSettingState);
   121 
   128 
   122     // From activated back to menu
   129     // settings to progressive 
   123     wizardSettingState->addTransition(wizardSettingState,
   130     wizardSettingState->addTransition(wizardSettingState,
   124             SIGNAL(backEventTriggered()), wizardProgressiveState);
   131             SIGNAL(switchToProState()), wizardProgressiveState);
   125     
   132 
       
   133     // online to settings
       
   134     wizardOnlineState->addTransition(wizardOnlineState,
       
   135             SIGNAL(switchOnlineToSettingsState()), wizardSettingState);
       
   136 
       
   137     // settings to online 
       
   138     wizardSettingState->addTransition(wizardSettingState,
       
   139             SIGNAL(switchToOnlineState()), wizardOnlineState);
       
   140 
   126     connect(wizardSettingState, SIGNAL(clickstatus(bool)),
   141     connect(wizardSettingState, SIGNAL(clickstatus(bool)),
   127                 wizardProgressiveState, SLOT(settingsaction(bool)));
   142             wizardProgressiveState, SLOT(settingsaction(bool)));
   128 
   143 
   129     connect(wizardSettingState, SIGNAL(publishSelectedCategory(int,bool)),
   144     connect(wizardSettingState, SIGNAL(publishSelectedCategory(int,bool)),
   130             wizardProgressiveState, SLOT(getSettingCategory(int,bool)));
   145             wizardProgressiveState, SLOT(getSettingCategory(int,bool)));
       
   146     
       
   147     connect(wizardSettingState, SIGNAL(publishISProviderIcon(int,HbIcon)),
       
   148             wizardProgressiveState, SLOT(slotISProvidersIcon(int,HbIcon)));
   131 
   149 
   132     connect(wizardSettingState, SIGNAL(customizeGoButton(bool)),
   150     connect(wizardProgressiveState, SIGNAL(inDeviceSearchQuery(QString)),
   133             wizardProgressiveState, SLOT(_customizeGoButton(bool)));
   151             wizardOnlineState, SLOT(slotIndeviceQuery(QString)));
       
   152     
       
   153     connect(wizardProgressiveState, SIGNAL(launchLink(int,QString)),
       
   154             wizardOnlineState, SLOT(slotlaunchLink(int,QString)));
       
   155 
       
   156     connect(wizardOnlineState, SIGNAL(onlineSearchQuery(QString)),
       
   157             wizardProgressiveState, SLOT(slotOnlineQuery(QString)));
   134 
   158 
   135     // set initial state for statemachine
   159     // set initial state for statemachine
   136     if (hbApp->activateReason() == Hb::ActivationReasonActivity)
   160     if (hbApp->activateReason() == Hb::ActivationReasonActivity)
   137         {
   161         {
   138 
   162 
   144             searchRootState->setInitialState(wizardProgressiveState);
   168             searchRootState->setInitialState(wizardProgressiveState);
   145             }
   169             }
   146         else if (var == "SearchDeviceQueryView")
   170         else if (var == "SearchDeviceQueryView")
   147             {
   171             {
   148             searchRootState->setInitialState(wizardProgressiveState);
   172             searchRootState->setInitialState(wizardProgressiveState);
   149            
   173 
   150             }
   174             }
   151         else if (var == "SearchWebQueryView")
   175         else if (var == "SearchWebQueryView")
   152             {
   176             {
   153             //set initial state as internet
   177             searchRootState->setInitialState(wizardOnlineState);
   154             }
   178             }
   155         }
   179         }
   156     else if (hbApp->activateReason() == Hb::ActivationReasonNormal)
   180     else if (hbApp->activateReason() == Hb::ActivationReasonNormal)
   157         {
   181         {
   158 
   182 
   159         searchRootState->setInitialState(wizardProgressiveState);        
   183         searchRootState->setInitialState(wizardProgressiveState);
   160 
   184 
   161         }
   185         }
   162     guiRootState->setInitialState(searchRootState);
   186     guiRootState->setInitialState(searchRootState);
   163     this->setInitialState(parallel);
   187     this->setInitialState(parallel);
   164 
   188 
   165     connect(this, SIGNAL(started()),
   189     connect(this, SIGNAL(started()), SLOT(handleStateMachineStarted()));
   166             SLOT(handleStateMachineStarted()));
   190     connect(this, SIGNAL(stopped()), SLOT(handleStateMachineStopped()));
   167     connect(this, SIGNAL(stopped()),
   191     connect(this, SIGNAL(finished()), SLOT(handleStateMachineStopped()));
   168             SLOT(handleStateMachineStopped()));
       
   169     connect(this, SIGNAL(finished()),
       
   170             SLOT(handleStateMachineStopped()));
       
   171 
   192 
   172     }
   193     }