-rw-r--r-- | core/pim/todo/todoeditor.cpp | 4 | ||||
-rw-r--r-- | core/pim/todo/todotemplatemanager.cpp | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp index 5aa7097..c204325 100644 --- a/core/pim/todo/todoeditor.cpp +++ b/core/pim/todo/todoeditor.cpp | |||
@@ -11,50 +11,46 @@ Editor::Editor() { | |||
11 | Editor::~Editor() { | 11 | Editor::~Editor() { |
12 | delete m_self; | 12 | delete m_self; |
13 | m_self = 0; | 13 | m_self = 0; |
14 | } | 14 | } |
15 | OTodo Editor::newTodo( int cur, | 15 | OTodo Editor::newTodo( int cur, |
16 | QWidget*) { | 16 | QWidget*) { |
17 | 17 | ||
18 | OTaskEditor *e = self(); | 18 | OTaskEditor *e = self(); |
19 | e->setCaption( QObject::tr("Enter Task") ); | 19 | e->setCaption( QObject::tr("Enter Task") ); |
20 | e->init( cur ); | 20 | e->init( cur ); |
21 | 21 | ||
22 | 22 | ||
23 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
24 | e->showMaximized(); | 23 | e->showMaximized(); |
25 | #endif | ||
26 | 24 | ||
27 | int ret = e->exec(); | 25 | int ret = e->exec(); |
28 | if ( QDialog::Accepted == ret ) { | 26 | if ( QDialog::Accepted == ret ) { |
29 | m_accepted = true; | 27 | m_accepted = true; |
30 | }else | 28 | }else |
31 | m_accepted = false; | 29 | m_accepted = false; |
32 | 30 | ||
33 | OTodo ev = e->todo(); | 31 | OTodo ev = e->todo(); |
34 | qWarning("Todo uid"); | 32 | qWarning("Todo uid"); |
35 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); | 33 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); |
36 | ev.setUid(1); | 34 | ev.setUid(1); |
37 | 35 | ||
38 | return ev; | 36 | return ev; |
39 | } | 37 | } |
40 | OTodo Editor::edit( QWidget *, | 38 | OTodo Editor::edit( QWidget *, |
41 | const OTodo& todo ) { | 39 | const OTodo& todo ) { |
42 | OTaskEditor *e = self(); | 40 | OTaskEditor *e = self(); |
43 | e->init( todo ); | 41 | e->init( todo ); |
44 | e->setCaption( QObject::tr( "Edit Task" ) ); | 42 | e->setCaption( QObject::tr( "Edit Task" ) ); |
45 | 43 | ||
46 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
47 | e->showMaximized(); | 44 | e->showMaximized(); |
48 | #endif | ||
49 | int ret = e->exec(); | 45 | int ret = e->exec(); |
50 | 46 | ||
51 | OTodo ev = e->todo(); | 47 | OTodo ev = e->todo(); |
52 | if ( ret == QDialog::Accepted ) | 48 | if ( ret == QDialog::Accepted ) |
53 | m_accepted = true; | 49 | m_accepted = true; |
54 | else | 50 | else |
55 | m_accepted = false; | 51 | m_accepted = false; |
56 | 52 | ||
57 | return ev; | 53 | return ev; |
58 | } | 54 | } |
59 | bool Editor::accepted()const { | 55 | bool Editor::accepted()const { |
60 | return m_accepted; | 56 | return m_accepted; |
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 | |||
@@ -4,68 +4,74 @@ | |||
4 | #include <opie/otodoaccess.h> | 4 | #include <opie/otodoaccess.h> |
5 | #include <opie/otodoaccessxml.h> | 5 | #include <opie/otodoaccessxml.h> |
6 | 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 | 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"), |
21 | m_path ); | 21 | m_path ); |
22 | OTodoAccess todoDB(xml ); | 22 | OTodoAccess todoDB(xml ); |
23 | todoDB.load(); | 23 | todoDB.load(); |
24 | 24 | ||
25 | OTodoAccess::List::Iterator it; | 25 | OTodoAccess::List::Iterator it; |
26 | OTodoAccess::List list = todoDB.allRecords(); | 26 | OTodoAccess::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 | OTodo 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, | 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 ) { |
48 | OTodo ev = it.data(); | 50 | OTodo ev = it.data(); |
49 | conf.setGroup( QString::number( ev.uid() ) ); | 51 | conf.setGroup( QString::number( ev.uid() ) ); |
50 | qWarning("Name" + it.key() ); | 52 | qWarning("Name" + it.key() ); |
51 | conf.writeEntry("Name", it.key() ); | 53 | conf.writeEntry("Name", it.key() ); |
52 | db.add( ev ); | 54 | db.add( ev ); |
53 | } | 55 | } |
54 | db.save(); | 56 | db.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 | } |
64 | QStringList TemplateManager::templates() const { | 70 | QStringList TemplateManager::templates() const { |
65 | QStringList list; | 71 | QStringList list; |
66 | QMap<QString, OTodo>::ConstIterator it; | 72 | QMap<QString, OTodo>::ConstIterator it; |
67 | for (it = m_templates.begin(); it != m_templates.end(); ++it ) { | 73 | for (it = m_templates.begin(); it != m_templates.end(); ++it ) { |
68 | list << it.key(); | 74 | list << it.key(); |
69 | } | 75 | } |
70 | 76 | ||
71 | return list; | 77 | return list; |