qtinternetradio/ui/src/irsearchchannelsview.cpp
changeset 11 f683e24efca3
parent 8 3b03c28289e6
child 12 608f67c22514
equal deleted inserted replaced
8:3b03c28289e6 11:f683e24efca3
    23 #include <hbscrollbar.h> 
    23 #include <hbscrollbar.h> 
    24 #include <hbiconitem.h>
    24 #include <hbiconitem.h>
    25 #include <hbiconanimator.h>
    25 #include <hbiconanimator.h>
    26 #include <hblabel.h> 
    26 #include <hblabel.h> 
    27 #include <hbiconanimationmanager.h>
    27 #include <hbiconanimationmanager.h>
       
    28 #include <HbGroupBox>
    28 
    29 
    29 #include "irsearchchannelsview.h"
    30 #include "irsearchchannelsview.h"
    30 #include "iruidefines.h"
    31 #include "iruidefines.h"
    31 #include "irqisdsclient.h"
    32 #include "irqisdsclient.h"
    32 #include "irapplication.h"
    33 #include "irapplication.h"
    38  
    39  
    39 const uint KBitmapSize = 59;
    40 const uint KBitmapSize = 59;
    40 
    41 
    41 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication,
    42 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication,
    42         TIRViewId aViewId): IRBaseView(aApplication, aViewId),
    43         TIRViewId aViewId): IRBaseView(aApplication, aViewId),
    43         iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init),
    44         iHeadingLabel(NULL),iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init),
    44         iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL),
    45         iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL),
    45         iConvertTimer(NULL) 
    46         iConvertTimer(NULL) 
    46 {
    47 {
    47     //if this view is not starting view, finish all initialization in constructor
    48     //if this view is not starting view, finish all initialization in constructor
    48     if (getViewManager()->views().count() > 0)
    49     if (getViewManager()->views().count() > 0)
    76     }
    77     }
    77 }
    78 }
    78 
    79 
    79 void IRSearchChannelsView::initMenu()
    80 void IRSearchChannelsView::initMenu()
    80 {
    81 {
    81 
    82     HbMenu *viewMenu = menu();
       
    83     QObject *exitAction = iLoader.findObject(EXIT_ACTION);
       
    84     connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit()));
    82 }
    85 }
    83 
    86 
    84 void IRSearchChannelsView::initTimer()
    87 void IRSearchChannelsView::initTimer()
    85 {     
    88 {     
    86     iConvertTimer = new QTimer(this);
    89     iConvertTimer = new QTimer(this);
   121     QObjectList roots;
   124     QObjectList roots;
   122     roots.append( this );
   125     roots.append( this );
   123     iLoader.setObjectTree( roots );
   126     iLoader.setObjectTree( roots );
   124     iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME);
   127     iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME);
   125     
   128     
       
   129     iHeadingLabel = qobject_cast<HbGroupBox *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_HEADINGTEXT_WIDGET));
       
   130     
       
   131     
   126     iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET));    
   132     iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET));    
   127     
   133     
   128     iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET));   
   134     iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET));   
   129     iListView->setFlag(ItemIsFocusable);
   135     iListView->setFlag(ItemIsFocusable);
   130     HbScrollBar *scrollbar = iListView->verticalScrollBar();
   136     HbScrollBar *scrollbar = iListView->verticalScrollBar();
   133     iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
   139     iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
   134     
   140     
   135     iChannelModel = new IrChannelModel(this);
   141     iChannelModel = new IrChannelModel(this);
   136     iChannelModel->initWithCache();
   142     iChannelModel->initWithCache();
   137     iListView->setModel(iChannelModel);    
   143     iListView->setModel(iChannelModel);    
       
   144     //anywhere, before show the count, updated it ahead.
       
   145 #ifdef SUBTITLE_STR_BY_LOCID
       
   146     QString headingStr = hbTrId("txt_irad_subtitle_search_results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; 
       
   147 #else
       
   148     QString headingStr = hbTrId("Search results") + " (" + QString::number(iChannelModel->rowCount()) + ")";
       
   149 #endif
       
   150 
       
   151     setHeadingText(headingStr);  
   138 }
   152 }
   139 
   153 
   140 void IRSearchChannelsView::connectWidget()
   154 void IRSearchChannelsView::connectWidget()
   141 {     
   155 {     
   142     connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&)));
   156     connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&)));
   291         errStr = hbTrId("txt_irad_info_failed_to_connect");
   305         errStr = hbTrId("txt_irad_info_failed_to_connect");
   292         break;   
   306         break;   
   293     }
   307     }
   294     
   308     
   295     popupNote(errStr, HbMessageBox::MessageTypeWarning);     
   309     popupNote(errStr, HbMessageBox::MessageTypeWarning);     
       
   310     iChannelModel->cleanupDatabase();
   296 }
   311 }
   297 
   312 
   298 void IRSearchChannelsView::clickItem(const QModelIndex&)
   313 void IRSearchChannelsView::clickItem(const QModelIndex&)
   299 {
   314 {
   300     setUseNetworkReason(EIR_UseNetwork_SelectItem);
   315     setUseNetworkReason(EIR_UseNetwork_SelectItem);
   330     { 
   345     { 
   331         startConvert(iIconIndexArray[0]);   
   346         startConvert(iIconIndexArray[0]);   
   332     }
   347     }
   333 }
   348 }
   334 
   349 
       
   350 //set the subtitle and counter;
       
   351 void IRSearchChannelsView::setHeadingText(const QString &aText)
       
   352 {
       
   353     if (iHeadingLabel)
       
   354     {
       
   355         iHeadingLabel->setHeading(aText);
       
   356     }    
       
   357 }
   335 void IRSearchChannelsView::dataChanged()
   358 void IRSearchChannelsView::dataChanged()
   336 {
   359 {
   337     switch2InitState(); 
   360     switch2InitState(); 
       
   361     //here update count in subtitle
       
   362 #ifdef SUBTITLE_STR_BY_LOCID
       
   363     QString headingStr = hbTrId("txt_irad_subtitle_search_results") + " (" + QString::number(iChannelModel->rowCount()) + ")"; 
       
   364 #else
       
   365     QString headingStr = hbTrId("Search results") + " (" + QString::number(iChannelModel->rowCount()) + ")";
       
   366 #endif
       
   367     setHeadingText(headingStr);   
   338     iListView->reset();
   368     iListView->reset();
   339     iListView->setCurrentIndex(iChannelModel->index(0));
   369     if( iChannelModel->rowCount() )
   340     iListView->scrollTo(iChannelModel->index(0)); 
   370     {
   341  
   371         iListView->setCurrentIndex(iChannelModel->index(0));
       
   372         iListView->scrollTo(iChannelModel->index(0));         
       
   373     }
       
   374     
   342     //we move the focus to the listview and the search panel will
   375     //we move the focus to the listview and the search panel will
   343     //hide the virtual keyboard at the same time
   376     //hide the virtual keyboard at the same time
   344     iListView->setFocus();            
   377     iListView->setFocus();            
   345     
   378     
   346     iIconIndexArray.clear();
   379     iIconIndexArray.clear();
   354     }
   387     }
   355     
   388     
   356     if( iIconIndexArray.count() > 0 )
   389     if( iIconIndexArray.count() > 0 )
   357     {
   390     {
   358         iConvertTimer->start();        
   391         iConvertTimer->start();        
   359     } 
   392     }   
   360     
       
   361     iSearchPanelWidget->setPlaceholderText(iKeyText); 
       
   362 }
   393 }
   363 
   394 
   364 void IRSearchChannelsView::startConvert(int aIndex)
   395 void IRSearchChannelsView::startConvert(int aIndex)
   365 {
   396 {
   366     QString url = iChannelModel->imageUrl(aIndex);
   397     QString url = iChannelModel->imageUrl(aIndex);