calendarui/views/src/calenagendaviewwidget.cpp
changeset 70 a5ed90760192
parent 64 1881ad52dc45
child 75 7ac58b2aae6f
equal deleted inserted replaced
64:1881ad52dc45 70:a5ed90760192
    56 const QString singleSpace(" ");
    56 const QString singleSpace(" ");
    57 const QString doubleSpace("  ");
    57 const QString doubleSpace("  ");
    58 const QString space("              ");
    58 const QString space("              ");
    59 const QString singleHyphen("-");
    59 const QString singleHyphen("-");
    60 const QString customLayout("custom");
    60 const QString customLayout("custom");
    61 const char *stretchLayout("stretchItem");
    61 const char *stretchLayout("customstretch");
    62 const QString toDoIcon("qtg_small_todo");
    62 const QString toDoIcon("qtg_small_todo");
    63 const QString reminderIcon("qtg_mono_alarm");
    63 const QString reminderIcon("qtg_mono_alarm");
    64 const QString locationIcon("qtg_mono_location");
    64 const QString locationIcon("qtg_mono_location");
    65 const QString repeatIcon("qtg_mono_repeat");
    65 const QString repeatIcon("qtg_mono_repeat");
    66 // TODO: Replace with actual image name once its available
    66 // TODO: Replace with actual image name once its available
    77                                        CalenDocLoader *docLoader) :
    77                                        CalenDocLoader *docLoader) :
    78 mServices(services),
    78 mServices(services),
    79 mDocLoader(docLoader),
    79 mDocLoader(docLoader),
    80 mRegionalInfoGroupBox(NULL),
    80 mRegionalInfoGroupBox(NULL),
    81 mLongTapEventFlag(false),
    81 mLongTapEventFlag(false),
    82 mNotesPluginLoaded(false),
    82 mNotesPluginLoaded(false)
    83 mIndex(0),
       
    84 mIconCheck(false)
       
    85 {
    83 {
    86     OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_ENTRY );
    84     OstTraceFunctionEntry0( CALENAGENDAVIEWWIDGET_CALENAGENDAVIEWWIDGET_ENTRY );
    87     
    85     
    88     // Construct the list view prototype
    86     // Construct the list view prototype
    89     mListViewPrototype = new CalenEventListViewItem(this);
    87     mListViewPrototype = new CalenEventListViewItem(this);
   372     } else if (mInstanceArray.count() < mListModel->rowCount()) {
   370     } else if (mInstanceArray.count() < mListModel->rowCount()) {
   373         // There are less number of events than the number
   371         // There are less number of events than the number
   374         // of items in the list. Remove the extra rows
   372         // of items in the list. Remove the extra rows
   375         mListModel->removeRows(0, mListModel->rowCount() - mInstanceArray.count());
   373         mListModel->removeRows(0, mListModel->rowCount() - mInstanceArray.count());
   376     }
   374     }
   377     //to set the index to first item of the list , when view refresh
       
   378     mIndex = 0; 
       
   379     //status reset for not setting any property
       
   380     mIconCheck = false;
       
   381     mListModel->setColumnCount(singleColumn);
   375     mListModel->setColumnCount(singleColumn);
   382     mIconCheck = true;
       
   383     // Add all the events to the list
   376     // Add all the events to the list
   384     for (int index = 0; index < mInstanceArray.count(); index++) {
   377     for (int index = 0; index < mInstanceArray.count(); index++) {
   385         // Get each of the entry details
   378         // Get each of the entry details
   386         AgendaEntry entry = mInstanceArray[index];
   379         AgendaEntry entry = mInstanceArray[index];
   387         // Create a list item for each entry
   380         // Create a list item for each entry
   445 	// Get localised name of the day from locale
   438 	// Get localised name of the day from locale
   446 	QString dayString = systemLocale.dayName(mDate.date().dayOfWeek());
   439 	QString dayString = systemLocale.dayName(mDate.date().dayOfWeek());
   447 	// Append a single space
   440 	// Append a single space
   448 	dayString.append(singleSpace);
   441 	dayString.append(singleSpace);
   449 	// Set the heading
   442 	// Set the heading
   450 	// Append the date which is formatted as per the locale
   443 
   451 	mHeadingLabel->setHeading(hbTrId(
   444     // Append the date which is formatted as per the locale   
   452 				"txt_calendar_subhead_1_2").arg(dayString).arg(
   445     mHeadingLabel->setHeading(QString("%1 %2").arg(dayString).arg(
   453 				systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
   446         systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
       
   447 	
   454 	
   448 	
   455 	OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SETHEADINGTEXT_EXIT );
   449 	OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_SETHEADINGTEXT_EXIT );
   456 }
   450 }
   457 
   451 
   458 // ----------------------------------------------------------------------------
   452 // ----------------------------------------------------------------------------
   627     	endtime.append(singleSpace);
   621     	endtime.append(singleSpace);
   628     	textData << endtime;
   622     	textData << endtime;
   629     }else {
   623     }else {
   630     	textData<<QString(space);
   624     	textData<<QString(space);
   631     }
   625     }
   632     // Get the list model index and set the text and icon data
   626 
   633     QModelIndex listIndex = mListModel->index(index, 0);
       
   634     mNextEntry = false;
       
   635     mListModel->setData(listIndex, textData, Qt::DisplayRole);
       
   636     mNextEntry = true;
       
   637     mListModel->setData(listIndex, iconData, Qt::DecorationRole);
       
   638     
   627     
   639     // Disable item stretching by removing the dynamic property
   628     // Disable item stretching by removing the dynamic property
   640     HbListViewItem *listViewItem = static_cast<HbListViewItem*>
   629     HbListViewItem *listViewItem = static_cast<HbListViewItem*>
   641                                         (mEventsList->itemByIndex(mListModel->index(index, 0)));
   630                                         (mEventsList->itemByIndex(mListModel->index(index, 0)));
   642     if (listViewItem) {
   631     if (listViewItem) {
   643         listViewItem->setProperty(stretchLayout, false);
   632         listViewItem->setProperty(stretchLayout, false);
   644     }
   633     }
   645     
   634     // Get the list model index and set the text and icon data
       
   635     QModelIndex listIndex = mListModel->index(index, 0);
       
   636     mListModel->setData(listIndex, textData, Qt::DisplayRole);
       
   637     mListModel->setData(listIndex, iconData, Qt::DecorationRole);    
   646     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDTIMEDEVENTTOLIST_EXIT );
   638     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDTIMEDEVENTTOLIST_EXIT );
   647 }
   639 }
   648 
   640 
   649 // ----------------------------------------------------------------------------
   641 // ----------------------------------------------------------------------------
   650 // CalenAgendaViewWidget::addNonTimedEventToList
   642 // CalenAgendaViewWidget::addNonTimedEventToList
   793         	if (entry.alarm().isNull()) {
   785         	if (entry.alarm().isNull()) {
   794         		iconData << QVariant();
   786         		iconData << QVariant();
   795         	}
   787         	}
   796         }
   788         }
   797     }
   789     }
   798     
       
   799     // Get the list model index and set the text and icon data
       
   800     QModelIndex listIndex = mListModel->index(index, 0);
       
   801     mNextEntry = false;
       
   802     mListModel->setData(listIndex, textData, Qt::DisplayRole);
       
   803     mNextEntry = true;
       
   804     mListModel->setData(listIndex, iconData, Qt::DecorationRole);
       
   805     
       
   806     // Enable item stretching by adding the dynamic property
   790     // Enable item stretching by adding the dynamic property
   807     HbListViewItem *listViewItem = static_cast<HbListViewItem*>
   791     HbListViewItem *listViewItem = static_cast<HbListViewItem*>
   808                                         (mEventsList->itemByIndex(mListModel->index(index, 0)));
   792                                         (mEventsList->itemByIndex(mListModel->index(index, 0)));
   809     Qt::Orientation orientation = mServices.MainWindow().orientation();
   793     Qt::Orientation orientation = mServices.MainWindow().orientation();
   810     // Apply stretch only for landscape orientation
   794     // Apply stretch only for landscape orientation
   813             listViewItem->setProperty(stretchLayout, true);
   797             listViewItem->setProperty(stretchLayout, true);
   814         } else {
   798         } else {
   815             listViewItem->setProperty(stretchLayout, false);
   799             listViewItem->setProperty(stretchLayout, false);
   816         }
   800         }
   817     }
   801     }
       
   802     // Get the list model index and set the text and icon data
       
   803     QModelIndex listIndex = mListModel->index(index, 0);
       
   804     mListModel->setData(listIndex, textData, Qt::DisplayRole);
       
   805     mListModel->setData(listIndex, iconData, Qt::DecorationRole);
   818     
   806     
   819     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDNONTIMEDEVENTTOLIST_EXIT );
   807     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_ADDNONTIMEDEVENTTOLIST_EXIT );
   820 }
   808 }
   821 
   809 
   822 // ----------------------------------------------------------------------------
   810 // ----------------------------------------------------------------------------
   860                             // must be stretched in landscape.
   848                             // must be stretched in landscape.
   861                             // NOTE: Property name MUST match the name specified in
   849                             // NOTE: Property name MUST match the name specified in
   862                             // css file, else wierd things might happen
   850                             // css file, else wierd things might happen
   863                             listItem->setProperty(stretchLayout, true);
   851                             listItem->setProperty(stretchLayout, true);
   864                         }
   852                         }
       
   853                         if (orientation == Qt::Vertical) {
       
   854                             // Set a dynamic property to indicate that this list item
       
   855                             // NOTE: Property name MUST match the name specified in
       
   856                             // css file, else wierd things might happen
       
   857                             listItem->setProperty(stretchLayout, false);
       
   858                         }
   865                     }
   859                     }
   866                 }
   860                 }
   867                     break;
   861                     break;
   868                 default:
   862                 default:
   869                 {
   863                 {
  1031     // Get the entry details first
  1025     // Get the entry details first
  1032     AgendaEntry entry = mInstanceArray[mSelectedIndex];
  1026     AgendaEntry entry = mInstanceArray[mSelectedIndex];
  1033     
  1027     
  1034     // Set the context
  1028     // Set the context
  1035     setContextFromHighlight(entry);
  1029     setContextFromHighlight(entry);
  1036     
  1030 
  1037     //for not setting any property again 
       
  1038     mIconCheck = false;
       
  1039     // Launch the event viewer.
  1031     // Launch the event viewer.
  1040     mServices.IssueCommandL(ECalenEventView);
  1032     mServices.IssueCommandL(ECalenEventView);
  1041     
  1033     
  1042     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_VIEWENTRY_EXIT );
  1034     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_VIEWENTRY_EXIT );
  1043 }
  1035 }
  1152     contextMenu->setPreferredPos(coords);
  1144     contextMenu->setPreferredPos(coords);
  1153     connect(contextMenu, SIGNAL(aboutToClose()),
  1145     connect(contextMenu, SIGNAL(aboutToClose()),
  1154 								this, 
  1146 								this, 
  1155 								SLOT(contextMenuClosed()));
  1147 								SLOT(contextMenuClosed()));
  1156     
  1148     
       
  1149     // Close the context menu once closeDialogs() is received
       
  1150     connect(mView, SIGNAL(closeDialogs()), contextMenu, SLOT(close()));
       
  1151     
  1157     contextMenu->open(this, SLOT(contextManuTriggered(HbAction *)));
  1152     contextMenu->open(this, SLOT(contextManuTriggered(HbAction *)));
  1158     
  1153     
  1159     OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_ITEMLONGPRESSED_EXIT );
  1154     OstTraceFunctionExit0( DUP1_CALENAGENDAVIEWWIDGET_ITEMLONGPRESSED_EXIT );
  1160 }
  1155 }
  1161 
  1156 
  1277     mListModel->clear();
  1272     mListModel->clear();
  1278     
  1273     
  1279     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CLEARLISTMODEL_EXIT );
  1274     OstTraceFunctionExit0( CALENAGENDAVIEWWIDGET_CLEARLISTMODEL_EXIT );
  1280     }
  1275     }
  1281 
  1276 
  1282 // ----------------------------------------------------------------------------
       
  1283 // CalenAgendaViewWidget::hasAllDayIcon
       
  1284 // return true  if property for all day icon to set
       
  1285 // ----------------------------------------------------------------------------
       
  1286 //
       
  1287 bool CalenAgendaViewWidget::hasAllDayIcon()
       
  1288     {
       
  1289     return mIconCheck;
       
  1290     }
       
  1291 
       
  1292 
       
  1293 // ----------------------------------------------------------------------------
       
  1294 // CalenAgendaViewWidget::checkEntryIcons
       
  1295 // check if all day icon is present
       
  1296 // ----------------------------------------------------------------------------
       
  1297 //
       
  1298 void CalenAgendaViewWidget::checkEntryIcons()
       
  1299     {
       
  1300     int index = 0;
       
  1301     //check the number of entries
       
  1302     index  = mInstanceArray.count(); 
       
  1303     // Get each of the entry details
       
  1304     AgendaEntry entry;
       
  1305      if(mIndex < index )   
       
  1306      entry = mInstanceArray[mIndex];
       
  1307      
       
  1308      mLeftAllDayIcon = false;
       
  1309      
       
  1310      if(!entry.isTimedEntry() || CalenAgendaUtils::isAlldayEvent(entry)){
       
  1311          //all day icon is not there if its a timed entry
       
  1312          mLeftAllDayIcon = true;
       
  1313          }
       
  1314      
       
  1315      //check if shift to next entry
       
  1316     if(mNextEntry)
       
  1317         mIndex++;     
       
  1318 
       
  1319     }
       
  1320 
       
  1321 // ----------------------------------------------------------------------------
       
  1322 // CalenAgendaViewWidget::isAllDayIcon
       
  1323 // retirn true  if all day icon is present
       
  1324 // ----------------------------------------------------------------------------
       
  1325 //
       
  1326 bool CalenAgendaViewWidget::isAllDayIcon()
       
  1327     {
       
  1328     return mLeftAllDayIcon;
       
  1329     }
       
  1330 
  1277 
  1331 // End of file	--Don't remove this.
  1278 // End of file	--Don't remove this.