summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp167
-rw-r--r--korganizer/calendarview.h20
-rw-r--r--korganizer/kotodoview.cpp2
-rw-r--r--korganizer/mainwindow.cpp4
4 files changed, 191 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 503ef12..36db9c4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -138,6 +138,124 @@ extern int globalFlagBlockAgenda;
extern int globalFlagBlockStartup;
+MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
+
+{
+ mAlarms = alarms;
+ setBackgroundColor( QColor( 86, 153, 205 ) );
+ QString mText = "<table width=\"100%\">\n";
+ //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
+#ifdef DESKTOP_VERSION
+ mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
+#else
+ mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
+#endif
+ // mText += "<img src=\"";
+ // mText += ipath;
+ // mText += "\">";
+ //mEventDate = QDate::currentDate();
+#ifdef DESKTOP_VERSION
+ mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h1>";
+#else
+ mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
+#endif
+ mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
+
+ Incidence * inc = getNextInc( start );
+ int time = 0;
+ mText += "<table>";
+ while ( inc ) {
+ QDateTime dt ;
+ QString tempText = "<a ";
+ bool ok;
+ dt = inc->getNextOccurence( start, &ok );
+ if ( !ok ) continue;
+ if ( inc->type() == "Event" ) {
+ tempText += "href=\"event:";
+ } else if ( inc->type() == "Todo" ) {
+ tempText += "href=\"todo:";
+ }
+ tempText += inc->uid() + "\">";
+ if ( inc->type() == "Todo" )
+ tempText += i18n("Todo: ");
+ if ( inc->summary().length() > 0 )
+ tempText += inc->summary();
+ else
+ tempText += i18n("-no summary-");
+ QString timestr;
+ if (!inc->doesFloat())
+ timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
+ else
+ timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
+ if ( dt.date() == QDate::currentDate() && time == 0 ) {
+ time = 1;
+ mText +="</table>";
+ mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
+ mText += "<table>";
+
+ }
+ if ( dt.date() > QDate::currentDate() && time != 2 ) {
+ time = 2;
+ mText +="</table>";
+ mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
+ mText += "<table>";
+ }
+ mText +="<tr><td><b>";
+ mText += timestr;
+ mText += "</b></td><td>";
+ mText += tempText;
+ mText += "</td></tr>\n";
+ inc = getNextInc( start );
+ }
+ mText +="</table>";
+ setText( mText );
+}
+
+Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
+{
+ QDateTime dt ;
+ Incidence * retInc;
+ Incidence * inc = mAlarms.first();
+ if ( inc == 0 )
+ return 0;
+ bool ok;
+ dt = inc->getNextOccurence( start, &ok );
+ if ( ! ok ) return 0;
+ QDateTime dtn ;
+ retInc = inc;
+ inc = mAlarms.next();
+ while ( inc ) {
+ dtn = inc->getNextOccurence( start, &ok );
+ if ( ! ok ) return 0;
+ if ( dtn < dt ) {
+ dt = dtn;
+ retInc = inc;
+ }
+ inc = mAlarms.next();
+ }
+ mAlarms.remove( retInc );
+ return retInc;
+
+}
+void MissedAlarmTextBrowser::setSource(const QString & n)
+{
+ if (n.startsWith("event:")) {
+#ifdef DESKTOP_VERSION
+ emit showIncidence(n.mid(8));
+#else
+ emit showIncidence(n.mid(6));
+#endif
+ return;
+ } else if (n.startsWith("todo:")) {
+#ifdef DESKTOP_VERSION
+ emit showIncidence(n.mid(7));
+#else
+ emit showIncidence(n.mid(5));
+#endif
+ return;
+ }
+}
+
class KOBeamPrefs : public QDialog
{
@@ -506,7 +624,45 @@ CalendarView::~CalendarView()
delete mEventViewerDialog;
//kdDebug() << "~CalendarView() done" << endl;
}
+void CalendarView::checkAlarms()
+{
+ KConfig *config = KOGlobals::config();
+ config->setGroup( "AppRun" );
+ QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
+ int secs = config->readNumEntry( "LatestProgramStop" ) - 30;
+ //secs -= ( 3600 * 24*3 ); // debug only
+ QDateTime latest = dt.addSecs ( secs );
+ qDebug("KO: Last termination on %s ", latest.toString().latin1());
+ QPtrList<Incidence> el = mCalendar->rawIncidences();
+ QPtrList<Incidence> al;
+ Incidence* inL = el.first();
+ while ( inL ) {
+ bool ok = false;
+ int offset = 0;
+ QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
+ if ( ok ) {
+ //qDebug("OK %s",next.toString().latin1());
+ if ( next < QDateTime::currentDateTime() ) {
+ al.append( inL );
+ qDebug("found missed alarm: %s ", inL->summary().latin1() );
+ }
+ }
+ inL = el.next();
+ }
+ if ( al.count() ) {
+ QDialog dia ( this, "huhu", true );
+ dia.setCaption( i18n("KO/Pi: Missing alarm notification!") );
+ QVBoxLayout* lay = new QVBoxLayout( &dia );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+ MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( &dia, al, latest );
+ connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
+ lay->addWidget( matb );
+ dia.resize(240,240);
+ dia.exec();
+ }
+}
void CalendarView::showDay( QDate d )
{
dateNavigator()->blockSignals( true );
@@ -1969,7 +2125,9 @@ void CalendarView::writeSettings()
KOPrefs::instance()->writeConfig();
writeFilterSettings(config);
-
+ config->setGroup( "AppRun" );
+ QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
+ config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) );
config->setGroup( "Views" );
config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
@@ -3921,7 +4079,12 @@ void CalendarView::deleteIncidence()
deleteIncidence(incidence);
}
}
-
+void CalendarView::showIncidence(QString uid)
+{
+ Incidence *inc = mCalendar->incidence( uid );
+ if ( inc )
+ showIncidence( inc );
+}
void CalendarView::showIncidence(Incidence *incidence)
{
mViewerCallerIsSearchDialog = false;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 05a34b4..1eca905 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -80,6 +80,24 @@ using namespace KCal;
@short main calendar view widget
@author Cornelius Schumacher
*/
+
+#include <qtextbrowser.h>
+#include <qtextcodec.h>
+
+class MissedAlarmTextBrowser : public QTextBrowser {
+ Q_OBJECT
+ public:
+ MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
+ void setSource(const QString & n);
+
+ private:
+ Incidence * getNextInc(QDateTime start );
+ QPtrList<Incidence> mAlarms;
+ signals:
+ void showIncidence( QString uid);
+};
+
+
class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
{
Q_OBJECT
@@ -176,6 +194,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public slots:
+ void checkAlarms();
void slotprintSelInc();
void showNextAlarms();
void showOpenError();
@@ -240,6 +259,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
/** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
void showIncidence(Incidence *);
+ void showIncidence(QString uid);
/** Create an editor for the supplied incidence. It calls the correct editXXX method*/
void editIncidence(Incidence *);
/** Delete the supplied incidence. It calls the correct deleteXXX method*/
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8fe9999..5aaf360 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -477,8 +477,10 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
SLOT (cloneTodo()));
mItemPopupMenu->insertItem( i18n("Move..."), this,
SLOT (moveTodo()));
+#ifndef DESKTOP_VERSION
mItemPopupMenu->insertItem( i18n("Beam..."), this,
SLOT (beamTodo()));
+#endif
mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
SLOT (cancelTodo()));
mItemPopupMenu->insertSeparator();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 94d7293..1320231 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -372,6 +372,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
SLOT( updateWeekNum( const KCal::DateList & ) ) );
mBRdisabled = false;
//toggleBeamReceive();
+
+ QTimer::singleShot( 1000, mView, SLOT ( checkAlarms() ));
}
MainWindow::~MainWindow()
{
@@ -797,6 +799,8 @@ void MainWindow::initActions()
mToggleFilter, SLOT( setEnabled ( bool ) ) );
connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
mToggleAllday, SLOT( setEnabled ( bool ) ) );
+ // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
+ // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
viewMenu->insertSeparator();
icon = loadPixmap( pathString + "picker" );