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 |
21 |
|
22 #include "HelpBaseView.h" |
22 #include "HelpCategoryView.h" |
23 #include "HelpCategoryView.h" |
|
24 #include "HelpKeywordView.h" |
23 #include "HelpContentsView.h" |
25 #include "HelpContentsView.h" |
24 |
26 |
25 #include "HelpMainWindow.h" |
27 #include "HelpMainWindow.h" |
26 #include "HelpDataProvider.h" |
28 #include "HelpDataProvider.h" |
27 |
29 |
28 HelpMainWindow::HelpMainWindow() : |
30 HelpMainWindow::HelpMainWindow() : |
29 mCategoryView(NULL), |
31 mCategoryView(NULL), |
|
32 mKeywordView(NULL), |
30 mContentsView(NULL) |
33 mContentsView(NULL) |
31 { |
34 { |
32 connect(this, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(onOrientationChanged(Qt::Orientation))); |
|
33 initToolbar(); |
|
34 activateCategoryView(); |
35 activateCategoryView(); |
35 } |
36 } |
36 |
37 |
37 HelpMainWindow::~HelpMainWindow() |
38 HelpMainWindow::~HelpMainWindow() |
38 { |
39 { |
39 HelpDataProvider::destroyInstance(); |
40 HelpDataProvider::destroyInstance(); |
40 } |
|
41 |
|
42 void HelpMainWindow::initToolbar() |
|
43 { |
|
44 mBuilder.load(QRC_DOCML_TOOLBAR); |
|
45 mToolBar = mBuilder.findWidget<HbToolBar*>(DOCML_TOOLBAR); |
|
46 |
|
47 HbAction* allAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_ALL); |
|
48 HbAction* findAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_SEARCH); |
|
49 HbAction* onLineSupportAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_LINK_NOKIA); |
|
50 |
|
51 connect(allAction, SIGNAL(triggered()), this, SLOT(onToolbarAll())); |
|
52 connect(findAction, SIGNAL(triggered()), this, SLOT(onToolbarFind())); |
|
53 connect(onLineSupportAction, SIGNAL(triggered()), this, SLOT(onToolbarOnlineSupport())); |
|
54 } |
41 } |
55 |
42 |
56 void HelpMainWindow::onActivateView(HelpViewName viewName) |
43 void HelpMainWindow::onActivateView(HelpViewName viewName) |
57 { |
44 { |
58 switch(viewName) |
45 switch(viewName) |
59 { |
46 { |
60 case HelpViewCategory: |
47 case HelpViewCategory: |
61 activateCategoryView(); |
48 activateCategoryView(); |
62 break; |
49 break; |
63 |
50 case HelpViewKeyword: |
|
51 activateKeywordView(); |
|
52 break; |
64 case HelpViewContents: |
53 case HelpViewContents: |
65 activateContentsView(); |
54 activateContentsView(); |
66 break; |
55 break; |
67 |
56 case PreviousView: |
|
57 { |
|
58 onActivateView(mPreviousViewName); |
|
59 } |
|
60 break; |
68 default: |
61 default: |
69 break; |
62 break; |
70 } |
63 } |
71 } |
64 } |
72 |
65 |
75 if(!mCategoryView) |
68 if(!mCategoryView) |
76 { |
69 { |
77 mCategoryView = new HelpCategoryView(); |
70 mCategoryView = new HelpCategoryView(); |
78 addView(mCategoryView); |
71 addView(mCategoryView); |
79 mCategoryView->init(); |
72 mCategoryView->init(); |
80 mCategoryView->setToolBar(mToolBar); |
|
81 emit currentViewChanged(mCategoryView); |
73 emit currentViewChanged(mCategoryView); |
82 connectViewSignal(mCategoryView); |
74 connectViewSignal(mCategoryView); |
83 } |
75 } |
84 |
76 |
|
77 mPreviousViewName = HelpViewCategory; |
85 setCurrentView(mCategoryView); |
78 setCurrentView(mCategoryView); |
|
79 } |
|
80 |
|
81 void HelpMainWindow::activateKeywordView() |
|
82 { |
|
83 if(!mKeywordView) |
|
84 { |
|
85 mKeywordView = new HelpKeywordView(); |
|
86 addView(mKeywordView); |
|
87 mKeywordView->init(); |
|
88 connectViewSignal(mKeywordView); |
|
89 } |
|
90 |
|
91 mPreviousViewName = HelpViewKeyword; |
|
92 setCurrentView(mKeywordView); |
86 } |
93 } |
87 |
94 |
88 void HelpMainWindow::activateContentsView() |
95 void HelpMainWindow::activateContentsView() |
89 { |
96 { |
90 if(!mContentsView) |
97 if(!mContentsView) |
91 { |
98 { |
92 mContentsView = new HelpContentsView(); |
99 mContentsView = new HelpContentsView(); |
93 addView(mContentsView); |
100 addView(mContentsView); |
94 mContentsView->init(); |
101 mContentsView->init(); |
95 mContentsView->setToolBar(mToolBar); |
|
96 |
102 |
97 connectViewSignal(mContentsView); |
103 connectViewSignal(mContentsView); |
98 } |
104 } |
99 |
|
100 setCurrentView(mContentsView); |
105 setCurrentView(mContentsView); |
101 } |
106 } |
102 |
107 |
103 void HelpMainWindow::connectViewSignal(const QObject *object) |
108 void HelpMainWindow::connectViewSignal(const HelpBaseView *view) |
104 { |
109 { |
105 connect(object, SIGNAL(activateView(HelpViewName)), this, SLOT(onActivateView(HelpViewName))); |
110 connect(this, SIGNAL(orientationChanged(Qt::Orientation)), view, SLOT(onOrientationChanged(Qt::Orientation))); |
|
111 connect(view, SIGNAL(activateView(HelpViewName)), this, SLOT(onActivateView(HelpViewName))); |
|
112 |
|
113 connect(view, SIGNAL(showAllList()), this, SLOT(onShowAllList())); |
|
114 connect(view, SIGNAL(showFindList()), this, SLOT(onShowFindList())); |
106 } |
115 } |
107 |
116 |
108 |
117 |
109 //////////////////////////////////////////////////////////////////////////////////// |
118 //////////////////////////////////////////////////////////////////////////////////// |
110 // handle view event |
119 // handle view event |
111 |
120 |
112 void HelpMainWindow::onToolbarAll() |
121 void HelpMainWindow::onShowAllList() |
113 { |
122 { |
114 activateCategoryView(); |
123 activateCategoryView(); |
115 mCategoryView->switchViewMode(HelpCategoryView::ViewModeAll); |
|
116 } |
124 } |
117 |
125 |
118 void HelpMainWindow::onToolbarFind() |
126 void HelpMainWindow::onShowFindList() |
119 { |
127 { |
120 activateCategoryView(); |
128 activateKeywordView(); |
121 mCategoryView->switchViewMode(HelpCategoryView::ViewModeSearch); |
129 mKeywordView->loadAllContent(); |
122 } |
|
123 |
|
124 void HelpMainWindow::onToolbarOnlineSupport() |
|
125 { |
|
126 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
|
127 notificationDialog->setParent(this); |
|
128 notificationDialog->setTitle(URL_LINK_SUPPORT); |
|
129 notificationDialog->show(); |
|
130 } |
|
131 |
|
132 void HelpMainWindow::onOrientationChanged(Qt::Orientation orientation) |
|
133 { |
|
134 RefreshToolbarText(orientation); |
|
135 } |
|
136 |
|
137 void HelpMainWindow::RefreshToolbarText(Qt::Orientation orientation) |
|
138 { |
|
139 bool isLandscape = (Qt::Horizontal==orientation); |
|
140 HbAction* tollbarAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_ALL); |
|
141 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_ALL) : QString()); |
|
142 |
|
143 tollbarAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_SEARCH); |
|
144 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_FIND) : QString()); |
|
145 |
|
146 tollbarAction = mBuilder.findObject<HbAction*>(DOCML_ACTION_LINK_NOKIA); |
|
147 tollbarAction->setText(isLandscape ? qtTrId(TXT_BUTTON_LINK_SUPPORT) : QString()); |
|
148 } |
130 } |
149 |
131 |
150 // end of file |
132 // end of file |
151 |
133 |