notes/notesui/notesviews/src/notesmainview.cpp
author hgs
Mon, 28 Jun 2010 15:22:02 +0530
changeset 45 b6db4fd4947b
parent 23 fd30d51f876b
child 55 2c54b51f39c4
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* Definition file for NotesMainView class.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
// System includes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QDateTime>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbListView>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbListWidget>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <HbAction>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbTextEdit>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbInstance>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <HbMainWindow>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <HbMenu>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <HbLabel>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <HbAbstractViewItem>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <HbAbstractItemView>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <HbGroupBox>
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <HbListViewItem>
45
hgs
parents: 23
diff changeset
    33
#include <hbapplication> // hbapplication
hgs
parents: 23
diff changeset
    34
#include <hbactivitymanager> // hbactivitymanager
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
// User includes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "agendaeventviewer.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "notesmainview.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "notescommon.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "notesdocloader.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "agendautil.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include "notesmodel.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include "notessortfilterproxymodel.h"
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "noteseditor.h"
45
hgs
parents: 23
diff changeset
    45
#include "notescommon.h" // NotesNamespace
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	\class NotesMainView
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	\brief The main view of the notes application. Responsible for displaying
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
			notes and todos.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	\sa NotesViewManager
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	Constructs the NotesMainView object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	\param parent The parent of type QGraphicsWidget.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
NotesMainView::NotesMainView(QGraphicsWidget *parent)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
:HbView(parent),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
 mSelectedItem(0),
45
hgs
parents: 23
diff changeset
    63
 mDeleteAction(0),
hgs
parents: 23
diff changeset
    64
 mIsLongTop(false),
hgs
parents: 23
diff changeset
    65
 mIsScreenShotCapruted(false)
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
	// Nothing yet.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
	Destructor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
NotesMainView::~NotesMainView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
	if (mDocLoader) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
		delete mDocLoader;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
		mDocLoader = 0;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
	Called by the NotesViewManager after loading the view from the docml.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
	The initializaion/setup of the view is done here.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
	\param controller The NotesAppController object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	\param docLoader Pointer to NotesDocLoader object.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
void NotesMainView::setupView(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
		NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
	mDocLoader = docLoader;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	mAppControllerIf = &controllerIf;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	mNotesModel = mAppControllerIf->notesModel();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
	mAgendaUtil = mAppControllerIf->agendaUtil();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	mProxyModel = new NotesSortFilterProxyModel(*mAgendaUtil, this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
	mProxyModel->setDynamicSortFilter(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
	mProxyModel->setSourceModel(mNotesModel->sourceModel());
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
	NotesSortFilterProxyModel *subModel =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
			new NotesSortFilterProxyModel(*mAgendaUtil, this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
	subModel->setDynamicSortFilter(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
	subModel->setSourceModel(mProxyModel);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
	// Get the list object from the document and update the model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
	mListView = static_cast<HbListView *> (mDocLoader->findWidget("listView"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
	Q_ASSERT_X(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
			mListView,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
			"notesmainview.cpp",
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
			"Unable to find list view.");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
	// Update the list view model.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	mListView->setModel(subModel);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	// Setup the operations that can be done with a list view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
			mListView, SIGNAL(activated(const QModelIndex &)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
			this, SLOT(handleItemReleased(const QModelIndex &)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
			mListView,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
			SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
			this,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
			SLOT(handleItemLongPressed(HbAbstractViewItem *, const QPointF &)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
			mNotesModel, SIGNAL(rowAdded(QModelIndex)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
			this, SLOT(scrollTo(QModelIndex)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
45
hgs
parents: 23
diff changeset
   129
	// Get the empty list label.
hgs
parents: 23
diff changeset
   130
	mEmptyListLabel = static_cast<HbLabel *> (
hgs
parents: 23
diff changeset
   131
			mDocLoader->findWidget("emptyListLabel"));
hgs
parents: 23
diff changeset
   132
	mEmptyListLabel->hide();
hgs
parents: 23
diff changeset
   133
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
	// Get the view heading label
45
hgs
parents: 23
diff changeset
   135
	mSubTitle = static_cast<HbGroupBox *>(
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
			mDocLoader->findWidget("viewHeading"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
45
hgs
parents: 23
diff changeset
   138
	// Handles the orientation change for list items
hgs
parents: 23
diff changeset
   139
	HbMainWindow *window = hbInstance->allMainWindows().first();
hgs
parents: 23
diff changeset
   140
	handleOrientationChanged(window->orientation());
hgs
parents: 23
diff changeset
   141
	connect(
hgs
parents: 23
diff changeset
   142
			window, SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 23
diff changeset
   143
			this, SLOT(handleOrientationChanged(Qt::Orientation)));
hgs
parents: 23
diff changeset
   144
hgs
parents: 23
diff changeset
   145
	// Set the graphics size for the icons.
hgs
parents: 23
diff changeset
   146
	HbListViewItem *prototype = mListView->listItemPrototype();
hgs
parents: 23
diff changeset
   147
	prototype->setGraphicsSize(HbListViewItem::SmallIcon);
hgs
parents: 23
diff changeset
   148
	
hgs
parents: 23
diff changeset
   149
    // Get a pointer to activity Manager
hgs
parents: 23
diff changeset
   150
    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
hgs
parents: 23
diff changeset
   151
  
hgs
parents: 23
diff changeset
   152
    // clean up any previous versions of this activity from the activity manager.
hgs
parents: 23
diff changeset
   153
    // ignore return value as the first boot would always return a false
hgs
parents: 23
diff changeset
   154
    // bool declared on for debugging purpose
hgs
parents: 23
diff changeset
   155
    bool ok = activityManager->removeActivity(notes);
hgs
parents: 23
diff changeset
   156
	
hgs
parents: 23
diff changeset
   157
	// connect main view for the first time to recieve aboutToQuit signal
hgs
parents: 23
diff changeset
   158
    connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
hgs
parents: 23
diff changeset
   159
    
hgs
parents: 23
diff changeset
   160
 }
hgs
parents: 23
diff changeset
   161
hgs
parents: 23
diff changeset
   162
void NotesMainView::setupAfterViewReady()
hgs
parents: 23
diff changeset
   163
{
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
	// Get the toolbar/menu actions.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
	mAddNoteAction = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
			mDocLoader->findObject("newNoteAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
	Q_ASSERT_X(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
			mAddNoteAction,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
			"notesmainview.cpp",
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
			"Unable to find addNoteAction.");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
			mAddNoteAction, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
			this, SLOT(createNewNote()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
	mAllNotesAction = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
			mDocLoader->findObject("allNotesAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
	Q_ASSERT_X(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
			mAllNotesAction,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
			"notesmainview.cpp",
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
			"Unable to find allNotesAction.");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
	mAllNotesAction->setCheckable(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
	mAllNotesAction->setChecked(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
			mAllNotesAction, SIGNAL(changed()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
			this, SLOT(handleActionStateChanged()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
	mViewCollectionAction = static_cast<HbAction *> (
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
			mDocLoader->findObject("collectionsViewAction"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	Q_ASSERT_X(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
			mViewCollectionAction,
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
			"notescollectionview.cpp",
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
			"Unable to find viewCollectionAction.");
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
			mViewCollectionAction, SIGNAL(triggered()),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
			this, SLOT(displayCollectionView()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
			mAgendaUtil, SIGNAL(entryAdded(ulong)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
			this,SLOT(updateSubTitle(ulong)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
			mAgendaUtil, SIGNAL(entryDeleted(ulong)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
			this,SLOT(updateSubTitle(ulong)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
			mAgendaUtil, SIGNAL(entryUpdated(ulong)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
			this, SLOT(updateSubTitle(ulong)));
45
hgs
parents: 23
diff changeset
   207
}
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   208
45
hgs
parents: 23
diff changeset
   209
/*
hgs
parents: 23
diff changeset
   210
	Updates the title text for the first launch
hgs
parents: 23
diff changeset
   211
 */
hgs
parents: 23
diff changeset
   212
void NotesMainView::updateTitle()
hgs
parents: 23
diff changeset
   213
{
hgs
parents: 23
diff changeset
   214
	updateSubTitle();
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
	Slot which gets called when `+ New note' action is triggered from the view
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	toolbar. This is responsible for launching the editor to create a new note.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
void NotesMainView::createNewNote()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
	// Here we Display an editor to the use to enter text.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
	mNotesEditor = new NotesEditor(mAgendaUtil, this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
			mNotesEditor, SIGNAL(editingCompleted(bool)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
			this, SLOT(handleEditingCompleted(bool)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
	mNotesEditor->create(NotesEditor::CreateNote);
45
hgs
parents: 23
diff changeset
   230
	// capture screenshot for future use, if application
hgs
parents: 23
diff changeset
   231
	// is exited/Quit from notesEditor
hgs
parents: 23
diff changeset
   232
	captureScreenShot(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
	Handles the pressing of a list item in the view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
	Here we open the editor for viewing/editing.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
	\param index Reference to the QModelIndex representing the view item.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
	\sa HbAbstractViewItem
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
void NotesMainView::handleItemReleased(const QModelIndex &index)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
{
45
hgs
parents: 23
diff changeset
   245
	if(!mIsLongTop) {
hgs
parents: 23
diff changeset
   246
		// Sanity check.
hgs
parents: 23
diff changeset
   247
		if (!index.isValid()) {
hgs
parents: 23
diff changeset
   248
			return;
hgs
parents: 23
diff changeset
   249
		}
hgs
parents: 23
diff changeset
   250
hgs
parents: 23
diff changeset
   251
		// First get the id of the note and get the corresponding information from
hgs
parents: 23
diff changeset
   252
		// agendautil.
hgs
parents: 23
diff changeset
   253
		ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong>();
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
45
hgs
parents: 23
diff changeset
   255
		if (0 >= noteId) {
hgs
parents: 23
diff changeset
   256
			// Something wrong.
hgs
parents: 23
diff changeset
   257
			return;
hgs
parents: 23
diff changeset
   258
		}
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
45
hgs
parents: 23
diff changeset
   260
		// Get the entry details.
hgs
parents: 23
diff changeset
   261
		AgendaEntry entry = mAgendaUtil->fetchById(noteId);
hgs
parents: 23
diff changeset
   262
		if (entry.isNull()) {
hgs
parents: 23
diff changeset
   263
			// Entry invalid.
hgs
parents: 23
diff changeset
   264
			return;
hgs
parents: 23
diff changeset
   265
		}
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
45
hgs
parents: 23
diff changeset
   267
		if(AgendaEntry::TypeTodo == entry.type()) {
hgs
parents: 23
diff changeset
   268
			// Construct agenda event viewer.
hgs
parents: 23
diff changeset
   269
			mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
45
hgs
parents: 23
diff changeset
   271
			connect(
hgs
parents: 23
diff changeset
   272
					mAgendaEventViewer, SIGNAL(viewingCompleted(const QDate)),
hgs
parents: 23
diff changeset
   273
					this, SLOT(handleViewingCompleted()));
hgs
parents: 23
diff changeset
   274
			// Launch agenda event viewer
hgs
parents: 23
diff changeset
   275
			mAgendaEventViewer->view(
hgs
parents: 23
diff changeset
   276
					entry, AgendaEventViewer::ActionEditDelete);
hgs
parents: 23
diff changeset
   277
		}else if(AgendaEntry::TypeNote == entry.type()) {
hgs
parents: 23
diff changeset
   278
			// Construct notes editor.
hgs
parents: 23
diff changeset
   279
			mNotesEditor = new NotesEditor(mAgendaUtil, this);
hgs
parents: 23
diff changeset
   280
			connect(
hgs
parents: 23
diff changeset
   281
					mNotesEditor, SIGNAL(editingCompleted(bool)),
hgs
parents: 23
diff changeset
   282
					this, SLOT(handleEditingCompleted(bool)));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
45
hgs
parents: 23
diff changeset
   284
			// Launch the notes editor with the obtained info.
hgs
parents: 23
diff changeset
   285
			mNotesEditor->edit(entry);
hgs
parents: 23
diff changeset
   286
		}
hgs
parents: 23
diff changeset
   287
		// capture screenshot for future use, if application
hgs
parents: 23
diff changeset
   288
		// is exited/Quit from eventViewer/notesEditor
hgs
parents: 23
diff changeset
   289
		captureScreenShot(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
	Displays a list item specific context menu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
	\param item The HbAbstractViewItem that was long pressed.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
	\param coords The position where mouse was pressed.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
	\sa HbAbstractViewItem, HbListView, HbMenu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
void NotesMainView::handleItemLongPressed(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
		HbAbstractViewItem *item, const QPointF &coords)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
{
45
hgs
parents: 23
diff changeset
   304
	mIsLongTop = true;
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
	mSelectedItem = item;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
	ulong noteId = item->modelIndex().data(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
			NotesNamespace::IdRole).value<qulonglong>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
	// Display a context specific menu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
	HbMenu *contextMenu = new HbMenu();
45
hgs
parents: 23
diff changeset
   313
	connect(
hgs
parents: 23
diff changeset
   314
			contextMenu,SIGNAL(aboutToClose()),
hgs
parents: 23
diff changeset
   315
			this, SLOT(handleMenuClosed()));
hgs
parents: 23
diff changeset
   316
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   317
	mOpenAction =
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   318
			contextMenu->addAction(hbTrId("txt_common_menu_open"));
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
	// Add actions to the context menu.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
	if (AgendaEntry::TypeTodo == entry.type()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
		mEditTodoAction =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
				contextMenu->addAction(hbTrId("txt_common_menu_edit"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
	mDeleteAction =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
			contextMenu->addAction(hbTrId("txt_common_menu_delete"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
	if (AgendaEntry::TypeNote == entry.type()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
		if (entry.favourite()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
			mMakeFavouriteAction = contextMenu->addAction(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
					hbTrId("txt_notes_menu_remove_from_favorites"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
		} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
			mMakeFavouriteAction = contextMenu->addAction(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
					hbTrId("txt_notes_menu_mark_as_favorite"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   338
		mMarkTodoAction =
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   339
				contextMenu->addAction(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   340
						hbTrId("txt_notes_menu_make_it_as_todo_note"));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   341
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
	} else if (AgendaEntry::TypeTodo == entry.type()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
		if (AgendaEntry::TodoNeedsAction == entry.status()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
			mTodoStatusAction = contextMenu->addAction(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
					hbTrId("txt_notes_menu_mark_as_done"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
		} else if (AgendaEntry::TodoCompleted == entry.status()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
			mTodoStatusAction = contextMenu->addAction(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
					hbTrId("txt_notes_menu_mark_as_not_done"));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
		}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
	// Show the menu.
45
hgs
parents: 23
diff changeset
   353
	contextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
hgs
parents: 23
diff changeset
   354
	contextMenu->setPreferredPos(coords);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
	Slot to delete a selected note.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
void NotesMainView::deleteNote()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
	Q_ASSERT(mSelectedItem);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
	QModelIndex index = mSelectedItem->modelIndex();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
	if (!index.isValid()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
		return;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
	ulong noteId =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
			index.data(NotesNamespace::IdRole).value<qulonglong>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
	if (!noteId) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
		return;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   375
	// Emit the signal.Deletion would happen in view manager.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   376
	emit deleteEntry(noteId);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
	mSelectedItem = 0;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
	Marks to-do entry as done or undone based on the completed value
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
	\param entry reference to the agenda entry
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
	\param status is true if to-do entry to be marked as done
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
			is false if to-do entry to be marked as undone
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
void NotesMainView::markTodoStatus()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
	ulong noteId = mSelectedItem->modelIndex().data(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
			NotesNamespace::IdRole).value<qulonglong>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
	QDateTime currentDateTime = QDateTime::currentDateTime();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
	if (AgendaEntry::TodoNeedsAction == entry.status()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
		mAgendaUtil->setCompleted(entry, true, currentDateTime);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
	} else if (AgendaEntry::TodoCompleted == entry.status()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
		mAgendaUtil->setCompleted(entry, false, currentDateTime);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
	Marks/unmarks the note as favourite.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
void NotesMainView::markNoteAsFavourite()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
	ulong noteId = mSelectedItem->modelIndex().data(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
				NotesNamespace::IdRole).value<qulonglong>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
	if (entry.favourite()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
		entry.setFavourite(0);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
		entry.setFavourite(1);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
	mAgendaUtil->updateEntry(entry);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
	Slot to handle the signal editingCompleted by the notes editor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
	\param status Boolean value indicating whether the note was saved or not.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
	\sa NotesEditor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
void NotesMainView::handleEditingCompleted(bool status)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
	Q_UNUSED(status)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
	// Cleanup.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
	mNotesEditor->deleteLater();
45
hgs
parents: 23
diff changeset
   435
	// set captured screenshot as invalid as the control is returned back 
hgs
parents: 23
diff changeset
   436
	// to the main view
hgs
parents: 23
diff changeset
   437
	captureScreenShot(false);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
	Displays the collections' view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
void NotesMainView::displayCollectionView()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
{
45
hgs
parents: 23
diff changeset
   445
    // no need to capture the screen shot for future use as 
hgs
parents: 23
diff changeset
   446
    // NotesViewManager::switchToView takes care of it
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
	// Switch to collections view.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
	mAppControllerIf->switchToView(NotesNamespace::NotesCollectionViewId);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
	Slot where the list view is made to scroll to the QModelIndex index.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
	\param index QModelIndex to be scrolled to.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
void NotesMainView::scrollTo(QModelIndex index)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
	mListView->scrollTo(index, HbAbstractItemView::EnsureVisible);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
	Slot to handle viewing Completed signal from agenda event viewer
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
	\param status Indicates the status of viewing
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
 */
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   467
void NotesMainView::handleViewingCompleted()
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
	mAgendaEventViewer->deleteLater();
45
hgs
parents: 23
diff changeset
   470
	// set captured screenshot as invalid as the control is returned back 
hgs
parents: 23
diff changeset
   471
	// to the main view
hgs
parents: 23
diff changeset
   472
	captureScreenShot(false);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
	Slot to handle the case when the state of an action has changed.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
void NotesMainView::handleActionStateChanged()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
	mAllNotesAction->setChecked(true);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
	Launches the to-do editor to edit the to-do entry
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
void NotesMainView::editTodo()
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
	// Get the selected list item index
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
	QModelIndex index = mSelectedItem->modelIndex();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
	if (!index.isValid()) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
		return;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
	ulong todoId =
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
			index.data(NotesNamespace::IdRole).value<qulonglong>();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
	if (!todoId) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
		return;
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
	// Construct notes editor.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
	mNotesEditor = new NotesEditor(mAgendaUtil, this);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
	connect(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
			mNotesEditor, SIGNAL(editingCompleted(bool)),
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
			this, SLOT(handleEditingCompleted(bool)));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
	// Launch the to-do editor with the obtained info.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
	mNotesEditor->edit(todoId);
45
hgs
parents: 23
diff changeset
   509
	// capture screenshot for future use, if application
hgs
parents: 23
diff changeset
   510
	// is exited/Quit from notesEditor
hgs
parents: 23
diff changeset
   511
	captureScreenShot(true);
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
	Handles the orientation changes.Updates the list
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
	item when orientation is changed
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
	\param orientation Value of the orientation
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
void NotesMainView::handleOrientationChanged(Qt::Orientation orientation)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
	HbListViewItem *prototype = mListView->listItemPrototype();
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
	if (Qt::Horizontal == orientation) {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
		prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
	} else {
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
		prototype->setStretchingStyle(HbListViewItem::NoStretching);
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
	}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
}
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
/*!
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
	Updates the sub heading text
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
 */
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
void NotesMainView::updateSubTitle(ulong id)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
{
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
	Q_UNUSED(id)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
	// Get the number of notes and to-do entries.
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
	QList<ulong> entries = mAgendaUtil->entryIds(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
			(AgendaUtil::FilterFlags)
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
			(AgendaUtil::IncludeNotes
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
			| AgendaUtil::IncludeCompletedTodos
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
			| AgendaUtil::IncludeIncompletedTodos));
45
hgs
parents: 23
diff changeset
   545
	
hgs
parents: 23
diff changeset
   546
	if (0 >= entries.count()) {
hgs
parents: 23
diff changeset
   547
		mEmptyListLabel->show();
hgs
parents: 23
diff changeset
   548
		mListView->hide();
hgs
parents: 23
diff changeset
   549
	} else {
hgs
parents: 23
diff changeset
   550
		mEmptyListLabel->hide();
hgs
parents: 23
diff changeset
   551
		mListView->show();
hgs
parents: 23
diff changeset
   552
	}
hgs
parents: 23
diff changeset
   553
	
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
	mSubTitle->setHeading(
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
			hbTrId("txt_notes_subhead_ln_notes",entries.count()));
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
}
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   557
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   558
/*!
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   559
	Slot to make a note as to-do.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   560
 */
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   561
void NotesMainView::markNoteAsTodo()
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   562
{
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   563
	Q_ASSERT(mSelectedItem);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   564
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   565
	QModelIndex index = mSelectedItem->modelIndex();
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   566
	if (!index.isValid()) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   567
		return;
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   568
	}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   569
	ulong noteId = index.data(NotesNamespace::IdRole).value<qulonglong> ();
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   570
	if (!noteId) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   571
		return;
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   572
	}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   573
	// Get the entry details.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   574
	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   575
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   576
	if (entry.isNull()) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   577
		// Entry invalid.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   578
		return;
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   579
	}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   580
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   581
	// Here change the type of modified note and destroy the noteeditor and
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   582
	// construct the to-do editor.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   583
	entry.setType(AgendaEntry::TypeTodo);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   584
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   585
	QDateTime dueDateTime;
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   586
	QDate currentDate(QDate::currentDate());
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   587
	dueDateTime.setDate(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   588
			QDate(currentDate.year(),currentDate.month(),currentDate.day()+1));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   589
	dueDateTime.setTime(QTime::fromString("12:00 am", "hh:mm ap"));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   590
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   591
	entry.setStartAndEndTime(dueDateTime, dueDateTime);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   592
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   593
	entry.setSummary(entry.description().left(80));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   594
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   595
	if (80 > entry.description().length()) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   596
		entry.setDescription("");
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   597
	}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   598
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   599
	// Remove favourite if marked so.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   600
	entry.setFavourite(0);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   601
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   602
	// Set the status of the to-do.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   603
	entry.setStatus(AgendaEntry::TodoNeedsAction);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   604
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   605
	// First clone the todoEntry for the new type.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   606
	mAgendaUtil->cloneEntry(entry, AgendaEntry::TypeTodo);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   607
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   608
	// Delete the old entry.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   609
	mAgendaUtil->deleteEntry(entry.id());
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   610
}
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   611
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   612
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   613
/*
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   614
	Opens the notes editor if selected item is note otherwise opens
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   615
	to-do viewer if selected item is to-do event
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   616
 */
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   617
void NotesMainView::openNote()
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   618
{
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   619
	ulong noteId = mSelectedItem->modelIndex().data(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   620
			NotesNamespace::IdRole).value<qulonglong>();
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   621
	AgendaEntry entry = mAgendaUtil->fetchById(noteId);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   622
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   623
	if (AgendaEntry::TypeNote == entry.type()) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   624
		// Construct notes editor.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   625
		mNotesEditor = new NotesEditor(mAgendaUtil, this);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   626
		connect(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   627
				mNotesEditor, SIGNAL(editingCompleted(bool)),
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   628
				this, SLOT(handleEditingCompleted(bool)));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   629
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   630
		// Launch the notes editor with the obtained info.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   631
		mNotesEditor->edit(entry);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   632
	} else if (AgendaEntry::TypeTodo == entry.type()) {
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   633
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   634
		// Construct agenda event viewer.
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   635
		mAgendaEventViewer = new AgendaEventViewer(mAgendaUtil, this);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   636
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   637
		connect(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   638
				mAgendaEventViewer, SIGNAL(viewingCompleted(bool)),
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   639
				this, SLOT(handleViewingCompleted(bool)));
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   640
		// Launch agenda event viewer
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   641
		mAgendaEventViewer->view(
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   642
				entry, AgendaEventViewer::ActionEditDelete);
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   643
	}
45
hgs
parents: 23
diff changeset
   644
	// capture screenshot for future use, if application
hgs
parents: 23
diff changeset
   645
	// is exited/Quit from notesEditor/eventViewer
hgs
parents: 23
diff changeset
   646
	captureScreenShot(true);
23
fd30d51f876b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   647
}
45
hgs
parents: 23
diff changeset
   648
hgs
parents: 23
diff changeset
   649
/*!
hgs
parents: 23
diff changeset
   650
	 Slot to handle the selected context menu actions
hgs
parents: 23
diff changeset
   651
 */
hgs
parents: 23
diff changeset
   652
void NotesMainView::selectedMenuAction(HbAction *action)
hgs
parents: 23
diff changeset
   653
{
hgs
parents: 23
diff changeset
   654
	if (action == mOpenAction) {
hgs
parents: 23
diff changeset
   655
		openNote();
hgs
parents: 23
diff changeset
   656
	} else if (action == mEditTodoAction) {
hgs
parents: 23
diff changeset
   657
		editTodo();
hgs
parents: 23
diff changeset
   658
	} else if (action == mDeleteAction) {
hgs
parents: 23
diff changeset
   659
		deleteNote();
hgs
parents: 23
diff changeset
   660
	} else if (action == mMakeFavouriteAction) {
hgs
parents: 23
diff changeset
   661
		markNoteAsFavourite();
hgs
parents: 23
diff changeset
   662
	} else if (action == mMarkTodoAction) {
hgs
parents: 23
diff changeset
   663
		markNoteAsTodo();
hgs
parents: 23
diff changeset
   664
	} else if (action == mTodoStatusAction) {
hgs
parents: 23
diff changeset
   665
		markTodoStatus();
hgs
parents: 23
diff changeset
   666
	}
hgs
parents: 23
diff changeset
   667
}
hgs
parents: 23
diff changeset
   668
hgs
parents: 23
diff changeset
   669
/*!
hgs
parents: 23
diff changeset
   670
	Slot to handle the context menu closed.
hgs
parents: 23
diff changeset
   671
 */
hgs
parents: 23
diff changeset
   672
void NotesMainView::handleMenuClosed()
hgs
parents: 23
diff changeset
   673
{
hgs
parents: 23
diff changeset
   674
	mIsLongTop = false;
hgs
parents: 23
diff changeset
   675
}
hgs
parents: 23
diff changeset
   676
hgs
parents: 23
diff changeset
   677
/*!
hgs
parents: 23
diff changeset
   678
	CaptureScreenShot captures screen shot 
hgs
parents: 23
diff changeset
   679
	\param captureScreenShot bool to indicate if screenshot needs to be captured
hgs
parents: 23
diff changeset
   680
*/ 
hgs
parents: 23
diff changeset
   681
void NotesMainView::captureScreenShot(bool captureScreenShot)
hgs
parents: 23
diff changeset
   682
    {
hgs
parents: 23
diff changeset
   683
    if (captureScreenShot) // check if screen shot needs to be captured
hgs
parents: 23
diff changeset
   684
        {
hgs
parents: 23
diff changeset
   685
        mScreenShot.clear();
hgs
parents: 23
diff changeset
   686
        mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
hgs
parents: 23
diff changeset
   687
        }
hgs
parents: 23
diff changeset
   688
    mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot
hgs
parents: 23
diff changeset
   689
    }
hgs
parents: 23
diff changeset
   690
hgs
parents: 23
diff changeset
   691
/*!    
hgs
parents: 23
diff changeset
   692
	saveActivity saves main view as an activity 
hgs
parents: 23
diff changeset
   693
*/ 
hgs
parents: 23
diff changeset
   694
void NotesMainView::saveActivity()
hgs
parents: 23
diff changeset
   695
 {
hgs
parents: 23
diff changeset
   696
   // Get a pointer to activity Manager
hgs
parents: 23
diff changeset
   697
   HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
hgs
parents: 23
diff changeset
   698
 
hgs
parents: 23
diff changeset
   699
   if (!mIsScreenShotCapruted) // check if a valid screenshot is already captured
hgs
parents: 23
diff changeset
   700
       {
hgs
parents: 23
diff changeset
   701
       mScreenShot.clear();
hgs
parents: 23
diff changeset
   702
       mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
hgs
parents: 23
diff changeset
   703
       }
hgs
parents: 23
diff changeset
   704
 
hgs
parents: 23
diff changeset
   705
   // save any data necessary to save the state
hgs
parents: 23
diff changeset
   706
   QByteArray serializedActivity;
hgs
parents: 23
diff changeset
   707
   QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
hgs
parents: 23
diff changeset
   708
   stream << NotesNamespace::NotesMainViewId;
hgs
parents: 23
diff changeset
   709
 
hgs
parents: 23
diff changeset
   710
   // add the activity to the activity manager
hgs
parents: 23
diff changeset
   711
   bool ok = activityManager->addActivity(notes, serializedActivity, mScreenShot);
hgs
parents: 23
diff changeset
   712
   if ( !ok )
hgs
parents: 23
diff changeset
   713
       {
hgs
parents: 23
diff changeset
   714
       qFatal("Add failed" );
hgs
parents: 23
diff changeset
   715
       }
hgs
parents: 23
diff changeset
   716
 }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
// End of file	--Don't remove this.