summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Unidiff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/today.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 00a8842..eb8b50c 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -26,57 +26,67 @@
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qprocess.h> 28#include <qpe/qprocess.h>
29 29
30#include <qdir.h> 30#include <qdir.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qspinbox.h> 35#include <qspinbox.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qtimer.h>
38 39
39//#include <iostream.h> 40//#include <iostream.h>
40//#include <unistd.h> 41//#include <unistd.h>
41#include <stdlib.h> 42#include <stdlib.h>
42 43
43int MAX_LINES_TASK; 44int MAX_LINES_TASK;
44int MAX_CHAR_CLIP; 45int MAX_CHAR_CLIP;
45int MAX_LINES_MEET; 46int MAX_LINES_MEET;
46int SHOW_LOCATION; 47int SHOW_LOCATION;
47int SHOW_NOTES; 48int SHOW_NOTES;
48// show only later dates 49// show only later dates
49int ONLY_LATER = 1; 50int ONLY_LATER = 1;
50/* 51/*
51 * Constructs a Example which is a child of 'parent', with the 52 * Constructs a Example which is a child of 'parent', with the
52 * name 'name' and widget flags set to 'f' 53 * name 'name' and widget flags set to 'f'
53 */ 54 */
54Today::Today( QWidget* parent, const char* name, WFlags fl ) 55Today::Today( QWidget* parent, const char* name, WFlags fl )
55 : TodayBase( parent, name, fl ) 56 : TodayBase( parent, name, fl )
56{ 57{
57 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 58 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
58 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 59 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
59 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 60 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
61 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
60 62
61 QDate date = QDate::currentDate(); 63 QDate date = QDate::currentDate();
62 QString time = (date.toString()); 64 QString time = (date.toString());
63 TextLabel1->setText(time); 65 TextLabel1->setText(time);
64 db = new DateBookDB; 66 db = new DateBookDB;
65 67
68 draw();
69}
70
71
72void Today::draw()
73{
66 init(); 74 init();
67 getDates(); 75 getDates();
76 getMail();
68 getTodo(); 77 getTodo();
69} 78 QTimer::singleShot( 60*1000, this, SLOT(draw()) );
70 79
80}
71 81
72void Today::init() 82void Today::init()
73{ 83{
74 // read config 84 // read config
75 Config cfg("today"); 85 Config cfg("today");
76 cfg.setGroup("BaseConfig"); 86 cfg.setGroup("BaseConfig");
77 87
78 // how many lines should be showed in the task section 88 // how many lines should be showed in the task section
79 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); 89 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5);
80 // after how many chars should the be cut off on tasks and notes 90 // after how many chars should the be cut off on tasks and notes
81 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); 91 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30);
82 // how many lines should be showed in the datebook section 92 // how many lines should be showed in the datebook section
@@ -117,28 +127,25 @@ void Today::startConfig()
117 int location = conf->CheckBox1->isChecked(); 127 int location = conf->CheckBox1->isChecked();
118 int notes = conf->CheckBox2->isChecked(); 128 int notes = conf->CheckBox2->isChecked();
119 int maxcharclip = conf->SpinBox7->value(); 129 int maxcharclip = conf->SpinBox7->value();
120 130
121 cfg.writeEntry("maxlinestask",maxlinestask); 131 cfg.writeEntry("maxlinestask",maxlinestask);
122 cfg.writeEntry("maxcharclip", maxcharclip); 132 cfg.writeEntry("maxcharclip", maxcharclip);
123 cfg.writeEntry("maxlinesmeet",maxmeet); 133 cfg.writeEntry("maxlinesmeet",maxmeet);
124 cfg.writeEntry("showlocation",location); 134 cfg.writeEntry("showlocation",location);
125 cfg.writeEntry("shownotes", notes); 135 cfg.writeEntry("shownotes", notes);
126 // sync it to "disk" 136 // sync it to "disk"
127 cfg.write(); 137 cfg.write();
128 138
129 init(); 139 draw();
130 getDates();
131 getTodo();
132 //cout << location << endl;
133} 140}
134 141
135 142
136/* 143/*
137 * Get all events that are in the datebook xml file for today 144 * Get all events that are in the datebook xml file for today
138 */ 145 */
139void Today::getDates() 146void Today::getDates()
140{ 147{
141 QDate date = QDate::currentDate(); 148 QDate date = QDate::currentDate();
142 QTime time = QTime::currentTime(); 149 QTime time = QTime::currentTime();
143 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 150 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
144 151
@@ -253,24 +260,40 @@ QList<TodoItem> Today::loadTodo(const char *filename)
253 loadtodolist.append(tmp); 260 loadtodolist.append(tmp);
254 } 261 }
255 i++; 262 i++;
256 } 263 }
257 } 264 }
258 265
259 minidom_free(todo); 266 minidom_free(todo);
260 267
261 return loadtodolist; 268 return loadtodolist;
262} 269}
263 270
264 271
272void Today::getMail()
273{
274 Config cfg("opiemail");
275 cfg.setGroup("today");
276
277 // how many lines should be showed in the task section
278 int NEW_MAILS = cfg.readNumEntry("newmails",0);
279 int OUTGOING = cfg.readNumEntry("outgoing",0);
280
281 QString output = tr("<b>%1</b> new mails, <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
282
283
284 MailField->setText(output);
285}
286
287
265/* 288/*
266 * Get the todos 289 * Get the todos
267 * 290 *
268 */ 291 */
269void Today::getTodo() 292void Today::getTodo()
270{ 293{
271 QString output; 294 QString output;
272 QString tmpout; 295 QString tmpout;
273 int count = 0; 296 int count = 0;
274 297
275 QDir dir; 298 QDir dir;
276 QString homedir = dir.homeDirPath (); 299 QString homedir = dir.homeDirPath ();
@@ -299,36 +322,45 @@ void Today::getTodo()
299 output = QString("There are <b> %1</b> active tasks: <br>").arg(count); 322 output = QString("There are <b> %1</b> active tasks: <br>").arg(count);
300 output += tmpout; 323 output += tmpout;
301 } 324 }
302 else 325 else
303 { 326 {
304 output = ("No active tasks"); 327 output = ("No active tasks");
305 } 328 }
306 329
307 TodoField->setText(output); 330 TodoField->setText(output);
308} 331}
309 332
310/* 333/*
311 * lanches datebook 334 * launches datebook
312 */ 335 */
313void Today::startDatebook() 336void Today::startDatebook()
314{ 337{
315 QCopEnvelope e("QPE/System", "execute(QString)"); 338 QCopEnvelope e("QPE/System", "execute(QString)");
316 e << QString("datebook"); 339 e << QString("datebook");
317} 340}
318 341
319/* 342/*
320 * lanches todolist 343 * launches todolist
321 */ 344 */
322void Today::startTodo() 345void Today::startTodo()
323{ 346{
324 QCopEnvelope e("QPE/System", "execute(QString)"); 347 QCopEnvelope e("QPE/System", "execute(QString)");
325 e << QString("todolist"); 348 e << QString("todolist");
326} 349}
327 350
328/* 351/*
352 * launch opiemail
353 */
354void Today::startMail()
355{
356 QCopEnvelope e("QPE/System", "execute(QString)");
357 e << QString("opiemail");
358}
359
360/*
329 * Destroys the object and frees any allocated resources 361 * Destroys the object and frees any allocated resources
330 */ 362 */
331Today::~Today() 363Today::~Today()
332{ 364{
333 // no need to delete child widgets, Qt does it all for us 365 // no need to delete child widgets, Qt does it all for us
334} 366}