35 #include <hbi18ndef.h> |
40 #include <hbi18ndef.h> |
36 #include <HbRadioButtonList> |
41 #include <HbRadioButtonList> |
37 #include <HbMessageBox> |
42 #include <HbMessageBox> |
38 #include <HbDialog> |
43 #include <HbDialog> |
39 #include <HbLabel> |
44 #include <HbLabel> |
40 #include <QFile> |
|
41 #include <QString> |
|
42 #include <QIcon> |
|
43 #include <QPainter> |
|
44 #include <QPixmap> |
|
45 // User includes |
45 // User includes |
|
46 #include <maptileservice.h>//maptile service |
46 #include <agendautil.h> |
47 #include <agendautil.h> |
47 #include <noteseditor.h> |
48 #include <NotesEditorInterface> |
48 #include <caleneditor.h> |
49 #include <caleneditor.h> |
49 #include "agendaeventview.h" |
50 #include "agendaeventview.h" |
50 #include "agendaeventviewerdocloader.h" |
51 #include "agendaeventviewerdocloader.h" |
51 #include "agendaeventviewercommon.h" |
52 #include "agendaeventviewercommon.h" |
52 #include "agendaeventviewer_p.h" |
53 #include "agendaeventviewer_p.h" |
53 #include "agendaeventvieweritem.h" |
54 #include "agendaeventvieweritem.h" |
54 #include "calendateutils.h" |
55 #include "calendateutils.h" |
55 |
|
56 //maptile service |
|
57 #include <maptileservice.h> |
|
58 // Constants |
56 // Constants |
59 #define CHARACTER_HYPHEN "-" |
57 #define CHARACTER_HYPHEN "-" |
60 #define CHARACTER_SPACE " " |
58 #define CHARACTER_SPACE " " |
61 #define CHARACTER_NEW_LINE "\n" |
59 #define CHARACTER_NEW_LINE "\n" |
62 |
60 |
144 mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SCROLLAREA_CONTENTS)); |
148 mDocLoader->findWidget(AGENDA_EVENT_VIEWER_SCROLLAREA_CONTENTS)); |
145 |
149 |
146 mLinearLayout = |
150 mLinearLayout = |
147 static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout()); |
151 static_cast<QGraphicsLinearLayout *> (scrollAreaWidget->layout()); |
148 |
152 |
149 MapTileService::AppType appType; |
153 |
150 appType = MapTileService::AppTypeCalendar; |
154 //maptile service object , to retrive maptile path from database. |
151 mLocationFeatureEnabled = MapTileService::isLocationFeatureEnabled(appType); |
155 mMaptileService= new MapTileService(); |
152 |
156 mLocationFeatureEnabled = mMaptileService->isLocationFeatureEnabled( |
153 |
157 MapTileService::AppTypeCalendar); |
|
158 if (mLocationFeatureEnabled) { |
|
159 //timer to run progress indicator icon. |
|
160 mProgressTimer = new QTimer(this); |
|
161 mProgressTimer->setSingleShot(true); |
|
162 connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgressIndicator())); |
|
163 } |
154 qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--"; |
164 qDebug() << "AgendaEventViewer: AgendaEventView::AgendaEventView <--"; |
155 |
165 |
156 } |
166 } |
157 |
167 |
158 /*! |
168 /*! |
473 break; |
500 break; |
474 case AgendaEntry::TypeEvent: |
501 case AgendaEntry::TypeEvent: |
475 |
502 |
476 dateTimeText.append(systemLocale.format(startDateTime.date(), |
503 dateTimeText.append(systemLocale.format(startDateTime.date(), |
477 r_qtn_date_usual_with_zero)); |
504 r_qtn_date_usual_with_zero)); |
478 |
505 if (CalenDateUtils::onSameDay(startDateTime, endDateTime.addSecs(-60))) { |
479 if (CalenDateUtils::onSameDay(startDateTime, endDateTime)) { |
|
480 data.append(hbTrId("txt_calendar_dblist_meeting_date").arg( |
506 data.append(hbTrId("txt_calendar_dblist_meeting_date").arg( |
481 dateTimeText)); |
507 dateTimeText)); |
482 } else { |
508 } else { |
483 QString endDate; |
509 QString endDate; |
484 endDate.append( |
510 endDate.append( |
485 systemLocale.format(endDateTime.date(), |
511 systemLocale.format(endDateTime.addSecs(-60).date(), |
486 r_qtn_date_usual_with_zero)); |
512 r_qtn_date_usual_with_zero)); |
487 data.append(hbTrId("txt_calendar_dblist_start_end_time").arg( |
513 data.append(hbTrId("txt_calendar_dblist_start_end_time").arg( |
488 dateTimeText).arg(endDate)); |
514 dateTimeText).arg(endDate)); |
489 } |
515 } |
490 break; |
516 break; |
503 */ |
529 */ |
504 void AgendaEventView::addLocationData() |
530 void AgendaEventView::addLocationData() |
505 { |
531 { |
506 qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->"; |
532 qDebug() << "AgendaEventViewer: AgendaEventView::addLocationData -->"; |
507 QStringList itemData; |
533 QStringList itemData; |
508 itemData.append(QString::null); |
534 QString progressIcon(QString::null); |
509 itemData.append(QString::null); |
535 if ( mLocationFeatureEnabled ) { |
510 itemData.append("qtg_small_location"); |
536 getProgressIndicatorstatus(progressIcon); |
511 mLocationWidget->setProperty(primaryLeftIconItem, false); |
537 } |
|
538 if( progressIcon.isNull() ) { |
|
539 itemData.append(QString::null); |
|
540 itemData.append(QString::null); |
|
541 itemData.append("qtg_small_location"); |
|
542 mLocationWidget->setProperty(primaryLeftIconItem, false); |
|
543 } |
|
544 else { |
|
545 itemData.append("qtg_small_location"); |
|
546 itemData.append( progressIcon ); |
|
547 itemData.append(QString::null); |
|
548 mLocationWidget->setProperty(primaryLeftIconItem, true); |
|
549 } |
512 mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole); |
550 mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole); |
513 itemData.clear(); |
551 itemData.clear(); |
514 itemData.append(QString::null); |
552 itemData.append(QString::null); |
515 itemData.append(mAgendaEntry.location()); |
553 itemData.append(mAgendaEntry.location()); |
516 mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole); |
554 mLocationWidget->setEventViewerItemData(itemData, Qt::DisplayRole); |
520 /*! |
558 /*! |
521 Add maptile image to Event viewer |
559 Add maptile image to Event viewer |
522 */ |
560 */ |
523 void AgendaEventView::addMapTileImage() |
561 void AgendaEventView::addMapTileImage() |
524 { |
562 { |
525 |
563 if (mLocationFeatureEnabled && !mAgendaEntry.location().isEmpty() && !mMaptilePath.isEmpty()) { |
526 qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage -->"; |
564 |
527 |
565 HbIcon maptile(mMaptilePath); |
528 if (!mAgendaEntry.location().isEmpty() && mLocationFeatureEnabled){ |
566 mMaptileLabel->setIcon(maptile); |
529 MapTileService::AddressType addressType; |
567 mMaptileLabel->setPreferredSize(QSizeF(width, height)); |
530 addressType = MapTileService::AddressPlain; |
568 mMaptileLabel->setMinimumSize(QSizeF(width, height)); |
531 int eventId = mAgendaEntry.id(); |
569 mMaptileLabel->setMaximumSize(QSizeF(width, height)); |
532 mMaptilePath = MapTileService::getMapTileImage(eventId, addressType); |
570 mMaptileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
533 if (!mMaptilePath.isNull()) |
571 |
534 { |
572 } |
535 HbIcon maptile(mMaptilePath); |
|
536 mMaptileLabel->setIcon(maptile); |
|
537 |
|
538 mMaptileLabel->setPreferredSize(QSizeF(width, height)); |
|
539 mMaptileLabel->setMinimumSize(QSizeF(width, height)); |
|
540 mMaptileLabel->setMaximumSize(QSizeF(width, height)); |
|
541 mMaptileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, |
|
542 QSizePolicy::Fixed)); |
|
543 |
|
544 } |
|
545 } |
|
546 |
|
547 qDebug() << "AgendaEventViewer: AgendaEventView::addMapTileImage <--"; |
|
548 } |
573 } |
549 /*! |
574 /*! |
550 Add reminder data to Event viewer |
575 Add reminder data to Event viewer |
551 */ |
576 */ |
552 void AgendaEventView::addReminderData() |
577 void AgendaEventView::addReminderData() |
1020 qDebug() << "AgendaEventViewer: AgendaEventView::edit -->"; |
1046 qDebug() << "AgendaEventViewer: AgendaEventView::edit -->"; |
1021 |
1047 |
1022 mOwner->editingStarted(); |
1048 mOwner->editingStarted(); |
1023 |
1049 |
1024 if (AgendaEntry::TypeTodo == mAgendaEntry.type()) { |
1050 if (AgendaEntry::TypeTodo == mAgendaEntry.type()) { |
1025 // Launch the to-do editor using notes editor api |
1051 // Load notes editor plugin if not loaded. |
1026 // Construct Note editor for launching the to-do editor |
1052 if(!mNotesPluginLoaded) { |
1027 mNoteEditor = new NotesEditor(mOwner->mAgendaUtil, this); |
1053 // Launch the to-do editor using notes editor plugin api |
1028 mNoteEditor->edit(mAgendaEntry); |
1054 QDir dir(NOTES_EDITOR_PLUGIN_PATH); |
|
1055 QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME); |
|
1056 |
|
1057 // Create NotesEditor plugin loader object. |
|
1058 mNotesEditorPluginLoader = new QPluginLoader(pluginName); |
|
1059 |
|
1060 // Load the plugin |
|
1061 mNotesPluginLoaded = mNotesEditorPluginLoader->load(); |
|
1062 } |
|
1063 QObject *plugin = qobject_cast<QObject*> ( |
|
1064 mNotesEditorPluginLoader->instance()); |
|
1065 |
|
1066 NotesEditorInterface* interface = |
|
1067 qobject_cast<NotesEditorInterface*>(plugin); |
|
1068 |
|
1069 interface->edit(mAgendaEntry, mOwner->mAgendaUtil); |
1029 |
1070 |
1030 connect( |
1071 connect( |
1031 mNoteEditor, SIGNAL(editingCompleted(bool)), |
1072 interface, SIGNAL(editingCompleted(bool)), |
1032 this, SLOT(handleNoteEditorClosed(bool))); |
1073 this, SLOT(handleNoteEditorClosed(bool))); |
1033 |
1074 |
1034 |
1075 |
1035 } else { |
1076 } else { |
1036 // Launch the calendar entry editor using calendar editor api |
1077 // Launch the calendar entry editor using calendar editor api |
1263 } |
1305 } |
1264 |
1306 |
1265 qDebug() << "AgendaEventViewer: AgendaEventView::getSubjectIcon <--"; |
1307 qDebug() << "AgendaEventViewer: AgendaEventView::getSubjectIcon <--"; |
1266 } |
1308 } |
1267 |
1309 |
|
1310 /*! |
|
1311 According to maptile fetching status , update the viewer screen. |
|
1312 */ |
|
1313 void AgendaEventView::updateProgressIndicator() |
|
1314 { |
|
1315 if (!mMaptileStatusReceived) { |
|
1316 QString iconName("qtg_anim_small_loading_"); |
|
1317 mProgressIconCount = mProgressIconCount % 10 + 1; |
|
1318 iconName.append(QVariant(mProgressIconCount).toString()); |
|
1319 QStringList itemData; |
|
1320 itemData.append("qtg_small_location"); |
|
1321 itemData.append(iconName); |
|
1322 itemData.append(QString::null); |
|
1323 mLocationWidget->setProperty(primaryLeftIconItem, true); |
|
1324 mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole); |
|
1325 mProgressTimer->start(100); |
|
1326 } |
|
1327 else { |
|
1328 if (mProgressTimer->isActive()) { |
|
1329 mProgressTimer->stop(); |
|
1330 } |
|
1331 if (mMaptileStatus == MapTileService::MapTileFetchingCompleted) { |
|
1332 QStringList itemData; |
|
1333 itemData.append(QString::null); |
|
1334 itemData.append(QString::null); |
|
1335 itemData.append("qtg_small_location"); |
|
1336 mLocationWidget->setProperty(primaryLeftIconItem, false); |
|
1337 mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole); |
|
1338 MapTileService::AddressType addressType; |
|
1339 addressType = MapTileService::AddressPlain; |
|
1340 int eventId = mAgendaEntry.id(); |
|
1341 mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath); |
|
1342 addMapTileImage(); |
|
1343 QFile file(mMaptilePath); |
|
1344 if (file.exists()) { |
|
1345 //add to linear layout |
|
1346 int indexMaptileLabel = 3; |
|
1347 mLinearLayout->insertItem(indexMaptileLabel, mMaptileLabel); |
|
1348 mMaptileLabel->show(); |
|
1349 } |
|
1350 file.close(); |
|
1351 |
|
1352 } |
|
1353 else { |
|
1354 QStringList itemData; |
|
1355 itemData.append("qtg_small_location"); |
|
1356 QString stopIcon; |
|
1357 stopIcon.append(QString("qtg_mono_search_stop")); |
|
1358 itemData.append(stopIcon); |
|
1359 itemData.append(QString::null); |
|
1360 mLocationWidget->setProperty(primaryLeftIconItem, true); |
|
1361 mLocationWidget->setEventViewerItemData(itemData, Qt::DecorationRole); |
|
1362 |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 |
|
1367 /*! |
|
1368 Maptile status received from maptile service |
|
1369 */ |
|
1370 void AgendaEventView::receiveMapTileStatus(int entryid,int addressType, int status) |
|
1371 { |
|
1372 if (mAgendaEntry.id() == entryid && addressType == MapTileService::AddressPlain) { |
|
1373 mMaptileStatusReceived = true; |
|
1374 mMaptileStatus = status; |
|
1375 updateProgressIndicator(); |
|
1376 } |
|
1377 } |
|
1378 |
|
1379 /*! |
|
1380 Returns progress indication icon as per status of entry in database. |
|
1381 */ |
|
1382 void AgendaEventView::getProgressIndicatorstatus(QString &progressIcon) |
|
1383 { |
|
1384 MapTileService::AddressType addressType; |
|
1385 addressType = MapTileService::AddressPlain; |
|
1386 int eventId = mAgendaEntry.id(); |
|
1387 mMaptilePath.clear(); |
|
1388 int status = 0; |
|
1389 connect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int, |
|
1390 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int))); |
|
1391 status = mMaptileService->getMapTileImage(eventId, addressType, mMaptilePath); |
|
1392 if (status == MapTileService::MapTileFetchingNetworkError || status |
|
1393 == MapTileService::MapTileFetchingInProgress) { |
|
1394 mMaptilePath.clear(); |
|
1395 mMaptileStatusReceived = false; //reseting receiving status value |
|
1396 mMaptileStatus = -1;// reseting status value; |
|
1397 progressIcon.append(QString("qtg_anim_small_loading_1")); |
|
1398 mProgressTimer->start(100); |
|
1399 } |
|
1400 else if (status == MapTileService::MapTileFetchingInvalidAddress || status |
|
1401 == MapTileService::MapTileFetchingUnknownError) { |
|
1402 mMaptilePath.clear(); |
|
1403 //no further need of this coonnection |
|
1404 disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int, |
|
1405 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int))); |
|
1406 progressIcon.append(QString("qtg_mono_search_stop")); |
|
1407 } |
|
1408 else { |
|
1409 //no further need of this coonnection |
|
1410 disconnect(mMaptileService, SIGNAL(maptileFetchingStatusUpdate(int, |
|
1411 int ,int)), this, SLOT(receiveMapTileStatus(int,int,int))); |
|
1412 progressIcon.append(QString::null); |
|
1413 } |
|
1414 } |
1268 // End of file |
1415 // End of file |