[tasque/transition: 166/213] [SQLite] Adjust note handling methods to model.
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque/transition: 166/213] [SQLite] Adjust note handling methods to model.
- Date: Wed, 29 Aug 2012 18:47:59 +0000 (UTC)
commit a2930e7f7330a3169d9a6a7e4243813c042eca4c
Author: Antonius Riha <antoniusriha gmail com>
Date: Sat Aug 18 21:54:41 2012 +0200
[SQLite] Adjust note handling methods to model.
src/Addins/SqliteBackend/SqliteTask.cs | 44 +++++++++++--------------------
1 files changed, 16 insertions(+), 28 deletions(-)
---
diff --git a/src/Addins/SqliteBackend/SqliteTask.cs b/src/Addins/SqliteBackend/SqliteTask.cs
index 80f061b..37db811 100644
--- a/src/Addins/SqliteBackend/SqliteTask.cs
+++ b/src/Addins/SqliteBackend/SqliteTask.cs
@@ -83,48 +83,36 @@ namespace Tasque.Backends.Sqlite
backend.Database.ExecuteScalar (command);
base.OnStateChanged ();
}
-
- #region Public Methods
-
+
public override TaskNote CreateNote (string text)
{
Debug.WriteLine ("Creating New Note Object : {0} (id={1})", text, id);
text = backend.SanitizeText (text);
- string command = String.Format (
+ var command = String.Format (
"INSERT INTO Notes (Task, Text) VALUES ('{0}','{1}'); SELECT last_insert_rowid();",
- id,
- text
- );
- int taskId = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
+ id, text);
+ var taskId = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
- return new SqliteNote (taskId, text);
+ var note = new SqliteNote (taskId, text);
+ note.OnTextChangedAction = delegate { SaveNote (note); };
+ return note;
}
- public override void DeleteNote (TaskNote note)
+ protected override void OnRemoveNote (TaskNote note)
{
- SqliteNote sqNote = (note as SqliteNote);
-
- string command = String.Format (
- "DELETE FROM Notes WHERE ID='{0}'",
- sqNote.ID
- );
+ var sqNote = note as SqliteNote;
+ var command = string.Format ("DELETE FROM Notes WHERE ID='{0}'", sqNote.Id);
backend.Database.ExecuteScalar (command);
+ base.OnRemoveNote (note);
}
-
- public override void SaveNote (TaskNote note)
+
+ void SaveNote (TaskNote note)
{
- SqliteNote sqNote = (note as SqliteNote);
-
- string text = backend.SanitizeText (sqNote.Text);
- string command = String.Format (
- "UPDATE Notes SET Text='{0}' WHERE ID='{1}'",
- text,
- sqNote.ID
- );
+ var sqNote = note as SqliteNote;
+ var text = backend.SanitizeText (sqNote.Text);
+ var command = string.Format ("UPDATE Notes SET Text='{0}' WHERE ID='{1}'", text, sqNote.Id);
backend.Database.ExecuteScalar (command);
}
-
- #endregion // Public Methods
SqliteBackend backend;
int id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]