From bc79d3f4a7503c4298a5396b80c65a3e268f4be3 Mon Sep 17 00:00:00 2001 From: harlekin Date: Fri, 08 Mar 2002 23:41:05 +0000 Subject: check before parse --- diff --git a/core/pim/today/changelog b/core/pim/today/changelog index 692c0dc..7111154 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog @@ -1,3 +1,10 @@ +0.2.7 + +* check if todolist.xml was changed before parsing it +* check only every 30 sec for changes. +* some visual stuff +* as usual many little improvements .-) + 0.2.6 * added scrollbars to dates and todo diff --git a/core/pim/today/opie-today.control b/core/pim/today/opie-today.control index f16ddfb..4c0a1c0 100644 --- a/core/pim/today/opie-today.control +++ b/core/pim/today/opie-today.control @@ -3,7 +3,7 @@ Priority: optional Section: opie/applications Maintainer: Maximilian Reiß Architecture: arm -Version: 0.2.6 +Version: 0.2.7 Depends: opie-base ($QPE_VERSION) License: GPL Description: today screen diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index af1d4e4..d715fc1 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -38,11 +38,13 @@ #include #include #include +#include //#include //#include #include + int MAX_LINES_TASK; int MAX_CHAR_CLIP; int MAX_LINES_MEET; @@ -89,9 +91,36 @@ void Today::draw() { getMail(); getTodo(); // how often refresh - QTimer::singleShot( 5*1000, this, SLOT(draw()) ); + QTimer::singleShot( 30*1000, this, SLOT(draw()) ); +} + + +/* + * Check if the todolist.xml was modified (if there are new entries. + * Returns true if it was modified. + */ +bool Today::checkIfModified() { + + QDir dir; + QString homedir = dir.homeDirPath (); + QString time; + + Config cfg("today"); + cfg.setGroup("Files"); + time = cfg.readEntry("todolisttimestamp", ""); + + QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); + QDateTime fileTime = file.lastModified(); + if (time.compare(fileTime.toString()) == 0) { + return false; + } else { + cfg.writeEntry("todolisttimestamp", fileTime.toString() ); + cfg.write(); + return true; + } } + void Today::init() { QDate date = QDate::currentDate(); QString time = (tr( date.toString()) ); @@ -340,6 +369,12 @@ void Today::getMail() { * */ void Today::getTodo() { + + // if the todolist.xml file was not modified in between, do not parse it. + if (!checkIfModified()) { + return; + } + QString output; QString tmpout; int count = 0; diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 07bfd61..b3b7d01 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -49,6 +49,7 @@ class Today : public TodayBase void getTodo(); void getMail(); void autoStart(); + bool checkIfModified(); QList loadTodo(const char *filename); private: DateBookDB *db; -- cgit v0.9.0.2