summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-14 18:23:40 (UTC)
committer zecke <zecke>2003-02-14 18:23:40 (UTC)
commitfc117979a54fca11e591395b130cfef307deb66f (patch) (unidiff)
treec2aa7bb2e46a1506b9a8332c8e026aa04b550d2f
parent1f5bb42810965f86ae02fea7cb9df20cbe9aa22f (diff)
downloadopie-fc117979a54fca11e591395b130cfef307deb66f.zip
opie-fc117979a54fca11e591395b130cfef307deb66f.tar.gz
opie-fc117979a54fca11e591395b130cfef307deb66f.tar.bz2
Remove the #ifdef for QWS
Fix saving of templates The backends want's to load before it saves... Oliver now things should work again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todoeditor.cpp4
-rw-r--r--core/pim/todo/todotemplatemanager.cpp14
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
@@ -1,67 +1,63 @@
1 1
2#include "otaskeditor.h" 2#include "otaskeditor.h"
3#include "todoeditor.h" 3#include "todoeditor.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7Editor::Editor() { 7Editor::Editor() {
8 m_accepted = false; 8 m_accepted = false;
9 m_self = 0l; 9 m_self = 0l;
10} 10}
11Editor::~Editor() { 11Editor::~Editor() {
12 delete m_self; 12 delete m_self;
13 m_self = 0; 13 m_self = 0;
14} 14}
15OTodo Editor::newTodo( int cur, 15OTodo 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}
40OTodo Editor::edit( QWidget *, 38OTodo 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}
59bool Editor::accepted()const { 55bool Editor::accepted()const {
60 return m_accepted; 56 return m_accepted;
61} 57}
62OTaskEditor* Editor::self() { 58OTaskEditor* Editor::self() {
63 if (!m_self ) 59 if (!m_self )
64 m_self = new OTaskEditor(0); 60 m_self = new OTaskEditor(0);
65 61
66 return m_self; 62 return m_self;
67} 63}
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
@@ -1,75 +1,81 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include <qpe/global.h> 2#include <qpe/global.h>
3 3
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
10using namespace Todo; 10using namespace Todo;
11 11
12TemplateManager::TemplateManager() { 12TemplateManager::TemplateManager() {
13 m_path = Global::applicationFileName("todolist", "templates.xml"); 13 m_path = Global::applicationFileName("todolist", "templates.xml");
14} 14}
15TemplateManager::~TemplateManager() { 15TemplateManager::~TemplateManager() {
16 16 save();
17} 17}
18void TemplateManager::load() { 18void 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}
38void TemplateManager::save() { 37void 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}
56void TemplateManager::addEvent( const QString& str, 58void 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}
61void TemplateManager::removeEvent( const QString& str ) { 67void TemplateManager::removeEvent( const QString& str ) {
62 m_templates.remove( str ); 68 m_templates.remove( str );
63} 69}
64QStringList TemplateManager::templates() const { 70QStringList 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;
72} 78}
73OTodo TemplateManager::templateEvent( const QString& templateName ) { 79OTodo TemplateManager::templateEvent( const QString& templateName ) {
74 return m_templates[templateName]; 80 return m_templates[templateName];
75} 81}