summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-08 23:41:05 (UTC)
committer harlekin <harlekin>2002-03-08 23:41:05 (UTC)
commitbc79d3f4a7503c4298a5396b80c65a3e268f4be3 (patch) (side-by-side diff)
treeba27d1565f91458241a792091539683148086b2e
parent432eeb6cedecc0ee4dff3654803c18ebbac1f4d7 (diff)
downloadopie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.zip
opie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.tar.gz
opie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.tar.bz2
check before parse
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/changelog7
-rw-r--r--core/pim/today/opie-today.control2
-rw-r--r--core/pim/today/today.cpp37
-rw-r--r--core/pim/today/today.h1
4 files changed, 45 insertions, 2 deletions
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,45 +1,52 @@
+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
* all day detection
* some smaller bugfixes
0.2.5
* some other minor fixes regarding autoupdate
* fixed segfault with todolist > 7 entries
* fixed the "ugly grey border around buttons" issue
* fixed the "empty calendar field" "bug"
* shown only later appointments as option
0.2.4
* added support for email
* autoupdates after 1 min
* QCopEnvelope instead of system()
* starting to use qvbox in gui
0.2.3
* the 4 am release
* several bugfixes
0.2.2
* started working on calling other apps
* and finished it
0.2.1
* images no more inline
* config dialog
0.1.1
* started changelog.
* fixed segfault on empty/nonexistant todolist.xml
* better handling for file location
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
@@ -1,10 +1,10 @@
Files: bin/today apps/Applications/today.desktop pics/today_icon.png pics/today/today_logo.png pics/today/config.png pics/today/mail.png
Priority: optional
Section: opie/applications
Maintainer: Maximilian Reiß <max.reiss@gmx.de>
Architecture: arm
-Version: 0.2.6
+Version: 0.2.7
Depends: opie-base ($QPE_VERSION)
License: GPL
Description: today screen
A short overview over current appointments and tasks.
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
@@ -1,142 +1,171 @@
/*
* today.cpp : main class
*
* ---------------------
*
* begin : Sun 10 17:20:00 CEST 2002
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.de
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "today.h"
#include "minidom.h"
#include "TodoItem.h"
#include <qpe/datebookdb.h>
#include <qpe/timestring.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qprocess.h>
#include <qpe/resource.h>
#include <qdir.h>
#include <qfile.h>
#include <qdatetime.h>
#include <qtextstream.h>
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qpixmap.h>
+#include <qfileinfo.h>
//#include <iostream.h>
//#include <unistd.h>
#include <stdlib.h>
+
int MAX_LINES_TASK;
int MAX_CHAR_CLIP;
int MAX_LINES_MEET;
int SHOW_LOCATION;
int SHOW_NOTES;
// show only later dates
int ONLY_LATER;
int AUTOSTART;
/*
* Constructs a Example which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
Today::Today( QWidget* parent, const char* name, WFlags fl )
: TodayBase( parent, name, fl ) {
QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
autoStart();
draw();
}
void Today::autoStart() {
Config cfg("today");
cfg.setGroup("Autostart");
AUTOSTART = cfg.readNumEntry("autostart",1);
if (AUTOSTART) {
QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
e << QString("add");
e << QString("today");
} else {
QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
e << QString("remove");
e << QString("today");
}
}
void Today::draw() {
init();
getDates();
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()) );
// QString time = (tr( date.toString()) , white);
TextLabel1->setText(time);
db = new DateBookDB;
// read config
Config cfg("today");
cfg.setGroup("BaseConfig");
// how many lines should be showed in the task section
MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5);
// after how many chars should the be cut off on tasks and notes
MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30);
// how many lines should be showed in the datebook section
MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5);
// If location is to be showed too, 1 to activate it.
SHOW_LOCATION = cfg.readNumEntry("showlocation",1);
// if notes should be shown
SHOW_NOTES = cfg.readNumEntry("shownotes",0);
ONLY_LATER = cfg.readNumEntry("onlylater",1);
}
void Today::startConfig() {
conf = new todayconfig ( this, "", true );
//Config cfg = new Config("today");
// read the config
Config cfg("today");
cfg.setGroup("BaseConfig");
//init();
conf->SpinBox1->setValue(MAX_LINES_MEET);
// location show box
conf->CheckBox1->setChecked(SHOW_LOCATION);
// notes show box
conf->CheckBox2->setChecked(SHOW_NOTES);
// task lines
conf->SpinBox2->setValue(MAX_LINES_TASK);
// clip when?
conf->SpinBox7->setValue(MAX_CHAR_CLIP);
// only later
@@ -295,96 +324,102 @@ QList<TodoItem> Today::loadTodo(const char *filename) {
if(s == "Completed") {
completed = QString(attlist[j]->value).toInt();
}
}
// get Priority (1 to 5)
if(!strcmp(attlist[j]->name, "Priority")) {
QString s = attlist[j]->name;
if(s == "Priority") {
priority = QString(attlist[j]->value).toInt();
}
}
j++;
}
if(description) {
tmp = new TodoItem(description, completed, priority);
loadtodolist.append(tmp);
}
i++;
}
}
minidom_free(todo);
return loadtodolist;
}
void Today::getMail() {
Config cfg("opiemail");
cfg.setGroup("today");
// how many lines should be showed in the task section
int NEW_MAILS = cfg.readNumEntry("newmails",0);
int OUTGOING = cfg.readNumEntry("outgoing",0);
QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
MailField->setText(output);
}
/*
* Get the todos
*
*/
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;
QDir dir;
QString homedir = dir.homeDirPath ();
// see if todolist.xml does exist.
QFile f(homedir +"/Applications/todolist/todolist.xml");
if ( f.exists() ) {
QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml");
TodoItem *item;
for( item = todolist.first(); item; item = todolist.next()) {
if (!(item->getCompleted() == 1) ) {
count++;
if (count <= MAX_LINES_TASK) {
tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
}
}
}
}
if (count > 0) {
if( count == 1 ) {
output = tr("There is <b> 1</b> active task: <br>" );
} else {
output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
}
output += tmpout;
} else {
output = tr("No active tasks");
}
TodoField->setText(tr(output));
}
/*
* launches datebook
*/
void Today::startDatebook() {
QCopEnvelope e("QPE/System", "execute(QString)");
e << QString("datebook");
}
/*
* launches todolist
*/
void Today::startTodo() {
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
@@ -4,61 +4,62 @@
* ---------------------
*
* begin : Sun 10 17:20:00 CEST 2002
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.de
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TODAY_H
#define TODAY_H
#include "todaybase.h"
#include <qpe/datebookdb.h>
#include <qdatetime.h>
#include <qlist.h>
#include "TodoItem.h"
#include "todayconfig.h"
class Today : public TodayBase
{
Q_OBJECT
public:
Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~Today();
private slots:
void startConfig();
void startTodo();
void startDatebook();
void startMail();
void draw();
private:
void init();
void getDates();
void getTodo();
void getMail();
void autoStart();
+ bool checkIfModified();
QList<TodoItem> loadTodo(const char *filename);
private:
DateBookDB *db;
todayconfig *conf;
//Config cfg;
int MAX_LINES_TASK;
int MAX_CHAR_CLIP;
int MAX_LINES_MEET;
int SHOW_LOCATION;
int SHOW_NOTES;
};
#endif // TODAY_H