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 #include <HbGroupBox> |
|
29 #include <qinputcontext.h> |
|
30 #include <qapplication.h> |
29 |
31 |
30 #include "irsearchchannelsview.h" |
32 #include "irsearchchannelsview.h" |
31 #include "iruidefines.h" |
33 #include "iruidefines.h" |
32 #include "irqisdsclient.h" |
34 #include "irqisdsclient.h" |
33 #include "irapplication.h" |
35 #include "irapplication.h" |
34 #include "irviewmanager.h" |
36 #include "irviewmanager.h" |
35 #include "irqnetworkcontroller.h" |
37 #include "irqnetworkcontroller.h" |
36 #include "irchannelmodel.h" |
38 #include "irchannelmodel.h" |
37 #include "irqisdsdatastructure.h" |
39 #include "irqisdsdatastructure.h" |
38 #include "irplaycontroller.h" |
40 #include "irplaycontroller.h" |
|
41 #include "irqlogger.h" |
|
42 #include "irqsettings.h" |
39 |
43 |
40 const uint KBitmapSize = 59; |
44 const uint KBitmapSize = 59; |
41 |
45 |
42 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
46 IRSearchChannelsView::IRSearchChannelsView(IRApplication* aApplication, |
43 TIRViewId aViewId): IRBaseView(aApplication, aViewId), |
47 TIRViewId aViewId): IRBaseView(aApplication, aViewId), |
44 iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init), |
48 iListView(NULL),iSearchPanelWidget(NULL),iSearchState(ESearch_init), |
45 iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL), |
49 iChannelModel(NULL),iPreset(NULL),iLogoPreset(NULL), |
46 iConvertTimer(NULL) |
50 iConvertTimer(NULL) |
47 { |
51 { |
|
52 LOG_METHOD; |
|
53 iSettings = IRQSettings::openInstance(); |
48 //if this view is not starting view, finish all initialization in constructor |
54 //if this view is not starting view, finish all initialization in constructor |
49 if (getViewManager()->views().count() > 0) |
55 if (getViewManager()->views().count() > 0) |
50 { |
56 { |
51 if (!initCompleted()) |
57 if (!initCompleted()) |
52 { |
58 { |
77 } |
85 } |
78 } |
86 } |
79 |
87 |
80 void IRSearchChannelsView::initMenu() |
88 void IRSearchChannelsView::initMenu() |
81 { |
89 { |
|
90 LOG_METHOD; |
82 HbMenu *viewMenu = menu(); |
91 HbMenu *viewMenu = menu(); |
83 QObject *exitAction = iLoader.findObject(EXIT_ACTION); |
92 QObject *exitAction = iLoader.findObject(EXIT_ACTION); |
84 connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit())); |
93 connect(exitAction, SIGNAL(triggered()), iApplication, SIGNAL(quit())); |
85 } |
94 } |
86 |
95 |
87 void IRSearchChannelsView::initTimer() |
96 void IRSearchChannelsView::initTimer() |
88 { |
97 { |
|
98 LOG_METHOD; |
89 iConvertTimer = new QTimer(this); |
99 iConvertTimer = new QTimer(this); |
90 iConvertTimer->setInterval(10); |
100 iConvertTimer->setInterval(10); |
91 |
101 |
92 connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother())); |
102 connect(iConvertTimer, SIGNAL(timeout()), this, SLOT(convertAnother())); |
93 } |
103 } |
94 |
104 |
95 |
105 |
96 |
106 |
97 IRSearchChannelsView::~IRSearchChannelsView() |
107 IRSearchChannelsView::~IRSearchChannelsView() |
98 { |
108 { |
|
109 LOG_METHOD; |
|
110 |
|
111 if (iSettings) |
|
112 { |
|
113 iSettings->setSearchText(iKeyText); |
|
114 iSettings->closeInstance(); |
|
115 } |
|
116 |
99 if( iPreset != NULL ) |
117 if( iPreset != NULL ) |
100 { |
118 { |
101 delete iPreset; |
119 delete iPreset; |
102 iPreset = NULL; |
120 iPreset = NULL; |
103 } |
121 } |
115 |
133 |
116 } |
134 } |
117 |
135 |
118 void IRSearchChannelsView::loadLayout() |
136 void IRSearchChannelsView::loadLayout() |
119 { |
137 { |
|
138 LOG_METHOD; |
120 // Create widget hierarchy |
139 // Create widget hierarchy |
121 setObjectName( SEARCH_CHANNELS_VIEW_OBJECT_VIEW ); |
140 setObjectName( SEARCH_CHANNELS_VIEW_OBJECT_VIEW ); |
122 // List existing root elements - this allows us to refer to objects in the XML |
141 // List existing root elements - this allows us to refer to objects in the XML |
123 // which are created outside the document. |
142 // which are created outside the document. |
124 QObjectList roots; |
143 QObjectList roots; |
125 roots.append( this ); |
144 roots.append( this ); |
126 iLoader.setObjectTree( roots ); |
145 iLoader.setObjectTree( roots ); |
127 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
146 iLoader.load(SEARCH_CHANNELS_VIEW_LAYOUT_FILENAME); |
128 |
147 |
129 iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET)); |
148 iSearchPanelWidget = qobject_cast<HbSearchPanel *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHPANEL_WIDGET)); |
130 |
149 QString searchText; |
|
150 iSettings->getSearchText(searchText); |
|
151 iKeyText = searchText; |
|
152 iSearchPanelWidget->setCriteria(searchText); |
|
153 |
131 iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET)); |
154 iListView = qobject_cast<HbListView *>(iLoader.findWidget(SEARCH_CHANNELS_VIEW_SEARCHLISTVIEW_WIDGET)); |
132 iListView->setFlag(ItemIsFocusable); |
155 iListView->setFlag(ItemIsFocusable); |
133 HbScrollBar *scrollbar = iListView->verticalScrollBar(); |
156 HbScrollBar *scrollbar = iListView->verticalScrollBar(); |
134 scrollbar->setVisible(true); |
157 scrollbar->setVisible(true); |
135 scrollbar->setInteractive(true); |
158 scrollbar->setInteractive(true); |
136 iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
159 iListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
137 |
160 |
138 iChannelModel = new IrChannelModel(this); |
161 iChannelModel = new IrChannelModel(this); |
139 iChannelModel->initWithCache(); |
162 iChannelModel->initWithCache(); |
140 iListView->setModel(iChannelModel); |
163 iListView->setModel(iChannelModel); |
|
164 scrollbar->setValue(0.0); |
|
165 |
|
166 iListView->installEventFilter(this); |
|
167 |
|
168 #ifdef SUBTITLE_STR_BY_LOCID |
|
169 setTitle(hbTrId("txt_irad_title_internet_radio")); |
|
170 |
|
171 #else |
|
172 setTitle("Internet radio"); |
|
173 #endif |
|
174 |
141 } |
175 } |
142 |
176 |
143 void IRSearchChannelsView::connectWidget() |
177 void IRSearchChannelsView::connectWidget() |
144 { |
178 { |
|
179 LOG_METHOD; |
145 connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&))); |
180 connect(iListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(clickItem(const QModelIndex&))); |
146 connect(iChannelModel, SIGNAL(dataAvailable()), this, SLOT(dataChanged())); |
181 connect(iChannelModel, SIGNAL(dataAvailable()), this, SLOT(dataChanged())); |
147 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
182 connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), this, SLOT(networkRequestNotified(IRQNetworkEvent))); |
148 connect(iSearchPanelWidget,SIGNAL(criteriaChanged(const QString&)),this,SLOT(searchTextAlready(const QString&))); |
183 connect(iSearchPanelWidget,SIGNAL(criteriaChanged(const QString&)),this,SLOT(searchTextAlready(const QString&))); |
149 connect(iSearchPanelWidget, SIGNAL(exitClicked()), this, SLOT(minimizeSearchPanel())); |
184 connect(iSearchPanelWidget, SIGNAL(exitClicked()), this, SLOT(minimizeSearchPanel())); |
150 } |
185 } |
151 |
186 |
152 void IRSearchChannelsView::connectIsdsClient() |
187 void IRSearchChannelsView::connectIsdsClient() |
153 { |
188 { |
|
189 LOG_METHOD; |
154 connect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
190 connect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
155 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
191 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
156 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
192 connect(iIsdsClient, SIGNAL(operationException(IRQError)), |
157 this, SLOT(operationException(IRQError))); |
193 this, SLOT(operationException(IRQError))); |
158 connect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
194 connect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
165 |
201 |
166 } |
202 } |
167 |
203 |
168 void IRSearchChannelsView::disconnectIsdsClient() |
204 void IRSearchChannelsView::disconnectIsdsClient() |
169 { |
205 { |
|
206 LOG_METHOD; |
170 disconnect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
207 disconnect(iIsdsClient, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)), |
171 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
208 iChannelModel, SLOT(updateData(QList<IRQChannelItem *> *))); |
172 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), this, |
209 disconnect(iIsdsClient, SIGNAL(operationException(IRQError)), this, |
173 SLOT(operationException(IRQError))); |
210 SLOT(operationException(IRQError))); |
174 disconnect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
211 disconnect(iIsdsClient, SIGNAL(presetResponse(IRQPreset *)), |
179 this, SLOT(presetLogoDownloadError())); |
216 this, SLOT(presetLogoDownloadError())); |
180 } |
217 } |
181 |
218 |
182 void IRSearchChannelsView::switch2InitState() |
219 void IRSearchChannelsView::switch2InitState() |
183 { |
220 { |
|
221 LOG_METHOD; |
184 iSearchState = ESearch_init; |
222 iSearchState = ESearch_init; |
185 iApplication->stopLoadingAnimation(); |
223 iApplication->stopLoadingAnimation(); |
186 } |
224 } |
187 |
225 |
188 void IRSearchChannelsView::switch2LoadingState() |
226 void IRSearchChannelsView::switch2LoadingState() |
189 { |
227 { |
|
228 LOG_METHOD; |
190 iSearchPanelWidget->clearFocus(); |
229 iSearchPanelWidget->clearFocus(); |
191 iListView->setFocus(); |
230 iListView->setFocus(); |
192 iSearchState = ESearch_Loading; |
231 iSearchState = ESearch_Loading; |
193 iApplication->startLoadingAnimation(this, SLOT(minimizeSearchPanel())); |
232 iApplication->startLoadingAnimation(this, SLOT(minimizeSearchPanel())); |
194 } |
233 } |
195 |
234 |
196 void IRSearchChannelsView::handleItemSelected() |
235 void IRSearchChannelsView::handleItemSelected() |
197 { |
236 { |
|
237 LOG_METHOD; |
198 if (iListView) |
238 if (iListView) |
199 { |
239 { |
200 int index = iListView->currentIndex().row(); |
240 int index = iListView->currentIndex().row(); |
201 IRQChannelItem* aItem = iChannelModel->getChannelItemByIndex(index); |
241 IRQChannelItem* aItem = iChannelModel->getChannelItemByIndex(index); |
202 if( NULL != aItem ) |
242 if( NULL != aItem ) |