45
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Definition of NotesEditorPlugin class.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// System includes.
|
|
20 |
#include <noteseditorinterface.h>
|
|
21 |
#include <AgendaUtil>
|
|
22 |
#include <AgendaEntry>
|
|
23 |
|
|
24 |
// User includes.
|
|
25 |
#include "noteseditorplugin.h"
|
|
26 |
#include "noteseditor.h"
|
|
27 |
|
|
28 |
/*!
|
|
29 |
\class NotesEditorPlugin
|
|
30 |
|
|
31 |
NotesEditorPlugin provides QT plugin implementation of NotesEditorInterface.
|
|
32 |
*/
|
|
33 |
|
|
34 |
/*!
|
|
35 |
\fn void NotesEditorPlugin::editingCompleted(bool status = true)
|
|
36 |
|
|
37 |
This signal is emitted when editing/creation of a note/to-do is completed.
|
|
38 |
|
|
39 |
\param status This indicates whether the note/to-do was saved or not.
|
|
40 |
This will be `true' if the note was saved by the user.
|
|
41 |
false' otherwise.
|
|
42 |
*/
|
|
43 |
|
|
44 |
|
|
45 |
/*!
|
|
46 |
Constructor.
|
|
47 |
|
|
48 |
\param parent QObject pointer.
|
|
49 |
*/
|
|
50 |
NotesEditorPlugin::NotesEditorPlugin(QObject *parent)
|
|
51 |
{
|
|
52 |
Q_UNUSED(parent)
|
|
53 |
}
|
|
54 |
|
|
55 |
/*!
|
|
56 |
Destructor.
|
|
57 |
*/
|
|
58 |
NotesEditorPlugin::~NotesEditorPlugin()
|
|
59 |
{
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
/*!
|
|
64 |
Shows the noteseditor. The argument acts as the description for the note.
|
|
65 |
|
|
66 |
\param string reference to file string/buffer.
|
|
67 |
*/
|
|
68 |
void NotesEditorPlugin::edit(const QString &string, AgendaUtil *agendaUtil)
|
|
69 |
{
|
|
70 |
if (!mNotesEditor) {
|
|
71 |
createNotesEditor(agendaUtil);
|
|
72 |
}
|
|
73 |
|
|
74 |
mNotesEditor->edit(string);
|
|
75 |
}
|
|
76 |
|
|
77 |
/*!
|
|
78 |
Shows the noteseditor by parsing a .vcs which could be of a To-do or a plain
|
|
79 |
.txt file which will be edited as a note.
|
|
80 |
|
|
81 |
\param handle reference to QFile handle.
|
|
82 |
*/
|
|
83 |
void NotesEditorPlugin::edit(const QFile &handle, AgendaUtil *agendaUtil)
|
|
84 |
{
|
|
85 |
if (!mNotesEditor) {
|
|
86 |
createNotesEditor(agendaUtil);
|
|
87 |
}
|
|
88 |
|
|
89 |
mNotesEditor->edit(handle);
|
|
90 |
}
|
|
91 |
|
|
92 |
/*!
|
|
93 |
Shows the noteseditor, by parsing an AgendaEntry.
|
|
94 |
|
|
95 |
\param entry An object of AgendaEntry.
|
|
96 |
*/
|
|
97 |
void NotesEditorPlugin::edit(AgendaEntry entry, AgendaUtil *agendaUtil)
|
|
98 |
{
|
|
99 |
if (!mNotesEditor) {
|
|
100 |
createNotesEditor(agendaUtil);
|
|
101 |
}
|
|
102 |
|
|
103 |
mNotesEditor->edit(entry);
|
|
104 |
}
|
|
105 |
|
|
106 |
/*!
|
|
107 |
Shows the noteseditor, by fetching the note using the entry id provided.
|
|
108 |
|
|
109 |
\param id entry id of the note.
|
|
110 |
*/
|
|
111 |
void NotesEditorPlugin::edit(ulong id, AgendaUtil *agendaUtil)
|
|
112 |
{
|
|
113 |
if (!mNotesEditor) {
|
|
114 |
createNotesEditor(agendaUtil);
|
|
115 |
}
|
|
116 |
|
|
117 |
mNotesEditor->edit(id);
|
|
118 |
}
|
|
119 |
|
|
120 |
/*!
|
|
121 |
Creates a new note or to-do based on the create type.It lanuches the
|
|
122 |
respective editors for editing
|
|
123 |
|
|
124 |
\type type of the editor to be shown for creating new note and new to-do
|
|
125 |
*/
|
|
126 |
void NotesEditorPlugin::create( NotesEditorInterface::CreateType type,
|
|
127 |
AgendaUtil *agendaUtil)
|
|
128 |
{
|
|
129 |
if (!mNotesEditor) {
|
|
130 |
createNotesEditor(agendaUtil);
|
|
131 |
}
|
|
132 |
|
|
133 |
mNotesEditor->create(static_cast<NotesEditor::CreateType>(type));
|
|
134 |
}
|
|
135 |
|
|
136 |
/*!
|
|
137 |
Closes the notes editor
|
|
138 |
|
|
139 |
\param type Type of the close required.
|
|
140 |
*/
|
|
141 |
ulong NotesEditorPlugin::close( NotesEditorInterface::CloseType type,
|
|
142 |
AgendaUtil *agendaUtil)
|
|
143 |
{
|
|
144 |
if (!mNotesEditor) {
|
|
145 |
createNotesEditor(agendaUtil);
|
|
146 |
}
|
|
147 |
|
|
148 |
return mNotesEditor->close(static_cast<NotesEditor::CloseType>(type));
|
|
149 |
}
|
|
150 |
|
|
151 |
/*!
|
|
152 |
Creates notes Editor.
|
|
153 |
*/
|
|
154 |
void NotesEditorPlugin::createNotesEditor(AgendaUtil *agendaUtil)
|
|
155 |
{
|
|
156 |
if (agendaUtil) {
|
|
157 |
mNotesEditor = new NotesEditor(agendaUtil, this);
|
|
158 |
} else {
|
|
159 |
mNotesEditor = new NotesEditor(this);
|
|
160 |
}
|
|
161 |
|
|
162 |
if (mNotesEditor) {
|
|
163 |
connect(
|
|
164 |
mNotesEditor, SIGNAL(editingCompleted(bool)),
|
|
165 |
this, SLOT(handleEditingCompleted(bool)));
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
/*!
|
|
170 |
Slot to handle editing completed
|
|
171 |
*/
|
|
172 |
void NotesEditorPlugin::handleEditingCompleted(bool status)
|
|
173 |
{
|
|
174 |
// Emits the signal.
|
|
175 |
emit editingCompleted(status);
|
|
176 |
|
|
177 |
// Cleanup.
|
|
178 |
if (mNotesEditor) {
|
|
179 |
mNotesEditor->deleteLater();
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
// Exports plugin class NotesEditorPlugin for the target
|
|
184 |
// plugin noteseditorplugin.
|
|
185 |
Q_EXPORT_PLUGIN2(noteseditorplugin, NotesEditorPlugin)
|
|
186 |
|
|
187 |
// End of file --Don't remove this.
|
|
188 |
|