userguide/src/HelpMainWindow.cpp
changeset 53 01c62bde3a2a
parent 27 0a93cba9d57a
equal deleted inserted replaced
50:024e23fdab18 53:01c62bde3a2a
    17 
    17 
    18 #include <hbtoolbar.h>
    18 #include <hbtoolbar.h>
    19 #include <hbnotificationdialog.h>
    19 #include <hbnotificationdialog.h>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hbapplication.h>
    21 #include <hbapplication.h>
    22 #include <hbactivitymanager.h>
    22 #include <afactivitystorage.h>
    23 
    23 
    24 #include "HelpBaseView.h"
    24 #include "HelpBaseView.h"
    25 #include "HelpCategoryView.h"
    25 #include "HelpCategoryView.h"
    26 #include "HelpKeywordView.h"
    26 #include "HelpKeywordView.h"
    27 #include "HelpContentsView.h"
    27 #include "HelpContentsView.h"
    33 mCategoryView(NULL),
    33 mCategoryView(NULL),
    34 mKeywordView(NULL),
    34 mKeywordView(NULL),
    35 mContentsView(NULL)
    35 mContentsView(NULL)
    36 {
    36 {
    37     QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
    37     QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
       
    38 
       
    39     mActivityStorage = new AfActivityStorage(this);
    38 	HelpDataProvider::instance()->createHelpCategory();
    40 	HelpDataProvider::instance()->createHelpCategory();
       
    41 
    39     activateCategoryView();
    42     activateCategoryView();
    40 }
    43 }
    41 
    44 
    42 HelpMainWindow::~HelpMainWindow()
    45 HelpMainWindow::~HelpMainWindow()
    43 {
    46 {
    49 	switch(viewName)
    52 	switch(viewName)
    50 	{
    53 	{
    51 	    case HelpViewCategory:
    54 	    case HelpViewCategory:
    52             activateCategoryView();
    55             activateCategoryView();
    53 			break;
    56 			break;
       
    57 			
    54 	    case HelpViewKeyword:
    58 	    case HelpViewKeyword:
    55             activateKeywordView();
    59             activateKeywordView();
    56 			break;
    60 			break;
       
    61 			
    57 	    case HelpViewContents:
    62 	    case HelpViewContents:
    58             activateContentsView();
    63             activateContentsView();
    59 			break;
    64 			break;
       
    65 			
    60 		case PreviousView:
    66 		case PreviousView:
    61 			{
    67 			onActivateView(mPreviousViewName);
    62 				onActivateView(mPreviousViewName);
       
    63 			}
       
    64 			break;
    68 			break;
       
    69 			
    65 	    default:
    70 	    default:
    66 			HbApplication::exit();
    71 			HbApplication::exit();
    67 	        break;
    72 	        break;
    68 	}
    73 	}
    69 }
    74 }
   134 	mKeywordView->loadAllContent();
   139 	mKeywordView->loadAllContent();
   135 }
   140 }
   136 
   141 
   137 void HelpMainWindow::saveActivity()
   142 void HelpMainWindow::saveActivity()
   138 {
   143 {
   139 	HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   140 
       
   141 	// clean up any previous versions of this activity from the activity manager.
   144 	// clean up any previous versions of this activity from the activity manager.
   142 	bool ok = activityManager->removeActivity("UserGuideMainView");
   145 	bool ok = mActivityStorage->removeActivity("UserGuideMainView");
   143 	if ( !ok )
   146 	if(!ok)
   144 	{
   147 	{
   145 		//qFatal("Remove failed" );
   148 		//qFatal("Remove failed" );
   146 	}
   149 	}
   147 
   150 
   148 	// get a screenshot for saving to the activity manager
   151 	// get a screenshot for saving to the activity manager
   152 	// save any data necessary to save the state
   155 	// save any data necessary to save the state
   153 	QByteArray serializedActivity;
   156 	QByteArray serializedActivity;
   154 	QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
   157 	QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
   155 
   158 
   156 	// add the activity to the activity manager
   159 	// add the activity to the activity manager
   157 	ok = activityManager->addActivity("UserGuideMainView", serializedActivity, metadata);
   160 	ok = mActivityStorage->saveActivity("UserGuideMainView", serializedActivity, metadata);
   158 	if ( !ok )
   161 	if(!ok)
   159 	{
   162 	{
   160 		qFatal("Add failed" );
   163 		//qFatal("Add failed");
   161 	}
   164 	}
   162 }
   165 }
   163 
   166 
   164 // end of file
   167 // end of file
   165 
   168