homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
equal deleted inserted replaced
62:341166945d65 63:52b0f64eeb51
    26 #include <HbSearchPanel>
    26 #include <HbSearchPanel>
    27 #include <HbPushButton>
    27 #include <HbPushButton>
    28 #include <HbToolBar>
    28 #include <HbToolBar>
    29 #include <HbView>
    29 #include <HbView>
    30 #include <HbToolBarExtension>
    30 #include <HbToolBarExtension>
    31 #include <HbStaticVkbHost>
    31 #include <HbShrinkingVkbHost>
    32 
    32 
    33 #include "hsallappsstate.h"
    33 #include "hsallappsstate.h"
    34 #include "hsallcollectionsstate.h"
    34 #include "hsallcollectionsstate.h"
    35 #include "hscollectionstate.h"
    35 #include "hscollectionstate.h"
    36 #include "hsmenuitemmodel.h"
    36 #include "hsmenuitemmodel.h"
    63     mProxyModel(new QSortFilterProxyModel(this)),
    63     mProxyModel(new QSortFilterProxyModel(this)),
    64     mView(NULL),
    64     mView(NULL),
    65     mListView(NULL),
    65     mListView(NULL),
    66     mViewLabel(NULL),
    66     mViewLabel(NULL),
    67     mSearchListView(NULL),
    67     mSearchListView(NULL),
    68     mSearchPanel(NULL), 
    68     mSearchPanel(NULL),
    69     mVkbHost(NULL)
    69     mVkbHost(NULL)
    70 {
    70 {
    71     mBuilder.setOperationalContext(HsItemViewContext);
    71     mBuilder.setOperationalContext(HsItemViewContext);
    72     mBuilder.setViewContext(mViewContext);
    72     mBuilder.setViewContext(mViewContext);
    73     mBuilder.build();
    73     mBuilder.build();
    81 
    81 
    82     mProxyModel->setFilterRole(CaItemModel::TextRole);
    82     mProxyModel->setFilterRole(CaItemModel::TextRole);
    83     mProxyModel->setFilterKeyColumn(1);
    83     mProxyModel->setFilterKeyColumn(1);
    84     mProxyModel->setSortRole(CaItemModel::TextRole);
    84     mProxyModel->setSortRole(CaItemModel::TextRole);
    85 
    85 
    86     mVkbHost = new HbStaticVkbHost(mView);
    86     mVkbHost.reset(new HbShrinkingVkbHost(mView));
    87     connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
       
    88     connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
       
    89 
    87 
    90     connect(mListView,
    88     connect(mListView,
    91             SIGNAL(activated(QModelIndex)),
    89             SIGNAL(activated(QModelIndex)),
    92             this, SIGNAL(activated(QModelIndex)));
    90             this, SIGNAL(activated(QModelIndex)));
    93     connect(mListView,
    91     connect(mListView,
   365  Looks up for item and if found scrolls to it.
   363  Looks up for item and if found scrolls to it.
   366  \param criteriaStr The item name to find.
   364  \param criteriaStr The item name to find.
   367  */
   365  */
   368 void HsMenuView::findItem(QString criteriaStr)
   366 void HsMenuView::findItem(QString criteriaStr)
   369 {
   367 {
   370     qDebug
   368    qDebug() << QString("hsmenuview::findItem: %1").arg(criteriaStr);
   371     () << QString("hsmenuview::findItem: %1").arg(criteriaStr);
       
   372     HSMENUTEST_FUNC_ENTRY("hsmenuview::findItem");
   369     HSMENUTEST_FUNC_ENTRY("hsmenuview::findItem");
   373 
   370 
   374     if ("" != criteriaStr) {
   371     mProxyModel->invalidate();
   375         mProxyModel->invalidate();
   372     mProxyModel->setSourceModel(mListView->model());
   376         mProxyModel->setSourceModel(mListView->model());
   373     mProxyModel->setFilterRegExp(QRegExp(
   377         mProxyModel->setFilterRegExp(QRegExp(
   374             QString("(^|\\b)%1").arg(criteriaStr), Qt::CaseInsensitive));
   378                 QString("(^|\\b)%1").arg(criteriaStr), Qt::CaseInsensitive));
   375 
   379         mSearchListView->scrollTo(mProxyModel->index(0,0),
   376     mSearchListView->scrollTo(mProxyModel->index(0,0),
   380                                   HbAbstractItemView::PositionAtTop);
   377                               HbAbstractItemView::PositionAtTop);
   381     } else {
   378     
   382         mProxyModel->setFilterRegExp(QRegExp(QString(".*"),
       
   383                                              Qt::CaseInsensitive, QRegExp::RegExp));
       
   384 
       
   385         // scroll to first item in model
       
   386         mSearchListView->scrollTo(
       
   387             mProxyModel->index(0, 0),
       
   388 
       
   389             HbAbstractItemView::PositionAtTop);
       
   390     }
       
   391     HSMENUTEST_FUNC_EXIT("hsmenuview::findItem");
   379     HSMENUTEST_FUNC_EXIT("hsmenuview::findItem");
   392 }
   380 }
   393 
   381 
   394 /*!
   382 /*!
   395  Makes the view display search panel with view representing search results.
   383  Makes the view display search panel with view representing search results.
   438 
   426 
   439     mListView->scrollTo(indexToScroll, HbAbstractItemView::PositionAtTop);
   427     mListView->scrollTo(indexToScroll, HbAbstractItemView::PositionAtTop);
   440 
   428 
   441     mSearchListView = NULL;
   429     mSearchListView = NULL;
   442     mSearchPanel = NULL;
   430     mSearchPanel = NULL;
   443     vkbClosed();
       
   444     HSMENUTEST_FUNC_EXIT("hsmenuview::searchFinished");
   431     HSMENUTEST_FUNC_EXIT("hsmenuview::searchFinished");
   445 }
   432 }
   446 
   433 
   447 /*!
   434 /*!
   448  Slot used to translate activated signal from proxy model to normal model.
   435  Slot used to translate activated signal from proxy model to normal model.
   491     mBuilder.toolBarExtension()->close();
   478     mBuilder.toolBarExtension()->close();
   492 
   479 
   493     disconnect(mBuilder.searchAction(), SIGNAL(triggered()),
   480     disconnect(mBuilder.searchAction(), SIGNAL(triggered()),
   494                this, SLOT(showSearchPanel()));
   481                this, SLOT(showSearchPanel()));
   495 }
   482 }
   496 
       
   497 
       
   498 /*!
       
   499  change size of view when VKB is opened
       
   500  */
       
   501 void HsMenuView::vkbOpened()
       
   502 {
       
   503     mView->setMaximumHeight(mVkbHost->applicationArea().height());   
       
   504 }
       
   505 
       
   506 /*!
       
   507  change size of view when VKB is closed
       
   508  */
       
   509 void HsMenuView::vkbClosed()
       
   510 {
       
   511      mView->setMaximumHeight(-1);   
       
   512 }
       
   513