notes/notesui/notesviews/src/notescollectionview.cpp
changeset 77 b0711afde476
parent 58 ef813d54df51
equal deleted inserted replaced
68:a5a1242fd2e8 77:b0711afde476
    28 #include <HbDialog>
    28 #include <HbDialog>
    29 #include <HbLabel>
    29 #include <HbLabel>
    30 #include <HbAbstractViewItem>
    30 #include <HbAbstractViewItem>
    31 #include <HbGroupBox>
    31 #include <HbGroupBox>
    32 #include <HbStyleLoader>
    32 #include <HbStyleLoader>
       
    33 #include <HbParameterLengthLimiter>
    33 
    34 
    34 // User includes
    35 // User includes
    35 #include <agendautil.h>
    36 #include <agendautil.h>
    36 #include "notescollectionview.h"
    37 #include "notescollectionview.h"
    37 #include "notescommon.h"
    38 #include "notescommon.h"
   121 			this, SLOT(updateFavouritesCount(QModelIndex, int, int)));
   122 			this, SLOT(updateFavouritesCount(QModelIndex, int, int)));
   122 
   123 
   123 	// Get the list view from the document and update the model.
   124 	// Get the list view from the document and update the model.
   124 	mListView = static_cast<HbListView *> (
   125 	mListView = static_cast<HbListView *> (
   125 			mDocLoader->findWidget("listView"));
   126 			mDocLoader->findWidget("listView"));
       
   127 	mListView->setItemPixmapCacheEnabled(true);
   126 	connect(
   128 	connect(
   127 			mListView, SIGNAL(activated(const QModelIndex &)),
   129 			mListView, SIGNAL(activated(const QModelIndex &)),
   128 			this, SLOT(handleActivated(const QModelIndex &)));
   130 			this, SLOT(handleActivated(const QModelIndex &)));
   129 
   131 
   130 	// Get the toolbar/menu actions.
   132 	// Get the toolbar/menu actions.
   172 {
   174 {
   173 	OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_POPULATELISTVIEW_ENTRY );
   175 	OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_POPULATELISTVIEW_ENTRY );
   174 	QStandardItemModel *model = new QStandardItemModel(this);
   176 	QStandardItemModel *model = new QStandardItemModel(this);
   175 	model->setColumnCount(1);
   177 	model->setColumnCount(1);
   176 
   178 
   177 	QString countString(hbTrId("txt_notes_list_note_count"));
       
   178 
       
   179 	// Add To-do's item.
   179 	// Add To-do's item.
   180 	QStandardItem *item = new QStandardItem();
   180 	QStandardItem *item = new QStandardItem();
   181 	QStringList todoStringList;
   181 	QStringList todoStringList;
   182 	todoStringList.append(hbTrId("txt_notes_list_todos"));
   182 	todoStringList.append(hbTrId("txt_notes_list_todos"));
   183 	todoStringList.append(countString.arg(QString::number(todosCount())));
   183 	todoStringList.append(
       
   184 			HbParameterLengthLimiter(
       
   185 					hbTrId("txt_notes_list_note_count")).arg(QString::number(
       
   186 							todosCount())));
   184 	item->setData(todoStringList, Qt::DisplayRole);
   187 	item->setData(todoStringList, Qt::DisplayRole);
   185 	model->appendRow(item);
   188 	model->appendRow(item);
   186 
   189 
   187 	// Add Favorites item.
   190 	// Add Favorites item.
   188 	item = new QStandardItem();
   191 	item = new QStandardItem();
   189 	QStringList favStringList;
   192 	QStringList favStringList;
   190 	favStringList.append(hbTrId("txt_notes_list_favorites"));
   193 	favStringList.append(hbTrId("txt_notes_list_favorites"));
   191 	favStringList.append(countString.arg(mFavouriteModel->rowCount()));
   194 	favStringList.append(
       
   195 			HbParameterLengthLimiter(
       
   196 					hbTrId("txt_notes_list_note_count")).arg(QString::number(
       
   197 							mFavouriteModel->rowCount())));
   192 	item->setData(favStringList, Qt::DisplayRole);
   198 	item->setData(favStringList, Qt::DisplayRole);
   193 	model->appendRow(item);
   199 	model->appendRow(item);
   194 
   200 
   195 	// Add Recent notes item.
   201 	// Add Recent notes item.
   196 	item = new QStandardItem();
   202 	item = new QStandardItem();
   197 	QStringList notesStringList;
   203 	QStringList notesStringList;
   198 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
   204 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
   199 	notesStringList.append(
   205 	notesStringList.append(
   200 			countString.arg(QString::number(recentNotesCount())));
   206 			HbParameterLengthLimiter(
       
   207 					hbTrId("txt_notes_list_note_count")).arg(QString::number(
       
   208 							recentNotesCount())));
   201 	item->setData(notesStringList, Qt::DisplayRole);
   209 	item->setData(notesStringList, Qt::DisplayRole);
   202 	model->appendRow(item);
   210 	model->appendRow(item);
   203 
   211 
   204 	HbStyleLoader::registerFilePath(":/style");
   212 	HbStyleLoader::registerFilePath(":/style");
   205 	mListView->setLayoutName("custom");
   213 	mListView->setLayoutName("custom");
   222 	Refreshes the content of the collection view if needed.
   230 	Refreshes the content of the collection view if needed.
   223  */
   231  */
   224 void NotesCollectionView::resetCollectionView()
   232 void NotesCollectionView::resetCollectionView()
   225 {
   233 {
   226 	OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_ENTRY );
   234 	OstTraceFunctionEntry0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_ENTRY );
   227 	QString countString(hbTrId("txt_notes_list_note_count"));
       
   228 
   235 
   229 	// Update the count of to-do's.
   236 	// Update the count of to-do's.
   230 	QModelIndex mdlIndex = mListView->model()->index(0, 0);
   237 	QModelIndex mdlIndex = mListView->model()->index(0, 0);
   231 	QStringList todoStringList;
   238 	QStringList todoStringList;
   232 	todoStringList.append(hbTrId("txt_notes_list_todos"));
   239 	todoStringList.append(hbTrId("txt_notes_list_todos"));
   233 	todoStringList.append(countString.arg(QString::number(todosCount())));
   240 	todoStringList.append(
       
   241 			HbParameterLengthLimiter(
       
   242 					hbTrId("txt_notes_list_note_count")).arg(QString::number(
       
   243 							todosCount())));
   234 	mListView->model()->setData(mdlIndex, todoStringList, Qt::DisplayRole);
   244 	mListView->model()->setData(mdlIndex, todoStringList, Qt::DisplayRole);
   235 
   245 
   236 	// Update the count of notes in the view.
   246 	// Update the count of notes in the view.
   237 	mdlIndex = mListView->model()->index(2, 0);
   247 	mdlIndex = mListView->model()->index(2, 0);
   238 	QStringList notesStringList;
   248 	QStringList notesStringList;
   239 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
   249 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
   240 	notesStringList.append(
   250 	notesStringList.append(
   241 			countString.arg(QString::number(recentNotesCount())));
   251 			HbParameterLengthLimiter(
       
   252 					hbTrId("txt_notes_list_note_count")).arg(QString::number(
       
   253 							recentNotesCount())));
   242 	mListView->model()->setData(mdlIndex, notesStringList, Qt::DisplayRole);
   254 	mListView->model()->setData(mdlIndex, notesStringList, Qt::DisplayRole);
   243 	OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_EXIT );
   255 	OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_RESETCOLLECTIONVIEW_EXIT );
   244 }
   256 }
   245 
   257 
   246 /*!
   258 /*!
   367 	
   379 	
   368 	// Check model is set for mListView  before update 	
   380 	// Check model is set for mListView  before update 	
   369 	if( mListView->model())
   381 	if( mListView->model())
   370 	{
   382 	{
   371 		// Update the count of notes in the view.
   383 		// Update the count of notes in the view.
   372 		QString countString(hbTrId("txt_notes_list_note_count"));
       
   373 		QModelIndex mdlIndex = mListView->model()->index(1, 0);
   384 		QModelIndex mdlIndex = mListView->model()->index(1, 0);
   374 		QStringList favStringList;
   385 		QStringList favStringList;
   375 		favStringList.append(hbTrId("txt_notes_list_favorites"));
   386 		favStringList.append(hbTrId("txt_notes_list_favorites"));
   376 		favStringList.append(countString.arg(mFavouriteModel->rowCount()));
   387 		favStringList.append(
       
   388 				HbParameterLengthLimiter(
       
   389 						hbTrId("txt_notes_list_note_count")).arg(
       
   390 								QString::number(mFavouriteModel->rowCount())));
   377 		mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole);
   391 		mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole);
   378 	}
   392 	}
   379 	OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_UPDATEFAVOURITESCOUNT_EXIT );
   393 	OstTraceFunctionExit0( NOTESCOLLECTIONVIEW_UPDATEFAVOURITESCOUNT_EXIT );
   380 }
   394 }
   381 
   395