Diffstat (limited to 'core/pim/todo/todotemplatemanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/todotemplatemanager.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/pim/todo/todotemplatemanager.cpp b/core/pim/todo/todotemplatemanager.cpp index 02941ac..5b83f76 100644 --- a/core/pim/todo/todotemplatemanager.cpp +++ b/core/pim/todo/todotemplatemanager.cpp | |||
@@ -12,9 +12,9 @@ using namespace Todo; | |||
12 | TemplateManager::TemplateManager() { | 12 | TemplateManager::TemplateManager() { |
13 | m_path = Global::applicationFileName("todolist", "templates.xml"); | 13 | m_path = Global::applicationFileName("todolist", "templates.xml"); |
14 | } | 14 | } |
15 | TemplateManager::~TemplateManager() { | 15 | TemplateManager::~TemplateManager() { |
16 | 16 | save(); | |
17 | } | 17 | } |
18 | void TemplateManager::load() { | 18 | void TemplateManager::load() { |
19 | Config conf("todolist_templates"); | 19 | Config conf("todolist_templates"); |
20 | OTodoAccessXML *xml = new OTodoAccessXML( QString::fromLatin1("template"), | 20 | OTodoAccessXML *xml = new OTodoAccessXML( QString::fromLatin1("template"), |
@@ -30,18 +30,20 @@ void TemplateManager::load() { | |||
30 | QString str = conf.readEntry("Name", QString::null ); | 30 | QString str = conf.readEntry("Name", QString::null ); |
31 | if (str.isEmpty() ) | 31 | if (str.isEmpty() ) |
32 | continue; | 32 | continue; |
33 | 33 | ||
34 | m_templates.insert( str, | 34 | m_templates.insert( str, ev ); |
35 | ev ); | ||
36 | } | 35 | } |
37 | } | 36 | } |
38 | void TemplateManager::save() { | 37 | void TemplateManager::save() { |
38 | qWarning("Saving!!!!"); | ||
39 | Config conf("todolist_templates"); | 39 | Config conf("todolist_templates"); |
40 | 40 | ||
41 | OTodoAccessXML *res = new OTodoAccessXML( "template", | 41 | OTodoAccessXML *res = new OTodoAccessXML( "template", |
42 | m_path ); | 42 | m_path ); |
43 | OTodoAccess db(res); | 43 | OTodoAccess db(res); |
44 | db.load(); | ||
45 | db.clear(); | ||
44 | 46 | ||
45 | 47 | ||
46 | QMap<QString, OTodo>::Iterator it; | 48 | QMap<QString, OTodo>::Iterator it; |
47 | for ( it = m_templates.begin(); it != m_templates.end(); ++it ) { | 49 | for ( it = m_templates.begin(); it != m_templates.end(); ++it ) { |
@@ -55,9 +57,13 @@ void TemplateManager::save() { | |||
55 | } | 57 | } |
56 | void TemplateManager::addEvent( const QString& str, | 58 | void TemplateManager::addEvent( const QString& str, |
57 | const OTodo& ev) { | 59 | const OTodo& ev) { |
58 | qWarning("AddEvent"+ str ); | 60 | qWarning("AddEvent"+ str ); |
59 | m_templates.replace( str, ev ); | 61 | OTodo todo = ev; |
62 | if( ev.uid() == 0 ) | ||
63 | todo.setUid(1); // generate a new uid | ||
64 | |||
65 | m_templates.replace( str, todo ); | ||
60 | } | 66 | } |
61 | void TemplateManager::removeEvent( const QString& str ) { | 67 | void TemplateManager::removeEvent( const QString& str ) { |
62 | m_templates.remove( str ); | 68 | m_templates.remove( str ); |
63 | } | 69 | } |