summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-04 10:29:18 (UTC)
committer zautrix <zautrix>2005-06-04 10:29:18 (UTC)
commita7939017000e165e711e3f0cffeab46852a9fb2e (patch) (unidiff)
tree6b1c0d44051039e47f7b7f6cf55e25af9a6e7024 /korganizer
parentd40cf5135c640506011334364274b8ee5df9998b (diff)
downloadkdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.zip
kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.gz
kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 42166ab..608b73b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -97,153 +97,160 @@
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 setBackgroundColor( QColor( 86, 153, 205 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->type() == "Event" ) { 173 if ( inc->type() == "Event" ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->type() == "Todo" ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->type() == "Todo" ) 179 if ( inc->type() == "Todo" )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() == QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>";
191 time = 1; 193 time = 1;
192 mText +="</table>"; 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 )
197 mText +="</table>";
193 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
194 mText += "<table>"; 199 mText += "<table>";
200 time = 2;
195 201
196 } 202 }
197 if ( dt.date() > QDate::currentDate() && time != 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
198 time = 2; 204 if ( time > 0 )
199 mText +="</table>"; 205 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
201 mText += "<table>"; 207 mText += "<table>";
208 time = 3;
202 } 209 }
203 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
204 mText += timestr; 211 mText += timestr;
205 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
206 mText += tempText; 213 mText += tempText;
207 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
208 inc = getNextInc( start ); 215 inc = getNextInc( start );
209 } 216 }
210 mText +="</table>"; 217 mText +="</table>";
211 setText( mText ); 218 setText( mText );
212} 219}
213 220
214MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
215{ 222{
216 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
217} 224}
218Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
219{ 226{
220 QDateTime dt ; 227 QDateTime dt ;
221 Incidence * retInc; 228 Incidence * retInc;
222 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
223 if ( inc == 0 ) 230 if ( inc == 0 )
224 return 0; 231 return 0;
225 bool ok; 232 bool ok;
226 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
227 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
228 QDateTime dtn ; 235 QDateTime dtn ;
229 retInc = inc; 236 retInc = inc;
230 inc = mAlarms.next(); 237 inc = mAlarms.next();
231 while ( inc ) { 238 while ( inc ) {
232 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
233 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
234 if ( dtn < dt ) { 241 if ( dtn < dt ) {
235 dt = dtn; 242 dt = dtn;
236 retInc = inc; 243 retInc = inc;
237 } 244 }
238 inc = mAlarms.next(); 245 inc = mAlarms.next();
239 } 246 }
240 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
241 return retInc; 248 return retInc;
242 249
243} 250}
244void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
245{ 252{
246 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
247#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
248 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
249#else 256#else
@@ -589,128 +596,135 @@ void CalendarView::init()
589 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 596 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
590 597
591 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 598 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
592 599
593 mEventEditor = mDialogManager->getEventEditor(); 600 mEventEditor = mDialogManager->getEventEditor();
594 mTodoEditor = mDialogManager->getTodoEditor(); 601 mTodoEditor = mDialogManager->getTodoEditor();
595 602
596 mFlagEditDescription = false; 603 mFlagEditDescription = false;
597 604
598 mSuspendTimer = new QTimer( this ); 605 mSuspendTimer = new QTimer( this );
599 mAlarmTimer = new QTimer( this ); 606 mAlarmTimer = new QTimer( this );
600 mRecheckAlarmTimer = new QTimer( this ); 607 mRecheckAlarmTimer = new QTimer( this );
601 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 608 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
602 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 609 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
603 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 610 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
604 mAlarmDialog = new AlarmDialog( this ); 611 mAlarmDialog = new AlarmDialog( this );
605 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 612 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
606 mAlarmDialog->setServerNotification( false ); 613 mAlarmDialog->setServerNotification( false );
607 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 614 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
608 615
609 616
610#ifndef DESKTOP_VERSION 617#ifndef DESKTOP_VERSION
611//US listen for arriving address resultsets 618//US listen for arriving address resultsets
612 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 619 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
613 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 620 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
614#endif 621#endif
615 mDateNavigator->setCalendar( mCalendar ); 622 mDateNavigator->setCalendar( mCalendar );
616} 623}
617 624
618 625
619CalendarView::~CalendarView() 626CalendarView::~CalendarView()
620{ 627{
621 // kdDebug() << "~CalendarView()" << endl; 628 // kdDebug() << "~CalendarView()" << endl;
622 //qDebug("CalendarView::~CalendarView() "); 629 //qDebug("CalendarView::~CalendarView() ");
623 delete mDialogManager; 630 delete mDialogManager;
624 delete mViewManager; 631 delete mViewManager;
625 delete mStorage; 632 delete mStorage;
626 delete mDateFrame ; 633 delete mDateFrame ;
627 delete beamDialog; 634 delete beamDialog;
628 delete mEventViewerDialog; 635 delete mEventViewerDialog;
629 //kdDebug() << "~CalendarView() done" << endl; 636 //kdDebug() << "~CalendarView() done" << endl;
630} 637}
631void CalendarView::checkAlarms() 638void CalendarView::checkAlarms()
632{ 639{
633 KConfig *config = KOGlobals::config(); 640 KConfig *config = KOGlobals::config();
634 config->setGroup( "AppRun" ); 641 config->setGroup( "AppRun" );
635 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 642 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
636 int secs = config->readNumEntry( "LatestProgramStop" ) - 30; 643 int secs = config->readNumEntry( "LatestProgramStop" ) - 30;
637 secs -= ( 3600 * 24*3 ); // debug only 644 //secs -= ( 3600 * 24*3 ); // debug only
638 QDateTime latest = dt.addSecs ( secs ); 645 QDateTime latest = dt.addSecs ( secs );
639 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 646 qDebug("KO: Last termination on %s ", latest.toString().latin1());
640 QPtrList<Incidence> el = mCalendar->rawIncidences(); 647 QPtrList<Incidence> el = mCalendar->rawIncidences();
641 QPtrList<Incidence> al; 648 QPtrList<Incidence> al;
642 Incidence* inL = el.first(); 649 Incidence* inL = el.first();
643 while ( inL ) { 650 while ( inL ) {
644 bool ok = false; 651 bool ok = false;
645 int offset = 0; 652 int offset = 0;
646 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 653 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
647 if ( ok ) { 654 if ( ok ) {
648 //qDebug("OK %s",next.toString().latin1()); 655 //qDebug("OK %s",next.toString().latin1());
649 if ( next < QDateTime::currentDateTime() ) { 656 if ( next < QDateTime::currentDateTime() ) {
650 al.append( inL ); 657 al.append( inL );
651 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 658 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
652 } 659 }
653 } 660 }
654 inL = el.next(); 661 inL = el.next();
655 } 662 }
656 if ( al.count() ) { 663 if ( al.count() ) {
657 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 664 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
658 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 665 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
659 QVBoxLayout* lay = new QVBoxLayout( dia ); 666 QVBoxLayout* lay = new QVBoxLayout( dia );
660 lay->setSpacing( 0 ); 667 lay->setSpacing( 0 );
661 lay->setMargin( 0 ); 668 lay->setMargin( 0 );
662 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 669 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
663 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 670 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
664 lay->addWidget( matb ); 671 lay->addWidget( matb );
665 int si = 220; 672 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
666 if ( QApplication::desktop()->width() > 470 ) 673 int wid = 210;
667 si = 400; 674 int x = QApplication::desktop()->width() - wid - 7;
668 dia->resize(si,si/2); 675 int y = QApplication::desktop()->height() - wid - 70;
676 dia->setGeometry ( x,y,wid,wid);
677 } else {
678 int si = 220;
679 if ( QApplication::desktop()->width() > 470 )
680 si = 400;
681 dia->resize(si,si/2);
682 }
669 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 683 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
670 dia->show(); 684 dia->show();
671 685
672 } 686 }
673} 687}
674void CalendarView::showDay( QDate d ) 688void CalendarView::showDay( QDate d )
675{ 689{
676 dateNavigator()->blockSignals( true ); 690 dateNavigator()->blockSignals( true );
677 dateNavigator()->selectDate( d ); 691 dateNavigator()->selectDate( d );
678 dateNavigator()->blockSignals( false ); 692 dateNavigator()->blockSignals( false );
679 mViewManager->showDayView(); 693 mViewManager->showDayView();
680 //dateNavigator()->selectDate( d ); 694 //dateNavigator()->selectDate( d );
681} 695}
682void CalendarView::timerAlarm() 696void CalendarView::timerAlarm()
683{ 697{
684 //qDebug("CalendarView::timerAlarm() "); 698 //qDebug("CalendarView::timerAlarm() ");
685 computeAlarm(mAlarmNotification ); 699 computeAlarm(mAlarmNotification );
686} 700}
687 701
688void CalendarView::suspendAlarm() 702void CalendarView::suspendAlarm()
689{ 703{
690 //qDebug(" CalendarView::suspendAlarm() "); 704 //qDebug(" CalendarView::suspendAlarm() ");
691 computeAlarm(mSuspendAlarmNotification ); 705 computeAlarm(mSuspendAlarmNotification );
692 706
693} 707}
694 708
695void CalendarView::startAlarm( QString mess , QString filename) 709void CalendarView::startAlarm( QString mess , QString filename)
696{ 710{
697 711
698 topLevelWidget()->showNormal(); 712 topLevelWidget()->showNormal();
699 topLevelWidget()->setActiveWindow(); 713 topLevelWidget()->setActiveWindow();
700 topLevelWidget()->raise(); 714 topLevelWidget()->raise();
701 715
702 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 716 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
703 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 717 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
704 718
705} 719}
706 720
707void CalendarView::checkNextTimerAlarm() 721void CalendarView::checkNextTimerAlarm()
708{ 722{
709 mCalendar->checkAlarmForIncidence( 0, true ); 723 mCalendar->checkAlarmForIncidence( 0, true );
710} 724}
711 725
712void CalendarView::computeAlarm( QString msg ) 726void CalendarView::computeAlarm( QString msg )
713{ 727{
714 728
715 QString mess = msg; 729 QString mess = msg;
716 QString mAlarmMessage = mess.mid( 9 ); 730 QString mAlarmMessage = mess.mid( 9 );