summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index c01be9b..5132f98 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -53,204 +53,204 @@
#include <kglobal.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <knotifyclient.h>
#include <kconfig.h>
#include <libkdepim/ksyncprefsdialog.h>
#include <krun.h>
#include <kdirwatch.h>
#include <libkdepim/kdatepicker.h>
#include <libkdepim/ksyncprofile.h>
#include <libkdepim/kpimglobalprefs.h>
#include <libkcal/vcaldrag.h>
#include <libkcal/icaldrag.h>
#include <libkcal/icalformat.h>
#include <libkcal/vcalformat.h>
#include <libkcal/scheduler.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/journal.h>
#include <libkcal/calfilter.h>
#include <libkcal/attendee.h>
#include <libkcal/dndfactory.h>
#include <libkcal/freebusy.h>
#include <libkcal/filestorage.h>
#include <libkcal/calendarresources.h>
#include <libkcal/qtopiaformat.h>
#include "../kalarmd/alarmdialog.h"
#ifndef DESKTOP_VERSION
#include <libkcal/sharpformat.h>
#include <externalapphandler.h>
#endif
#include <libkcal/phoneformat.h>
#ifndef KORG_NOMAIL
#include "komailclient.h"
#endif
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include "koeventeditor.h"
#include "kotodoeditor.h"
#include "koprefs.h"
#include "koeventviewerdialog.h"
#include "publishdialog.h"
#include "kofilterview.h"
#include "koglobals.h"
#include "koviewmanager.h"
#include "koagendaview.h"
#include "kodialogmanager.h"
#include "outgoingdialog.h"
#include "incomingdialog.h"
#include "datenavigatorcontainer.h"
#include "statusdialog.h"
#include "kdatenavigator.h"
#include "kotodoview.h"
#include "datenavigator.h"
#include "resourceview.h"
#include "navigatorbar.h"
#include "searchdialog.h"
#include "mainwindow.h"
#include "calendarview.h"
#ifndef DESKTOP_VERSION
#include <qtopia/alarmserver.h>
#endif
#ifndef _WIN32_
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#else
#include <qprocess.h>
#endif
#ifdef DESKTOP_VERSION
#include <kabc/stdaddressbook.h>
#endif
using namespace KOrg;
using namespace KCal;
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>";
+#else
+ mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
#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>";
+#else
+ mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
#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;
}
@@ -557,202 +557,206 @@ void CalendarView::init()
SLOT( updateTodo( Todo *, int ) ) );
connect( this, SIGNAL( todoModified( Todo *, int )), this,
SLOT( changeTodoDisplay( Todo *, int ) ) );
connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
connect(QApplication::clipboard(),SIGNAL(dataChanged()),
SLOT(checkClipboard()));
connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
SLOT( processTodoListSelection( Incidence * ) ) );
connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
// kdDebug() << "CalendarView::CalendarView() done" << endl;
mDateFrame = new QVBox(0,0,WType_Popup);
//mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
mDateFrame->setLineWidth(3);
mDateFrame->hide();
mDateFrame->setCaption( i18n( "Pick a date to display"));
mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
mEventEditor = mDialogManager->getEventEditor();
mTodoEditor = mDialogManager->getTodoEditor();
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 & ) ) );
mAlarmDialog->setServerNotification( false );
mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
#ifndef DESKTOP_VERSION
//US listen for arriving address resultsets
connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
#endif
mDateNavigator->setCalendar( mCalendar );
}
CalendarView::~CalendarView()
{
// kdDebug() << "~CalendarView()" << endl;
//qDebug("CalendarView::~CalendarView() ");
delete mDialogManager;
delete mViewManager;
delete mStorage;
delete mDateFrame ;
delete beamDialog;
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 );
+ QDialog* dia = new QDialog( this, "huhu", false );
+ dia->setCaption( i18n("KO/Pi: Missing alarm notification!") );
+ QVBoxLayout* lay = new QVBoxLayout( dia );
+ lay->setSpacing( 0 );
+ lay->setMargin( 0 );
+ MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
lay->addWidget( matb );
- dia.resize(240,240);
- dia.exec();
+ int si = 220;
+ if ( QApplication::desktop()->width() > 470 )
+ si = 400;
+ dia->resize(si,si/2);
+ dia->setBackgroundColor( QColor( 255, 255, 255 ) );
+ dia->show();
}
}
void CalendarView::showDay( QDate d )
{
dateNavigator()->blockSignals( true );
dateNavigator()->selectDate( d );
dateNavigator()->blockSignals( false );
mViewManager->showDayView();
//dateNavigator()->selectDate( d );
}
void CalendarView::timerAlarm()
{
//qDebug("CalendarView::timerAlarm() ");
computeAlarm(mAlarmNotification );
}
void CalendarView::suspendAlarm()
{
//qDebug(" CalendarView::suspendAlarm() ");
computeAlarm(mSuspendAlarmNotification );
}
void CalendarView::startAlarm( QString mess , QString filename)
{
topLevelWidget()->showNormal();
topLevelWidget()->setActiveWindow();
topLevelWidget()->raise();
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 )
{
QString mess = msg;
QString mAlarmMessage = mess.mid( 9 );
QString filename = MainWindow::resourcePath();
filename += "koalarm.wav";
QString tempfilename;
if ( mess.left( 13 ) == "suspend_alarm") {
bool error = false;
int len = mess.mid( 13 ).find("+++");
if ( len < 2 )
error = true;
else {
tempfilename = mess.mid( 13, len );
if ( !QFile::exists( tempfilename ) )
error = true;
}
if ( ! error ) {
filename = tempfilename;
}
mAlarmMessage = mess.mid( 13+len+3 );
//qDebug("suspend file %s ",tempfilename.latin1() );
startAlarm( mAlarmMessage, filename);
return;
}
if ( mess.left( 11 ) == "timer_alarm") {
//mTimerTime = 0;
startAlarm( mess.mid( 11 ), filename );
return;
}
if ( mess.left( 10 ) == "proc_alarm") {
bool error = false;
int len = mess.mid( 10 ).find("+++");
if ( len < 2 )
error = true;
else {
tempfilename = mess.mid( 10, len );
if ( !QFile::exists( tempfilename ) )
error = true;
}
if ( error ) {
mAlarmMessage = "Procedure Alarm\nError - File not found\n";
mAlarmMessage += mess.mid( 10+len+3+9 );
} else {
//QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
//qDebug("-----system command %s ",tempfilename.latin1() );
#ifndef _WIN32_
if ( vfork () == 0 ) {
execl ( tempfilename.latin1(), 0 );
return;
}
#else
QProcess* p = new QProcess();
p->addArgument( tempfilename.latin1() );