summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-03 16:49:55 (UTC)
committer zautrix <zautrix>2004-07-03 16:49:55 (UTC)
commit1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (patch) (unidiff)
treeae690b33cbe50291a610842e24de33f9d766f2f2
parente3b89230f065c48c84b48c88edb6eb088374c487 (diff)
downloadkdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.zip
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.gz
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.bz2
Alarm Bugfix. Added connection to KM. Cleaned up main.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp31
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koeventviewer.cpp34
-rw-r--r--korganizer/koeventviewer.h1
-rw-r--r--korganizer/main.cpp26
5 files changed, 67 insertions, 29 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bf98ad4..c3c3d47 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -455,6 +455,8 @@ void CalendarView::init()
455 455
456 mSuspendTimer = new QTimer( this ); 456 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 457 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
@@ -491,9 +493,14 @@ void CalendarView::suspendAlarm()
491void CalendarView::startAlarm( QString mess , QString filename) 493void CalendarView::startAlarm( QString mess , QString filename)
492{ 494{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 497
495} 498}
496 499
500void CalendarView::checkNextTimerAlarm()
501{
502 mCalendar->checkAlarmForIncidence( 0, true );
503}
497 504
498void CalendarView::computeAlarm( QString msg ) 505void CalendarView::computeAlarm( QString msg )
499{ 506{
@@ -604,12 +611,30 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
604#endif 611#endif
605 return; 612 return;
606 } 613 }
614 int maxSec;
615 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour
607 mAlarmNotification = noti; 617 mAlarmNotification = noti;
608 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 618 int sec = QDateTime::currentDateTime().secsTo( qdt );
609 //qDebug("Alarm timer started with secs: %d ", ms/1000); 619 if ( sec > maxSec ) {
610 mAlarmTimer->start( ms , true ); 620 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return;
623 } else {
624 mRecheckAlarmTimer->stop();
625 }
626 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true );
611 628
612} 629}
630// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm()
633{
634 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true );
637}
613void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
614{ 639{
615 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index e7aa351..fda02f7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -171,7 +171,8 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
171 171
172 172
173 public slots: 173 public slots:
174 174 void recheckTimerAlarm();
175 void checkNextTimerAlarm();
175 void addAlarm(const QDateTime &qdt, const QString &noti ); 176 void addAlarm(const QDateTime &qdt, const QString &noti );
176 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
177 void removeAlarm(const QDateTime &qdt, const QString &noti ); 178 void removeAlarm(const QDateTime &qdt, const QString &noti );
@@ -474,6 +475,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
474 QString mSuspendAlarmNotification; 475 QString mSuspendAlarmNotification;
475 QTimer* mSuspendTimer; 476 QTimer* mSuspendTimer;
476 QTimer* mAlarmTimer; 477 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer;
477 void computeAlarm( QString ); 479 void computeAlarm( QString );
478 void startAlarm( QString, QString ); 480 void startAlarm( QString, QString );
479 void setSyncEventsReadOnly(); 481 void setSyncEventsReadOnly();
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index bac66d3..1f69700 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -50,6 +50,10 @@
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53#ifndef DESKTOP_VERSION
54#include <qtopia/qcopenvelope_qws.h>
55#endif
56
53KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 57KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
54 : QTextBrowser(parent,name) 58 : QTextBrowser(parent,name)
55{ 59{
@@ -63,6 +67,8 @@ KOEventViewer::~KOEventViewer()
63 67
64void KOEventViewer::setSource(const QString& n) 68void KOEventViewer::setSource(const QString& n)
65{ 69{
70
71 if ( n.left(3) == "uid" ) {
66 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 72 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
67 KABC::AddressBook::Iterator it; 73 KABC::AddressBook::Iterator it;
68 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 74 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
@@ -91,6 +97,16 @@ void KOEventViewer::setSource(const QString& n)
91 break; 97 break;
92 } 98 }
93 } 99 }
100 return;
101 }
102 if ( n.left(6) == "mailto" ) {
103 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
104#ifndef DESKTOP_VERSION
105 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" );
106 e << n.mid(7);
107#endif
108
109 }
94 110
95 111
96#ifndef KORG_NODCOP 112#ifndef KORG_NODCOP
@@ -170,6 +186,7 @@ void KOEventViewer::setColorMode( int m )
170} 186}
171void KOEventViewer::appendEvent(Event *event, int mode ) 187void KOEventViewer::appendEvent(Event *event, int mode )
172{ 188{
189 mMailSubject = "";
173 mCurrentIncidence = event; 190 mCurrentIncidence = event;
174 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 191 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
175 topLevelWidget()->setCaption(i18n("Event Viewer")); 192 topLevelWidget()->setCaption(i18n("Event Viewer"));
@@ -193,15 +210,18 @@ void KOEventViewer::appendEvent(Event *event, int mode )
193 if ( mColorMode ) 210 if ( mColorMode )
194 mText += "</font>"; 211 mText += "</font>";
195 } 212 }
213 mMailSubject += i18n( "Meeting " )+ event->summary();
196 if (event->cancelled ()) { 214 if (event->cancelled ()) {
197 mText +="<font color=\"#B00000\">"; 215 mText +="<font color=\"#B00000\">";
198 addTag("i",i18n("This event has been cancelled!")); 216 addTag("i",i18n("This event has been cancelled!"));
199 mText.append("<br>"); 217 mText.append("<br>");
200 mText += "</font>"; 218 mText += "</font>";
219 mMailSubject += i18n("(cancelled)");
201 } 220 }
202 if (!event->location().isEmpty()) { 221 if (!event->location().isEmpty()) {
203 addTag("b",i18n("Location: ")); 222 addTag("b",i18n("Location: "));
204 mText.append(event->location()+"<br>"); 223 mText.append(event->location()+"<br>");
224 mMailSubject += i18n(" at ") + event->location();
205 } 225 }
206 if (event->doesFloat()) { 226 if (event->doesFloat()) {
207 if (event->isMultiDay()) { 227 if (event->isMultiDay()) {
@@ -238,10 +258,16 @@ void KOEventViewer::appendEvent(Event *event, int mode )
238 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 258 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
239 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 259 addTag("p",i18n("<b>Next recurrence is on:</b>") );
240 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 260 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
261 QDateTime nextdt = QDateTime( next, event->dtStart().time());
262 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
263
241 } else { 264 } else {
242 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 265 addTag("p",i18n("<b>Last recurrence was on:</b>") );
243 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 266 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
244 } 267 }
268 } else {
269 mMailSubject += i18n(" - " )+event->dtStartStr( true );
270
245 } 271 }
246 272
247 273
@@ -274,6 +300,7 @@ void KOEventViewer::appendEvent(Event *event, int mode )
274 300
275void KOEventViewer::appendTodo(Todo *event, int mode ) 301void KOEventViewer::appendTodo(Todo *event, int mode )
276{ 302{
303 mMailSubject = "";
277 mCurrentIncidence = event; 304 mCurrentIncidence = event;
278 topLevelWidget()->setCaption(i18n("Todo Viewer")); 305 topLevelWidget()->setCaption(i18n("Todo Viewer"));
279 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 306 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
@@ -295,19 +322,23 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
295 if ( mColorMode ) 322 if ( mColorMode )
296 mText += "</font>"; 323 mText += "</font>";
297 } 324 }
325 mMailSubject += i18n( "Todo " )+ event->summary();
298 if (event->cancelled ()) { 326 if (event->cancelled ()) {
299 mText +="<font color=\"#B00000\">"; 327 mText +="<font color=\"#B00000\">";
300 addTag("i",i18n("This todo has been cancelled!")); 328 addTag("i",i18n("This todo has been cancelled!"));
301 mText.append("<br>"); 329 mText.append("<br>");
302 mText += "</font>"; 330 mText += "</font>";
331 mMailSubject += i18n("(cancelled)");
303 } 332 }
304 333
305 if (!event->location().isEmpty()) { 334 if (!event->location().isEmpty()) {
306 addTag("b",i18n("Location: ")); 335 addTag("b",i18n("Location: "));
307 mText.append(event->location()+"<br>"); 336 mText.append(event->location()+"<br>");
337 mMailSubject += i18n(" at ") + event->location();
308 } 338 }
309 if (event->hasDueDate()) { 339 if (event->hasDueDate()) {
310 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 340 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
341 mMailSubject += i18n(" - " )+event->dtDueStr( true );
311 } 342 }
312 addTag("b",i18n("Access: ")); 343 addTag("b",i18n("Access: "));
313 mText.append(event->secrecyStr()+"<br>"); 344 mText.append(event->secrecyStr()+"<br>");
@@ -405,9 +436,10 @@ void KOEventViewer::formatAttendees(Incidence *event)
405 mText += "</a>\n"; 436 mText += "</a>\n";
406#endif 437#endif
407 438
439
408 if (!a->email().isEmpty()) { 440 if (!a->email().isEmpty()) {
409 if (iconPath) { 441 if (iconPath) {
410 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 442 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
411 mText += "<IMG src=\"" + iconPath + "\">"; 443 mText += "<IMG src=\"" + iconPath + "\">";
412 mText += "</a>\n"; 444 mText += "</a>\n";
413 } 445 }
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index 74f1135..0cd3f33 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -65,6 +65,7 @@ class KOEventViewer : public QTextBrowser {
65 bool mSyncMode; 65 bool mSyncMode;
66 66
67 QString mText; 67 QString mText;
68 QString mMailSubject;
68 Incidence* mCurrentIncidence; 69 Incidence* mCurrentIncidence;
69 signals: 70 signals:
70 void launchaddressbook(QString uid); 71 void launchaddressbook(QString uid);
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index a357988..69ef294 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -53,37 +53,15 @@ int main( int argc, char **argv )
53 } 53 }
54 if ( ! exitHelp ) { 54 if ( ! exitHelp ) {
55 KGlobal::setAppName( "korganizer" ); 55 KGlobal::setAppName( "korganizer" );
56
57
58 QString fileName ; 56 QString fileName ;
59#ifndef DESKTOP_VERSION 57#ifndef DESKTOP_VERSION
60 QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName();
61 KStandardDirs::setAppDir( appdir );
62
63 fileName = getenv("QPEDIR"); 58 fileName = getenv("QPEDIR");
64 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 59 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
65#else 60#else
66
67#ifndef _WIN32_
68 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 61 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
69#else 62 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
70 fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\";
71#endif
72
73 KGlobal::iconLoader()->setIconPath(fileName);
74
75 QString appdir = QDir::homeDirPath();
76 //appdir = "C:\\";
77 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
78 appdir += "korganizer";
79 else
80 appdir += "/korganizer";
81 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
82 // qDebug(" %s ",KStandardDirs::appDir().latin1() );
83#endif 63#endif
84 QDir app_dir; 64 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
85 if ( !app_dir.exists(KStandardDirs::appDir()) )
86 app_dir.mkdir (KStandardDirs::appDir());
87 MainWindow m; 65 MainWindow m;
88#ifndef DESKTOP_VERSION 66#ifndef DESKTOP_VERSION
89 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 67 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));