-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 | |||
@@ -17,15 +17,13 @@ OTodo Editor::newTodo( int cur, | |||
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; |
@@ -40,15 +38,13 @@ OTodo Editor::newTodo( int cur, | |||
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 |
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 | |||
@@ -10,13 +10,13 @@ | |||
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 ); |
@@ -28,22 +28,24 @@ void TemplateManager::load() { | |||
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() ) ); |
@@ -53,13 +55,17 @@ void TemplateManager::save() { | |||
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; |