userguide/src/HelpKeywordView.cpp
branchGCC_SURGE
changeset 35 3ae60d69bf22
parent 34 4533d75b8d4e
equal deleted inserted replaced
21:e70b37c1a9d5 35:3ae60d69bf22
    29 #include <hbsearchpanel.h>
    29 #include <hbsearchpanel.h>
    30 #include <hbscrollbar.h>
    30 #include <hbscrollbar.h>
    31 #include <hblineedit.h>
    31 #include <hblineedit.h>
    32 #include <hbmenu.h>
    32 #include <hbmenu.h>
    33 #include <hbstaticvkbhost.h>
    33 #include <hbstaticvkbhost.h>
    34 #include <hbgroupbox.h>
       
    35 
    34 
    36 #include "HelpDataProvider.h"
    35 #include "HelpDataProvider.h"
    37 #include "HelpProxyModel.h"
    36 #include "HelpProxyModel.h"
    38 
    37 
    39 #include "HelpKeywordView.h"
    38 #include "HelpKeywordView.h"
    59 	initDocMl();
    58 	initDocMl();
    60     initBackAction();
    59     initBackAction();
    61     initSearchList();
    60     initSearchList();
    62     initSearchPanel();
    61     initSearchPanel();
    63 	initVirtualKeyboard();
    62 	initVirtualKeyboard();
    64 	initEmptyLabel();
       
    65     
    63     
    66     connect(mainWindow(), SIGNAL(currentViewChanged(HbView*)), this, SLOT(onCurrentViewChanged(HbView*)));
    64     connect(mainWindow(), SIGNAL(viewReady()), this, SLOT(onViewReady()));
    67 }
    65 }
    68 
    66 
    69 void HelpKeywordView::initDocMl()
    67 void HelpKeywordView::initDocMl()
    70 {
    68 {
    71 	initBaseDocMl(); 
    69 	initBaseDocMl(); 
    97 	mVirtualKeyboard = new HbStaticVkbHost(this);
    95 	mVirtualKeyboard = new HbStaticVkbHost(this);
    98     connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(onHandleKeypadOpen()));
    96     connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(onHandleKeypadOpen()));
    99     connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(onHandleKeypadClose()));
    97     connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(onHandleKeypadClose()));
   100 }
    98 }
   101 
    99 
   102 void HelpKeywordView::initEmptyLabel()
   100 HbLabel* HelpKeywordView::label()
   103 {
   101 {
   104 	HbLabel* label = mBuilder.findWidget<HbLabel*>(DOCML_NO_MATCH_LABEL);
   102 	return mBuilder.findWidget<HbLabel*>(DOCML_NO_MATCH_LABEL);
   105 	label->setFontSpec(HbFontSpec(HbFontSpec::Primary));
       
   106 }
   103 }
   107 
   104 
   108 void HelpKeywordView::loadAllContent()
   105 void HelpKeywordView::loadAllContent()
   109 {
   106 {
       
   107 	showToolBar(false);
   110 	mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
   108 	mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
   111 	ResetSearchPanel();
   109 	ResetSearchPanel();
   112 	toolBar()->hide();
   110 	
   113 }
       
   114 
       
   115 HbGroupBox* HelpKeywordView::groupBox()
       
   116 {
       
   117 	return mBuilder.findWidget<HbGroupBox*>(DOCML_GROUPBOX);
       
   118 }
   111 }
   119 
   112 
   120 ////////////////////////////////////////////////////////////////////////////////////////////
   113 ////////////////////////////////////////////////////////////////////////////////////////////
   121 
   114 
   122 void HelpKeywordView::updateVisibleItems(bool visible)
   115 void HelpKeywordView::updateVisibleItems(bool visible)
   141         {
   134         {
   142             HbLineEdit *const lineEdit = qobject_cast<HbLineEdit*>(widget);
   135             HbLineEdit *const lineEdit = qobject_cast<HbLineEdit*>(widget);
   143             if(lineEdit != NULL)
   136             if(lineEdit != NULL)
   144             {
   137             {
   145                 lineEdit->setText("");
   138                 lineEdit->setText("");
       
   139 				lineEdit->setFocus();
   146                 break;
   140                 break;
   147             }
   141             }
   148         }
   142         }
   149     }
   143     }
   150 }
   144 }
   151 
   145 
       
   146 void HelpKeywordView::updateLabelPos()
       
   147 {
       
   148 	HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow());
       
   149 	qreal unValue = profile.unitValue();
       
   150 	if(mainWindow()->orientation() == Qt::Vertical)
       
   151 	{
       
   152 		if(mVirtualKeyboard->keypadStatus() == HbVkbHost::HbVkbStatusClosed)
       
   153 		{
       
   154 			label()->setContentsMargins(0,30 * unValue,0,0);
       
   155 		}
       
   156 		else
       
   157 		{
       
   158 			label()->setContentsMargins(0,10 * unValue,0,0);
       
   159 		}
       
   160 	}
       
   161 	else
       
   162 	{
       
   163 		if(mVirtualKeyboard->keypadStatus() == HbVkbHost::HbVkbStatusClosed)
       
   164 		{
       
   165 			label()->setContentsMargins(0,10 * unValue,0,0);
       
   166 		}
       
   167 		else
       
   168 		{
       
   169             label()->setContentsMargins(0,0,0,0);
       
   170 			label()->setAlignment(label()->alignment() | Qt::AlignVCenter);
       
   171 		}
       
   172 	}
       
   173 }
       
   174 
       
   175 void HelpKeywordView::showToolBar(bool visible)
       
   176 {
       
   177 	Hb::SceneItems items = Hb::ToolBarItem;
       
   178 	if(visible)
       
   179 	{
       
   180 		showItems(items);
       
   181 	}
       
   182 	else
       
   183 	{
       
   184 		hideItems(items);
       
   185 	}
       
   186 }
       
   187 
   152 ////////////////////////////////////////////////////////////////////////////////////////////
   188 ////////////////////////////////////////////////////////////////////////////////////////////
   153 // handle system event
   189 // handle system event
   154 
   190 
   155 void HelpKeywordView::onCurrentViewChanged(HbView *view)
   191 void HelpKeywordView::onViewReady()
   156 {
   192 {
   157 	 if(this == view)
   193 	if(isVisible())
   158     {
   194 	{
   159 		setVisible(true);
       
   160 		setNavigationAction(mSoftKeyAction);  
   195 		setNavigationAction(mSoftKeyAction);  
   161 	}
   196 	}
   162 }
   197 }
   163 
   198 
   164 ///////////////////////////////////////////////////////////////////////////////////////
   199 ///////////////////////////////////////////////////////////////////////////////////////
   199 	}
   234 	}
   200 	else
   235 	else
   201 	{
   236 	{
   202 		mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH_NO_SRHPAL);
   237 		mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH_NO_SRHPAL);
   203 	}	
   238 	}	
   204 	toolBar()->show();
   239 	showToolBar(true);
   205 }
   240 }
   206 
   241 
   207 void HelpKeywordView::onSearchPanelCriteriaChanged(const QString &criteria)
   242 void HelpKeywordView::onSearchPanelCriteriaChanged(const QString &criteria)
   208 {
   243 {
   209     HelpDataProvider::instance()->getSearchData(criteria);
   244     HelpDataProvider::instance()->getSearchData(criteria);
   213 	}
   248 	}
   214 	else
   249 	else
   215 	{
   250 	{
   216 		mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
   251 		mBuilder.load(QRC_DOCML_KEYWORD, DOCML_LAYOUT_SEARCH);
   217 	}
   252 	}
   218 
   253 	showToolBar(false);
   219 	toolBar()->hide();
       
   220 
       
   221 	if(criteria.isEmpty())
       
   222 	{
       
   223 		groupBox()->setHeading(hbTrId(TXT_SETLABEL_SEARCH));
       
   224 	}
       
   225 	else
       
   226 	{
       
   227 		QString heading = qtTrId(TXT_SETLABEL_SEARCH_RESULTS);
       
   228 		heading.append(COLON);
       
   229 		heading.append(criteria);
       
   230 		groupBox()->setHeading(heading);
       
   231 	}
       
   232 }
   254 }
   233 
   255 
   234 ////////////////////////////////////////////////////////////////////////////////////////////
   256 ////////////////////////////////////////////////////////////////////////////////////////////
   235 // handle virtual keyboard event
   257 // handle virtual keyboard event
   236 
   258 
   237 void HelpKeywordView::onHandleKeypadOpen()
   259 void HelpKeywordView::onHandleKeypadOpen()
   238 {
   260 {
   239 	updateVisibleItems(false);
   261 	updateVisibleItems(false);
   240     qreal heightToSet = mainWindow()->layoutRect().height() - mVirtualKeyboard->keyboardArea().height();
   262     qreal heightToSet = mainWindow()->layoutRect().height() - mVirtualKeyboard->keyboardArea().height();
   241     this->setMaximumHeight(heightToSet);
   263     this->setMaximumHeight(heightToSet);
       
   264 	updateLabelPos();
   242 }
   265 }
   243 
   266 
   244 void HelpKeywordView::onHandleKeypadClose()
   267 void HelpKeywordView::onHandleKeypadClose()
   245 {	
   268 {	
   246 	updateVisibleItems(true);
   269 	updateVisibleItems(true);
   247 	qreal mainHeight  = mainWindow()->layoutRect().height();
   270 	qreal mainHeight  = mainWindow()->layoutRect().height();
   248 	qreal toolbarHeight = toolBar()->size().height();
   271 	qreal toolbarHeight = toolBar()->size().height();
   249 	qreal height = mainHeight - (toolBar()->isVisible() ? toolbarHeight : 0);
   272 	qreal height = mainHeight - ( toolBar()->isVisible() ? toolbarHeight : 0);
   250 	this->setMaximumHeight(height);
   273 	this->setMaximumHeight(height);
       
   274 	updateLabelPos();
       
   275 }
       
   276 
       
   277 void HelpKeywordView::onOrientationChanged(Qt::Orientation orientation)
       
   278 {
       
   279 	Q_UNUSED(orientation);
       
   280 	updateLabelPos();
   251 }
   281 }
   252 
   282 
   253 // end of file
   283 // end of file