Diffstat (limited to 'core/pim/todo/todotemplatemanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/todotemplatemanager.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/core/pim/todo/todotemplatemanager.cpp b/core/pim/todo/todotemplatemanager.cpp index 5b83f76..eeac51b 100644 --- a/core/pim/todo/todotemplatemanager.cpp +++ b/core/pim/todo/todotemplatemanager.cpp | |||
@@ -1,81 +1,81 @@ | |||
1 | #include <opie2/otodoaccess.h> | ||
2 | #include <opie2/otodoaccessxml.h> | ||
3 | |||
1 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
2 | #include <qpe/global.h> | 5 | #include <qpe/global.h> |
3 | 6 | ||
4 | #include <opie/otodoaccess.h> | ||
5 | #include <opie/otodoaccessxml.h> | ||
6 | |||
7 | #include "todotemplatemanager.h" | 7 | #include "todotemplatemanager.h" |
8 | 8 | ||
9 | 9 | ||
10 | using namespace Todo; | 10 | using namespace Todo; |
11 | 11 | ||
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 | save(); | 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 | OPimTodoAccessXML *xml = new OPimTodoAccessXML( QString::fromLatin1("template"), |
21 | m_path ); | 21 | m_path ); |
22 | OTodoAccess todoDB(xml ); | 22 | OPimTodoAccess todoDB(xml ); |
23 | todoDB.load(); | 23 | todoDB.load(); |
24 | 24 | ||
25 | OTodoAccess::List::Iterator it; | 25 | OPimTodoAccess::List::Iterator it; |
26 | OTodoAccess::List list = todoDB.allRecords(); | 26 | OPimTodoAccess::List list = todoDB.allRecords(); |
27 | for ( it = list.begin(); it != list.end(); ++it ) { | 27 | for ( it = list.begin(); it != list.end(); ++it ) { |
28 | OTodo ev = (*it); | 28 | OPimTodo ev = (*it); |
29 | conf.setGroup( QString::number( ev.uid() ) ); | 29 | conf.setGroup( QString::number( ev.uid() ) ); |
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, ev ); | 34 | m_templates.insert( str, ev ); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | void TemplateManager::save() { | 37 | void TemplateManager::save() { |
38 | qWarning("Saving!!!!"); | 38 | qWarning("Saving!!!!"); |
39 | Config conf("todolist_templates"); | 39 | Config conf("todolist_templates"); |
40 | 40 | ||
41 | OTodoAccessXML *res = new OTodoAccessXML( "template", | 41 | OPimTodoAccessXML *res = new OPimTodoAccessXML( "template", |
42 | m_path ); | 42 | m_path ); |
43 | OTodoAccess db(res); | 43 | OPimTodoAccess db(res); |
44 | db.load(); | 44 | db.load(); |
45 | db.clear(); | 45 | db.clear(); |
46 | 46 | ||
47 | 47 | ||
48 | QMap<QString, OTodo>::Iterator it; | 48 | QMap<QString, OPimTodo>::Iterator it; |
49 | for ( it = m_templates.begin(); it != m_templates.end(); ++it ) { | 49 | for ( it = m_templates.begin(); it != m_templates.end(); ++it ) { |
50 | OTodo ev = it.data(); | 50 | OPimTodo ev = it.data(); |
51 | conf.setGroup( QString::number( ev.uid() ) ); | 51 | conf.setGroup( QString::number( ev.uid() ) ); |
52 | qWarning("Name" + it.key() ); | 52 | qWarning("Name" + it.key() ); |
53 | conf.writeEntry("Name", it.key() ); | 53 | conf.writeEntry("Name", it.key() ); |
54 | db.add( ev ); | 54 | db.add( ev ); |
55 | } | 55 | } |
56 | db.save(); | 56 | db.save(); |
57 | } | 57 | } |
58 | void TemplateManager::addEvent( const QString& str, | 58 | void TemplateManager::addEvent( const QString& str, |
59 | const OTodo& ev) { | 59 | const OPimTodo& ev) { |
60 | qWarning("AddEvent"+ str ); | 60 | qWarning("AddEvent"+ str ); |
61 | OTodo todo = ev; | 61 | OPimTodo todo = ev; |
62 | if( ev.uid() == 0 ) | 62 | if( ev.uid() == 0 ) |
63 | todo.setUid(1); // generate a new uid | 63 | todo.setUid(1); // generate a new uid |
64 | 64 | ||
65 | m_templates.replace( str, todo ); | 65 | m_templates.replace( str, todo ); |
66 | } | 66 | } |
67 | void TemplateManager::removeEvent( const QString& str ) { | 67 | void TemplateManager::removeEvent( const QString& str ) { |
68 | m_templates.remove( str ); | 68 | m_templates.remove( str ); |
69 | } | 69 | } |
70 | QStringList TemplateManager::templates() const { | 70 | QStringList TemplateManager::templates() const { |
71 | QStringList list; | 71 | QStringList list; |
72 | QMap<QString, OTodo>::ConstIterator it; | 72 | QMap<QString, OPimTodo>::ConstIterator it; |
73 | for (it = m_templates.begin(); it != m_templates.end(); ++it ) { | 73 | for (it = m_templates.begin(); it != m_templates.end(); ++it ) { |
74 | list << it.key(); | 74 | list << it.key(); |
75 | } | 75 | } |
76 | 76 | ||
77 | return list; | 77 | return list; |
78 | } | 78 | } |
79 | OTodo TemplateManager::templateEvent( const QString& templateName ) { | 79 | OPimTodo TemplateManager::templateEvent( const QString& templateName ) { |
80 | return m_templates[templateName]; | 80 | return m_templates[templateName]; |
81 | } | 81 | } |