author | zautrix <zautrix> | 2004-07-03 16:49:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 16:49:55 (UTC) |
commit | 1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (patch) (side-by-side diff) | |
tree | ae690b33cbe50291a610842e24de33f9d766f2f2 /korganizer | |
parent | e3b89230f065c48c84b48c88edb6eb088374c487 (diff) | |
download | kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.zip kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.gz kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.bz2 |
Alarm Bugfix. Added connection to KM. Cleaned up main.
-rw-r--r-- | korganizer/calendarview.cpp | 31 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 34 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 1 | ||||
-rw-r--r-- | korganizer/main.cpp | 26 |
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 @@ -454,8 +454,10 @@ void CalendarView::init() mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); + mRecheckAlarmTimer = new QTimer( this ); + connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); @@ -490,11 +492,16 @@ void CalendarView::suspendAlarm() void CalendarView::startAlarm( QString mess , QString filename) { mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); + QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } +void CalendarView::checkNextTimerAlarm() +{ + mCalendar->checkAlarmForIncidence( 0, true ); +} void CalendarView::computeAlarm( QString msg ) { @@ -603,14 +610,32 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); #endif return; } + int maxSec; + //maxSec = 5; //testing only + maxSec = 86400+3600; // one day+1hour mAlarmNotification = noti; - int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; - //qDebug("Alarm timer started with secs: %d ", ms/1000); - mAlarmTimer->start( ms , true ); + int sec = QDateTime::currentDateTime().secsTo( qdt ); + if ( sec > maxSec ) { + mRecheckAlarmTimer->start( maxSec * 1000 ); + // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); + return; + } else { + mRecheckAlarmTimer->stop(); + } + //qDebug("Alarm timer started with secs: %d ", sec); + mAlarmTimer->start( sec *1000 , true ); } +// called by mRecheckAlarmTimer to get next alarm +// we need this, because a QTimer has only a max range of 25 days +void CalendarView::recheckTimerAlarm() +{ + mAlarmTimer->stop(); + mRecheckAlarmTimer->stop(); + mCalendar->checkAlarmForIncidence( 0, true ); +} void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index e7aa351..fda02f7 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -170,9 +170,10 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void updateSearchDialog(); public slots: - + void recheckTimerAlarm(); + void checkNextTimerAlarm(); void addAlarm(const QDateTime &qdt, const QString ¬i ); void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); void removeAlarm(const QDateTime &qdt, const QString ¬i ); @@ -473,8 +474,9 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; + QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index bac66d3..1f69700 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -49,8 +49,12 @@ #ifndef KORG_NOKABC #include <kabc/stdaddressbook.h> #define size count #endif +#ifndef DESKTOP_VERSION +#include <qtopia/qcopenvelope_qws.h> +#endif + KOEventViewer::KOEventViewer(QWidget *parent,const char *name) : QTextBrowser(parent,name) { mSyncMode = false; @@ -62,8 +66,10 @@ KOEventViewer::~KOEventViewer() } void KOEventViewer::setSource(const QString& n) { + + if ( n.left(3) == "uid" ) { KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { // LR I do not understand, why the uid string is different on zaurus and desktop @@ -90,8 +96,18 @@ void KOEventViewer::setSource(const QString& n) dia.exec(); break; } } + return; + } + if ( n.left(6) == "mailto" ) { + // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); +#ifndef DESKTOP_VERSION + QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" ); + e << n.mid(7); +#endif + + } #ifndef KORG_NODCOP kdDebug() << "KOEventViewer::setSource(): " << n << endl; @@ -169,8 +185,9 @@ void KOEventViewer::setColorMode( int m ) mColorMode = m; } void KOEventViewer::appendEvent(Event *event, int mode ) { + mMailSubject = ""; mCurrentIncidence = event; bool shortDate = KOPrefs::instance()->mShortDateInViewer; topLevelWidget()->setCaption(i18n("Event Viewer")); if ( mode == 0 ) { @@ -192,17 +209,20 @@ void KOEventViewer::appendEvent(Event *event, int mode ) addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } + mMailSubject += i18n( "Meeting " )+ event->summary(); if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This event has been cancelled!")); mText.append("<br>"); mText += "</font>"; + mMailSubject += i18n("(cancelled)"); } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); + mMailSubject += i18n(" at ") + event->location(); } if (event->doesFloat()) { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") @@ -237,12 +257,18 @@ void KOEventViewer::appendEvent(Event *event, int mode ) if ( !last ) { next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); addTag("p",i18n("<b>Next recurrence is on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next, shortDate )); + QDateTime nextdt = QDateTime( next, event->dtStart().time()); + mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); + } else { addTag("p",i18n("<b>Last recurrence was on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next, shortDate )); } + } else { + mMailSubject += i18n(" - " )+event->dtStartStr( true ); + } if (event->isAlarmEnabled()) { @@ -273,8 +299,9 @@ void KOEventViewer::appendEvent(Event *event, int mode ) } void KOEventViewer::appendTodo(Todo *event, int mode ) { + mMailSubject = ""; mCurrentIncidence = event; topLevelWidget()->setCaption(i18n("Todo Viewer")); bool shortDate = KOPrefs::instance()->mShortDateInViewer; if (mode == 0 ) @@ -294,21 +321,25 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } + mMailSubject += i18n( "Todo " )+ event->summary(); if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This todo has been cancelled!")); mText.append("<br>"); mText += "</font>"; + mMailSubject += i18n("(cancelled)"); } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); + mMailSubject += i18n(" at ") + event->location(); } if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); + mMailSubject += i18n(" - " )+event->dtDueStr( true ); } addTag("b",i18n("Access: ")); mText.append(event->secrecyStr()+"<br>"); if (!event->description().isEmpty()) { @@ -404,11 +435,12 @@ void KOEventViewer::formatAttendees(Incidence *event) else mText += a->email(); mText += "</a>\n"; #endif + if (!a->email().isEmpty()) { if (iconPath) { - mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; + mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; mText += "<IMG src=\"" + iconPath + "\">"; mText += "</a>\n"; } } diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index 74f1135..0cd3f33 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h @@ -64,8 +64,9 @@ class KOEventViewer : public QTextBrowser { QTextBrowser *mEventTextView; bool mSyncMode; QString mText; + QString mMailSubject; Incidence* mCurrentIncidence; signals: 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 @@ -52,39 +52,17 @@ int main( int argc, char **argv ) } } if ( ! exitHelp ) { KGlobal::setAppName( "korganizer" ); - - QString fileName ; #ifndef DESKTOP_VERSION - QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName(); - KStandardDirs::setAppDir( appdir ); - fileName = getenv("QPEDIR"); KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); #else - -#ifndef _WIN32_ fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; -#else - fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\"; -#endif - - KGlobal::iconLoader()->setIconPath(fileName); - - QString appdir = QDir::homeDirPath(); - //appdir = "C:\\"; - if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) - appdir += "korganizer"; - else - appdir += "/korganizer"; - KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); - // qDebug(" %s ",KStandardDirs::appDir().latin1() ); + KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); #endif - QDir app_dir; - if ( !app_dir.exists(KStandardDirs::appDir()) ) - app_dir.mkdir (KStandardDirs::appDir()); + KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); MainWindow m; #ifndef DESKTOP_VERSION QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); a.showMainWidget(&m ); |