-rw-r--r-- | core/pim/today/today.cpp | 642 |
1 files changed, 155 insertions, 487 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 62becb0..09540bd 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,9 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp : main class | 2 | * today.cpp |
3 | * | 3 | * |
4 | * --------------------- | ||
5 | * | ||
6 | * begin : Sun 10 17:20:00 CEST 2002 | ||
7 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 5 | * email : harlekin@handhelds.org |
9 | * | 6 | * |
@@ -19,5 +16,6 @@ | |||
19 | 16 | ||
17 | |||
20 | #include "today.h" | 18 | #include "today.h" |
19 | #include "configwidget.h" | ||
21 | 20 | ||
22 | #include <qpe/timestring.h> | ||
23 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
@@ -25,5 +23,5 @@ | |||
25 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
26 | #include <qpe/contact.h> | ||
27 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
28 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/contact.h> | ||
29 | 27 | ||
@@ -31,6 +29,2 @@ | |||
31 | #include <qfile.h> | 29 | #include <qfile.h> |
32 | #include <qdatetime.h> | ||
33 | #include <qtextstream.h> | ||
34 | #include <qcheckbox.h> | ||
35 | #include <qspinbox.h> | ||
36 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
@@ -40,30 +34,12 @@ | |||
40 | #include <qlayout.h> | 34 | #include <qlayout.h> |
41 | #include <qtl.h> | 35 | #include <qtabwidget.h> |
42 | 36 | #include <qdialog.h> | |
43 | 37 | ||
44 | #include <unistd.h> | ||
45 | #include <stdlib.h> | ||
46 | 38 | ||
47 | int MAX_LINES_TASK; | 39 | static QValueList<TodayPlugin> pluginList; |
48 | int MAX_CHAR_CLIP; | ||
49 | int MAX_LINES_MEET; | ||
50 | int SHOW_LOCATION; | ||
51 | int SHOW_NOTES; | ||
52 | // show only later dates | ||
53 | int ONLY_LATER; | ||
54 | int AUTOSTART; | ||
55 | int NEW_START=1; | ||
56 | QString AUTOSTART_TIMER; | ||
57 | int NEXTDAYS=1; | ||
58 | 40 | ||
59 | |||
60 | /* Constructs a Example which is a child of 'parent', with the | ||
61 | * name 'name' and widget flags set to 'f' | ||
62 | */ | ||
63 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 41 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
64 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 42 | : TodayBase( parent, name, fl ) { |
65 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 43 | |
66 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 44 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
67 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | ||
68 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | ||
69 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); | 45 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); |
@@ -78,13 +54,11 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
78 | 54 | ||
55 | pluginLayout = 0l; | ||
79 | 56 | ||
80 | |||
81 | db = NULL; | ||
82 | setOwnerField(); | 57 | setOwnerField(); |
83 | todo = new ToDoDB; | 58 | init(); |
84 | draw(); | 59 | refresh(); |
85 | getTodo(); | 60 | showMaximized(); |
86 | autoStart(); | ||
87 | } | 61 | } |
88 | 62 | ||
89 | /* | 63 | /** |
90 | * Qcop receive method. | 64 | * Qcop receive method. |
@@ -98,6 +72,5 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) { | |||
98 | } | 72 | } |
99 | |||
100 | } | 73 | } |
101 | 74 | ||
102 | /* | 75 | /** |
103 | * Initialises the owner field with the default value, the username | 76 | * Initialises the owner field with the default value, the username |
@@ -115,3 +88,3 @@ void Today::setOwnerField() { | |||
115 | 88 | ||
116 | /* | 89 | /** |
117 | * Set the owner field with a given QString, for example per qcop. | 90 | * Set the owner field with a given QString, for example per qcop. |
@@ -124,70 +97,4 @@ void Today::setOwnerField(QString &message) { | |||
124 | 97 | ||
125 | /* | ||
126 | * Autostart, uses the new (opie only) autostart method in the launcher code. | ||
127 | * If registered against that today ist started on each resume. | ||
128 | */ | ||
129 | void Today::autoStart() { | ||
130 | Config cfg("today"); | ||
131 | cfg.setGroup("Autostart"); | ||
132 | int AUTOSTART = cfg.readNumEntry("autostart",1); | ||
133 | // qDebug(QString("%1").arg(AUTOSTART)); | ||
134 | if (AUTOSTART) { | ||
135 | QCopEnvelope e("QPE/System", "autoStart(QString,QString,QString)"); | ||
136 | e << QString("add"); | ||
137 | e << QString("today"); | ||
138 | e << AUTOSTART_TIMER; | ||
139 | } else { | ||
140 | qDebug("Nun in else bei autostart"); | ||
141 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | ||
142 | e << QString("remove"); | ||
143 | e << QString("today"); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | /* | ||
148 | * Repaint method. Reread all fields. | ||
149 | */ | ||
150 | void Today::draw() { | ||
151 | init(); | ||
152 | getDates(); | ||
153 | getMail(); | ||
154 | |||
155 | // if the todolist.xml file was not modified in between, do not parse it. | ||
156 | if (checkIfModified() || NEW_START==1) { | ||
157 | if (todo) delete todo; | ||
158 | todo = new ToDoDB; | ||
159 | getTodo(); | ||
160 | } | ||
161 | |||
162 | // how often refresh | ||
163 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * Check if the todolist.xml was modified (if there are new entries. | ||
168 | * Returns true if it was modified. | ||
169 | */ | ||
170 | bool Today::checkIfModified() { | ||
171 | |||
172 | QDir dir; | ||
173 | QString homedir = dir.homeDirPath (); | ||
174 | QString time; | ||
175 | |||
176 | Config cfg("today"); | ||
177 | cfg.setGroup("Files"); | ||
178 | time = cfg.readEntry("todolisttimestamp", ""); | ||
179 | |||
180 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | ||
181 | QDateTime fileTime = file.lastModified(); | ||
182 | if (time.compare(fileTime.toString()) == 0) { | ||
183 | return false; | ||
184 | } else { | ||
185 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | ||
186 | cfg.write(); | ||
187 | return true; | ||
188 | } | ||
189 | } | ||
190 | 98 | ||
191 | 99 | /** | |
192 | /* | ||
193 | * Init stuff needed for today. Reads the config file. | 100 | * Init stuff needed for today. Reads the config file. |
@@ -195,2 +102,3 @@ bool Today::checkIfModified() { | |||
195 | void Today::init() { | 102 | void Today::init() { |
103 | |||
196 | QDate date = QDate::currentDate(); | 104 | QDate date = QDate::currentDate(); |
@@ -198,3 +106,3 @@ void Today::init() { | |||
198 | 106 | ||
199 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); | 107 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); |
200 | 108 | ||
@@ -202,81 +110,5 @@ void Today::init() { | |||
202 | Config cfg("today"); | 110 | Config cfg("today"); |
203 | cfg.setGroup("BaseConfig"); | ||
204 | |||
205 | // -- config file section -- | ||
206 | // how many lines should be showed in the task section | ||
207 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | ||
208 | // after how many chars should the be cut off on tasks and notes | ||
209 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); | ||
210 | // how many lines should be showed in the datebook section | ||
211 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | ||
212 | // If location is to be showed too, 1 to activate it. | ||
213 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | ||
214 | // if notes should be shown | ||
215 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | ||
216 | // should only later appointments be shown or all for the current day. | ||
217 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | ||
218 | |||
219 | cfg.setGroup("Autostart"); | ||
220 | AUTOSTART = cfg.readNumEntry("autostart",1); | ||
221 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); | ||
222 | |||
223 | //db = new DateBookDB; | ||
224 | } | ||
225 | |||
226 | /* | ||
227 | * The method for the configuration dialog. | ||
228 | */ | ||
229 | void Today::startConfig() { | ||
230 | 111 | ||
231 | conf = new todayconfig ( this, "", true ); | 112 | cfg.setGroup( "Applets" ); |
232 | // read the config | 113 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
233 | Config cfg("today"); | ||
234 | cfg.setGroup("BaseConfig"); | ||
235 | |||
236 | //init(); | ||
237 | |||
238 | conf->SpinBox1->setValue(MAX_LINES_MEET); | ||
239 | // location show box | ||
240 | conf->CheckBox1->setChecked(SHOW_LOCATION); | ||
241 | // notes show box | ||
242 | conf->CheckBox2->setChecked(SHOW_NOTES); | ||
243 | // task lines | ||
244 | conf->SpinBox2->setValue(MAX_LINES_TASK); | ||
245 | // clip when? | ||
246 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | ||
247 | // only later | ||
248 | conf->CheckBox3->setChecked(ONLY_LATER); | ||
249 | // if today should be autostarted | ||
250 | conf->CheckBoxAuto->setChecked(AUTOSTART); | ||
251 | // autostart only if device has been suspended for X minutes | ||
252 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); | ||
253 | |||
254 | conf->exec(); | ||
255 | |||
256 | int maxlinestask = conf->SpinBox2->value(); | ||
257 | int maxmeet = conf->SpinBox1->value(); | ||
258 | int location = conf->CheckBox1->isChecked(); | ||
259 | int notes = conf->CheckBox2->isChecked(); | ||
260 | int maxcharclip = conf->SpinBox7->value(); | ||
261 | int onlylater = conf->CheckBox3->isChecked(); | ||
262 | int autostart = conf->CheckBoxAuto->isChecked(); | ||
263 | int autostartdelay = conf->SpinBoxTime->value(); | ||
264 | |||
265 | |||
266 | cfg.writeEntry("maxlinestask",maxlinestask); | ||
267 | cfg.writeEntry("maxcharclip", maxcharclip); | ||
268 | cfg.writeEntry("maxlinesmeet",maxmeet); | ||
269 | cfg.writeEntry("showlocation",location); | ||
270 | cfg.writeEntry("shownotes", notes); | ||
271 | cfg.writeEntry("onlylater", onlylater); | ||
272 | cfg.setGroup("Autostart"); | ||
273 | cfg.writeEntry("autostart", autostart); | ||
274 | cfg.writeEntry("autostartdelay", autostartdelay); | ||
275 | |||
276 | // sync it to "disk" | ||
277 | cfg.write(); | ||
278 | NEW_START=1; | ||
279 | draw(); | ||
280 | AUTOSTART=autostart; | ||
281 | autoStart(); | ||
282 | } | 114 | } |
@@ -284,52 +116,44 @@ void Today::startConfig() { | |||
284 | 116 | ||
285 | /* | 117 | /** |
286 | * Get all events that are in the datebook xml file for today | 118 | * Load the plugins |
287 | */ | 119 | */ |
288 | void Today::getDates() { | 120 | void Today::loadPlugins() { |
289 | QDate date = QDate::currentDate(); | ||
290 | 121 | ||
291 | if (AllDateBookEvents) delete AllDateBookEvents; | 122 | QValueList<TodayPlugin>::Iterator tit; |
292 | AllDateBookEvents = new QWidget( ); | 123 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
293 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 124 | (*tit).library->unload(); |
294 | 125 | delete (*tit).library; | |
295 | if (db) { | ||
296 | delete db; | ||
297 | } | 126 | } |
298 | db = new DateBookDB; | ||
299 | |||
300 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | ||
301 | 127 | ||
302 | qBubbleSort(list); | 128 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
303 | // printf("Get dates\n"); | 129 | QDir dir( path, "lib*.so" ); |
304 | 130 | ||
305 | Config config( "qpe" ); | 131 | QStringList list = dir.entryList(); |
306 | // if 24 h format | 132 | QStringList::Iterator it; |
307 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
308 | 133 | ||
309 | int count=0; | 134 | uint count = 0; |
135 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
136 | TodayPluginInterface *iface = 0; | ||
137 | QLibrary *lib = new QLibrary( path + "/" + *it ); | ||
310 | 138 | ||
311 | if ( list.count() > 0 ) { | 139 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
140 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | ||
141 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | ||
142 | qDebug( QString(*it).latin1() ); | ||
143 | TodayPlugin plugin; | ||
144 | plugin.library = lib; | ||
145 | plugin.iface = iface; | ||
146 | plugin.name = QString(*it).latin1(); | ||
312 | 147 | ||
313 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 148 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
314 | it!=list.end(); ++it ) { | 149 | plugin.active = true; |
315 | 150 | } else { | |
316 | 151 | plugin.active = false; | |
317 | if ( count <= MAX_LINES_MEET ) { | 152 | } |
318 | 153 | plugin.guiPart = plugin.iface->guiPart(); | |
319 | QTime time = QTime::currentTime(); | 154 | pluginList.append( plugin ); |
320 | |||
321 | if (!ONLY_LATER) { | ||
322 | count++; | ||
323 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | ||
324 | layoutDates->addWidget(l); | ||
325 | connect (l, SIGNAL(editEvent(const Event &)), | ||
326 | this, SLOT(editEvent(const Event &))); | ||
327 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | ||
328 | count++; | 155 | count++; |
329 | 156 | } else { | |
330 | // show only later appointments | 157 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
331 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 158 | delete lib; |
332 | layoutDates->addWidget(l); | ||
333 | connect (l, SIGNAL(editEvent(const Event &)), | ||
334 | this, SLOT(editEvent(const Event &))); | ||
335 | } | 159 | } |
@@ -337,30 +161,71 @@ void Today::getDates() { | |||
337 | } | 161 | } |
338 | if (ONLY_LATER && count==0) { | 162 | |
339 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); | 163 | |
340 | noMoreEvents->setText(tr("No more appointments today")); | 164 | /** |
341 | layoutDates->addWidget(noMoreEvents); | 165 | * Repaint method. Reread all fields. |
166 | */ | ||
167 | void Today::draw() { | ||
168 | |||
169 | if ( pluginLayout ) { | ||
170 | delete pluginLayout; | ||
171 | } | ||
172 | pluginLayout = new QVBoxLayout( layout ); | ||
173 | |||
174 | if ( pluginList.count() == 0 ) { | ||
175 | QLabel *noPlugins = new QLabel( this ); | ||
176 | noPlugins->setText( tr( "No plugins found" ) ); | ||
177 | layout->addWidget( noPlugins ); | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | uint count = 0; | ||
182 | TodayPlugin plugin; | ||
183 | for ( uint i = 0; i < pluginList.count(); i++ ) { | ||
184 | plugin = pluginList[i]; | ||
185 | |||
186 | if ( plugin.active ) { | ||
187 | QHBoxLayout* plugLayout = new QHBoxLayout( this ); | ||
188 | QPixmap plugPix; | ||
189 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); | ||
190 | OClickableLabel* plugIcon = new OClickableLabel( this ); | ||
191 | plugIcon->setPixmap( plugPix ); | ||
192 | QScrollView* sv = new QScrollView( this ); | ||
193 | QWidget* plugWidget = plugin.guiPart->widget( sv->viewport() ); | ||
194 | // plugWidget->reparent( sv->viewport(), QPoint( 0, 0 ) ); | ||
195 | sv->setMinimumHeight( plugin.guiPart->minHeight() ); | ||
196 | //sv->setMaximumHeight( plugin.guiPart->maxHeight() ); | ||
197 | |||
198 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
199 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
200 | sv->setFrameShape( QFrame::NoFrame ); | ||
201 | sv->addChild( plugWidget ); | ||
202 | |||
203 | plugLayout->addWidget( plugIcon, 0, AlignTop ); | ||
204 | plugLayout->addWidget( sv, 0, AlignTop ); | ||
205 | plugLayout->setStretchFactor( plugIcon, 1 ); | ||
206 | plugLayout->setStretchFactor( sv, 9 ); | ||
207 | pluginLayout->addLayout( plugLayout ); | ||
208 | count++; | ||
342 | } | 209 | } |
343 | } else { | ||
344 | QLabel* noEvents = new QLabel(AllDateBookEvents); | ||
345 | noEvents->setText(tr("No appointments today")); | ||
346 | layoutDates->addWidget(noEvents); | ||
347 | } | 210 | } |
348 | 211 | ||
349 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 212 | if ( count == 0 ) { |
350 | sv1->addChild(AllDateBookEvents); | 213 | QLabel *noPluginsActive = new QLabel( this ); |
351 | AllDateBookEvents->show(); | 214 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
215 | layout->addWidget( noPluginsActive ); | ||
352 | } | 216 | } |
353 | 217 | ||
218 | layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | ||
354 | 219 | ||
355 | void Today::getMail() { | ||
356 | Config cfg("opiemail"); | ||
357 | cfg.setGroup("today"); | ||
358 | 220 | ||
359 | // how many lines should be showed in the task section | 221 | // how often refresh - later have qcop update calls in *db |
360 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 222 | // QTimer::singleShot( 20*1000, this, SLOT( draw() ) ); |
361 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 223 | } |
362 | 224 | ||
363 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | ||
364 | 225 | ||
365 | MailField->setText(output); | 226 | void Today::refresh() { |
227 | loadPlugins(); | ||
228 | draw(); | ||
229 | qDebug( "redraw" ); | ||
230 | // QTimer::singleShot( 30*1000, this, SLOT( refresh() ) ); | ||
366 | } | 231 | } |
@@ -368,61 +233,43 @@ void Today::getMail() { | |||
368 | 233 | ||
369 | /* | 234 | /** |
370 | * Get the todos | 235 | * The method for the configuration dialog. |
371 | */ | 236 | */ |
372 | void Today::getTodo() { | 237 | void Today::startConfig() { |
373 | 238 | conf = new TodayConfig ( this, "", true ); | |
374 | QString output; | ||
375 | QString tmpout; | ||
376 | int count = 0; | ||
377 | int ammount = 0; | ||
378 | |||
379 | // get overdue todos first | ||
380 | QValueList<ToDoEvent> overDueList = todo->overDue(); | ||
381 | qBubbleSort(overDueList); | ||
382 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | ||
383 | it!=overDueList.end(); ++it ) { | ||
384 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | ||
385 | QString desc = (*it).summary(); | ||
386 | if( desc.isEmpty() ) { | ||
387 | desc = (*it).description(); | ||
388 | } | ||
389 | tmpout += "<font color=#e00000><b>-" + desc.mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | ||
390 | 239 | ||
391 | ammount++; | 240 | uint count = 0; |
392 | } | 241 | TodayPlugin plugin; |
393 | } | ||
394 | 242 | ||
395 | // get total number of still open todos | 243 | QList<ConfigWidget> configWidgetList; |
396 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); | 244 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
397 | qBubbleSort(openTodo); | 245 | plugin = pluginList[i]; |
398 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); | 246 | |
399 | it!=openTodo.end(); ++it ) { | 247 | // load the config widgets in the tabs |
400 | if (!(*it).isCompleted()){ | 248 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
401 | count +=1; | 249 | ConfigWidget* widget = plugin.guiPart->configWidget( this ); |
402 | // not the overdues, we allready got them, and not if we are | 250 | widget->reparent( conf , QPoint( 0,0 ) ); |
403 | // over the maxlines | 251 | configWidgetList.append( widget ); |
404 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 252 | conf->TabWidget3->insertTab( widget, plugin.guiPart->appName() ); |
405 | QString desc = (*it).summary(); | ||
406 | if( desc.isEmpty() ) { | ||
407 | desc = (*it).description(); | ||
408 | } | ||
409 | tmpout += "<b>-</b>" + desc.mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
410 | ammount++; | ||
411 | } | ||
412 | } | 253 | } |
254 | // set the order/activate tab | ||
255 | conf->pluginManagement( plugin.name, plugin.guiPart->pluginName(), | ||
256 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | ||
257 | count++; | ||
413 | } | 258 | } |
414 | 259 | ||
260 | conf->showMaximized(); | ||
415 | 261 | ||
416 | if (count > 0) { | 262 | if ( conf->exec() == QDialog::Accepted ) { |
417 | if( count == 1 ) { | 263 | ConfigWidget *confWidget; |
418 | output = tr("There is <b> 1</b> active task: <br>" ); | 264 | for ( confWidget=configWidgetList.first(); confWidget != 0; |
419 | } else { | 265 | confWidget = configWidgetList.next() ) { |
420 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 266 | confWidget->writeConfig(); |
421 | } | ||
422 | output += tmpout; | ||
423 | } else { | ||
424 | output = tr("No active tasks"); | ||
425 | } | 267 | } |
268 | conf->writeConfig(); | ||
426 | 269 | ||
427 | TodoField->setText(tr(output)); | 270 | init(); |
271 | loadPlugins(); | ||
272 | draw(); | ||
273 | } | ||
274 | delete conf; | ||
428 | } | 275 | } |
@@ -435,5 +282,4 @@ void Today::startAddressbook() { | |||
435 | 282 | ||
436 | extern QPEApplication *todayApp; | ||
437 | 283 | ||
438 | /* | 284 | /** |
439 | * launch addressbook (personal card) | 285 | * launch addressbook (personal card) |
@@ -441,34 +287,7 @@ extern QPEApplication *todayApp; | |||
441 | void Today::editCard() { | 287 | void Today::editCard() { |
442 | |||
443 | startAddressbook(); | 288 | startAddressbook(); |
444 | 289 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { | |
445 | while( !QCopChannel::isRegistered("QPE/Addressbook")) todayApp->processEvents(); | 290 | qApp->processEvents(); |
446 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); | ||
447 | } | ||
448 | |||
449 | /* | ||
450 | * launches datebook | ||
451 | */ | ||
452 | void Today::startDatebook() { | ||
453 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
454 | e << QString("datebook"); | ||
455 | } | 291 | } |
456 | 292 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); | |
457 | /* | ||
458 | * starts the edit dialog as known from datebook | ||
459 | */ | ||
460 | void Today::editEvent(const Event &e) { | ||
461 | startDatebook(); | ||
462 | |||
463 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | ||
464 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | ||
465 | env << e.uid(); | ||
466 | } | ||
467 | |||
468 | /* | ||
469 | * launches todolist | ||
470 | */ | ||
471 | void Today::startTodo() { | ||
472 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
473 | e << QString("todolist"); | ||
474 | } | 293 | } |
@@ -476,13 +295,9 @@ void Today::startTodo() { | |||
476 | /* | 295 | /* |
477 | * launch opiemail | 296 | * launches an App |
478 | */ | 297 | */ |
479 | void Today::startMail() { | 298 | void Today::launchApp( QString appName ) { |
480 | QCopEnvelope e("QPE/System", "execute(QString)"); | 299 | QCopEnvelope e("QPE/System", "execute(QString)"); |
481 | e << QString("opiemail"); | 300 | e << QString( appName ); |
482 | //Right now start both, maybe decide which to rum via config file .. | ||
483 | QCopEnvelope f("QPE/System", "execute(QString)"); | ||
484 | f << QString("qtmail"); | ||
485 | } | 301 | } |
486 | 302 | ||
487 | |||
488 | Today::~Today() { | 303 | Today::~Today() { |
@@ -490,148 +305 @@ Today::~Today() { | |||
490 | |||
491 | /* | ||
492 | * Gets the events for the current day, if it should get all dates | ||
493 | */ | ||
494 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | ||
495 | QWidget* parent, | ||
496 | int SHOW_LOCATION, | ||
497 | int SHOW_NOTES, | ||
498 | const char* name, | ||
499 | WFlags fl) : | ||
500 | OClickableLabel(parent,name,fl), event(ev) { | ||
501 | |||
502 | QString msg; | ||
503 | //QTime time = QTime::currentTime(); | ||
504 | |||
505 | Config config( "qpe" ); | ||
506 | config.setGroup( "Time" ); | ||
507 | // if 24 h format | ||
508 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
509 | |||
510 | |||
511 | if (!ONLY_LATER) { | ||
512 | msg += "<B>" + (ev).description() + "</B>"; | ||
513 | if ( (ev).event().hasAlarm() ) { | ||
514 | msg += " <b>[with alarm]</b>"; | ||
515 | } | ||
516 | // include location or not | ||
517 | if (SHOW_LOCATION == 1) { | ||
518 | msg += "<BR><i>" + (ev).location() + "</i>"; | ||
519 | } | ||
520 | |||
521 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | ||
522 | msg += "<br>All day"; | ||
523 | } else { | ||
524 | // start time of event | ||
525 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | ||
526 | // end time of event | ||
527 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | ||
528 | } | ||
529 | |||
530 | // include possible note or not | ||
531 | if (SHOW_NOTES == 1) { | ||
532 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | ||
533 | } | ||
534 | } | ||
535 | setText(msg); | ||
536 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | ||
537 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
538 | } | ||
539 | |||
540 | |||
541 | QString DateBookEvent::ampmTime(QTime tm) { | ||
542 | |||
543 | QString s; | ||
544 | if( ampm ) { | ||
545 | int hour = tm.hour(); | ||
546 | if (hour == 0) | ||
547 | hour = 12; | ||
548 | if (hour > 12) | ||
549 | hour -= 12; | ||
550 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | ||
551 | (tm.hour() >= 12) ? "PM" : "AM" ); | ||
552 | return s; | ||
553 | } else { | ||
554 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | ||
555 | return s; | ||
556 | } | ||
557 | |||
558 | } | ||
559 | |||
560 | |||
561 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | ||
562 | QWidget* parent, | ||
563 | int SHOW_LOCATION, | ||
564 | int SHOW_NOTES, | ||
565 | const char* name, | ||
566 | WFlags fl) : | ||
567 | OClickableLabel(parent,name,fl), event(ev) { | ||
568 | |||
569 | QString msg; | ||
570 | QTime time = QTime::currentTime(); | ||
571 | |||
572 | Config config( "qpe" ); | ||
573 | config.setGroup( "Time" ); | ||
574 | // if 24 h format | ||
575 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
576 | |||
577 | |||
578 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | ||
579 | // show only later appointments | ||
580 | msg += "<B>" + (ev).description() + "</B>"; | ||
581 | if ( (ev).event().hasAlarm() ) { | ||
582 | msg += " <b>[with alarm]</b>"; | ||
583 | } | ||
584 | // include location or not | ||
585 | if (SHOW_LOCATION == 1) { | ||
586 | msg += "<BR><i>" + (ev).location() + "</i>"; | ||
587 | } | ||
588 | |||
589 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | ||
590 | msg += "<br>All day"; | ||
591 | } else { | ||
592 | // start time of event | ||
593 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | ||
594 | // end time of event | ||
595 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | ||
596 | } | ||
597 | // include possible note or not | ||
598 | if (SHOW_NOTES == 1) { | ||
599 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | ||
600 | } | ||
601 | } | ||
602 | |||
603 | setText(msg); | ||
604 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | ||
605 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
606 | } | ||
607 | |||
608 | |||
609 | QString DateBookEventLater::ampmTime(QTime tm) { | ||
610 | |||
611 | QString s; | ||
612 | if( ampm ) { | ||
613 | int hour = tm.hour(); | ||
614 | if (hour == 0) | ||
615 | hour = 12; | ||
616 | if (hour > 12) | ||
617 | hour -= 12; | ||
618 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | ||
619 | (tm.hour() >= 12) ? "PM" : "AM" ); | ||
620 | return s; | ||
621 | } else { | ||
622 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | ||
623 | return s; | ||
624 | } | ||
625 | |||
626 | } | ||
627 | |||
628 | |||
629 | void DateBookEvent::editMe() { | ||
630 | emit editEvent(event.event()); | ||
631 | } | ||
632 | |||
633 | void DateBookEventLater::editMe() { | ||
634 | emit editEvent(event.event()); | ||
635 | } | ||
636 | |||
637 | |||