notes/notesui/notesviews/src/notescollectionview.cpp
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 55 2c54b51f39c4
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
   115 			mDocLoader->findWidget("listView"));
   115 			mDocLoader->findWidget("listView"));
   116 	connect(
   116 	connect(
   117 			mListView, SIGNAL(activated(const QModelIndex &)),
   117 			mListView, SIGNAL(activated(const QModelIndex &)),
   118 			this, SLOT(handleActivated(const QModelIndex &)));
   118 			this, SLOT(handleActivated(const QModelIndex &)));
   119 
   119 
   120 	// Populate the content of the view.
       
   121 	populateListView();
       
   122 
       
   123 	// Get the toolbar/menu actions.
   120 	// Get the toolbar/menu actions.
   124 	mAllNotesAction = static_cast<HbAction *> (
   121 	mAllNotesAction = static_cast<HbAction *> (
   125 			mDocLoader->findObject("allNotesAction"));
   122 			mDocLoader->findObject("allNotesAction"));
   126 	Q_ASSERT_X(
   123 	Q_ASSERT_X(
   127 			mAllNotesAction,
   124 			mAllNotesAction,
   156 			mAddNoteAction, SIGNAL(triggered()),
   153 			mAddNoteAction, SIGNAL(triggered()),
   157 			this, SLOT(createNewNote()));
   154 			this, SLOT(createNewNote()));
   158 }
   155 }
   159 
   156 
   160 /*!
   157 /*!
       
   158 	Populate the content of the view.
       
   159  */
       
   160 void NotesCollectionView::populateListView()
       
   161 {
       
   162 	QStandardItemModel *model = new QStandardItemModel(this);
       
   163 	model->setColumnCount(1);
       
   164 
       
   165 	QString countString(hbTrId("txt_notes_list_note_count"));
       
   166 
       
   167 	// Add To-do's item.
       
   168 	QStandardItem *item = new QStandardItem();
       
   169 	QStringList todoStringList;
       
   170 	todoStringList.append(hbTrId("txt_notes_list_todos"));
       
   171 	todoStringList.append(countString.arg(QString::number(todosCount())));
       
   172 	item->setData(todoStringList, Qt::DisplayRole);
       
   173 	model->appendRow(item);
       
   174 
       
   175 	// Add Favorites item.
       
   176 	item = new QStandardItem();
       
   177 	QStringList favStringList;
       
   178 	favStringList.append(hbTrId("txt_notes_list_favorites"));
       
   179 	favStringList.append(countString.arg(mFavouriteModel->rowCount()));
       
   180 	item->setData(favStringList, Qt::DisplayRole);
       
   181 	model->appendRow(item);
       
   182 
       
   183 	// Add Recent notes item.
       
   184 	item = new QStandardItem();
       
   185 	QStringList notesStringList;
       
   186 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
       
   187 	notesStringList.append(
       
   188 			countString.arg(QString::number(recentNotesCount())));
       
   189 	item->setData(notesStringList, Qt::DisplayRole);
       
   190 	model->appendRow(item);
       
   191 
       
   192 	HbStyleLoader::registerFilePath(":/style");
       
   193 	mListView->setLayoutName("custom");
       
   194 	mListView->setModel(model);
       
   195 }
       
   196 
       
   197 /*!
   161 	Displays all notes view.
   198 	Displays all notes view.
   162  */
   199  */
   163 void NotesCollectionView::displayAllNotesView()
   200 void NotesCollectionView::displayAllNotesView()
   164 {
   201 {
   165 	// Switch to collections view.
   202 	// Switch to collections view.
   213 	// Refresh the content of the view.
   250 	// Refresh the content of the view.
   214 	resetCollectionView();
   251 	resetCollectionView();
   215 
   252 
   216 	// Cleanup.
   253 	// Cleanup.
   217 	mNotesEditor->deleteLater();
   254 	mNotesEditor->deleteLater();
       
   255 	
       
   256 	mAppControllerIf->switchToView(NotesNamespace::NotesMainViewId);
   218 }
   257 }
   219 
   258 
   220 /*!
   259 /*!
   221 	Updates the view data in case of changes in the database.
   260 	Updates the view data in case of changes in the database.
   222 	Handles the case when entry is added or deleted by notes application.
   261 	Handles the case when entry is added or deleted by notes application.
   295 		const QModelIndex &index, int start, int end)
   334 		const QModelIndex &index, int start, int end)
   296 {
   335 {
   297 	Q_UNUSED(index)
   336 	Q_UNUSED(index)
   298 	Q_UNUSED(start)
   337 	Q_UNUSED(start)
   299 	Q_UNUSED(end)
   338 	Q_UNUSED(end)
   300 
   339 	
   301 	// Update the count of notes in the view.
   340 	// Check model is set for mListView  before update 	
   302 	QString countString(hbTrId("txt_notes_list_note_count"));
   341 	if( mListView->model())
   303 	QModelIndex mdlIndex = mListView->model()->index(1, 0);
   342 	{
   304 	QStringList favStringList;
   343 		// Update the count of notes in the view.
   305 	favStringList.append(hbTrId("txt_notes_list_favorites"));
   344 		QString countString(hbTrId("txt_notes_list_note_count"));
   306 	favStringList.append(countString.arg(mFavouriteModel->rowCount()));
   345 		QModelIndex mdlIndex = mListView->model()->index(1, 0);
   307 	mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole);
   346 		QStringList favStringList;
       
   347 		favStringList.append(hbTrId("txt_notes_list_favorites"));
       
   348 		favStringList.append(countString.arg(mFavouriteModel->rowCount()));
       
   349 		mListView->model()->setData(mdlIndex, favStringList, Qt::DisplayRole);
       
   350 	}
   308 }
   351 }
   309 
   352 
   310 /*!
   353 /*!
   311 	Slot to handle the case when the state of an action has changed.
   354 	Slot to handle the case when the state of an action has changed.
   312  */
   355  */
   313 void NotesCollectionView::handleActionStateChanged()
   356 void NotesCollectionView::handleActionStateChanged()
   314 {
   357 {
   315 	mViewCollectionAction->setChecked(true);
   358 	mViewCollectionAction->setChecked(true);
   316 }
       
   317 
       
   318 /*!
       
   319 	Populate the content of the view.
       
   320  */
       
   321 void NotesCollectionView::populateListView()
       
   322 {
       
   323 	QStandardItemModel *model = new QStandardItemModel(this);
       
   324 	model->setColumnCount(1);
       
   325 
       
   326 	QString countString(hbTrId("txt_notes_list_note_count"));
       
   327 
       
   328 	// Add To-do's item.
       
   329 	QStandardItem *item = new QStandardItem();
       
   330 	QStringList todoStringList;
       
   331 	todoStringList.append(hbTrId("txt_notes_list_todos"));
       
   332 	todoStringList.append(countString.arg(QString::number(todosCount())));
       
   333 	item->setData(todoStringList, Qt::DisplayRole);
       
   334 	model->appendRow(item);
       
   335 
       
   336 	// Add Favorites item.
       
   337 	item = new QStandardItem();
       
   338 	QStringList favStringList;
       
   339 	favStringList.append(hbTrId("txt_notes_list_favorites"));
       
   340 	favStringList.append(countString.arg(mFavouriteModel->rowCount()));
       
   341 	item->setData(favStringList, Qt::DisplayRole);
       
   342 	model->appendRow(item);
       
   343 
       
   344 	// Add Recent notes item.
       
   345 	item = new QStandardItem();
       
   346 	QStringList notesStringList;
       
   347 	notesStringList.append(hbTrId("txt_notes_list_plain_notes"));
       
   348 	notesStringList.append(
       
   349 			countString.arg(QString::number(recentNotesCount())));
       
   350 	item->setData(notesStringList, Qt::DisplayRole);
       
   351 	model->appendRow(item);
       
   352 
       
   353 	HbStyleLoader::registerFilePath(":/style");
       
   354 	mListView->setLayoutName("custom");
       
   355 	mListView->setModel(model);
       
   356 }
   359 }
   357 
   360 
   358 
   361 
   359 /*!
   362 /*!
   360 	Returns the todos count
   363 	Returns the todos count