summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Unidiff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 0f4cbdb..4368201 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -61,50 +61,50 @@ QString AUTOSTART_TIMER;
61/* 61/*
62 * Constructs a Example which is a child of 'parent', with the 62 * Constructs a Example which is a child of 'parent', with the
63 * name 'name' and widget flags set to 'f' 63 * name 'name' and widget flags set to 'f'
64 */ 64 */
65Today::Today( QWidget* parent, const char* name, WFlags fl ) 65Today::Today( QWidget* parent, const char* name, WFlags fl )
66 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { 66 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) {
67 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 67 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
68 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 68 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
69 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 69 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
70 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 70 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
71 71
72#if defined(Q_WS_QWS) 72#if defined(Q_WS_QWS)
73#if !defined(QT_NO_COP) 73#if !defined(QT_NO_COP)
74 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); 74 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this );
75 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), 75 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)),
76 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); 76 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) );
77#endif 77#endif
78#endif 78#endif
79 79
80 80
81 81
82 db = NULL; 82 db = NULL;
83 setOwnerField(); 83 setOwnerField();
84 todo = new ToDoDB; 84 todo = new ToDoDB;
85 getTodo();
86 draw(); 85 draw();
86 getTodo();
87 autoStart(); 87 autoStart();
88} 88}
89 89
90/* 90/*
91 * Qcop receive method. 91 * Qcop receive method.
92 */ 92 */
93void Today::channelReceived(const QCString &msg, const QByteArray & data) { 93void Today::channelReceived(const QCString &msg, const QByteArray & data) {
94 QDataStream stream(data, IO_ReadOnly ); 94 QDataStream stream(data, IO_ReadOnly );
95 if ( msg == "message(QString)" ) { 95 if ( msg == "message(QString)" ) {
96 QString message; 96 QString message;
97 stream >> message; 97 stream >> message;
98 setOwnerField(message); 98 setOwnerField(message);
99 } 99 }
100 100
101} 101}
102 102
103/* 103/*
104 * Initialises the owner field with the default value, the username 104 * Initialises the owner field with the default value, the username
105 */ 105 */
106void Today::setOwnerField() { 106void Today::setOwnerField() {
107 QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); 107 QString file = Global::applicationFileName("addressbook", "businesscard.vcf");
108 if (QFile::exists(file)) { 108 if (QFile::exists(file)) {
109 Contact cont = Contact::readVCard(file)[0]; 109 Contact cont = Contact::readVCard(file)[0];
110 QString returnString = cont.fullName(); 110 QString returnString = cont.fullName();
@@ -133,49 +133,49 @@ void Today::autoStart() {
133 int AUTOSTART = cfg.readNumEntry("autostart",1); 133 int AUTOSTART = cfg.readNumEntry("autostart",1);
134// qDebug(QString("%1").arg(AUTOSTART)); 134// qDebug(QString("%1").arg(AUTOSTART));
135 if (AUTOSTART) { 135 if (AUTOSTART) {
136 QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); 136 QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)");
137 e << QString("add"); 137 e << QString("add");
138 e << QString("today"); 138 e << QString("today");
139 e << AUTOSTART_TIMER; 139 e << AUTOSTART_TIMER;
140 } else { 140 } else {
141 qDebug("Nun in else bei autostart"); 141 qDebug("Nun in else bei autostart");
142 QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); 142 QCopEnvelope e("QPE/System", "autoStart(QString, QString)");
143 e << QString("remove"); 143 e << QString("remove");
144 e << QString("today"); 144 e << QString("today");
145 } 145 }
146} 146}
147 147
148/* 148/*
149 * Repaint method. Reread all fields. 149 * Repaint method. Reread all fields.
150 */ 150 */
151void Today::draw() { 151void Today::draw() {
152 init(); 152 init();
153 getDates(); 153 getDates();
154 getMail(); 154 getMail();
155 155
156 // if the todolist.xml file was not modified in between, do not parse it. 156 // if the todolist.xml file was not modified in between, do not parse it.
157 if (checkIfModified()) { 157 if (checkIfModified() || NEW_START==1) {
158 if (todo) delete todo; 158 if (todo) delete todo;
159 todo = new ToDoDB; 159 todo = new ToDoDB;
160 getTodo(); 160 getTodo();
161 } 161 }
162 162
163 // how often refresh 163 // how often refresh
164 QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); 164 QTimer::singleShot( 20*1000, this, SLOT(draw() ) );
165} 165}
166 166
167/* 167/*
168 * Check if the todolist.xml was modified (if there are new entries. 168 * Check if the todolist.xml was modified (if there are new entries.
169 * Returns true if it was modified. 169 * Returns true if it was modified.
170 */ 170 */
171bool Today::checkIfModified() { 171bool Today::checkIfModified() {
172 172
173 QDir dir; 173 QDir dir;
174 QString homedir = dir.homeDirPath (); 174 QString homedir = dir.homeDirPath ();
175 QString time; 175 QString time;
176 176
177 Config cfg("today"); 177 Config cfg("today");
178 cfg.setGroup("Files"); 178 cfg.setGroup("Files");
179 time = cfg.readEntry("todolisttimestamp", ""); 179 time = cfg.readEntry("todolisttimestamp", "");
180 180
181 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); 181 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml");
@@ -368,52 +368,52 @@ void Today::getMail() {
368 368
369 369
370/* 370/*
371 * Get the todos 371 * Get the todos
372 */ 372 */
373void Today::getTodo() { 373void Today::getTodo() {
374 374
375 QString output; 375 QString output;
376 QString tmpout; 376 QString tmpout;
377 int count = 0; 377 int count = 0;
378 int ammount = 0; 378 int ammount = 0;
379 379
380 // get overdue todos first 380 // get overdue todos first
381 QValueList<ToDoEvent> overDueList = todo->overDue(); 381 QValueList<ToDoEvent> overDueList = todo->overDue();
382 qBubbleSort(overDueList); 382 qBubbleSort(overDueList);
383 for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); 383 for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin();
384 it!=overDueList.end(); ++it ) { 384 it!=overDueList.end(); ++it ) {
385 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { 385 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) {
386 tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; 386 tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>";
387 ammount++; 387 ammount++;
388 } 388 }
389 } 389 }
390 390
391 // get total number of still open todos 391 // get total number of still open todos
392 QValueList<ToDoEvent> open = todo->rawToDos(); 392 QValueList<ToDoEvent> openTodo = todo->rawToDos();
393 qBubbleSort(open); 393 qBubbleSort(openTodo);
394 for ( QValueList<ToDoEvent>::Iterator it=open.begin(); 394 for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin();
395 it!=open.end(); ++it ) { 395 it!=openTodo.end(); ++it ) {
396 if (!(*it).isCompleted()){ 396 if (!(*it).isCompleted()){
397 count +=1; 397 count +=1;
398 // not the overdues, we allready got them, and not if we are 398 // not the overdues, we allready got them, and not if we are
399 // over the maxlines 399 // over the maxlines
400 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { 400 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) {
401 tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; 401 tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>";
402 ammount++; 402 ammount++;
403 } 403 }
404 } 404 }
405 } 405 }
406 406
407 407
408 if (count > 0) { 408 if (count > 0) {
409 if( count == 1 ) { 409 if( count == 1 ) {
410 output = tr("There is <b> 1</b> active task: <br>" ); 410 output = tr("There is <b> 1</b> active task: <br>" );
411 } else { 411 } else {
412 output = tr("There are <b> %1</b> active tasks: <br>").arg(count); 412 output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
413 } 413 }
414 output += tmpout; 414 output += tmpout;
415 } else { 415 } else {
416 output = tr("No active tasks"); 416 output = tr("No active tasks");
417 } 417 }
418 418
419 TodoField->setText(tr(output)); 419 TodoField->setText(tr(output));