|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Definition file for class ClockAlarmListModel. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <QDebug> |
|
21 #include <QTimer> |
|
22 |
|
23 #include <QStandardItemModel> |
|
24 #include <QStandardItem> |
|
25 #include <HbIcon> |
|
26 |
|
27 // User includes |
|
28 #include "clockalarmlistmodel.h" |
|
29 #include "alarmclient.h" |
|
30 #include "timezoneclient.h" |
|
31 #include "clockalarmlistitemprototype.h" |
|
32 #include "clockappcontrollerif.h" |
|
33 #include "settingsutility.h" |
|
34 |
|
35 // Constants |
|
36 const int KOneHourInMinute(60); |
|
37 const int KOneMinuteInSecons(60); |
|
38 const int KSecondsInOneDay(24 * 60 * 60); |
|
39 |
|
40 /*! |
|
41 \class ClockAlarmListModel |
|
42 |
|
43 This is the source model class for the clock main view. This owns |
|
44 a QStandardItemModel which is a model for the data containing alarms. |
|
45 */ |
|
46 |
|
47 /*! |
|
48 Constructor. |
|
49 |
|
50 \param parent Parent of type QObject. |
|
51 */ |
|
52 ClockAlarmListModel::ClockAlarmListModel( |
|
53 ClockAppControllerIf &controllerIf, QObject *parent) |
|
54 :QObject(parent), |
|
55 mSourceModel(0), |
|
56 mAppControllerIf(controllerIf) |
|
57 { |
|
58 qDebug() << "clock: ClockAlarmListModel::ClockAlarmListModel -->"; |
|
59 |
|
60 // Construct the source model. |
|
61 mSourceModel = new QStandardItemModel(0, 1, this); |
|
62 |
|
63 // Register to listen to the alarm state changes. |
|
64 mAppControllerIf.alarmClient()->startListener(); |
|
65 connect( |
|
66 mAppControllerIf.alarmClient(), SIGNAL(alarmStateChanged(int)), |
|
67 this, SLOT(updateSourceModel(int))); |
|
68 |
|
69 connect( |
|
70 mAppControllerIf.timezoneClient(), SIGNAL(timechanged()), |
|
71 this, SLOT(updateRemainingTime())); |
|
72 // Start a timer. For updating the remaining alarm time. |
|
73 mTickTimer = new QTimer(this); |
|
74 connect( |
|
75 mTickTimer, SIGNAL(timeout()), |
|
76 this, SLOT(updateRemainingTime())); |
|
77 |
|
78 qDebug() << "clock: ClockAlarmListModel::ClockAlarmListModel <--"; |
|
79 } |
|
80 |
|
81 /*! |
|
82 Destructor. |
|
83 */ |
|
84 ClockAlarmListModel::~ClockAlarmListModel() |
|
85 { |
|
86 qDebug() << "clock: ClockAlarmListModel::~ClockAlarmListModel -->"; |
|
87 |
|
88 if (mSourceModel) { |
|
89 delete mSourceModel; |
|
90 mSourceModel = 0; |
|
91 } |
|
92 |
|
93 qDebug() << "clock: ClockAlarmListModel::~ClockAlarmListModel <--"; |
|
94 } |
|
95 |
|
96 /*! |
|
97 Populates the source model & starts the timer for 1 minute. |
|
98 */ |
|
99 void ClockAlarmListModel::populateModel() |
|
100 { |
|
101 // Populate the model in a different thread. |
|
102 QTimer::singleShot(1, this, SLOT(populateSourceModel())); |
|
103 } |
|
104 /*! |
|
105 Returns the source model to be used with clock main view. |
|
106 |
|
107 \return QAbstractItemModel |
|
108 \sa QAbstractItemModel, HbListView. |
|
109 */ |
|
110 QAbstractItemModel *ClockAlarmListModel::sourceModel() |
|
111 { |
|
112 qDebug() << "clock: ClockAlarmListModel::sourceModel -->"; |
|
113 |
|
114 qDebug() << "clock: ClockAlarmListModel::sourceModel <--"; |
|
115 |
|
116 return mSourceModel; |
|
117 } |
|
118 |
|
119 /*! |
|
120 Populates the source model. |
|
121 */ |
|
122 void ClockAlarmListModel::populateSourceModel() |
|
123 { |
|
124 qDebug() << "clock: ClockAlarmListModel::populateSourceModel -->"; |
|
125 |
|
126 // Clear the model if it has any data already. |
|
127 mSourceModel->clear(); |
|
128 mSourceModel->setColumnCount(1); |
|
129 |
|
130 QList<AlarmInfo> alarmInfoList; |
|
131 |
|
132 // Get the list of pending clock alarms. |
|
133 mAppControllerIf.alarmClient()->getAlarmList(alarmInfoList); |
|
134 |
|
135 // First create a list of alarms with the order of active & inactive alarms. |
|
136 AlarmInfo alarminfo; |
|
137 for (int index = 0; index < alarmInfoList.count(); index++) { |
|
138 alarminfo = alarmInfoList[index]; |
|
139 if (Enabled == alarminfo.alarmStatus) { |
|
140 // Append alarm into the source model. |
|
141 appendAlarmToModel(alarminfo); |
|
142 } |
|
143 } |
|
144 for (int index = 0; index < alarmInfoList.count(); index++) { |
|
145 alarminfo = alarmInfoList[index]; |
|
146 if (Disabled == alarminfo.alarmStatus) { |
|
147 // Append alarm into the source model. |
|
148 appendAlarmToModel(alarminfo); |
|
149 } |
|
150 } |
|
151 |
|
152 if (0 < getActiveAlarmCount() && !mTickTimer->isActive()) { |
|
153 // Start the Timer for 1 minute. |
|
154 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
|
155 } |
|
156 qDebug() << "clock: ClockAlarmListModel::populateSourceModel <--"; |
|
157 } |
|
158 |
|
159 /*! |
|
160 Calculates the remaining time for the given alarm. |
|
161 |
|
162 \param alarmInfo AlarmInfo containing the active alarm. |
|
163 */ |
|
164 QString ClockAlarmListModel::calculateRemainingTime(AlarmInfo alarmInfo) |
|
165 { |
|
166 qDebug() << "clock: ClockAlarmListModel::calculateRemainingTime -->"; |
|
167 |
|
168 QDateTime currentDateTime = QDateTime::currentDateTime(); |
|
169 QDateTime alarmTime = QDateTime( |
|
170 alarmInfo.alarmDateTime, alarmInfo.nextDueTime); |
|
171 QString timeNote; |
|
172 |
|
173 // TODO: method getRemainingSeconds is used since secsTo API is |
|
174 // not returning the proper value. |
|
175 // int remianSecs = currentDateTime.secsTo(alarmTime); |
|
176 int remainSecs = getRemainingSeconds(alarmTime); |
|
177 QDateTime timeLeft(QDate(2009,1,1), QTime(0,0)); //do -1 for day always. |
|
178 |
|
179 QDateTime temp = timeLeft.addSecs(remainSecs); |
|
180 |
|
181 int hourleft = temp.time().hour(); |
|
182 int minleft = temp.time().minute(); |
|
183 int secleft = temp.time().second(); |
|
184 int dayleft = temp.date().day() - 1; |
|
185 |
|
186 if (dayleft >= 1) { |
|
187 hourleft += (dayleft * 24); |
|
188 } |
|
189 QString formatTimeNote; |
|
190 |
|
191 if (hourleft <= 48) { |
|
192 switch (hourleft) { |
|
193 case 1: { |
|
194 if (1 == minleft) { |
|
195 formatTimeNote = |
|
196 hbTrId("txt_clock_main_view_setlabel_in_1hr_2min"); |
|
197 } else { |
|
198 formatTimeNote = |
|
199 hbTrId("txt_clock_main_view_setlabel_in_1hr_2mins"); |
|
200 } |
|
201 } |
|
202 break; |
|
203 |
|
204 default: { |
|
205 if (1 == minleft) { |
|
206 formatTimeNote = |
|
207 hbTrId("txt_clock_main_view_setlabel_in_1hrs_2min"); |
|
208 } else { |
|
209 formatTimeNote = |
|
210 hbTrId("txt_clock_main_view_setlabel_in_1hrs_2mins"); |
|
211 } |
|
212 } |
|
213 } |
|
214 timeNote = formatTimeNote.arg( |
|
215 QString::number(hourleft), QString::number(minleft)); |
|
216 } else { |
|
217 formatTimeNote = hbTrId("txt_clock_main_view_setlabel_in_1days"); |
|
218 timeNote = formatTimeNote.arg(QString::number(dayleft)); |
|
219 } |
|
220 qDebug() << "clock: ClockAlarmListModel::calculateRemainingTime <--"; |
|
221 |
|
222 return timeNote; |
|
223 } |
|
224 |
|
225 /*! |
|
226 Gets remaining seconds to the alarm time from current date time. |
|
227 |
|
228 \param alarmDateTime reference to the alarm date time. |
|
229 \return int returns the remaining seconds calculated. |
|
230 */ |
|
231 int ClockAlarmListModel::getRemainingSeconds(QDateTime &alarmDateTime) |
|
232 { |
|
233 int remainingSeconds; |
|
234 QDateTime currentDateTime = QDateTime::currentDateTime(); |
|
235 |
|
236 int currentTimeInSec = |
|
237 (currentDateTime.time().hour() |
|
238 * KOneHourInMinute * KOneMinuteInSecons) |
|
239 + (currentDateTime.time().minute() * KOneMinuteInSecons) |
|
240 + currentDateTime.time().second(); |
|
241 |
|
242 int alarmTimeInSec = |
|
243 alarmDateTime.time().hour() * KOneHourInMinute * KOneMinuteInSecons |
|
244 + alarmDateTime.time().minute() * KOneMinuteInSecons |
|
245 + alarmDateTime.time().second(); |
|
246 |
|
247 int dayInterval = |
|
248 alarmDateTime.date().day() - currentDateTime.date().day(); |
|
249 |
|
250 if (dayInterval) { |
|
251 alarmTimeInSec += (dayInterval*KSecondsInOneDay); |
|
252 } |
|
253 |
|
254 remainingSeconds = alarmTimeInSec - currentTimeInSec; |
|
255 return remainingSeconds; |
|
256 } |
|
257 |
|
258 /*! |
|
259 Slot which Updates the source model with the given alarm `id'. |
|
260 The alarm could be newly added or deleted or have undergone a status change |
|
261 or have just been modified. |
|
262 |
|
263 \param id of alarm, identifies the alarm which was changed. |
|
264 */ |
|
265 void ClockAlarmListModel::updateSourceModel(int alarmId) |
|
266 { |
|
267 qDebug() << "clock: ClockAlarmListModel::updateSourceModel -->"; |
|
268 |
|
269 Q_UNUSED(alarmId) |
|
270 int alarmInfoCount; |
|
271 int modelCount; |
|
272 bool newAlarm = false; |
|
273 bool alarmDeleted = false; |
|
274 |
|
275 // Get the list of pending clock alarms from server. |
|
276 QList<AlarmInfo> alarmInfoList; |
|
277 mAppControllerIf.alarmClient()->getAlarmList(alarmInfoList); |
|
278 modelCount = mSourceModel->rowCount(); |
|
279 |
|
280 // First create a list of alarms with the order of active & inactive alarms. |
|
281 QList<AlarmInfo> alarmDisplayList; |
|
282 AlarmInfo alarminfo; |
|
283 for (int index = 0; index < alarmInfoList.count(); index++) { |
|
284 alarminfo = alarmInfoList[index]; |
|
285 if (Enabled == alarminfo.alarmStatus |
|
286 && Notified != alarminfo.alarmState) { |
|
287 // Append only active alarms to the alarmDisplayList. |
|
288 alarmDisplayList.append(alarminfo); |
|
289 } |
|
290 } |
|
291 for (int index = 0; index < alarmInfoList.count(); index++) { |
|
292 alarminfo = alarmInfoList[index]; |
|
293 if (Disabled == alarminfo.alarmStatus) { |
|
294 // Append only active alarms to the alarmDisplayList. |
|
295 alarmDisplayList.append(alarminfo); |
|
296 } |
|
297 } |
|
298 alarmInfoCount = alarmDisplayList.count(); |
|
299 |
|
300 AlarmInfo alarmInfo; |
|
301 int index = 0; |
|
302 |
|
303 if (alarmInfoCount > modelCount) { |
|
304 // If alarm count from server is more than in model then, a new alarm |
|
305 // has been queued into server. |
|
306 newAlarm = true; |
|
307 } else if (alarmInfoCount < modelCount) { |
|
308 // If alarm count from server is less than in model then, an alarm |
|
309 // has been deleted from server. |
|
310 alarmDeleted = true; |
|
311 } |
|
312 if (0 < modelCount) { |
|
313 int maxCount = 0; |
|
314 if (newAlarm) { |
|
315 maxCount = modelCount; |
|
316 } else if (alarmDeleted) { |
|
317 maxCount = alarmInfoCount; |
|
318 } else { |
|
319 maxCount = alarmInfoCount; |
|
320 } |
|
321 // Update the alarm details. |
|
322 for (; index < maxCount; index++) { |
|
323 alarmInfo = alarmDisplayList[index]; |
|
324 QModelIndex modelIndex = mSourceModel->index(index,0); |
|
325 if (modelIndex.isValid()) { |
|
326 updateAlarmDetails(modelIndex, alarmInfo); |
|
327 } |
|
328 } |
|
329 } |
|
330 if (newAlarm) { |
|
331 emit changeAlarmListDisplay(); |
|
332 alarmInfo = alarmDisplayList[index]; |
|
333 appendAlarmToModel(alarmInfo); |
|
334 } |
|
335 if (alarmDeleted) { |
|
336 QModelIndex modelIndex = mSourceModel->index(index, 0); |
|
337 if (modelIndex.isValid()) { |
|
338 mSourceModel->removeRow(modelIndex.row()); |
|
339 } |
|
340 // If alarm count is "0" then hide the alarmlist in the view. |
|
341 if (0 == mSourceModel->rowCount()) { |
|
342 emit changeAlarmListDisplay(); |
|
343 } |
|
344 } |
|
345 if (0 < getActiveAlarmCount()) { |
|
346 if (!mTickTimer->isActive()) { |
|
347 // Start the Timer for 1 minute. |
|
348 mTickTimer->start(60000 - 1000 * QTime::currentTime().second()); |
|
349 } |
|
350 } else { |
|
351 if (mTickTimer->isActive()) { |
|
352 // Stop the timer if no more active alarms are present. |
|
353 mTickTimer->stop(); |
|
354 } |
|
355 } |
|
356 |
|
357 qDebug() << "clock: ClockAlarmListModel::updateSourceModel <--"; |
|
358 } |
|
359 |
|
360 /*! |
|
361 Slot which Updates the remaining time field in the alarms list for all the |
|
362 alarms. |
|
363 |
|
364 */ |
|
365 void ClockAlarmListModel::updateRemainingTime() |
|
366 { |
|
367 // Get the list of pending clock alarms from server. |
|
368 AlarmInfo alarmInfo; |
|
369 for (int row = 0; row < mSourceModel->rowCount(); row++) { |
|
370 // Get the data for the alarm. |
|
371 QList<QVariant> alarmData = |
|
372 mSourceModel->index(row, 0).data(AlarmDetails).toList(); |
|
373 int alarmId = alarmData.at(0).value<int>(); |
|
374 |
|
375 int error = mAppControllerIf.alarmClient()->getAlarmInfo( |
|
376 alarmId, alarmInfo); |
|
377 if (-1 != error) { |
|
378 if (Enabled == alarmInfo.alarmStatus) { |
|
379 // Get the model index. |
|
380 QModelIndex mdlIndex = mSourceModel->index(row, 0); |
|
381 if (Notified != alarmInfo.alarmState) { |
|
382 QStringList displayStringList = |
|
383 getDisplayStringListforAlarmItem(alarmInfo); |
|
384 mSourceModel->setData( |
|
385 mdlIndex, displayStringList, Qt::DisplayRole); |
|
386 } |
|
387 } |
|
388 } |
|
389 } |
|
390 // Start the Timer for 1 minute. |
|
391 mTickTimer->start(60000); |
|
392 } |
|
393 |
|
394 /*! |
|
395 Returns the stringList to be set for "displayRole" for the alarm item. |
|
396 |
|
397 \param alarmInfo AlarmInfo containing the alarm. |
|
398 |
|
399 \return QStringList contains the stringList to be set. |
|
400 */ |
|
401 QStringList ClockAlarmListModel::getDisplayStringListforAlarmItem( |
|
402 AlarmInfo alarmInfo) |
|
403 { |
|
404 qDebug() << "clock: ClockAlarmListModel::getDisplayStringforAlarmItem -->"; |
|
405 |
|
406 QStringList displayStringList; |
|
407 QString timeString; |
|
408 if (Snoozed == alarmInfo.alarmState) { |
|
409 timeString = alarmInfo.nextDueTime.toString( |
|
410 mAppControllerIf.settingsUtility()->timeFormatString()); |
|
411 } else { |
|
412 timeString = alarmInfo.origAlarmTime.toString( |
|
413 mAppControllerIf.settingsUtility()->timeFormatString()); |
|
414 } |
|
415 |
|
416 QStringList stringList = timeString.split(" "); |
|
417 QString time; |
|
418 time.append(stringList[0]); |
|
419 if (stringList.count() > 1) { |
|
420 time.append("\n"); |
|
421 time.append(stringList[1]); |
|
422 } |
|
423 displayStringList.append(time); |
|
424 |
|
425 if (Enabled == alarmInfo.alarmStatus) { |
|
426 QString remainingTime = calculateRemainingTime(alarmInfo); |
|
427 displayStringList.append(remainingTime); |
|
428 } else { |
|
429 displayStringList.append(QString(" ")); |
|
430 } |
|
431 |
|
432 QString alarmDescription = alarmInfo.alarmDesc; |
|
433 displayStringList.append(alarmDescription); |
|
434 |
|
435 QString repeatTypeString; |
|
436 // The repeat type string. |
|
437 if (Daily == alarmInfo.repeatType) { |
|
438 repeatTypeString.append(hbTrId("txt_clock_main_view_dblist_daily")); |
|
439 } else if (Workday == alarmInfo.repeatType) { |
|
440 repeatTypeString.append( |
|
441 hbTrId("txt_clock_main_view_dblist_daily_val_workdays")); |
|
442 } else if (Weekly == alarmInfo.repeatType) { |
|
443 repeatTypeString.append(hbTrId("txt_clock_main_view_setlabel_every_1")); |
|
444 repeatTypeString = |
|
445 repeatTypeString.arg(alarmInfo.alarmDateTime.toString("dddd")); |
|
446 } else { |
|
447 if (QDate::currentDate() == alarmInfo.alarmDateTime) { |
|
448 repeatTypeString.append( |
|
449 hbTrId("txt_clock_main_view_dblist_daily_val_today")); |
|
450 } else { |
|
451 repeatTypeString.append( |
|
452 alarmInfo.alarmDateTime.toString("dddd")); |
|
453 } |
|
454 } |
|
455 displayStringList.append(repeatTypeString); |
|
456 |
|
457 qDebug() << "clock: ClockAlarmListModel::getDisplayStringforAlarmItem <--"; |
|
458 |
|
459 return displayStringList; |
|
460 } |
|
461 |
|
462 /*! |
|
463 Appends an alarm to the source model. |
|
464 |
|
465 \param alarmInfo AlarmInfo containing the alarm. |
|
466 */ |
|
467 void ClockAlarmListModel::appendAlarmToModel(AlarmInfo alarmInfo) |
|
468 { |
|
469 // Append only pending alarms to the model. |
|
470 if (Notified != alarmInfo.alarmState) { |
|
471 QStandardItem *item = new QStandardItem(); |
|
472 QStringList displayStringList = |
|
473 getDisplayStringListforAlarmItem(alarmInfo); |
|
474 |
|
475 item->setData(displayStringList, Qt::DisplayRole); |
|
476 |
|
477 // The repeat icon. |
|
478 QList<QVariant> displayiconList; |
|
479 if (Weekly == alarmInfo.repeatType || |
|
480 Daily == alarmInfo.repeatType || |
|
481 Workday == alarmInfo.repeatType) { |
|
482 displayiconList.append(HbIcon(":/clock/alarm_repeat")); |
|
483 } else { |
|
484 displayiconList.append(QVariant()); |
|
485 } |
|
486 item->setData(displayiconList, Qt::DecorationRole); |
|
487 |
|
488 // The status. |
|
489 if (Enabled == alarmInfo.alarmStatus) { |
|
490 item->setData(QString(":/clock/alarm_active"), AlarmIcon); |
|
491 } else { |
|
492 item->setData(QString(":/clock/alarm_inactive"), AlarmIcon); |
|
493 } |
|
494 |
|
495 // If the alarm is snoozed. |
|
496 if (Snoozed == alarmInfo.alarmState) { |
|
497 // TODO : Change the alarm icon also to alarm snooze icon |
|
498 } |
|
499 |
|
500 // The model for the list item will have: |
|
501 // 1. Id of the alarm that the list item represents. |
|
502 // 2. The repeat type of the alarm (Recurrence type). |
|
503 // 3. TAlarmStatus value. |
|
504 QList<QVariant> alarmData; |
|
505 alarmData.append(alarmInfo.alarmId); |
|
506 alarmData.append(alarmInfo.repeatType); |
|
507 alarmData.append(alarmInfo.alarmStatus); |
|
508 item->setData(alarmData, AlarmDetails); |
|
509 |
|
510 mSourceModel->appendRow(item); |
|
511 } |
|
512 |
|
513 } |
|
514 |
|
515 /*! |
|
516 Updates the alarm details in the source model with updated |
|
517 details from server. |
|
518 |
|
519 \param item Contains the alarm to be updated. |
|
520 \param alarmInfo AlarmInfo containing the alarm. |
|
521 */ |
|
522 void ClockAlarmListModel::updateAlarmDetails( |
|
523 QModelIndex modelIndex, AlarmInfo alarmInfo) |
|
524 { |
|
525 if (Notified != alarmInfo.alarmState) { |
|
526 QStringList displayStringList = |
|
527 getDisplayStringListforAlarmItem(alarmInfo); |
|
528 |
|
529 mSourceModel->setData( |
|
530 modelIndex, displayStringList, Qt::DisplayRole); |
|
531 |
|
532 // The repeat icon. |
|
533 QList<QVariant> displayiconList; |
|
534 if (Weekly == alarmInfo.repeatType || |
|
535 Daily == alarmInfo.repeatType || |
|
536 Workday == alarmInfo.repeatType) { |
|
537 displayiconList.append(HbIcon(":/clock/alarm_repeat")); |
|
538 } else { |
|
539 displayiconList.append(QVariant()); |
|
540 } |
|
541 mSourceModel->setData( |
|
542 modelIndex, displayiconList, Qt::DecorationRole); |
|
543 // The status. |
|
544 if (Enabled == alarmInfo.alarmStatus) { |
|
545 mSourceModel->setData( |
|
546 modelIndex, QString(":/clock/alarm_active"), AlarmIcon); |
|
547 } else { |
|
548 mSourceModel->setData( |
|
549 modelIndex, QString(":/clock/alarm_inactive"), AlarmIcon); |
|
550 } |
|
551 |
|
552 // If the alarm is snoozed. |
|
553 if (Snoozed == alarmInfo.alarmState) { |
|
554 // TODO : Change the alarm icon also to alarm snooze icon |
|
555 } |
|
556 |
|
557 // The model for the list item will have: |
|
558 // 1. Id of the alarm that the list item represents. |
|
559 // 2. The repeat type of the alarm (Recurrence type). |
|
560 // 3. TAlarmStatus value. |
|
561 QList<QVariant> alarmData; |
|
562 alarmData.append(alarmInfo.alarmId); |
|
563 alarmData.append(alarmInfo.repeatType); |
|
564 alarmData.append(alarmInfo.alarmStatus); |
|
565 mSourceModel->setData(modelIndex, alarmData, AlarmDetails); |
|
566 } |
|
567 } |
|
568 |
|
569 /*! |
|
570 Returns the number of active alarms present in the model. |
|
571 |
|
572 \return int number of active alarms present in the model. |
|
573 */ |
|
574 int ClockAlarmListModel::getActiveAlarmCount() |
|
575 { |
|
576 int activeAlarmCount = 0; |
|
577 for (int index = 0; index < mSourceModel->rowCount(); index++) { |
|
578 // Get the data for the alarm. |
|
579 QList<QVariant> alarmData = mSourceModel-> |
|
580 index(index, 0).data(AlarmDetails).toList(); |
|
581 if (Enabled == alarmData.at(2).value<int>()) { |
|
582 activeAlarmCount++; |
|
583 } |
|
584 } |
|
585 return activeAlarmCount; |
|
586 } |
|
587 // End of file --Don't remove this. |