summaryrefslogtreecommitdiff
path: root/core/pim
Side-by-side diff
Diffstat (limited to 'core/pim') (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
@@ -15,19 +15,17 @@ Editor::~Editor() {
OTodo Editor::newTodo( int cur,
QWidget*) {
OTaskEditor *e = self();
e->setCaption( QObject::tr("Enter Task") );
e->init( cur );
-#if defined(Q_WS_QWS) || defined(_WS_QWS_)
e->showMaximized();
-#endif
int ret = e->exec();
if ( QDialog::Accepted == ret ) {
m_accepted = true;
}else
m_accepted = false;
OTodo ev = e->todo();
@@ -38,19 +36,17 @@ OTodo Editor::newTodo( int cur,
return ev;
}
OTodo Editor::edit( QWidget *,
const OTodo& todo ) {
OTaskEditor *e = self();
e->init( todo );
e->setCaption( QObject::tr( "Edit Task" ) );
-#if defined(Q_WS_QWS) || defined(_WS_QWS_)
e->showMaximized();
-#endif
int ret = e->exec();
OTodo ev = e->todo();
if ( ret == QDialog::Accepted )
m_accepted = true;
else
m_accepted = false;
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
@@ -8,17 +8,17 @@
using namespace Todo;
TemplateManager::TemplateManager() {
m_path = Global::applicationFileName("todolist", "templates.xml");
}
TemplateManager::~TemplateManager() {
-
+ save();
}
void TemplateManager::load() {
Config conf("todolist_templates");
OTodoAccessXML *xml = new OTodoAccessXML( QString::fromLatin1("template"),
m_path );
OTodoAccess todoDB(xml );
todoDB.load();
@@ -26,42 +26,48 @@ void TemplateManager::load() {
OTodoAccess::List list = todoDB.allRecords();
for ( it = list.begin(); it != list.end(); ++it ) {
OTodo ev = (*it);
conf.setGroup( QString::number( ev.uid() ) );
QString str = conf.readEntry("Name", QString::null );
if (str.isEmpty() )
continue;
- m_templates.insert( str,
- ev );
+ m_templates.insert( str, ev );
}
}
void TemplateManager::save() {
+ qWarning("Saving!!!!");
Config conf("todolist_templates");
OTodoAccessXML *res = new OTodoAccessXML( "template",
m_path );
OTodoAccess db(res);
+ db.load();
+ db.clear();
QMap<QString, OTodo>::Iterator it;
for ( it = m_templates.begin(); it != m_templates.end(); ++it ) {
OTodo ev = it.data();
conf.setGroup( QString::number( ev.uid() ) );
qWarning("Name" + it.key() );
conf.writeEntry("Name", it.key() );
db.add( ev );
}
db.save();
}
void TemplateManager::addEvent( const QString& str,
const OTodo& ev) {
qWarning("AddEvent"+ str );
- m_templates.replace( str, ev );
+ OTodo todo = ev;
+ if( ev.uid() == 0 )
+ todo.setUid(1); // generate a new uid
+
+ m_templates.replace( str, todo );
}
void TemplateManager::removeEvent( const QString& str ) {
m_templates.remove( str );
}
QStringList TemplateManager::templates() const {
QStringList list;
QMap<QString, OTodo>::ConstIterator it;
for (it = m_templates.begin(); it != m_templates.end(); ++it ) {