# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1272878687 -10800 # Node ID c0dfc135a46c7018557db5f05296b5fa119911a4 # Parent 1eb8015a8491b0aa60ba7f3deae395e240308735 Revision: 201015 Kit: 201018 diff -r 1eb8015a8491 -r c0dfc135a46c userguide/Userguide.pro --- a/userguide/Userguide.pro Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/Userguide.pro Mon May 03 12:24:47 2010 +0300 @@ -49,10 +49,6 @@ src/HelpProxyModel.cpp \ src/HelpStandardItem.cpp -win32 { - SOURCES += src/HelpUtils_win.cpp -} - symbian { TARGET.UID3 = 0x10005234 TARGET.CAPABILITY = CAP_APPLICATION @@ -62,6 +58,7 @@ include(rom/userguide.pri) } +ICON = resources/qtg_large_help.svg RESOURCES += resources/Userguide.qrc debug: DESTDIR = ./debug diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpCategoryView.h --- a/userguide/inc/HelpCategoryView.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpCategoryView.h Mon May 03 12:24:47 2010 +0300 @@ -21,10 +21,14 @@ #include #include "HelpCommon.h" +#include "HelpDocumentLoader.h" class HbTreeView; -class HbToolBar; +class HbListView; class HbSearchPanel; +class QStandardItem; +class HbStaticVkbHost; +class HbGroupBox; class HelpCategoryView : public HbView { @@ -36,12 +40,17 @@ void init(); private: + void initDocMl(); void initAllList(); void initSearchList(); void initSearchPanel(); - void initToolbar(); void initBackAction(); + void initEmptyLabel(); + void initVirtualKeyboard(); +private: + HbGroupBox* groupBox(); + public: enum ViewMode { @@ -54,28 +63,19 @@ signals: void activateView(HelpViewName viewName); -signals: // from tollbar event - void showAllList(); - void showFindList(); - void showOnlineSupport(); +private: + void updateVisibleItems(bool visible); + void ResetSearchPanel(); private: - void RefreshToolbarText(bool isLandscape); - void RefreshTitlebarVisibility(); - void ResetSearchPanel(); - + void expandCollapseAllList(QStandardItem* item, bool expand); + private slots: // handle system event void onCurrentViewChanged(HbView *view); - void onOrientationChanged(Qt::Orientation orientation); private slots: // handle button action void onBackAction(); -private slots: // handle tollbar event - void onToolbarAll() { emit showAllList(); }; - void onToolbarFind() { emit showFindList(); }; - void onToolbarOnlineSupport() { emit showOnlineSupport(); }; - private slots: // handle list event void onAllListActivated(const QModelIndex& index); void onSearchListActivated(const QModelIndex& index); @@ -84,13 +84,22 @@ void onSearchPanelExitClicked(); void onSearchPanelCriteriaChanged(const QString &criteria); +private slots: + void onExpandAll(); + void onCollapseAll(); + +private slots: // handle virtual keyboard event + void onHandleKeypadOpen(); + void onHandleKeypadClose(); + private: - ViewMode mViewMode; - HbTreeView* mListAll; - HbTreeView* mListSearch; - HbSearchPanel* mSearchPanel; - HbToolBar* mToolBar; - HbAction* mSoftKeyAction; + ViewMode mViewMode; + HbTreeView* mListAll; + HbListView* mListSearch; + HbSearchPanel* mSearchPanel; + HbAction* mSoftKeyAction; + HbStaticVkbHost* mVirtualKeyboard; + HelpUIBuilder mBuilder; }; #endif //HELPCATEGORYVIEW_H diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpCommon.h --- a/userguide/inc/HelpCommon.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpCommon.h Mon May 03 12:24:47 2010 +0300 @@ -24,7 +24,7 @@ const char* const BACKSLASH = "/"; const char* const SPECIALCHAR = "+"; const char* const HASHMARK = "#"; - +const char* const COLON = ":"; // help content file name const char* const XHTMLPATH = "resource/xhtml/"; const char* const CONTENTSZIP = "contents.zip"; @@ -45,14 +45,16 @@ const char* const URL_LINK_SUPPORT= "Link to Nokia.com/support"; // text -const char* const TXT_TITLE = "txt_user_guide_title_user_guide"; const char* const TXT_BUTTON_ALL = "txt_common_button_all"; const char* const TXT_BUTTON_FIND = "txt_common_button_find"; const char* const TXT_BUTTON_LINK_SUPPORT = "txt_user_guide_button_link_to_nokiacomsupport"; +const char* const TXT_SETLABEL_SEARCH = "txt_user_guide_setlabel_search"; +const char* const TXT_SETLABEL_SEARCH_RESULTS = "txt_user_guide_setlabel_search_results"; // docml const char* const QRC_DOCML_CATEGORY = ":/xml/categoryView.docml"; const char* const QRC_DOCML_CONTENTS = ":/xml/contentsView.docml"; +const char* const QRC_DOCML_TOOLBAR = ":/xml/toolbar.docml"; const char* const DOCML_ACTION_ALL = "action_all"; const char* const DOCML_ACTION_SEARCH = "action_find"; const char* const DOCML_ACTION_LINK_NOKIA = "action_online_support"; @@ -67,6 +69,10 @@ const char* const DOCML_LAYOUT_CATEGORY_ALL = "layout_category_all"; const char* const DOCML_LAYOUT_CATEGORY_SEARCH = "layout_category_find"; const char* const DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL = "layout_category_find_no_searchpanel"; +const char* const DOCML_GROUPBOX = "groupBox"; +const char* const DOCML_LAYOUT_CATEGORY_SEARCH_NO_MATCH = "layout_category_find_no_match"; +const char* const DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL_NO_MATCH = "layout_category_find_no_searchpanel_no_match"; +const char* const DOCML_NO_MATCH_LABEL = "no_match_label"; // enum diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpContentsView.h --- a/userguide/inc/HelpContentsView.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpContentsView.h Mon May 03 12:24:47 2010 +0300 @@ -18,11 +18,12 @@ #ifndef HELPCONTENTSVIEW_H #define HELPCONTENTSVIEW_H -#include +#include #include #include "HelpCommon.h" +#include "HelpDocumentLoader.h" class BrowserWrapper; @@ -38,16 +39,12 @@ void init(); private: + void initDocMl(); void initBackAction(); signals: void activateView(HelpViewName viewName); -signals: // from tollbar event - void showAllList(); - void showFindList(); - void showOnlineSupport(); - private: bool openApplication(const QUrl& url); bool openExternalLink(const QUrl& url); @@ -59,11 +56,6 @@ private slots: // handle button action void onBackAction(); -private slots: // handle tollbar event - void onToolbarAll() { emit showAllList(); }; - void onToolbarFind() { emit showFindList(); }; - void onToolbarOnlineSupport() { emit showOnlineSupport(); }; - private slots: // handle browser event void onLinkClicked(const QUrl& url); void onUrlChanged(const QUrl& url); @@ -71,6 +63,7 @@ private: BrowserWrapper* mBrowser; HbAction* mSoftKeyAction; + HelpUIBuilder mBuilder; }; #endif //HELPCONTENTSVIEW_H diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpDataProvider.h --- a/userguide/inc/HelpDataProvider.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpDataProvider.h Mon May 03 12:24:47 2010 +0300 @@ -44,16 +44,18 @@ void createHelpCategory(); void createBuiltInCategory(const QString& path); void constructAppHelp(const QString& path); - void constructKeywordModel(const QString& path); + void constructKeywordModel(const QString& title, const QString& uid, const QString& href); +// void searchInAllData(HelpStandardItem* item, const QString& key=QString()); +// void searchInResult(const QString& key=QString()); HelpStandardItem* constructCategory2(const QString& title, const QString& uid); HelpStandardItem* findItemWithHref(HelpStandardItem* itemParent, const QString& href); private: - QStandardItemModel* mHelpModel; //category tree model - QStandardItemModel* mKeywordModel; //keyword list model - HelpProxyModel* mSearhResultModel; //search result proxy model of keyword model - - QString mHelpContentRoot; + QStandardItemModel* mHelpModel; //category tree model + QStandardItemModel* mKeywordModel; //keyword list model + HelpProxyModel* mSearhResultModel; //search result proxy model of keyword model + QString mHelpContentRoot; + QString mLastSrhKey; }; diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpDocumentLoader.h --- a/userguide/inc/HelpDocumentLoader.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpDocumentLoader.h Mon May 03 12:24:47 2010 +0300 @@ -20,21 +20,27 @@ #include +class HelpDocumentLoader : public HbDocumentLoader +{ +private: + virtual QObject* createObject(const QString& type, const QString& name); +}; + class HelpUIBuilder { public: - static void destroyInstance(); - static QObjectList load(const QString& fileName); - static QObjectList load(const QString& fileName, const QString& section); - static QGraphicsWidget* findWidget(const QString& name); - static QObject* findObject(const QString& name); + void setObjectTree(QObjectList roots); + QObjectList load(const QString& fileName); + QObjectList load(const QString& fileName, const QString& section); + QGraphicsWidget* findWidget(const QString& name); + QObject* findObject(const QString& name); public: - template static T findWidget(const QString& name) { return qobject_cast(findWidget(name)); } - template static T findObject(const QString& name) { return qobject_cast(findObject(name)); } + template T findWidget(const QString& name) { return qobject_cast(findWidget(name)); } + template T findObject(const QString& name) { return qobject_cast(findObject(name)); } private: - static HbDocumentLoader* instance(); + HelpDocumentLoader mDocLoader; }; diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpMainWindow.h --- a/userguide/inc/HelpMainWindow.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpMainWindow.h Mon May 03 12:24:47 2010 +0300 @@ -21,9 +21,11 @@ #include #include "HelpCommon.h" +#include "HelpDocumentLoader.h" class HelpCategoryView; class HelpContentsView; +class HbToolBar; class HelpMainWindow : public HbMainWindow { @@ -39,7 +41,8 @@ private: // activate views void activateCategoryView(); void activateContentsView(); - void initBackAction(); + void initToolbar(); + void RefreshToolbarText(Qt::Orientation orientation); private: void connectViewSignal(const QObject *object); @@ -47,14 +50,19 @@ signals: void backActionSignal(); -private slots: // handle view event - void onShowAllList(); - void onShowFindList(); - void onShowOnlineSupport(); +private slots: // handle tollbar event + void onToolbarAll(); + void onToolbarFind(); + void onToolbarOnlineSupport(); + +private slots: + void onOrientationChanged(Qt::Orientation orientation); private: HelpCategoryView* mCategoryView; HelpContentsView* mContentsView; + HbToolBar* mToolBar; + HelpUIBuilder mBuilder; }; diff -r 1eb8015a8491 -r c0dfc135a46c userguide/inc/HelpUtils.h --- a/userguide/inc/HelpUtils.h Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/inc/HelpUtils.h Mon May 03 12:24:47 2010 +0300 @@ -29,6 +29,8 @@ static QString UILocaleFromQtToSymbian(); static Qt::Orientation defaultOrientation(); static Qt::SortOrder sortOrder(); + static int findStr(const QString& strFrom, const QString& strToFind); + static int compareStr(const QString& str1, const QString& str2); }; #endif //HELPUTILS_H diff -r 1eb8015a8491 -r c0dfc135a46c userguide/resources/Userguide.qrc --- a/userguide/resources/Userguide.qrc Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/resources/Userguide.qrc Mon May 03 12:24:47 2010 +0300 @@ -3,11 +3,11 @@ xml/categoryView.docml xml/contentsView.docml - + xml/toolbar.docml + images/qtg_mono_show_all.svg - images/qtg_mono_search.svg images/qtg_mono_link_nokia.svg diff -r 1eb8015a8491 -r c0dfc135a46c userguide/resources/qtg_large_help.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/userguide/resources/qtg_large_help.svg Mon May 03 12:24:47 2010 +0300 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 1eb8015a8491 -r c0dfc135a46c userguide/rom/userguide.iby --- a/userguide/rom/userguide.iby Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/rom/userguide.iby Mon May 03 12:24:47 2010 +0300 @@ -24,6 +24,7 @@ file=ABI_DIR\BUILD_DIR\Userguide.exe SHARED_LIB_DIR\Userguide.exe +data = DATAZ_\APP_RESOURCE_DIR\Userguide.mif APP_RESOURCE_DIR\Userguide.mif HB_UPGRADABLE_APP_REG_RSC(Userguide) S60_APP_RESOURCE(Userguide) diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpCategoryView.cpp --- a/userguide/src/HelpCategoryView.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpCategoryView.cpp Mon May 03 12:24:47 2010 +0300 @@ -21,15 +21,18 @@ #include #include #include +#include +#include #include -#include +#include #include #include #include #include +#include +#include -#include "HelpDocumentLoader.h" #include "HelpDataProvider.h" #include "HelpProxyModel.h" @@ -42,8 +45,7 @@ mViewMode(ViewModeNull), mListAll(NULL), mListSearch(NULL), -mSearchPanel(NULL), -mToolBar(NULL) +mSearchPanel(NULL) { } @@ -56,16 +58,32 @@ void HelpCategoryView::init() { + initDocMl(); initBackAction(); initAllList(); initSearchList(); initSearchPanel(); - initToolbar(); + initVirtualKeyboard(); + initEmptyLabel(); switchViewMode(ViewModeAll); connect(mainWindow(), SIGNAL(currentViewChanged(HbView*)), this, SLOT(onCurrentViewChanged(HbView*))); - connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(onOrientationChanged(Qt::Orientation))); +} + +void HelpCategoryView::initDocMl() +{ + // Create widget hierarchy + setObjectName( DOCML_VIEW_CATEGORY ); + + // List existing root elements - this allows us to refer to objects in the XML + // which are created outside the document. + QObjectList roots; + roots.append( this ); + + mBuilder.setObjectTree(roots); + + mBuilder.load(QRC_DOCML_CATEGORY); } void HelpCategoryView::initBackAction() @@ -76,7 +94,7 @@ void HelpCategoryView::initAllList() { - mListAll = HelpUIBuilder::findWidget(DOCML_LIST_CATEGORY_ALL); + mListAll = mBuilder.findWidget(DOCML_LIST_CATEGORY_ALL); mListAll->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); mListAll->setModel(HelpDataProvider::instance()->getCategoryData()); connect(mListAll, SIGNAL(activated(const QModelIndex&)), this, SLOT(onAllListActivated(const QModelIndex&))); @@ -84,29 +102,35 @@ void HelpCategoryView::initSearchList() { - mListSearch = HelpUIBuilder::findWidget(DOCML_LIST_CATEGORY_SEARCH); + mListSearch = mBuilder.findWidget(DOCML_LIST_CATEGORY_SEARCH); mListSearch->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); mListSearch->setModel(HelpDataProvider::instance()->getSearchData()); connect(mListSearch, SIGNAL(activated(const QModelIndex&)), this, SLOT(onSearchListActivated(const QModelIndex&))); } void HelpCategoryView::initSearchPanel() { - mSearchPanel = HelpUIBuilder::findWidget(DOCML_SEARCH_PANEL_CATEGORY); + mSearchPanel = mBuilder.findWidget(DOCML_SEARCH_PANEL_CATEGORY); connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(onSearchPanelExitClicked())); connect(mSearchPanel, SIGNAL(criteriaChanged(const QString&)), this, SLOT(onSearchPanelCriteriaChanged(const QString&))); } -void HelpCategoryView::initToolbar() +void HelpCategoryView::initVirtualKeyboard() { - mToolBar = HelpUIBuilder::findWidget(DOCML_TOOLBAR); - - HbAction* allAction = HelpUIBuilder::findObject(DOCML_ACTION_ALL); - HbAction* findAction = HelpUIBuilder::findObject(DOCML_ACTION_SEARCH); - QActionGroup* toolBarActionGroup = new QActionGroup(mToolBar); - allAction->setActionGroup(toolBarActionGroup); - findAction->setActionGroup(toolBarActionGroup); + mVirtualKeyboard = new HbStaticVkbHost(this); + connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(onHandleKeypadOpen())); + connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(onHandleKeypadClose())); } +void HelpCategoryView::initEmptyLabel() +{ + HbLabel* label = mBuilder.findWidget(DOCML_NO_MATCH_LABEL); + label->setFontSpec(HbFontSpec(HbFontSpec::Primary)); +} + +HbGroupBox* HelpCategoryView::groupBox() +{ + return mBuilder.findWidget(DOCML_GROUPBOX); +} //////////////////////////////////////////////////////////////////////////////////////////// @@ -117,34 +141,44 @@ mViewMode = viewMode; if(ViewModeAll == viewMode) { - HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_ALL); + mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_ALL); + toolBar()->show(); } else if(ViewModeSearch == viewMode) { - HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); +// mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); + ResetSearchPanel(); } - - RefreshTitlebarVisibility(); } - //////////////////////////////////////////////////////////////////////////////////////////// -void HelpCategoryView::RefreshToolbarText(bool isLandscape) +void HelpCategoryView::expandCollapseAllList(QStandardItem* item, bool expand) { - HbAction* tollbarAction = HelpUIBuilder::findObject(DOCML_ACTION_ALL); - tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_ALL) : QString()); - - tollbarAction = HelpUIBuilder::findObject(DOCML_ACTION_SEARCH); - tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_FIND) : QString()); - - tollbarAction = HelpUIBuilder::findObject(DOCML_ACTION_LINK_NOKIA); - tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_LINK_SUPPORT) : QString()); + if(item->rowCount() <= 0) + { + return; + } + mListAll->setExpanded(item->index(),expand); + for(int i = 0; i < item->rowCount(); i++) + { + expandCollapseAllList(item->child(i),expand); + } } -void HelpCategoryView::RefreshTitlebarVisibility() +//////////////////////////////////////////////////////////////////////////////////////////// + +void HelpCategoryView::updateVisibleItems(bool visible) { - setTitleBarVisible(!(mSearchPanel->isVisible())); + static Hb::SceneItems items = Hb::TitleBarItem | Hb::StatusBarItem; + if(visible) + { + showItems(items); + } + else + { + hideItems(items); + } } void HelpCategoryView::ResetSearchPanel() @@ -175,19 +209,16 @@ } } -void HelpCategoryView::onOrientationChanged(Qt::Orientation orientation) -{ - bool isLandscape = (Qt::Horizontal==orientation); - RefreshToolbarText(isLandscape); -} - - /////////////////////////////////////////////////////////////////////////////////////// // handle button back action void HelpCategoryView::onBackAction() { - if(this == mainWindow()->currentView()) + if(ViewModeSearch == mViewMode) + { + switchViewMode(ViewModeAll); + } + else { HbApplication::exit(); } @@ -231,14 +262,75 @@ void HelpCategoryView::onSearchPanelExitClicked() { - setTitleBarVisible(true); - HelpUIBuilder::load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL); + if(mListSearch->model()->rowCount() == 0) + { + mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL_NO_MATCH); + } + else + { + mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_SRHPAL); + } + toolBar()->show(); } void HelpCategoryView::onSearchPanelCriteriaChanged(const QString &criteria) { - mListSearch->setModel(HelpDataProvider::instance()->getSearchData(criteria)); - mListSearch->update(); + HelpDataProvider::instance()->getSearchData(criteria); + if(mListSearch->model()->rowCount() == 0) + { + mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH_NO_MATCH); + } + else + { + mBuilder.load(QRC_DOCML_CATEGORY, DOCML_LAYOUT_CATEGORY_SEARCH); + } + + toolBar()->hide(); + + if(criteria.isEmpty()) + { + groupBox()->setHeading(hbTrId(TXT_SETLABEL_SEARCH)); + } + else + { + QString heading = qtTrId(TXT_SETLABEL_SEARCH_RESULTS); + heading.append(COLON); + heading.append(criteria); + groupBox()->setHeading(heading); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////// +// handle virtual keyboard event + +void HelpCategoryView::onHandleKeypadOpen() +{ + updateVisibleItems(false); + qreal heightToSet = mainWindow()->layoutRect().height() - mVirtualKeyboard->keyboardArea().height(); + this->setMaximumHeight(heightToSet); +} + +void HelpCategoryView::onHandleKeypadClose() +{ + updateVisibleItems(true); + qreal mainHeight = mainWindow()->layoutRect().height(); + qreal toolbarHeight = toolBar()->size().height(); + qreal height = mainHeight - (toolBar()->isVisible() ? toolbarHeight : 0); + this->setMaximumHeight(height); +} + +//////////////////////////////////////////////////////////////////////////////////////////// +// handle menu event +void HelpCategoryView::onExpandAll() +{ + QStandardItemModel* model = (QStandardItemModel*)(mListAll->model()); + expandCollapseAllList(model->invisibleRootItem(),true); +} + +void HelpCategoryView::onCollapseAll() +{ + QStandardItemModel* model = (QStandardItemModel*)(mListAll->model()); + expandCollapseAllList(model->invisibleRootItem(),false); } diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpContentsView.cpp --- a/userguide/src/HelpContentsView.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpContentsView.cpp Mon May 03 12:24:47 2010 +0300 @@ -25,7 +25,6 @@ #include #include "BrowserWrapper.h" -#include "HelpDocumentLoader.h" #include "HelpDataProvider.h" #include "HelpUtils.h" #include "HelpContentsView.h" @@ -40,8 +39,9 @@ void HelpContentsView::init() { + initDocMl(); initBackAction(); - mBrowser = HelpUIBuilder::findWidget(DOCML_BROWSER_CONTENTS); + mBrowser = mBuilder.findWidget(DOCML_BROWSER_CONTENTS); mBrowser->init(); connect(mBrowser, SIGNAL(linkClicked(const QUrl&)), this, SLOT(onLinkClicked(const QUrl&))); @@ -49,6 +49,21 @@ connect(mainWindow(), SIGNAL(currentViewChanged(HbView*)), this, SLOT(onCurrentViewChanged(HbView*))); } +void HelpContentsView::initDocMl() +{ + // Create widget hierarchy + setObjectName( DOCML_VIEW_CONTENTS ); + + // List existing root elements - this allows us to refer to objects in the XML + // which are created outside the document. + QObjectList roots; + roots.append( this ); + + mBuilder.setObjectTree(roots); + + mBuilder.load(QRC_DOCML_CONTENTS); +} + void HelpContentsView::initBackAction() { mSoftKeyAction = new HbAction(Hb::BackAction); @@ -119,16 +134,13 @@ void HelpContentsView::onBackAction() { - if(this == mainWindow()->currentView()) + if(mBrowser->canGoBack()) { - if(mBrowser->canGoBack()) - { - mBrowser->back(); - } - else - { - emit activateView(HelpViewCategory); - } + mBrowser->back(); + } + else + { + emit activateView(HelpViewCategory); } } diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpDataProvider.cpp --- a/userguide/src/HelpDataProvider.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpDataProvider.cpp Mon May 03 12:24:47 2010 +0300 @@ -34,7 +34,8 @@ { mHelpModel = new QStandardItemModel(); mKeywordModel = new QStandardItemModel(); - mSearhResultModel = NULL; + mSearhResultModel = new HelpProxyModel(); + mSearhResultModel->setSourceModel(mKeywordModel); } HelpDataProvider::~HelpDataProvider() @@ -80,14 +81,30 @@ QAbstractItemModel* HelpDataProvider::getSearchData(const QString& key) { - delete mSearhResultModel; - mSearhResultModel = NULL; - - mSearhResultModel = new HelpProxyModel();; - mSearhResultModel->setSourceModel(mKeywordModel); - mSearhResultModel->setFilterRole(KeywordRole); +/* if(key.isEmpty()) + { + return mKeywordModel; + }*/ + + if(key == mLastSrhKey) + { + return mSearhResultModel; + } +/* + if(!mLastSrhKey.isEmpty() && HelpUtils::findStr(key, mLastSrhKey) != -1) + { + searchInResult(key); + } + else + { + mSearhResultModel->removeRows(0, mSearhResultModel->rowCount()); + searchInAllData((HelpStandardItem*)mKeywordModel->invisibleRootItem(), key); + }*/ + + mLastSrhKey = key; mSearhResultModel->setFilterRegExp(key); + return mSearhResultModel; } @@ -157,6 +174,7 @@ constructAppHelp(path); } } + mKeywordModel->sort(0, HelpUtils::sortOrder()); } void HelpDataProvider::createBuiltInCategory(const QString& path) @@ -199,7 +217,7 @@ if(item) { mHelpModel->appendRow(item); - constructKeywordModel(uid); +// constructKeywordModel(uid); } } file.close(); @@ -249,6 +267,7 @@ HelpStandardItem* item = new HelpStandardItem(temp[1]); item->setData(temp[0], HrefRole); itemParent->appendRow(item); + constructKeywordModel(temp[1], uid, temp[0]); } file.close(); @@ -306,7 +325,7 @@ itemApp = new HelpStandardItem("Applications"); } itemApp->appendRow(item); - constructKeywordModel(pathTemp); +// constructKeywordModel(pathTemp); } file.close(); } @@ -318,56 +337,50 @@ } } -void HelpDataProvider::constructKeywordModel(const QString& path) +/* +void HelpDataProvider::searchInAllData(HelpStandardItem* item, const QString& key) { - QString pathKeyword(path); - pathKeyword.append(BACKSLASH); - pathKeyword.append(KEYWORDXML); - - QFile file(pathKeyword); - if (!file.open(QIODevice::ReadOnly)) { - return; + if(item->rowCount() > 0) + { + for(int i = 0; i < item->rowCount(); i++) + { + searchInAllData((HelpStandardItem*)item->child(i),key); + } } - - //construct keyword model, title and keyword is one to more - QXmlStreamReader reader(&file); - QString keyword; - QString title; - - while (!reader.atEnd()) { - if (!reader.readNextStartElement()) - { - continue; - } - if (reader.name() == "text") + else + { + if(HelpUtils::findStr(item->text(), key) != -1) { - keyword = reader.readElementText(); + HelpStandardItem* itemSearch = new HelpStandardItem(item->text()); + itemSearch->setData(item->data(UidRole), UidRole); + itemSearch->setData(item->data(HrefRole), HrefRole); + mSearhResultModel->appendRow(itemSearch); } - else if (reader.name() == "target") + } +} + +void HelpDataProvider::searchInResult(const QString& key) +{ + for(int i = 0; i < mSearhResultModel->rowCount();) + { + QStandardItem* item = mSearhResultModel->item(i); + if(HelpUtils::findStr(item->text(), key) == -1) { - QString href = reader.attributes().value("href").toString(); - HelpStandardItem* item = findItemWithHref((HelpStandardItem *)(mKeywordModel->invisibleRootItem()), href); - QStringList keywordLst; - if(item) - { - keywordLst = item->data(KeywordRole).toStringList(); - keywordLst.append(keyword); - item->setData(keywordLst,KeywordRole); - } - else - { - item = new HelpStandardItem(reader.readElementText()); - item->setData(path, UidRole); - item->setData(href, HrefRole); - - keywordLst.append(keyword); - item->setData(keywordLst,KeywordRole); - mKeywordModel->appendRow(item); - } - } + mSearhResultModel->removeRow(i); + } + else + { + i++; + } } - file.close(); - mKeywordModel->sort(0, HelpUtils::sortOrder()); +} +*/ +void HelpDataProvider::constructKeywordModel(const QString& title, const QString& uid, const QString& href) +{ + HelpStandardItem* itemTemp = new HelpStandardItem(title); + itemTemp->setData(uid, UidRole); + itemTemp->setData(href, HrefRole); + mKeywordModel->appendRow(itemTemp); } HelpStandardItem* HelpDataProvider::findItemWithHref(HelpStandardItem* itemParent, const QString& href) diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpDocumentLoader.cpp --- a/userguide/src/HelpDocumentLoader.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpDocumentLoader.cpp Mon May 03 12:24:47 2010 +0300 @@ -24,28 +24,8 @@ //////////////////////////////////////////////////////////////////////////////////////////// -class HelpDocumentLoader : public HbDocumentLoader -{ -private: - virtual QObject* createObject(const QString& type, const QString& name); -}; - QObject* HelpDocumentLoader::createObject(const QString& type, const QString& name) { - if(type == HelpCategoryView::staticMetaObject.className()) - { - QObject* object = new HelpCategoryView; - object->setObjectName(name); - return object; - } - - if(type == HelpContentsView::staticMetaObject.className()) - { - QObject* object = new HelpContentsView; - object->setObjectName(name); - return object; - } - if(type == BrowserWrapper::staticMetaObject.className()) { QObject* object = new BrowserWrapper; @@ -58,29 +38,15 @@ //////////////////////////////////////////////////////////////////////////////////////////// - -HbDocumentLoader* gHelpUIBuilderInstance = NULL; - -HbDocumentLoader* HelpUIBuilder::instance() +void HelpUIBuilder::setObjectTree(QObjectList roots) { - if(!gHelpUIBuilderInstance) - { - gHelpUIBuilderInstance = new HelpDocumentLoader(); - } - - return gHelpUIBuilderInstance; -} - -void HelpUIBuilder::destroyInstance() -{ - delete gHelpUIBuilderInstance; - gHelpUIBuilderInstance = NULL; + mDocLoader.setObjectTree(roots); } QObjectList HelpUIBuilder::load(const QString& fileName) { bool ok = false; - QObjectList list = instance()->load(fileName, &ok); + QObjectList list = mDocLoader.load(fileName, &ok); Q_ASSERT_X(ok, "Help", "HelpUIBuilder load file"); return list; } @@ -88,22 +54,20 @@ QObjectList HelpUIBuilder::load(const QString& fileName, const QString& section) { bool ok = false; - QObjectList list = instance()->load(fileName, section, &ok); + QObjectList list = mDocLoader.load(fileName, section, &ok); Q_ASSERT_X(ok, "Help", "HelpUIBuilder load section"); return list; } QGraphicsWidget* HelpUIBuilder::findWidget(const QString& name) { - return instance()->findWidget(name); + return mDocLoader.findWidget(name); } QObject* HelpUIBuilder::findObject(const QString& name) { - return instance()->findObject(name); + return mDocLoader.findObject(name); } - - // end of file diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpMainWindow.cpp --- a/userguide/src/HelpMainWindow.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpMainWindow.cpp Mon May 03 12:24:47 2010 +0300 @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -22,22 +23,36 @@ #include "HelpContentsView.h" #include "HelpMainWindow.h" -#include "HelpDocumentLoader.h" #include "HelpDataProvider.h" HelpMainWindow::HelpMainWindow() : mCategoryView(NULL), mContentsView(NULL) { + connect(this, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(onOrientationChanged(Qt::Orientation))); + initToolbar(); activateCategoryView(); } HelpMainWindow::~HelpMainWindow() { - HelpUIBuilder::destroyInstance(); HelpDataProvider::destroyInstance(); } +void HelpMainWindow::initToolbar() +{ + mBuilder.load(QRC_DOCML_TOOLBAR); + mToolBar = mBuilder.findWidget(DOCML_TOOLBAR); + + HbAction* allAction = mBuilder.findObject(DOCML_ACTION_ALL); + HbAction* findAction = mBuilder.findObject(DOCML_ACTION_SEARCH); + HbAction* onLineSupportAction = mBuilder.findObject(DOCML_ACTION_LINK_NOKIA); + + connect(allAction, SIGNAL(triggered()), this, SLOT(onToolbarAll())); + connect(findAction, SIGNAL(triggered()), this, SLOT(onToolbarFind())); + connect(onLineSupportAction, SIGNAL(triggered()), this, SLOT(onToolbarOnlineSupport())); +} + void HelpMainWindow::onActivateView(HelpViewName viewName) { switch(viewName) @@ -59,10 +74,10 @@ { if(!mCategoryView) { - HelpUIBuilder::load(QRC_DOCML_CATEGORY); - mCategoryView = HelpUIBuilder::findWidget(DOCML_VIEW_CATEGORY); + mCategoryView = new HelpCategoryView(); addView(mCategoryView); mCategoryView->init(); + mCategoryView->setToolBar(mToolBar); emit currentViewChanged(mCategoryView); connectViewSignal(mCategoryView); } @@ -74,10 +89,10 @@ { if(!mContentsView) { - HelpUIBuilder::load(QRC_DOCML_CONTENTS); - mContentsView = HelpUIBuilder::findWidget(DOCML_VIEW_CONTENTS); + mContentsView = new HelpContentsView(); addView(mContentsView); mContentsView->init(); + mContentsView->setToolBar(mToolBar); connectViewSignal(mContentsView); } @@ -88,29 +103,25 @@ void HelpMainWindow::connectViewSignal(const QObject *object) { connect(object, SIGNAL(activateView(HelpViewName)), this, SLOT(onActivateView(HelpViewName))); - - connect(object, SIGNAL(showAllList()), this, SLOT(onShowAllList())); - connect(object, SIGNAL(showFindList()), this, SLOT(onShowFindList())); - connect(object, SIGNAL(showOnlineSupport()), this, SLOT(onShowOnlineSupport())); } //////////////////////////////////////////////////////////////////////////////////// // handle view event -void HelpMainWindow::onShowAllList() +void HelpMainWindow::onToolbarAll() { activateCategoryView(); mCategoryView->switchViewMode(HelpCategoryView::ViewModeAll); } -void HelpMainWindow::onShowFindList() +void HelpMainWindow::onToolbarFind() { activateCategoryView(); mCategoryView->switchViewMode(HelpCategoryView::ViewModeSearch); } -void HelpMainWindow::onShowOnlineSupport() +void HelpMainWindow::onToolbarOnlineSupport() { HbNotificationDialog *notificationDialog = new HbNotificationDialog(); notificationDialog->setParent(this); @@ -118,5 +129,23 @@ notificationDialog->show(); } +void HelpMainWindow::onOrientationChanged(Qt::Orientation orientation) +{ + RefreshToolbarText(orientation); +} + +void HelpMainWindow::RefreshToolbarText(Qt::Orientation orientation) +{ + bool isLandscape = (Qt::Horizontal==orientation); + HbAction* tollbarAction = mBuilder.findObject(DOCML_ACTION_ALL); + tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_ALL) : QString()); + + tollbarAction = mBuilder.findObject(DOCML_ACTION_SEARCH); + tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_FIND) : QString()); + + tollbarAction = mBuilder.findObject(DOCML_ACTION_LINK_NOKIA); + tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_LINK_SUPPORT) : QString()); +} + // end of file diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpProxyModel.cpp --- a/userguide/src/HelpProxyModel.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpProxyModel.cpp Mon May 03 12:24:47 2010 +0300 @@ -18,8 +18,7 @@ #include #include -#include - +#include "HelpUtils.h" #include "HelpCommon.h" #include "HelpProxyModel.h" @@ -44,13 +43,22 @@ foreach(QString str, keywordLst) { - if(HbStringUtil::findC(str, filterRegExp().pattern()) != -1) + if(HelpUtils::findStr(str, filterRegExp().pattern()) != -1) { return true; } } return false; } + case Qt::DisplayRole: + { + QString title = sourceModel()->data(index, Qt::DisplayRole).toString(); + if(HelpUtils::findStr(title, filterRegExp().pattern()) != -1) + { + return true; + } + return false; + } default: return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpStandardItem.cpp --- a/userguide/src/HelpStandardItem.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpStandardItem.cpp Mon May 03 12:24:47 2010 +0300 @@ -15,8 +15,7 @@ * */ -#include - +#include "HelpUtils.h" #include "HelpCommon.h" #include "HelpStandardItem.h" @@ -34,7 +33,7 @@ switch(role) { case Qt::DisplayRole: - if(HbStringUtil::compareC(text(), other.text()) < 0) + if(HelpUtils::compareStr(text(), other.text()) < 0) { return true; } diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/HelpUtils.cpp --- a/userguide/src/HelpUtils.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/HelpUtils.cpp Mon May 03 12:24:47 2010 +0300 @@ -19,6 +19,8 @@ #include #include +#include + #include "HelpUtils.h" @@ -28,7 +30,7 @@ #include #include -#include +#include #include void LoadFileFromZipL(const TDesC& aZipName, const TDesC& aFileName, QString& desBuffer) @@ -88,7 +90,14 @@ QT_TRAP_THROWING(LoadFileFromZipL(zipNameDes, subFileDes, htmlContent)); } - +#else +void HelpUtils::loadHtmlFromZipFile(const QString& path, const QString& htmlFile, QString& htmlContent) +{ + Q_UNUSED(path); + Q_UNUSED(htmlFile); + Q_UNUSED(htmlContent); + return; +} #endif QString HelpUtils::rootPath() @@ -234,6 +243,8 @@ { return req5->lastError(); } +#else + Q_UNUSED(appUid); #endif return 0; } @@ -248,4 +259,14 @@ return Qt::AscendingOrder; } +int HelpUtils::findStr(const QString& strFrom, const QString& strToFind) +{ + return HbStringUtil::findC(strFrom, strToFind); +} + +int HelpUtils::compareStr(const QString& str1, const QString& str2) +{ + return HbStringUtil::compareC(str1, str2); +} + // end of file diff -r 1eb8015a8491 -r c0dfc135a46c userguide/src/main.cpp --- a/userguide/src/main.cpp Fri Apr 16 14:53:45 2010 +0300 +++ b/userguide/src/main.cpp Mon May 03 12:24:47 2010 +0300 @@ -17,7 +17,7 @@ #include #include -#include +#include #include @@ -39,8 +39,6 @@ translatorSelf->load("userguide_"+lang, PATH_TRANSLATIONS); qApp->installTranslator(translatorSelf); - app.setApplicationName(hbTrId(TXT_TITLE)); - HelpMainWindow mainWindow; mainWindow.show();