summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-08 10:34:22 (UTC)
committer zautrix <zautrix>2005-06-08 10:34:22 (UTC)
commit793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (unidiff)
tree5bc77e2b7a32a541c2a3b3c3d6d50f873216deef
parent39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff)
downloadkdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2
changed incidence type to a faster access method
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp62
-rw-r--r--korganizer/koagenda.cpp4
-rw-r--r--korganizer/koagendaitem.cpp16
-rw-r--r--korganizer/kolistview.cpp12
-rw-r--r--korganizer/kotodoview.cpp4
-rw-r--r--korganizer/kowhatsnextview.cpp10
-rw-r--r--korganizer/mainwindow.cpp10
-rw-r--r--libkcal/calendar.cpp6
-rw-r--r--libkcal/calendarlocal.cpp6
-rw-r--r--libkcal/calfilter.cpp6
-rw-r--r--libkcal/event.h1
-rw-r--r--libkcal/freebusy.h1
-rw-r--r--libkcal/icalformat.cpp4
-rw-r--r--libkcal/icalformatimpl.cpp6
-rw-r--r--libkcal/incidence.cpp6
-rw-r--r--libkcal/incidencebase.h2
-rw-r--r--libkcal/journal.h1
-rw-r--r--libkcal/kincidenceformatter.cpp4
-rw-r--r--libkcal/todo.cpp5
-rw-r--r--libkcal/todo.h1
20 files changed, 85 insertions, 82 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 720ad78..7c7466b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -77,199 +77,199 @@
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
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 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 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->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->typeID() == todoID ) {
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->typeID() == todoID )
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>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
@@ -880,626 +880,626 @@ KOViewManager *CalendarView::viewManager()
880{ 880{
881 return mViewManager; 881 return mViewManager;
882} 882}
883 883
884KODialogManager *CalendarView::dialogManager() 884KODialogManager *CalendarView::dialogManager()
885{ 885{
886 return mDialogManager; 886 return mDialogManager;
887} 887}
888 888
889QDate CalendarView::startDate() 889QDate CalendarView::startDate()
890{ 890{
891 DateList dates = mNavigator->selectedDates(); 891 DateList dates = mNavigator->selectedDates();
892 892
893 return dates.first(); 893 return dates.first();
894} 894}
895 895
896QDate CalendarView::endDate() 896QDate CalendarView::endDate()
897{ 897{
898 DateList dates = mNavigator->selectedDates(); 898 DateList dates = mNavigator->selectedDates();
899 899
900 return dates.last(); 900 return dates.last();
901} 901}
902 902
903 903
904void CalendarView::createPrinter() 904void CalendarView::createPrinter()
905{ 905{
906#ifndef KORG_NOPRINTER 906#ifndef KORG_NOPRINTER
907 if (!mCalPrinter) { 907 if (!mCalPrinter) {
908 mCalPrinter = new CalPrinter(this, mCalendar); 908 mCalPrinter = new CalPrinter(this, mCalendar);
909 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 909 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
910 } 910 }
911#endif 911#endif
912} 912}
913 913
914 914
915//KOPrefs::instance()->mWriteBackFile 915//KOPrefs::instance()->mWriteBackFile
916//KOPrefs::instance()->mWriteBackExistingOnly 916//KOPrefs::instance()->mWriteBackExistingOnly
917 917
918// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 918// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
919// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 919// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
920// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 920// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
921// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 921// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
922// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 922// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
923// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 923// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
924 924
925int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 925int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
926{ 926{
927 927
928 // 0 equal 928 // 0 equal
929 // 1 take local 929 // 1 take local
930 // 2 take remote 930 // 2 take remote
931 // 3 cancel 931 // 3 cancel
932 QDateTime lastSync = mLastCalendarSync; 932 QDateTime lastSync = mLastCalendarSync;
933 QDateTime localMod = local->lastModified(); 933 QDateTime localMod = local->lastModified();
934 QDateTime remoteMod = remote->lastModified(); 934 QDateTime remoteMod = remote->lastModified();
935 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 935 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
936 bool remCh, locCh; 936 bool remCh, locCh;
937 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 937 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
938 //if ( remCh ) 938 //if ( remCh )
939 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 939 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
940 locCh = ( localMod > mLastCalendarSync ); 940 locCh = ( localMod > mLastCalendarSync );
941 if ( !remCh && ! locCh ) { 941 if ( !remCh && ! locCh ) {
942 //qDebug("both not changed "); 942 //qDebug("both not changed ");
943 lastSync = localMod.addDays(1); 943 lastSync = localMod.addDays(1);
944 if ( mode <= SYNC_PREF_ASK ) 944 if ( mode <= SYNC_PREF_ASK )
945 return 0; 945 return 0;
946 } else { 946 } else {
947 if ( locCh ) { 947 if ( locCh ) {
948 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 948 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
949 lastSync = localMod.addDays( -1 ); 949 lastSync = localMod.addDays( -1 );
950 if ( !remCh ) 950 if ( !remCh )
951 remoteMod = ( lastSync.addDays( -1 ) ); 951 remoteMod = ( lastSync.addDays( -1 ) );
952 } else { 952 } else {
953 //qDebug(" not loc changed "); 953 //qDebug(" not loc changed ");
954 lastSync = localMod.addDays( 1 ); 954 lastSync = localMod.addDays( 1 );
955 if ( remCh ) 955 if ( remCh )
956 remoteMod =( lastSync.addDays( 1 ) ); 956 remoteMod =( lastSync.addDays( 1 ) );
957 957
958 } 958 }
959 } 959 }
960 full = true; 960 full = true;
961 if ( mode < SYNC_PREF_ASK ) 961 if ( mode < SYNC_PREF_ASK )
962 mode = SYNC_PREF_ASK; 962 mode = SYNC_PREF_ASK;
963 } else { 963 } else {
964 if ( localMod == remoteMod ) 964 if ( localMod == remoteMod )
965 // if ( local->revision() == remote->revision() ) 965 // if ( local->revision() == remote->revision() )
966 return 0; 966 return 0;
967 967
968 } 968 }
969 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 969 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
970 970
971 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 971 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
972 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 972 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
973 //full = true; //debug only 973 //full = true; //debug only
974 if ( full ) { 974 if ( full ) {
975 bool equ = false; 975 bool equ = false;
976 if ( local->type() == "Event" ) { 976 if ( local->typeID() == eventID ) {
977 equ = (*((Event*) local) == *((Event*) remote)); 977 equ = (*((Event*) local) == *((Event*) remote));
978 } 978 }
979 else if ( local->type() =="Todo" ) 979 else if ( local->typeID() == todoID )
980 equ = (*((Todo*) local) == (*(Todo*) remote)); 980 equ = (*((Todo*) local) == (*(Todo*) remote));
981 else if ( local->type() =="Journal" ) 981 else if ( local->typeID() == journalID )
982 equ = (*((Journal*) local) == *((Journal*) remote)); 982 equ = (*((Journal*) local) == *((Journal*) remote));
983 if ( equ ) { 983 if ( equ ) {
984 //qDebug("equal "); 984 //qDebug("equal ");
985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
986 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 986 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
987 } 987 }
988 if ( mode < SYNC_PREF_FORCE_LOCAL ) 988 if ( mode < SYNC_PREF_FORCE_LOCAL )
989 return 0; 989 return 0;
990 990
991 }//else //debug only 991 }//else //debug only
992 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 992 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
993 } 993 }
994 int result; 994 int result;
995 bool localIsNew; 995 bool localIsNew;
996 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 996 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
997 997
998 998
999 // ************************************************ 999 // ************************************************
1000 // ************************************************ 1000 // ************************************************
1001 // ************************************************ 1001 // ************************************************
1002 // We may have that lastSync > remoteMod AND lastSync > localMod 1002 // We may have that lastSync > remoteMod AND lastSync > localMod
1003 // BUT remoteMod != localMod 1003 // BUT remoteMod != localMod
1004 1004
1005 1005
1006 if ( full && mode < SYNC_PREF_NEWEST ) 1006 if ( full && mode < SYNC_PREF_NEWEST )
1007 mode = SYNC_PREF_ASK; 1007 mode = SYNC_PREF_ASK;
1008 1008
1009 switch( mode ) { 1009 switch( mode ) {
1010 case SYNC_PREF_LOCAL: 1010 case SYNC_PREF_LOCAL:
1011 if ( lastSync > remoteMod ) 1011 if ( lastSync > remoteMod )
1012 return 1; 1012 return 1;
1013 if ( lastSync > localMod ) 1013 if ( lastSync > localMod )
1014 return 2; 1014 return 2;
1015 return 1; 1015 return 1;
1016 break; 1016 break;
1017 case SYNC_PREF_REMOTE: 1017 case SYNC_PREF_REMOTE:
1018 if ( lastSync > localMod ) 1018 if ( lastSync > localMod )
1019 return 2; 1019 return 2;
1020 if ( lastSync > remoteMod ) 1020 if ( lastSync > remoteMod )
1021 return 1; 1021 return 1;
1022 return 2; 1022 return 2;
1023 break; 1023 break;
1024 case SYNC_PREF_NEWEST: 1024 case SYNC_PREF_NEWEST:
1025 if ( localMod >= remoteMod ) 1025 if ( localMod >= remoteMod )
1026 return 1; 1026 return 1;
1027 else 1027 else
1028 return 2; 1028 return 2;
1029 break; 1029 break;
1030 case SYNC_PREF_ASK: 1030 case SYNC_PREF_ASK:
1031 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1031 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1032 if ( lastSync > remoteMod && lastSync > localMod) 1032 if ( lastSync > remoteMod && lastSync > localMod)
1033 return 0; 1033 return 0;
1034 if ( lastSync > remoteMod ) 1034 if ( lastSync > remoteMod )
1035 return 1; 1035 return 1;
1036 if ( lastSync > localMod ) 1036 if ( lastSync > localMod )
1037 return 2; 1037 return 2;
1038 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1038 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1039 localIsNew = localMod >= remoteMod; 1039 localIsNew = localMod >= remoteMod;
1040 if ( localIsNew ) 1040 if ( localIsNew )
1041 getEventViewerDialog()->setColorMode( 1 ); 1041 getEventViewerDialog()->setColorMode( 1 );
1042 else 1042 else
1043 getEventViewerDialog()->setColorMode( 2 ); 1043 getEventViewerDialog()->setColorMode( 2 );
1044 getEventViewerDialog()->setIncidence(local); 1044 getEventViewerDialog()->setIncidence(local);
1045 if ( localIsNew ) 1045 if ( localIsNew )
1046 getEventViewerDialog()->setColorMode( 2 ); 1046 getEventViewerDialog()->setColorMode( 2 );
1047 else 1047 else
1048 getEventViewerDialog()->setColorMode( 1 ); 1048 getEventViewerDialog()->setColorMode( 1 );
1049 getEventViewerDialog()->addIncidence(remote); 1049 getEventViewerDialog()->addIncidence(remote);
1050 getEventViewerDialog()->setColorMode( 0 ); 1050 getEventViewerDialog()->setColorMode( 0 );
1051 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1051 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1052 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1052 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1053 getEventViewerDialog()->showMe(); 1053 getEventViewerDialog()->showMe();
1054 result = getEventViewerDialog()->executeS( localIsNew ); 1054 result = getEventViewerDialog()->executeS( localIsNew );
1055 return result; 1055 return result;
1056 1056
1057 break; 1057 break;
1058 case SYNC_PREF_FORCE_LOCAL: 1058 case SYNC_PREF_FORCE_LOCAL:
1059 return 1; 1059 return 1;
1060 break; 1060 break;
1061 case SYNC_PREF_FORCE_REMOTE: 1061 case SYNC_PREF_FORCE_REMOTE:
1062 return 2; 1062 return 2;
1063 break; 1063 break;
1064 1064
1065 default: 1065 default:
1066 // SYNC_PREF_TAKE_BOTH not implemented 1066 // SYNC_PREF_TAKE_BOTH not implemented
1067 break; 1067 break;
1068 } 1068 }
1069 return 0; 1069 return 0;
1070} 1070}
1071Event* CalendarView::getLastSyncEvent() 1071Event* CalendarView::getLastSyncEvent()
1072{ 1072{
1073 Event* lse; 1073 Event* lse;
1074 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1074 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1075 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1075 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1076 if (!lse) { 1076 if (!lse) {
1077 lse = new Event(); 1077 lse = new Event();
1078 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1078 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1079 QString sum = ""; 1079 QString sum = "";
1080 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1080 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1081 sum = "E: "; 1081 sum = "E: ";
1082 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1082 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1083 lse->setDtStart( mLastCalendarSync ); 1083 lse->setDtStart( mLastCalendarSync );
1084 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1084 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1085 lse->setCategories( i18n("SyncEvent") ); 1085 lse->setCategories( i18n("SyncEvent") );
1086 lse->setReadOnly( true ); 1086 lse->setReadOnly( true );
1087 mCalendar->addEvent( lse ); 1087 mCalendar->addEvent( lse );
1088 } 1088 }
1089 1089
1090 return lse; 1090 return lse;
1091 1091
1092} 1092}
1093 1093
1094// we check, if the to delete event has a id for a profile 1094// we check, if the to delete event has a id for a profile
1095// if yes, we set this id in the profile to delete 1095// if yes, we set this id in the profile to delete
1096void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1096void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1097{ 1097{
1098 if ( lastSync.count() == 0 ) { 1098 if ( lastSync.count() == 0 ) {
1099 //qDebug(" lastSync.count() == 0"); 1099 //qDebug(" lastSync.count() == 0");
1100 return; 1100 return;
1101 } 1101 }
1102 if ( toDelete->type() == "Journal" ) 1102 if ( toDelete->typeID() == journalID )
1103 return; 1103 return;
1104 1104
1105 Event* eve = lastSync.first(); 1105 Event* eve = lastSync.first();
1106 1106
1107 while ( eve ) { 1107 while ( eve ) {
1108 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1108 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1109 if ( !id.isEmpty() ) { 1109 if ( !id.isEmpty() ) {
1110 QString des = eve->description(); 1110 QString des = eve->description();
1111 QString pref = "e"; 1111 QString pref = "e";
1112 if ( toDelete->type() == "Todo" ) 1112 if ( toDelete->typeID() == todoID )
1113 pref = "t"; 1113 pref = "t";
1114 des += pref+ id + ","; 1114 des += pref+ id + ",";
1115 eve->setReadOnly( false ); 1115 eve->setReadOnly( false );
1116 eve->setDescription( des ); 1116 eve->setDescription( des );
1117 //qDebug("setdes %s ", des.latin1()); 1117 //qDebug("setdes %s ", des.latin1());
1118 eve->setReadOnly( true ); 1118 eve->setReadOnly( true );
1119 } 1119 }
1120 eve = lastSync.next(); 1120 eve = lastSync.next();
1121 } 1121 }
1122 1122
1123} 1123}
1124void CalendarView::checkExternalId( Incidence * inc ) 1124void CalendarView::checkExternalId( Incidence * inc )
1125{ 1125{
1126 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1126 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1127 checkExternSyncEvent( lastSync, inc ); 1127 checkExternSyncEvent( lastSync, inc );
1128 1128
1129} 1129}
1130bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1130bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1131{ 1131{
1132 bool syncOK = true; 1132 bool syncOK = true;
1133 int addedEvent = 0; 1133 int addedEvent = 0;
1134 int addedEventR = 0; 1134 int addedEventR = 0;
1135 int deletedEventR = 0; 1135 int deletedEventR = 0;
1136 int deletedEventL = 0; 1136 int deletedEventL = 0;
1137 int changedLocal = 0; 1137 int changedLocal = 0;
1138 int changedRemote = 0; 1138 int changedRemote = 0;
1139 int filteredIN = 0; 1139 int filteredIN = 0;
1140 int filteredOUT = 0; 1140 int filteredOUT = 0;
1141 //QPtrList<Event> el = local->rawEvents(); 1141 //QPtrList<Event> el = local->rawEvents();
1142 Event* eventR; 1142 Event* eventR;
1143 QString uid; 1143 QString uid;
1144 int take; 1144 int take;
1145 Event* eventL; 1145 Event* eventL;
1146 Event* eventRSync; 1146 Event* eventRSync;
1147 Event* eventLSync; 1147 Event* eventLSync;
1148 clearAllViews(); 1148 clearAllViews();
1149 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1149 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1150 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1150 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1151 bool fullDateRange = false; 1151 bool fullDateRange = false;
1152 local->resetTempSyncStat(); 1152 local->resetTempSyncStat();
1153 mLastCalendarSync = QDateTime::currentDateTime(); 1153 mLastCalendarSync = QDateTime::currentDateTime();
1154 if ( mSyncManager->syncWithDesktop() ) { 1154 if ( mSyncManager->syncWithDesktop() ) {
1155 remote->resetPilotStat(1); 1155 remote->resetPilotStat(1);
1156 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1156 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1157 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1157 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1158 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1158 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1159 } else { 1159 } else {
1160 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1160 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1161 } 1161 }
1162 } 1162 }
1163 QDateTime modifiedCalendar = mLastCalendarSync; 1163 QDateTime modifiedCalendar = mLastCalendarSync;
1164 eventLSync = getLastSyncEvent(); 1164 eventLSync = getLastSyncEvent();
1165 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1165 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1166 if ( eventR ) { 1166 if ( eventR ) {
1167 eventRSync = (Event*) eventR->clone(); 1167 eventRSync = (Event*) eventR->clone();
1168 remote->deleteEvent(eventR ); 1168 remote->deleteEvent(eventR );
1169 1169
1170 } else { 1170 } else {
1171 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1171 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1172 eventRSync = (Event*)eventLSync->clone(); 1172 eventRSync = (Event*)eventLSync->clone();
1173 } else { 1173 } else {
1174 fullDateRange = true; 1174 fullDateRange = true;
1175 eventRSync = new Event(); 1175 eventRSync = new Event();
1176 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1176 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1177 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1177 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1178 eventRSync->setDtStart( mLastCalendarSync ); 1178 eventRSync->setDtStart( mLastCalendarSync );
1179 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1179 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1180 eventRSync->setCategories( i18n("SyncEvent") ); 1180 eventRSync->setCategories( i18n("SyncEvent") );
1181 } 1181 }
1182 } 1182 }
1183 if ( eventLSync->dtStart() == mLastCalendarSync ) 1183 if ( eventLSync->dtStart() == mLastCalendarSync )
1184 fullDateRange = true; 1184 fullDateRange = true;
1185 1185
1186 if ( ! fullDateRange ) { 1186 if ( ! fullDateRange ) {
1187 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1187 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1188 1188
1189 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1189 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1190 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1190 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1191 fullDateRange = true; 1191 fullDateRange = true;
1192 } 1192 }
1193 } 1193 }
1194 if ( mSyncManager->syncWithDesktop() ) { 1194 if ( mSyncManager->syncWithDesktop() ) {
1195 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1195 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1196 } 1196 }
1197 if ( fullDateRange ) 1197 if ( fullDateRange )
1198 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1198 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1199 else 1199 else
1200 mLastCalendarSync = eventLSync->dtStart(); 1200 mLastCalendarSync = eventLSync->dtStart();
1201 // for resyncing if own file has changed 1201 // for resyncing if own file has changed
1202 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1202 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1203 mLastCalendarSync = loadedFileVersion; 1203 mLastCalendarSync = loadedFileVersion;
1204 //qDebug("setting mLastCalendarSync "); 1204 //qDebug("setting mLastCalendarSync ");
1205 } 1205 }
1206 //qDebug("*************************** "); 1206 //qDebug("*************************** ");
1207 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1207 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1208 QPtrList<Incidence> er = remote->rawIncidences(); 1208 QPtrList<Incidence> er = remote->rawIncidences();
1209 Incidence* inR = er.first(); 1209 Incidence* inR = er.first();
1210 Incidence* inL; 1210 Incidence* inL;
1211 QProgressBar bar( er.count(),0 ); 1211 QProgressBar bar( er.count(),0 );
1212 bar.setCaption (i18n("Syncing - close to abort!") ); 1212 bar.setCaption (i18n("Syncing - close to abort!") );
1213 1213
1214 // ************** setting up filter ************* 1214 // ************** setting up filter *************
1215 CalFilter *filterIN = 0; 1215 CalFilter *filterIN = 0;
1216 CalFilter *filterOUT = 0; 1216 CalFilter *filterOUT = 0;
1217 CalFilter *filter = mFilters.first(); 1217 CalFilter *filter = mFilters.first();
1218 while(filter) { 1218 while(filter) {
1219 if ( filter->name() == mSyncManager->mFilterInCal ) 1219 if ( filter->name() == mSyncManager->mFilterInCal )
1220 filterIN = filter; 1220 filterIN = filter;
1221 if ( filter->name() == mSyncManager->mFilterOutCal ) 1221 if ( filter->name() == mSyncManager->mFilterOutCal )
1222 filterOUT = filter; 1222 filterOUT = filter;
1223 filter = mFilters.next(); 1223 filter = mFilters.next();
1224 } 1224 }
1225 int w = 300; 1225 int w = 300;
1226 if ( QApplication::desktop()->width() < 320 ) 1226 if ( QApplication::desktop()->width() < 320 )
1227 w = 220; 1227 w = 220;
1228 int h = bar.sizeHint().height() ; 1228 int h = bar.sizeHint().height() ;
1229 int dw = QApplication::desktop()->width(); 1229 int dw = QApplication::desktop()->width();
1230 int dh = QApplication::desktop()->height(); 1230 int dh = QApplication::desktop()->height();
1231 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1231 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1232 bar.show(); 1232 bar.show();
1233 int modulo = (er.count()/10)+1; 1233 int modulo = (er.count()/10)+1;
1234 int incCounter = 0; 1234 int incCounter = 0;
1235 while ( inR ) { 1235 while ( inR ) {
1236 if ( ! bar.isVisible() ) 1236 if ( ! bar.isVisible() )
1237 return false; 1237 return false;
1238 if ( incCounter % modulo == 0 ) 1238 if ( incCounter % modulo == 0 )
1239 bar.setProgress( incCounter ); 1239 bar.setProgress( incCounter );
1240 ++incCounter; 1240 ++incCounter;
1241 uid = inR->uid(); 1241 uid = inR->uid();
1242 bool skipIncidence = false; 1242 bool skipIncidence = false;
1243 if ( uid.left(15) == QString("last-syncEvent-") ) 1243 if ( uid.left(15) == QString("last-syncEvent-") )
1244 skipIncidence = true; 1244 skipIncidence = true;
1245 QString idS; 1245 QString idS;
1246 qApp->processEvents(); 1246 qApp->processEvents();
1247 if ( !skipIncidence ) { 1247 if ( !skipIncidence ) {
1248 inL = local->incidence( uid ); 1248 inL = local->incidence( uid );
1249 if ( inL ) { // maybe conflict - same uid in both calendars 1249 if ( inL ) { // maybe conflict - same uid in both calendars
1250 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1250 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1251 //qDebug("take %d %s ", take, inL->summary().latin1()); 1251 //qDebug("take %d %s ", take, inL->summary().latin1());
1252 if ( take == 3 ) 1252 if ( take == 3 )
1253 return false; 1253 return false;
1254 if ( take == 1 ) {// take local ********************** 1254 if ( take == 1 ) {// take local **********************
1255 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1255 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1256 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1256 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1257 else 1257 else
1258 idS = inR->IDStr(); 1258 idS = inR->IDStr();
1259 remote->deleteIncidence( inR ); 1259 remote->deleteIncidence( inR );
1260 inR = inL->clone(); 1260 inR = inL->clone();
1261 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1261 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1262 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1262 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1263 inR->setIDStr( idS ); 1263 inR->setIDStr( idS );
1264 remote->addIncidence( inR ); 1264 remote->addIncidence( inR );
1265 if ( mSyncManager->syncWithDesktop() ) 1265 if ( mSyncManager->syncWithDesktop() )
1266 inR->setPilotId( 2 ); 1266 inR->setPilotId( 2 );
1267 ++changedRemote; 1267 ++changedRemote;
1268 } else {// take remote ********************** 1268 } else {// take remote **********************
1269 idS = inL->IDStr(); 1269 idS = inL->IDStr();
1270 int pid = inL->pilotId(); 1270 int pid = inL->pilotId();
1271 local->deleteIncidence( inL ); 1271 local->deleteIncidence( inL );
1272 inL = inR->clone(); 1272 inL = inR->clone();
1273 if ( mSyncManager->syncWithDesktop() ) 1273 if ( mSyncManager->syncWithDesktop() )
1274 inL->setPilotId( pid ); 1274 inL->setPilotId( pid );
1275 inL->setIDStr( idS ); 1275 inL->setIDStr( idS );
1276 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1276 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1277 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1277 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1278 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1278 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1279 } 1279 }
1280 local->addIncidence( inL ); 1280 local->addIncidence( inL );
1281 ++changedLocal; 1281 ++changedLocal;
1282 } 1282 }
1283 } 1283 }
1284 } else { // no conflict ********** add or delete remote 1284 } else { // no conflict ********** add or delete remote
1285 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1285 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1286 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1286 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1287 QString des = eventLSync->description(); 1287 QString des = eventLSync->description();
1288 QString pref = "e"; 1288 QString pref = "e";
1289 if ( inR->type() == "Todo" ) 1289 if ( inR->typeID() == todoID )
1290 pref = "t"; 1290 pref = "t";
1291 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1291 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1292 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1292 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1293 //remote->deleteIncidence( inR ); 1293 //remote->deleteIncidence( inR );
1294 ++deletedEventR; 1294 ++deletedEventR;
1295 } else { 1295 } else {
1296 inR->setLastModified( modifiedCalendar ); 1296 inR->setLastModified( modifiedCalendar );
1297 inL = inR->clone(); 1297 inL = inR->clone();
1298 inL->setIDStr( ":" ); 1298 inL->setIDStr( ":" );
1299 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1299 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1300 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1300 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1301 local->addIncidence( inL ); 1301 local->addIncidence( inL );
1302 ++addedEvent; 1302 ++addedEvent;
1303 1303
1304 } 1304 }
1305 } else { 1305 } else {
1306 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1306 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1307 inR->setLastModified( modifiedCalendar ); 1307 inR->setLastModified( modifiedCalendar );
1308 inL = inR->clone(); 1308 inL = inR->clone();
1309 inL->setIDStr( ":" ); 1309 inL->setIDStr( ":" );
1310 local->addIncidence( inL ); 1310 local->addIncidence( inL );
1311 ++addedEvent; 1311 ++addedEvent;
1312 1312
1313 } else { 1313 } else {
1314 checkExternSyncEvent(eventRSyncSharp, inR); 1314 checkExternSyncEvent(eventRSyncSharp, inR);
1315 remote->deleteIncidence( inR ); 1315 remote->deleteIncidence( inR );
1316 ++deletedEventR; 1316 ++deletedEventR;
1317 } 1317 }
1318 } 1318 }
1319 } else { 1319 } else {
1320 ++filteredIN; 1320 ++filteredIN;
1321 } 1321 }
1322 } 1322 }
1323 } 1323 }
1324 inR = er.next(); 1324 inR = er.next();
1325 } 1325 }
1326 QPtrList<Incidence> el = local->rawIncidences(); 1326 QPtrList<Incidence> el = local->rawIncidences();
1327 inL = el.first(); 1327 inL = el.first();
1328 modulo = (el.count()/10)+1; 1328 modulo = (el.count()/10)+1;
1329 bar.setCaption (i18n("Add / remove events") ); 1329 bar.setCaption (i18n("Add / remove events") );
1330 bar.setTotalSteps ( el.count() ) ; 1330 bar.setTotalSteps ( el.count() ) ;
1331 bar.show(); 1331 bar.show();
1332 incCounter = 0; 1332 incCounter = 0;
1333 1333
1334 while ( inL ) { 1334 while ( inL ) {
1335 1335
1336 qApp->processEvents(); 1336 qApp->processEvents();
1337 if ( ! bar.isVisible() ) 1337 if ( ! bar.isVisible() )
1338 return false; 1338 return false;
1339 if ( incCounter % modulo == 0 ) 1339 if ( incCounter % modulo == 0 )
1340 bar.setProgress( incCounter ); 1340 bar.setProgress( incCounter );
1341 ++incCounter; 1341 ++incCounter;
1342 uid = inL->uid(); 1342 uid = inL->uid();
1343 bool skipIncidence = false; 1343 bool skipIncidence = false;
1344 if ( uid.left(15) == QString("last-syncEvent-") ) 1344 if ( uid.left(15) == QString("last-syncEvent-") )
1345 skipIncidence = true; 1345 skipIncidence = true;
1346 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1346 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1347 skipIncidence = true; 1347 skipIncidence = true;
1348 if ( !skipIncidence ) { 1348 if ( !skipIncidence ) {
1349 inR = remote->incidence( uid ); 1349 inR = remote->incidence( uid );
1350 if ( ! inR ) { 1350 if ( ! inR ) {
1351 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1351 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1352 // no conflict ********** add or delete local 1352 // no conflict ********** add or delete local
1353 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1353 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1354 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1354 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1355 checkExternSyncEvent(eventLSyncSharp, inL); 1355 checkExternSyncEvent(eventLSyncSharp, inL);
1356 local->deleteIncidence( inL ); 1356 local->deleteIncidence( inL );
1357 ++deletedEventL; 1357 ++deletedEventL;
1358 } else { 1358 } else {
1359 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1359 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1360 inL->removeID(mCurrentSyncDevice ); 1360 inL->removeID(mCurrentSyncDevice );
1361 ++addedEventR; 1361 ++addedEventR;
1362 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1362 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1363 inL->setLastModified( modifiedCalendar ); 1363 inL->setLastModified( modifiedCalendar );
1364 inR = inL->clone(); 1364 inR = inL->clone();
1365 inR->setIDStr( ":" ); 1365 inR->setIDStr( ":" );
1366 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1366 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1367 remote->addIncidence( inR ); 1367 remote->addIncidence( inR );
1368 } 1368 }
1369 } 1369 }
1370 } else { 1370 } else {
1371 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1371 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1372 checkExternSyncEvent(eventLSyncSharp, inL); 1372 checkExternSyncEvent(eventLSyncSharp, inL);
1373 local->deleteIncidence( inL ); 1373 local->deleteIncidence( inL );
1374 ++deletedEventL; 1374 ++deletedEventL;
1375 } else { 1375 } else {
1376 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1376 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1377 ++addedEventR; 1377 ++addedEventR;
1378 inL->setLastModified( modifiedCalendar ); 1378 inL->setLastModified( modifiedCalendar );
1379 inR = inL->clone(); 1379 inR = inL->clone();
1380 inR->setIDStr( ":" ); 1380 inR->setIDStr( ":" );
1381 remote->addIncidence( inR ); 1381 remote->addIncidence( inR );
1382 } 1382 }
1383 } 1383 }
1384 } 1384 }
1385 } else { 1385 } else {
1386 ++filteredOUT; 1386 ++filteredOUT;
1387 } 1387 }
1388 } 1388 }
1389 } 1389 }
1390 inL = el.next(); 1390 inL = el.next();
1391 } 1391 }
1392 int delFut = 0; 1392 int delFut = 0;
1393 int remRem = 0; 1393 int remRem = 0;
1394 if ( mSyncManager->mWriteBackInFuture ) { 1394 if ( mSyncManager->mWriteBackInFuture ) {
1395 er = remote->rawIncidences(); 1395 er = remote->rawIncidences();
1396 remRem = er.count(); 1396 remRem = er.count();
1397 inR = er.first(); 1397 inR = er.first();
1398 QDateTime dt; 1398 QDateTime dt;
1399 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1399 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1400 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1400 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1401 while ( inR ) { 1401 while ( inR ) {
1402 if ( inR->type() == "Todo" ) { 1402 if ( inR->typeID() == todoID ) {
1403 Todo * t = (Todo*)inR; 1403 Todo * t = (Todo*)inR;
1404 if ( t->hasDueDate() ) 1404 if ( t->hasDueDate() )
1405 dt = t->dtDue(); 1405 dt = t->dtDue();
1406 else 1406 else
1407 dt = cur.addSecs( 62 ); 1407 dt = cur.addSecs( 62 );
1408 } 1408 }
1409 else if (inR->type() == "Event" ) { 1409 else if (inR->typeID() == eventID ) {
1410 bool ok; 1410 bool ok;
1411 dt = inR->getNextOccurence( cur, &ok ); 1411 dt = inR->getNextOccurence( cur, &ok );
1412 if ( !ok ) 1412 if ( !ok )
1413 dt = cur.addSecs( -62 ); 1413 dt = cur.addSecs( -62 );
1414 } 1414 }
1415 else 1415 else
1416 dt = inR->dtStart(); 1416 dt = inR->dtStart();
1417 if ( dt < cur || dt > end ) { 1417 if ( dt < cur || dt > end ) {
1418 remote->deleteIncidence( inR ); 1418 remote->deleteIncidence( inR );
1419 ++delFut; 1419 ++delFut;
1420 } 1420 }
1421 inR = er.next(); 1421 inR = er.next();
1422 } 1422 }
1423 } 1423 }
1424 bar.hide(); 1424 bar.hide();
1425 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1425 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1426 eventLSync->setReadOnly( false ); 1426 eventLSync->setReadOnly( false );
1427 eventLSync->setDtStart( mLastCalendarSync ); 1427 eventLSync->setDtStart( mLastCalendarSync );
1428 eventRSync->setDtStart( mLastCalendarSync ); 1428 eventRSync->setDtStart( mLastCalendarSync );
1429 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1429 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1430 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1430 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1431 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1431 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1432 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1432 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1433 eventLSync->setReadOnly( true ); 1433 eventLSync->setReadOnly( true );
1434 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1434 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1435 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1435 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1436 remote->addEvent( eventRSync ); 1436 remote->addEvent( eventRSync );
1437 else 1437 else
1438 delete eventRSync; 1438 delete eventRSync;
1439 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1439 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1440 QString mes; 1440 QString mes;
1441 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1441 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1442 QString delmess; 1442 QString delmess;
1443 if ( delFut ) { 1443 if ( delFut ) {
1444 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1444 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1445 mes += delmess; 1445 mes += delmess;
1446 } 1446 }
1447 mes = i18n("Local calendar changed!\n") +mes; 1447 mes = i18n("Local calendar changed!\n") +mes;
1448 mCalendar->checkAlarmForIncidence( 0, true ); 1448 mCalendar->checkAlarmForIncidence( 0, true );
1449 qDebug( mes ); 1449 qDebug( mes );
1450 if ( mSyncManager->mShowSyncSummary ) { 1450 if ( mSyncManager->mShowSyncSummary ) {
1451 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1451 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1452 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1452 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1453 qDebug("KO: WB cancelled "); 1453 qDebug("KO: WB cancelled ");
1454 mSyncManager->mWriteBackFile = false; 1454 mSyncManager->mWriteBackFile = false;
1455 return syncOK; 1455 return syncOK;
1456 } 1456 }
1457 } 1457 }
1458 return syncOK; 1458 return syncOK;
1459} 1459}
1460 1460
1461void CalendarView::setSyncDevice( QString s ) 1461void CalendarView::setSyncDevice( QString s )
1462{ 1462{
1463 mCurrentSyncDevice= s; 1463 mCurrentSyncDevice= s;
1464} 1464}
1465void CalendarView::setSyncName( QString s ) 1465void CalendarView::setSyncName( QString s )
1466{ 1466{
1467 mCurrentSyncName= s; 1467 mCurrentSyncName= s;
1468} 1468}
1469bool CalendarView::syncCalendar(QString filename, int mode) 1469bool CalendarView::syncCalendar(QString filename, int mode)
1470{ 1470{
1471 //qDebug("syncCalendar %s ", filename.latin1()); 1471 //qDebug("syncCalendar %s ", filename.latin1());
1472 mGlobalSyncMode = SYNC_MODE_NORMAL; 1472 mGlobalSyncMode = SYNC_MODE_NORMAL;
1473 CalendarLocal* calendar = new CalendarLocal(); 1473 CalendarLocal* calendar = new CalendarLocal();
1474 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1474 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1475 FileStorage* storage = new FileStorage( calendar ); 1475 FileStorage* storage = new FileStorage( calendar );
1476 bool syncOK = false; 1476 bool syncOK = false;
1477 storage->setFileName( filename ); 1477 storage->setFileName( filename );
1478 // qDebug("loading ... "); 1478 // qDebug("loading ... ");
1479 if ( storage->load() ) { 1479 if ( storage->load() ) {
1480 getEventViewerDialog()->setSyncMode( true ); 1480 getEventViewerDialog()->setSyncMode( true );
1481 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1481 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1482 getEventViewerDialog()->setSyncMode( false ); 1482 getEventViewerDialog()->setSyncMode( false );
1483 if ( syncOK ) { 1483 if ( syncOK ) {
1484 if ( mSyncManager->mWriteBackFile ) 1484 if ( mSyncManager->mWriteBackFile )
1485 { 1485 {
1486 storage->setSaveFormat( new ICalFormat() ); 1486 storage->setSaveFormat( new ICalFormat() );
1487 storage->save(); 1487 storage->save();
1488 } 1488 }
1489 } 1489 }
1490 setModified( true ); 1490 setModified( true );
1491 } 1491 }
1492 delete storage; 1492 delete storage;
1493 delete calendar; 1493 delete calendar;
1494 if ( syncOK ) 1494 if ( syncOK )
1495 updateView(); 1495 updateView();
1496 return syncOK; 1496 return syncOK;
1497} 1497}
1498 1498
1499void CalendarView::syncExternal( int mode ) 1499void CalendarView::syncExternal( int mode )
1500{ 1500{
1501 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1501 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1502 1502
1503 qApp->processEvents(); 1503 qApp->processEvents();
1504 CalendarLocal* calendar = new CalendarLocal(); 1504 CalendarLocal* calendar = new CalendarLocal();
1505 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1505 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
@@ -2384,616 +2384,616 @@ void CalendarView::changeTodoDisplay(Todo *which, int action)
2384 //mTodoList->updateView(); 2384 //mTodoList->updateView();
2385 } 2385 }
2386 2386
2387} 2387}
2388 2388
2389void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2389void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2390{ 2390{
2391 updateUnmanagedViews(); 2391 updateUnmanagedViews();
2392 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2392 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2393 if ( action == KOGlobals::EVENTDELETED ) { //delete 2393 if ( action == KOGlobals::EVENTDELETED ) { //delete
2394 mCalendar->checkAlarmForIncidence( 0, true ); 2394 mCalendar->checkAlarmForIncidence( 0, true );
2395 if ( mEventViewerDialog ) 2395 if ( mEventViewerDialog )
2396 mEventViewerDialog->hide(); 2396 mEventViewerDialog->hide();
2397 } 2397 }
2398 else 2398 else
2399 mCalendar->checkAlarmForIncidence( which , false ); 2399 mCalendar->checkAlarmForIncidence( which , false );
2400} 2400}
2401 2401
2402// most of the changeEventDisplays() right now just call the view's 2402// most of the changeEventDisplays() right now just call the view's
2403// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2403// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2404void CalendarView::changeEventDisplay(Event *which, int action) 2404void CalendarView::changeEventDisplay(Event *which, int action)
2405{ 2405{
2406 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2406 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2407 changeIncidenceDisplay((Incidence *)which, action); 2407 changeIncidenceDisplay((Incidence *)which, action);
2408 mDateNavigator->updateView(); 2408 mDateNavigator->updateView();
2409 //mDialogManager->updateSearchDialog(); 2409 //mDialogManager->updateSearchDialog();
2410 2410
2411 if (which) { 2411 if (which) {
2412 // If there is an event view visible update the display 2412 // If there is an event view visible update the display
2413 mViewManager->currentView()->changeEventDisplay(which,action); 2413 mViewManager->currentView()->changeEventDisplay(which,action);
2414 // TODO: check, if update needed 2414 // TODO: check, if update needed
2415 // if (which->getTodoStatus()) { 2415 // if (which->getTodoStatus()) {
2416 mTodoList->updateView(); 2416 mTodoList->updateView();
2417 // } 2417 // }
2418 } else { 2418 } else {
2419 mViewManager->currentView()->updateView(); 2419 mViewManager->currentView()->updateView();
2420 } 2420 }
2421} 2421}
2422 2422
2423 2423
2424void CalendarView::updateTodoViews() 2424void CalendarView::updateTodoViews()
2425{ 2425{
2426 mTodoList->updateView(); 2426 mTodoList->updateView();
2427 mViewManager->currentView()->updateView(); 2427 mViewManager->currentView()->updateView();
2428 2428
2429} 2429}
2430 2430
2431 2431
2432void CalendarView::updateView(const QDate &start, const QDate &end) 2432void CalendarView::updateView(const QDate &start, const QDate &end)
2433{ 2433{
2434 mTodoList->updateView(); 2434 mTodoList->updateView();
2435 mViewManager->updateView(start, end); 2435 mViewManager->updateView(start, end);
2436 //mDateNavigator->updateView(); 2436 //mDateNavigator->updateView();
2437} 2437}
2438 2438
2439void CalendarView::clearAllViews() 2439void CalendarView::clearAllViews()
2440{ 2440{
2441 mTodoList->clearList(); 2441 mTodoList->clearList();
2442 mViewManager->clearAllViews(); 2442 mViewManager->clearAllViews();
2443 SearchDialog * sd = mDialogManager->getSearchDialog(); 2443 SearchDialog * sd = mDialogManager->getSearchDialog();
2444 if ( sd ) { 2444 if ( sd ) {
2445 KOListView* kol = sd->listview(); 2445 KOListView* kol = sd->listview();
2446 if ( kol ) 2446 if ( kol )
2447 kol->clearList(); 2447 kol->clearList();
2448 } 2448 }
2449} 2449}
2450void CalendarView::updateView() 2450void CalendarView::updateView()
2451{ 2451{
2452 DateList tmpList = mNavigator->selectedDates(); 2452 DateList tmpList = mNavigator->selectedDates();
2453 2453
2454 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2454 if ( KOPrefs::instance()->mHideNonStartedTodos )
2455 mTodoList->updateView(); 2455 mTodoList->updateView();
2456 // We assume that the navigator only selects consecutive days. 2456 // We assume that the navigator only selects consecutive days.
2457 updateView( tmpList.first(), tmpList.last() ); 2457 updateView( tmpList.first(), tmpList.last() );
2458} 2458}
2459 2459
2460void CalendarView::updateUnmanagedViews() 2460void CalendarView::updateUnmanagedViews()
2461{ 2461{
2462 mDateNavigator->updateDayMatrix(); 2462 mDateNavigator->updateDayMatrix();
2463} 2463}
2464 2464
2465int CalendarView::msgItemDelete(const QString name) 2465int CalendarView::msgItemDelete(const QString name)
2466{ 2466{
2467 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2467 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2468 i18n("This item will be\npermanently deleted."), 2468 i18n("This item will be\npermanently deleted."),
2469 i18n("KO/Pi Confirmation"),i18n("Delete")); 2469 i18n("KO/Pi Confirmation"),i18n("Delete"));
2470} 2470}
2471 2471
2472 2472
2473void CalendarView::edit_cut() 2473void CalendarView::edit_cut()
2474{ 2474{
2475 Event *anEvent=0; 2475 Event *anEvent=0;
2476 2476
2477 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2477 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2478 2478
2479 if (mViewManager->currentView()->isEventView()) { 2479 if (mViewManager->currentView()->isEventView()) {
2480 if ( incidence && incidence->type() == "Event" ) { 2480 if ( incidence && incidence->typeID() == eventID ) {
2481 anEvent = static_cast<Event *>(incidence); 2481 anEvent = static_cast<Event *>(incidence);
2482 } 2482 }
2483 } 2483 }
2484 2484
2485 if (!anEvent) { 2485 if (!anEvent) {
2486 KNotifyClient::beep(); 2486 KNotifyClient::beep();
2487 return; 2487 return;
2488 } 2488 }
2489 DndFactory factory( mCalendar ); 2489 DndFactory factory( mCalendar );
2490 factory.cutIncidence(anEvent); 2490 factory.cutIncidence(anEvent);
2491 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2491 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2492} 2492}
2493 2493
2494void CalendarView::edit_copy() 2494void CalendarView::edit_copy()
2495{ 2495{
2496 Event *anEvent=0; 2496 Event *anEvent=0;
2497 2497
2498 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2498 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2499 2499
2500 if (mViewManager->currentView()->isEventView()) { 2500 if (mViewManager->currentView()->isEventView()) {
2501 if ( incidence && incidence->type() == "Event" ) { 2501 if ( incidence && incidence->typeID() == eventID ) {
2502 anEvent = static_cast<Event *>(incidence); 2502 anEvent = static_cast<Event *>(incidence);
2503 } 2503 }
2504 } 2504 }
2505 2505
2506 if (!anEvent) { 2506 if (!anEvent) {
2507 KNotifyClient::beep(); 2507 KNotifyClient::beep();
2508 return; 2508 return;
2509 } 2509 }
2510 DndFactory factory( mCalendar ); 2510 DndFactory factory( mCalendar );
2511 factory.copyIncidence(anEvent); 2511 factory.copyIncidence(anEvent);
2512} 2512}
2513 2513
2514void CalendarView::edit_paste() 2514void CalendarView::edit_paste()
2515{ 2515{
2516 QDate date = mNavigator->selectedDates().first(); 2516 QDate date = mNavigator->selectedDates().first();
2517 2517
2518 DndFactory factory( mCalendar ); 2518 DndFactory factory( mCalendar );
2519 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2519 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2520 2520
2521 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2521 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2522} 2522}
2523 2523
2524void CalendarView::edit_options() 2524void CalendarView::edit_options()
2525{ 2525{
2526 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2526 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2527 emit save(); 2527 emit save();
2528 emit saveStopTimer(); 2528 emit saveStopTimer();
2529 mDialogManager->showOptionsDialog(); 2529 mDialogManager->showOptionsDialog();
2530 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2530 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2531 emit saveStopTimer(); 2531 emit saveStopTimer();
2532 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2532 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2533 i18n("Timezone settings"),i18n("Reload"))) { 2533 i18n("Timezone settings"),i18n("Reload"))) {
2534 qDebug("KO: TZ reload cancelled "); 2534 qDebug("KO: TZ reload cancelled ");
2535 return; 2535 return;
2536 } 2536 }
2537 qDebug("KO: Timezone change "); 2537 qDebug("KO: Timezone change ");
2538 openCalendar( MainWindow::defaultFileName() ); 2538 openCalendar( MainWindow::defaultFileName() );
2539 setModified(true); 2539 setModified(true);
2540 } 2540 }
2541 else 2541 else
2542 qDebug("KO: No tz change "); 2542 qDebug("KO: No tz change ");
2543 2543
2544} 2544}
2545 2545
2546 2546
2547void CalendarView::slotSelectPickerDate( QDate d) 2547void CalendarView::slotSelectPickerDate( QDate d)
2548{ 2548{
2549 mDateFrame->hide(); 2549 mDateFrame->hide();
2550 if ( mDatePickerMode == 1 ) { 2550 if ( mDatePickerMode == 1 ) {
2551 mNavigator->slotDaySelect( d ); 2551 mNavigator->slotDaySelect( d );
2552 } else if ( mDatePickerMode == 2 ) { 2552 } else if ( mDatePickerMode == 2 ) {
2553 if ( mMoveIncidence->type() == "Todo" ) { 2553 if ( mMoveIncidence->typeID() == todoID ) {
2554 Todo * to = (Todo *) mMoveIncidence; 2554 Todo * to = (Todo *) mMoveIncidence;
2555 QTime tim; 2555 QTime tim;
2556 int len = 0; 2556 int len = 0;
2557 if ( to->hasStartDate() && to->hasDueDate() ) 2557 if ( to->hasStartDate() && to->hasDueDate() )
2558 len = to->dtStart().secsTo( to->dtDue()); 2558 len = to->dtStart().secsTo( to->dtDue());
2559 if ( to->hasDueDate() ) 2559 if ( to->hasDueDate() )
2560 tim = to->dtDue().time(); 2560 tim = to->dtDue().time();
2561 else { 2561 else {
2562 tim = QTime ( 0,0,0 ); 2562 tim = QTime ( 0,0,0 );
2563 to->setFloats( true ); 2563 to->setFloats( true );
2564 to->setHasDueDate( true ); 2564 to->setHasDueDate( true );
2565 } 2565 }
2566 QDateTime dt ( d,tim ); 2566 QDateTime dt ( d,tim );
2567 to->setDtDue( dt ); 2567 to->setDtDue( dt );
2568 2568
2569 if ( to->hasStartDate() ) { 2569 if ( to->hasStartDate() ) {
2570 if ( len>0 ) 2570 if ( len>0 )
2571 to->setDtStart(to->dtDue().addSecs( -len )); 2571 to->setDtStart(to->dtDue().addSecs( -len ));
2572 else 2572 else
2573 if (to->dtStart() > to->dtDue() ) 2573 if (to->dtStart() > to->dtDue() )
2574 to->setDtStart(to->dtDue().addDays( -3 )); 2574 to->setDtStart(to->dtDue().addDays( -3 ));
2575 } 2575 }
2576 2576
2577 todoChanged( to ); 2577 todoChanged( to );
2578 } else { 2578 } else {
2579 if ( mMoveIncidence->doesRecur() ) { 2579 if ( mMoveIncidence->doesRecur() ) {
2580#if 0 2580#if 0
2581 // PENDING implement this 2581 // PENDING implement this
2582 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2582 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2583 mCalendar()->addIncidence( newInc ); 2583 mCalendar()->addIncidence( newInc );
2584 if ( mMoveIncidence->type() == "Todo" ) 2584 if ( mMoveIncidence->typeID() == todoID )
2585 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2585 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2586 else 2586 else
2587 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2587 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2588 mMoveIncidence = newInc; 2588 mMoveIncidence = newInc;
2589 2589
2590#endif 2590#endif
2591 } 2591 }
2592 QTime tim = mMoveIncidence->dtStart().time(); 2592 QTime tim = mMoveIncidence->dtStart().time();
2593 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2593 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2594 QDateTime dt ( d,tim ); 2594 QDateTime dt ( d,tim );
2595 mMoveIncidence->setDtStart( dt ); 2595 mMoveIncidence->setDtStart( dt );
2596 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2596 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2597 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2597 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2598 } 2598 }
2599 2599
2600 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2600 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2601 } 2601 }
2602} 2602}
2603 2603
2604void CalendarView::removeCategories() 2604void CalendarView::removeCategories()
2605{ 2605{
2606 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2606 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2607 QStringList catList = KOPrefs::instance()->mCustomCategories; 2607 QStringList catList = KOPrefs::instance()->mCustomCategories;
2608 QStringList catIncList; 2608 QStringList catIncList;
2609 QStringList newCatList; 2609 QStringList newCatList;
2610 Incidence* inc = incList.first(); 2610 Incidence* inc = incList.first();
2611 int i; 2611 int i;
2612 int count = 0; 2612 int count = 0;
2613 while ( inc ) { 2613 while ( inc ) {
2614 newCatList.clear(); 2614 newCatList.clear();
2615 catIncList = inc->categories() ; 2615 catIncList = inc->categories() ;
2616 for( i = 0; i< catIncList.count(); ++i ) { 2616 for( i = 0; i< catIncList.count(); ++i ) {
2617 if ( catList.contains (catIncList[i])) 2617 if ( catList.contains (catIncList[i]))
2618 newCatList.append( catIncList[i] ); 2618 newCatList.append( catIncList[i] );
2619 } 2619 }
2620 newCatList.sort(); 2620 newCatList.sort();
2621 inc->setCategories( newCatList.join(",") ); 2621 inc->setCategories( newCatList.join(",") );
2622 inc = incList.next(); 2622 inc = incList.next();
2623 } 2623 }
2624} 2624}
2625 2625
2626int CalendarView::addCategories() 2626int CalendarView::addCategories()
2627{ 2627{
2628 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2628 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2629 QStringList catList = KOPrefs::instance()->mCustomCategories; 2629 QStringList catList = KOPrefs::instance()->mCustomCategories;
2630 QStringList catIncList; 2630 QStringList catIncList;
2631 Incidence* inc = incList.first(); 2631 Incidence* inc = incList.first();
2632 int i; 2632 int i;
2633 int count = 0; 2633 int count = 0;
2634 while ( inc ) { 2634 while ( inc ) {
2635 catIncList = inc->categories() ; 2635 catIncList = inc->categories() ;
2636 for( i = 0; i< catIncList.count(); ++i ) { 2636 for( i = 0; i< catIncList.count(); ++i ) {
2637 if ( !catList.contains (catIncList[i])) { 2637 if ( !catList.contains (catIncList[i])) {
2638 catList.append( catIncList[i] ); 2638 catList.append( catIncList[i] );
2639 //qDebug("add cat %s ", catIncList[i].latin1()); 2639 //qDebug("add cat %s ", catIncList[i].latin1());
2640 ++count; 2640 ++count;
2641 } 2641 }
2642 } 2642 }
2643 inc = incList.next(); 2643 inc = incList.next();
2644 } 2644 }
2645 catList.sort(); 2645 catList.sort();
2646 KOPrefs::instance()->mCustomCategories = catList; 2646 KOPrefs::instance()->mCustomCategories = catList;
2647 return count; 2647 return count;
2648} 2648}
2649 2649
2650void CalendarView::manageCategories() 2650void CalendarView::manageCategories()
2651{ 2651{
2652 KOCatPrefs* cp = new KOCatPrefs(); 2652 KOCatPrefs* cp = new KOCatPrefs();
2653 cp->show(); 2653 cp->show();
2654 int w =cp->sizeHint().width() ; 2654 int w =cp->sizeHint().width() ;
2655 int h = cp->sizeHint().height() ; 2655 int h = cp->sizeHint().height() ;
2656 int dw = QApplication::desktop()->width(); 2656 int dw = QApplication::desktop()->width();
2657 int dh = QApplication::desktop()->height(); 2657 int dh = QApplication::desktop()->height();
2658 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2658 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2659 if ( !cp->exec() ) { 2659 if ( !cp->exec() ) {
2660 delete cp; 2660 delete cp;
2661 return; 2661 return;
2662 } 2662 }
2663 int count = 0; 2663 int count = 0;
2664 if ( cp->addCat() ) { 2664 if ( cp->addCat() ) {
2665 count = addCategories(); 2665 count = addCategories();
2666 if ( count ) { 2666 if ( count ) {
2667 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2667 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2668 writeSettings(); 2668 writeSettings();
2669 } else 2669 } else
2670 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2670 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2671 } else { 2671 } else {
2672 removeCategories(); 2672 removeCategories();
2673 updateView(); 2673 updateView();
2674 } 2674 }
2675 delete cp; 2675 delete cp;
2676} 2676}
2677 2677
2678void CalendarView::beamIncidence(Incidence * Inc) 2678void CalendarView::beamIncidence(Incidence * Inc)
2679{ 2679{
2680 QPtrList<Incidence> delSel ; 2680 QPtrList<Incidence> delSel ;
2681 delSel.append(Inc); 2681 delSel.append(Inc);
2682 beamIncidenceList( delSel ); 2682 beamIncidenceList( delSel );
2683} 2683}
2684void CalendarView::beamCalendar() 2684void CalendarView::beamCalendar()
2685{ 2685{
2686 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2686 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2687 //qDebug("beamCalendar() "); 2687 //qDebug("beamCalendar() ");
2688 beamIncidenceList( delSel ); 2688 beamIncidenceList( delSel );
2689} 2689}
2690void CalendarView::beamFilteredCalendar() 2690void CalendarView::beamFilteredCalendar()
2691{ 2691{
2692 QPtrList<Incidence> delSel = mCalendar->incidences(); 2692 QPtrList<Incidence> delSel = mCalendar->incidences();
2693 //qDebug("beamFilteredCalendar() "); 2693 //qDebug("beamFilteredCalendar() ");
2694 beamIncidenceList( delSel ); 2694 beamIncidenceList( delSel );
2695} 2695}
2696void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2696void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2697{ 2697{
2698 if ( beamDialog->exec () == QDialog::Rejected ) 2698 if ( beamDialog->exec () == QDialog::Rejected )
2699 return; 2699 return;
2700#ifdef DESKTOP_VERSION 2700#ifdef DESKTOP_VERSION
2701 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2701 QString fn = locateLocal( "tmp", "kopibeamfile" );
2702#else 2702#else
2703 QString fn = "/tmp/kopibeamfile"; 2703 QString fn = "/tmp/kopibeamfile";
2704#endif 2704#endif
2705 QString mes; 2705 QString mes;
2706 bool createbup = true; 2706 bool createbup = true;
2707 if ( createbup ) { 2707 if ( createbup ) {
2708 QString description = "\n"; 2708 QString description = "\n";
2709 CalendarLocal* cal = new CalendarLocal(); 2709 CalendarLocal* cal = new CalendarLocal();
2710 if ( beamDialog->beamLocal() ) 2710 if ( beamDialog->beamLocal() )
2711 cal->setLocalTime(); 2711 cal->setLocalTime();
2712 else 2712 else
2713 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2713 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2714 Incidence *incidence = delSel.first(); 2714 Incidence *incidence = delSel.first();
2715 bool addText = false; 2715 bool addText = false;
2716 if ( delSel.count() < 10 ) 2716 if ( delSel.count() < 10 )
2717 addText = true; 2717 addText = true;
2718 else { 2718 else {
2719 description.sprintf(i18n(" %d items?"),delSel.count() ); 2719 description.sprintf(i18n(" %d items?"),delSel.count() );
2720 } 2720 }
2721 while ( incidence ) { 2721 while ( incidence ) {
2722 Incidence *in = incidence->clone(); 2722 Incidence *in = incidence->clone();
2723 if ( ! in->summary().isEmpty() ) { 2723 if ( ! in->summary().isEmpty() ) {
2724 in->setDescription(""); 2724 in->setDescription("");
2725 } else { 2725 } else {
2726 in->setSummary( in->description().left(20)); 2726 in->setSummary( in->description().left(20));
2727 in->setDescription(""); 2727 in->setDescription("");
2728 } 2728 }
2729 if ( addText ) 2729 if ( addText )
2730 description += in->summary() + "\n"; 2730 description += in->summary() + "\n";
2731 cal->addIncidence( in ); 2731 cal->addIncidence( in );
2732 incidence = delSel.next(); 2732 incidence = delSel.next();
2733 } 2733 }
2734 if ( beamDialog->beamVcal() ) { 2734 if ( beamDialog->beamVcal() ) {
2735 fn += ".vcs"; 2735 fn += ".vcs";
2736 FileStorage storage( cal, fn, new VCalFormat ); 2736 FileStorage storage( cal, fn, new VCalFormat );
2737 storage.save(); 2737 storage.save();
2738 } else { 2738 } else {
2739 fn += ".ics"; 2739 fn += ".ics";
2740 FileStorage storage( cal, fn, new ICalFormat( ) ); 2740 FileStorage storage( cal, fn, new ICalFormat( ) );
2741 storage.save(); 2741 storage.save();
2742 } 2742 }
2743 delete cal; 2743 delete cal;
2744 mes = i18n("KO/Pi: Ready for beaming"); 2744 mes = i18n("KO/Pi: Ready for beaming");
2745 topLevelWidget()->setCaption(mes); 2745 topLevelWidget()->setCaption(mes);
2746 KApplication::convert2latin1( fn ); 2746 KApplication::convert2latin1( fn );
2747#ifndef DESKTOP_VERSION 2747#ifndef DESKTOP_VERSION
2748 Ir *ir = new Ir( this ); 2748 Ir *ir = new Ir( this );
2749 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2749 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2750 ir->send( fn, description, "text/x-vCalendar" ); 2750 ir->send( fn, description, "text/x-vCalendar" );
2751#endif 2751#endif
2752 } 2752 }
2753} 2753}
2754void CalendarView::beamDone( Ir *ir ) 2754void CalendarView::beamDone( Ir *ir )
2755{ 2755{
2756#ifndef DESKTOP_VERSION 2756#ifndef DESKTOP_VERSION
2757 delete ir; 2757 delete ir;
2758#endif 2758#endif
2759 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2759 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2760 topLevelWidget()->raise(); 2760 topLevelWidget()->raise();
2761} 2761}
2762 2762
2763void CalendarView::moveIncidence(Incidence * inc ) 2763void CalendarView::moveIncidence(Incidence * inc )
2764{ 2764{
2765 if ( !inc ) return; 2765 if ( !inc ) return;
2766 showDatePickerPopup(); 2766 showDatePickerPopup();
2767 mDatePickerMode = 2; 2767 mDatePickerMode = 2;
2768 mMoveIncidence = inc ; 2768 mMoveIncidence = inc ;
2769 QDate da; 2769 QDate da;
2770 if ( mMoveIncidence->type() == "Todo" ) { 2770 if ( mMoveIncidence->typeID() == todoID ) {
2771 Todo * to = (Todo *) mMoveIncidence; 2771 Todo * to = (Todo *) mMoveIncidence;
2772 if ( to->hasDueDate() ) 2772 if ( to->hasDueDate() )
2773 da = to->dtDue().date(); 2773 da = to->dtDue().date();
2774 else 2774 else
2775 da = QDate::currentDate(); 2775 da = QDate::currentDate();
2776 } else { 2776 } else {
2777 da = mMoveIncidence->dtStart().date(); 2777 da = mMoveIncidence->dtStart().date();
2778 } 2778 }
2779 //PENDING set date for recurring incidence to date of recurrence 2779 //PENDING set date for recurring incidence to date of recurrence
2780 //mMoveIncidenceOldDate; 2780 //mMoveIncidenceOldDate;
2781 mDatePicker->setDate( da ); 2781 mDatePicker->setDate( da );
2782} 2782}
2783void CalendarView::showDatePickerPopup() 2783void CalendarView::showDatePickerPopup()
2784{ 2784{
2785 if ( mDateFrame->isVisible() ) 2785 if ( mDateFrame->isVisible() )
2786 mDateFrame->hide(); 2786 mDateFrame->hide();
2787 else { 2787 else {
2788 int offX = 0, offY = 0; 2788 int offX = 0, offY = 0;
2789#ifdef DESKTOP_VERSION 2789#ifdef DESKTOP_VERSION
2790 int w =mDatePicker->sizeHint().width() ; 2790 int w =mDatePicker->sizeHint().width() ;
2791 int h = mDatePicker->sizeHint().height() ; 2791 int h = mDatePicker->sizeHint().height() ;
2792 int dw = topLevelWidget()->width(); 2792 int dw = topLevelWidget()->width();
2793 int dh = topLevelWidget()->height(); 2793 int dh = topLevelWidget()->height();
2794 offX = topLevelWidget()->x(); 2794 offX = topLevelWidget()->x();
2795 offY = topLevelWidget()->y(); 2795 offY = topLevelWidget()->y();
2796#else 2796#else
2797 int w =mDatePicker->sizeHint().width() ; 2797 int w =mDatePicker->sizeHint().width() ;
2798 int h = mDatePicker->sizeHint().height() ; 2798 int h = mDatePicker->sizeHint().height() ;
2799 int dw = QApplication::desktop()->width(); 2799 int dw = QApplication::desktop()->width();
2800 int dh = QApplication::desktop()->height(); 2800 int dh = QApplication::desktop()->height();
2801#endif 2801#endif
2802 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2802 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2803 mDateFrame->show(); 2803 mDateFrame->show();
2804 } 2804 }
2805} 2805}
2806void CalendarView::showDatePicker( ) 2806void CalendarView::showDatePicker( )
2807{ 2807{
2808 showDatePickerPopup(); 2808 showDatePickerPopup();
2809 mDatePickerMode = 1; 2809 mDatePickerMode = 1;
2810 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2810 mDatePicker->setDate( mNavigator->selectedDates().first() );
2811} 2811}
2812 2812
2813void CalendarView::showEventEditor() 2813void CalendarView::showEventEditor()
2814{ 2814{
2815#ifdef DESKTOP_VERSION 2815#ifdef DESKTOP_VERSION
2816 int x,y,w,h; 2816 int x,y,w,h;
2817 x = mEventEditor->geometry().x(); 2817 x = mEventEditor->geometry().x();
2818 y = mEventEditor->geometry().y(); 2818 y = mEventEditor->geometry().y();
2819 w = mEventEditor->width(); 2819 w = mEventEditor->width();
2820 h = mEventEditor->height(); 2820 h = mEventEditor->height();
2821 mEventEditor->show(); 2821 mEventEditor->show();
2822 mEventEditor->setGeometry(x,y,w,h); 2822 mEventEditor->setGeometry(x,y,w,h);
2823#else 2823#else
2824 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2824 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2825 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2825 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2826 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2826 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2827 qApp->processEvents(); 2827 qApp->processEvents();
2828 delete mEventEditor; 2828 delete mEventEditor;
2829 mEventEditor = mDialogManager->getEventEditor(); 2829 mEventEditor = mDialogManager->getEventEditor();
2830 topLevelWidget()->setCaption( i18n("") ); 2830 topLevelWidget()->setCaption( i18n("") );
2831 } 2831 }
2832 mEventEditor->showMaximized(); 2832 mEventEditor->showMaximized();
2833#endif 2833#endif
2834} 2834}
2835void CalendarView::showTodoEditor() 2835void CalendarView::showTodoEditor()
2836{ 2836{
2837#ifdef DESKTOP_VERSION 2837#ifdef DESKTOP_VERSION
2838 int x,y,w,h; 2838 int x,y,w,h;
2839 x = mTodoEditor->geometry().x(); 2839 x = mTodoEditor->geometry().x();
2840 y = mTodoEditor->geometry().y(); 2840 y = mTodoEditor->geometry().y();
2841 w = mTodoEditor->width(); 2841 w = mTodoEditor->width();
2842 h = mTodoEditor->height(); 2842 h = mTodoEditor->height();
2843 mTodoEditor->show(); 2843 mTodoEditor->show();
2844 mTodoEditor->setGeometry(x,y,w,h); 2844 mTodoEditor->setGeometry(x,y,w,h);
2845#else 2845#else
2846 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2846 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2847 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2847 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2848 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2848 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2849 qApp->processEvents(); 2849 qApp->processEvents();
2850 delete mTodoEditor; 2850 delete mTodoEditor;
2851 mTodoEditor = mDialogManager->getTodoEditor(); 2851 mTodoEditor = mDialogManager->getTodoEditor();
2852 topLevelWidget()->setCaption( i18n("") ); 2852 topLevelWidget()->setCaption( i18n("") );
2853 } 2853 }
2854 mTodoEditor->showMaximized(); 2854 mTodoEditor->showMaximized();
2855#endif 2855#endif
2856} 2856}
2857 2857
2858void CalendarView::cloneIncidence() 2858void CalendarView::cloneIncidence()
2859{ 2859{
2860 Incidence *incidence = currentSelection(); 2860 Incidence *incidence = currentSelection();
2861 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2861 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2862 if ( incidence ) { 2862 if ( incidence ) {
2863 cloneIncidence(incidence); 2863 cloneIncidence(incidence);
2864 } 2864 }
2865} 2865}
2866void CalendarView::moveIncidence() 2866void CalendarView::moveIncidence()
2867{ 2867{
2868 Incidence *incidence = currentSelection(); 2868 Incidence *incidence = currentSelection();
2869 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2869 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2870 if ( incidence ) { 2870 if ( incidence ) {
2871 moveIncidence(incidence); 2871 moveIncidence(incidence);
2872 } 2872 }
2873} 2873}
2874void CalendarView::beamIncidence() 2874void CalendarView::beamIncidence()
2875{ 2875{
2876 Incidence *incidence = currentSelection(); 2876 Incidence *incidence = currentSelection();
2877 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2877 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2878 if ( incidence ) { 2878 if ( incidence ) {
2879 beamIncidence(incidence); 2879 beamIncidence(incidence);
2880 } 2880 }
2881} 2881}
2882void CalendarView::toggleCancelIncidence() 2882void CalendarView::toggleCancelIncidence()
2883{ 2883{
2884 Incidence *incidence = currentSelection(); 2884 Incidence *incidence = currentSelection();
2885 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2885 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2886 if ( incidence ) { 2886 if ( incidence ) {
2887 cancelIncidence(incidence); 2887 cancelIncidence(incidence);
2888 } 2888 }
2889} 2889}
2890 2890
2891 2891
2892void CalendarView::cancelIncidence(Incidence * inc ) 2892void CalendarView::cancelIncidence(Incidence * inc )
2893{ 2893{
2894 inc->setCancelled( ! inc->cancelled() ); 2894 inc->setCancelled( ! inc->cancelled() );
2895 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2895 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2896 updateView(); 2896 updateView();
2897} 2897}
2898void CalendarView::cloneIncidence(Incidence * orgInc ) 2898void CalendarView::cloneIncidence(Incidence * orgInc )
2899{ 2899{
2900 Incidence * newInc = orgInc->clone(); 2900 Incidence * newInc = orgInc->clone();
2901 newInc->recreate(); 2901 newInc->recreate();
2902 2902
2903 if ( newInc->type() == "Todo" ) { 2903 if ( newInc->typeID() == todoID ) {
2904 Todo* t = (Todo*) newInc; 2904 Todo* t = (Todo*) newInc;
2905 bool cloneSub = false; 2905 bool cloneSub = false;
2906 if ( orgInc->relations().count() ) { 2906 if ( orgInc->relations().count() ) {
2907 int result = KMessageBox::warningYesNoCancel(this, 2907 int result = KMessageBox::warningYesNoCancel(this,
2908 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2908 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2909 i18n("Todo has subtodos"), 2909 i18n("Todo has subtodos"),
2910 i18n("Yes"), 2910 i18n("Yes"),
2911 i18n("No")); 2911 i18n("No"));
2912 2912
2913 if ( result == KMessageBox::Cancel ) { 2913 if ( result == KMessageBox::Cancel ) {
2914 delete t; 2914 delete t;
2915 return; 2915 return;
2916 } 2916 }
2917 if (result == KMessageBox::Yes) cloneSub = true; 2917 if (result == KMessageBox::Yes) cloneSub = true;
2918 } 2918 }
2919 showTodoEditor(); 2919 showTodoEditor();
2920 mTodoEditor->editTodo( t ); 2920 mTodoEditor->editTodo( t );
2921 if ( mTodoEditor->exec() ) { 2921 if ( mTodoEditor->exec() ) {
2922 if ( cloneSub ) { 2922 if ( cloneSub ) {
2923 orgInc->cloneRelations( t ); 2923 orgInc->cloneRelations( t );
2924 mCalendar->addIncidenceBranch( t ); 2924 mCalendar->addIncidenceBranch( t );
2925 updateView(); 2925 updateView();
2926 2926
2927 } else { 2927 } else {
2928 mCalendar->addTodo( t ); 2928 mCalendar->addTodo( t );
2929 updateView(); 2929 updateView();
2930 } 2930 }
2931 } else { 2931 } else {
2932 delete t; 2932 delete t;
2933 } 2933 }
2934 } 2934 }
2935 else { 2935 else {
2936 Event* e = (Event*) newInc; 2936 Event* e = (Event*) newInc;
2937 showEventEditor(); 2937 showEventEditor();
2938 mEventEditor->editEvent( e ); 2938 mEventEditor->editEvent( e );
2939 if ( mEventEditor->exec() ) { 2939 if ( mEventEditor->exec() ) {
2940 mCalendar->addEvent( e ); 2940 mCalendar->addEvent( e );
2941 updateView(); 2941 updateView();
2942 } else { 2942 } else {
2943 delete e; 2943 delete e;
2944 } 2944 }
2945 } 2945 }
2946 setActiveWindow(); 2946 setActiveWindow();
2947} 2947}
2948 2948
2949void CalendarView::newEvent() 2949void CalendarView::newEvent()
2950{ 2950{
2951 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2951 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2952 KOAgendaView *aView = mViewManager->agendaView(); 2952 KOAgendaView *aView = mViewManager->agendaView();
2953 if (aView) { 2953 if (aView) {
2954 if (aView->selectionStart().isValid()) { 2954 if (aView->selectionStart().isValid()) {
2955 if (aView->selectedIsAllDay()) { 2955 if (aView->selectedIsAllDay()) {
2956 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2956 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2957 } else { 2957 } else {
2958 newEvent(aView->selectionStart(),aView->selectionEnd()); 2958 newEvent(aView->selectionStart(),aView->selectionEnd());
2959 } 2959 }
2960 return; 2960 return;
2961 } 2961 }
2962 } 2962 }
2963 2963
2964 QDate date = mNavigator->selectedDates().first(); 2964 QDate date = mNavigator->selectedDates().first();
2965 QDateTime current = QDateTime::currentDateTime(); 2965 QDateTime current = QDateTime::currentDateTime();
2966 if ( date <= current.date() ) { 2966 if ( date <= current.date() ) {
2967 int hour = current.time().hour() +1; 2967 int hour = current.time().hour() +1;
2968 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2968 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2969 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2969 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2970 } else 2970 } else
2971 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2971 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2972 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2972 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2973 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2973 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2974} 2974}
2975 2975
2976void CalendarView::newEvent(QDateTime fh) 2976void CalendarView::newEvent(QDateTime fh)
2977{ 2977{
2978 newEvent(fh, 2978 newEvent(fh,
2979 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2979 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2980} 2980}
2981 2981
2982void CalendarView::newEvent(QDate dt) 2982void CalendarView::newEvent(QDate dt)
2983{ 2983{
2984 newEvent(QDateTime(dt, QTime(0,0,0)), 2984 newEvent(QDateTime(dt, QTime(0,0,0)),
2985 QDateTime(dt, QTime(0,0,0)), true); 2985 QDateTime(dt, QTime(0,0,0)), true);
2986} 2986}
2987void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2987void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2988{ 2988{
2989 newEvent(fromHint, toHint, false); 2989 newEvent(fromHint, toHint, false);
2990} 2990}
2991void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2991void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2992{ 2992{
2993 2993
2994 showEventEditor(); 2994 showEventEditor();
2995 mEventEditor->newEvent(fromHint,toHint,allDay); 2995 mEventEditor->newEvent(fromHint,toHint,allDay);
2996 if ( mFilterView->filtersEnabled() ) { 2996 if ( mFilterView->filtersEnabled() ) {
2997 CalFilter *filter = mFilterView->selectedFilter(); 2997 CalFilter *filter = mFilterView->selectedFilter();
2998 if (filter && filter->showCategories()) { 2998 if (filter && filter->showCategories()) {
2999 mEventEditor->setCategories(filter->categoryList().join(",") ); 2999 mEventEditor->setCategories(filter->categoryList().join(",") );
@@ -3071,233 +3071,233 @@ void CalendarView::newFloatingEvent()
3071 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3071 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3072 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3072 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3073} 3073}
3074 3074
3075 3075
3076void CalendarView::editEvent( Event *event ) 3076void CalendarView::editEvent( Event *event )
3077{ 3077{
3078 3078
3079 if ( !event ) return; 3079 if ( !event ) return;
3080 if ( event->isReadOnly() ) { 3080 if ( event->isReadOnly() ) {
3081 showEvent( event ); 3081 showEvent( event );
3082 return; 3082 return;
3083 } 3083 }
3084 showEventEditor(); 3084 showEventEditor();
3085 mEventEditor->editEvent( event , mFlagEditDescription); 3085 mEventEditor->editEvent( event , mFlagEditDescription);
3086 mEventEditor->exec(); 3086 mEventEditor->exec();
3087 setActiveWindow(); 3087 setActiveWindow();
3088 3088
3089} 3089}
3090void CalendarView::editJournal( Journal *jour ) 3090void CalendarView::editJournal( Journal *jour )
3091{ 3091{
3092 if ( !jour ) return; 3092 if ( !jour ) return;
3093 mDialogManager->hideSearchDialog(); 3093 mDialogManager->hideSearchDialog();
3094 mViewManager->showJournalView(); 3094 mViewManager->showJournalView();
3095 mNavigator->slotDaySelect( jour->dtStart().date() ); 3095 mNavigator->slotDaySelect( jour->dtStart().date() );
3096} 3096}
3097void CalendarView::editTodo( Todo *todo ) 3097void CalendarView::editTodo( Todo *todo )
3098{ 3098{
3099 if ( !todo ) return; 3099 if ( !todo ) return;
3100 3100
3101 if ( todo->isReadOnly() ) { 3101 if ( todo->isReadOnly() ) {
3102 showTodo( todo ); 3102 showTodo( todo );
3103 return; 3103 return;
3104 } 3104 }
3105 showTodoEditor(); 3105 showTodoEditor();
3106 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3106 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3107 mTodoEditor->exec(); 3107 mTodoEditor->exec();
3108 setActiveWindow(); 3108 setActiveWindow();
3109 3109
3110} 3110}
3111 3111
3112KOEventViewerDialog* CalendarView::getEventViewerDialog() 3112KOEventViewerDialog* CalendarView::getEventViewerDialog()
3113{ 3113{
3114 if ( !mEventViewerDialog ) { 3114 if ( !mEventViewerDialog ) {
3115 mEventViewerDialog = new KOEventViewerDialog(0); 3115 mEventViewerDialog = new KOEventViewerDialog(0);
3116 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3116 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3117 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3117 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3118 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3118 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3119 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3119 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3120 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3120 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3121 viewManager(), SLOT( showAgendaView( bool ) ) ); 3121 viewManager(), SLOT( showAgendaView( bool ) ) );
3122 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3122 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3123 this, SLOT( slotViewerClosed() ) ); 3123 this, SLOT( slotViewerClosed() ) );
3124 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3124 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3125 this, SLOT( todoChanged(Todo *) ) ); 3125 this, SLOT( todoChanged(Todo *) ) );
3126 mEventViewerDialog->resize( 640, 480 ); 3126 mEventViewerDialog->resize( 640, 480 );
3127 3127
3128 } 3128 }
3129 return mEventViewerDialog; 3129 return mEventViewerDialog;
3130} 3130}
3131void CalendarView::showEvent(Event *event) 3131void CalendarView::showEvent(Event *event)
3132{ 3132{
3133 getEventViewerDialog()->setEvent(event); 3133 getEventViewerDialog()->setEvent(event);
3134 getEventViewerDialog()->showMe(); 3134 getEventViewerDialog()->showMe();
3135} 3135}
3136 3136
3137void CalendarView::showTodo(Todo *event) 3137void CalendarView::showTodo(Todo *event)
3138{ 3138{
3139 getEventViewerDialog()->setTodo(event); 3139 getEventViewerDialog()->setTodo(event);
3140 getEventViewerDialog()->showMe(); 3140 getEventViewerDialog()->showMe();
3141} 3141}
3142void CalendarView::showJournal( Journal *jour ) 3142void CalendarView::showJournal( Journal *jour )
3143{ 3143{
3144 getEventViewerDialog()->setJournal(jour); 3144 getEventViewerDialog()->setJournal(jour);
3145 getEventViewerDialog()->showMe(); 3145 getEventViewerDialog()->showMe();
3146 3146
3147} 3147}
3148// void CalendarView::todoModified (Todo *event, int changed) 3148// void CalendarView::todoModified (Todo *event, int changed)
3149// { 3149// {
3150// // if (mDialogList.find (event) != mDialogList.end ()) { 3150// // if (mDialogList.find (event) != mDialogList.end ()) {
3151// // kdDebug() << "Todo modified and open" << endl; 3151// // kdDebug() << "Todo modified and open" << endl;
3152// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3152// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3153// // temp->modified (changed); 3153// // temp->modified (changed);
3154 3154
3155// // } 3155// // }
3156 3156
3157// mViewManager->updateView(); 3157// mViewManager->updateView();
3158// } 3158// }
3159 3159
3160void CalendarView::appointment_show() 3160void CalendarView::appointment_show()
3161{ 3161{
3162 Event *anEvent = 0; 3162 Event *anEvent = 0;
3163 3163
3164 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3164 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3165 3165
3166 if (mViewManager->currentView()->isEventView()) { 3166 if (mViewManager->currentView()->isEventView()) {
3167 if ( incidence && incidence->type() == "Event" ) { 3167 if ( incidence && incidence->typeID() == eventID ) {
3168 anEvent = static_cast<Event *>(incidence); 3168 anEvent = static_cast<Event *>(incidence);
3169 } 3169 }
3170 } 3170 }
3171 3171
3172 if (!anEvent) { 3172 if (!anEvent) {
3173 KNotifyClient::beep(); 3173 KNotifyClient::beep();
3174 return; 3174 return;
3175 } 3175 }
3176 3176
3177 showEvent(anEvent); 3177 showEvent(anEvent);
3178} 3178}
3179 3179
3180void CalendarView::appointment_edit() 3180void CalendarView::appointment_edit()
3181{ 3181{
3182 Event *anEvent = 0; 3182 Event *anEvent = 0;
3183 3183
3184 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3184 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3185 3185
3186 if (mViewManager->currentView()->isEventView()) { 3186 if (mViewManager->currentView()->isEventView()) {
3187 if ( incidence && incidence->type() == "Event" ) { 3187 if ( incidence && incidence->typeID() == eventID ) {
3188 anEvent = static_cast<Event *>(incidence); 3188 anEvent = static_cast<Event *>(incidence);
3189 } 3189 }
3190 } 3190 }
3191 3191
3192 if (!anEvent) { 3192 if (!anEvent) {
3193 KNotifyClient::beep(); 3193 KNotifyClient::beep();
3194 return; 3194 return;
3195 } 3195 }
3196 3196
3197 editEvent(anEvent); 3197 editEvent(anEvent);
3198} 3198}
3199 3199
3200void CalendarView::appointment_delete() 3200void CalendarView::appointment_delete()
3201{ 3201{
3202 Event *anEvent = 0; 3202 Event *anEvent = 0;
3203 3203
3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3205 3205
3206 if (mViewManager->currentView()->isEventView()) { 3206 if (mViewManager->currentView()->isEventView()) {
3207 if ( incidence && incidence->type() == "Event" ) { 3207 if ( incidence && incidence->typeID() == eventID ) {
3208 anEvent = static_cast<Event *>(incidence); 3208 anEvent = static_cast<Event *>(incidence);
3209 } 3209 }
3210 } 3210 }
3211 3211
3212 if (!anEvent) { 3212 if (!anEvent) {
3213 KNotifyClient::beep(); 3213 KNotifyClient::beep();
3214 return; 3214 return;
3215 } 3215 }
3216 3216
3217 deleteEvent(anEvent); 3217 deleteEvent(anEvent);
3218} 3218}
3219 3219
3220void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3220void CalendarView::todo_resub( Todo * parent, Todo * sub )
3221{ 3221{
3222 if (!sub) return; 3222 if (!sub) return;
3223 if ( sub->relatedTo() == parent ) 3223 if ( sub->relatedTo() == parent )
3224 return; 3224 return;
3225 sub->setRelatedTo(parent); 3225 sub->setRelatedTo(parent);
3226 sub->updated(); 3226 sub->updated();
3227 setModified(true); 3227 setModified(true);
3228 updateView(); 3228 updateView();
3229} 3229}
3230void CalendarView::todo_unsub(Todo *anTodo ) 3230void CalendarView::todo_unsub(Todo *anTodo )
3231{ 3231{
3232 todo_resub( 0, anTodo ); 3232 todo_resub( 0, anTodo );
3233} 3233}
3234 3234
3235void CalendarView::deleteTodo(Todo *todo) 3235void CalendarView::deleteTodo(Todo *todo)
3236{ 3236{
3237 if (!todo) { 3237 if (!todo) {
3238 KNotifyClient::beep(); 3238 KNotifyClient::beep();
3239 return; 3239 return;
3240 } 3240 }
3241 if (KOPrefs::instance()->mConfirm) { 3241 if (KOPrefs::instance()->mConfirm) {
3242 QString text = todo->summary().left(20); 3242 QString text = todo->summary().left(20);
3243 if (!todo->relations().isEmpty()) { 3243 if (!todo->relations().isEmpty()) {
3244 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3244 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3245 3245
3246 } 3246 }
3247 switch (msgItemDelete(text)) { 3247 switch (msgItemDelete(text)) {
3248 case KMessageBox::Continue: // OK 3248 case KMessageBox::Continue: // OK
3249 bool deleteT = false; 3249 bool deleteT = false;
3250 if (!todo->relations().isEmpty()) { 3250 if (!todo->relations().isEmpty()) {
3251 deleteT = removeCompletedSubTodos( todo ); 3251 deleteT = removeCompletedSubTodos( todo );
3252 } 3252 }
3253 // deleteT == true: todo already deleted in removeCompletedSubTodos 3253 // deleteT == true: todo already deleted in removeCompletedSubTodos
3254 if ( !deleteT ) { 3254 if ( !deleteT ) {
3255 checkExternalId( todo ); 3255 checkExternalId( todo );
3256 calendar()->deleteTodo(todo); 3256 calendar()->deleteTodo(todo);
3257 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3257 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3258 updateView(); 3258 updateView();
3259 } 3259 }
3260 break; 3260 break;
3261 } // switch 3261 } // switch
3262 } else { 3262 } else {
3263 checkExternalId( todo ); 3263 checkExternalId( todo );
3264 mCalendar->deleteTodo(todo); 3264 mCalendar->deleteTodo(todo);
3265 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3265 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3266 updateView(); 3266 updateView();
3267 } 3267 }
3268 3268
3269 emit updateSearchDialog(); 3269 emit updateSearchDialog();
3270} 3270}
3271void CalendarView::deleteJournal(Journal *jour) 3271void CalendarView::deleteJournal(Journal *jour)
3272{ 3272{
3273 if (!jour) { 3273 if (!jour) {
3274 KNotifyClient::beep(); 3274 KNotifyClient::beep();
3275 return; 3275 return;
3276 } 3276 }
3277 if (KOPrefs::instance()->mConfirm) { 3277 if (KOPrefs::instance()->mConfirm) {
3278 switch (msgItemDelete( jour->description().left(20))) { 3278 switch (msgItemDelete( jour->description().left(20))) {
3279 case KMessageBox::Continue: // OK 3279 case KMessageBox::Continue: // OK
3280 calendar()->deleteJournal(jour); 3280 calendar()->deleteJournal(jour);
3281 updateView(); 3281 updateView();
3282 break; 3282 break;
3283 } // switch 3283 } // switch
3284 } else { 3284 } else {
3285 calendar()->deleteJournal(jour);; 3285 calendar()->deleteJournal(jour);;
3286 updateView(); 3286 updateView();
3287 } 3287 }
3288 emit updateSearchDialog(); 3288 emit updateSearchDialog();
3289} 3289}
3290 3290
3291void CalendarView::deleteEvent(Event *anEvent) 3291void CalendarView::deleteEvent(Event *anEvent)
3292{ 3292{
3293 if (!anEvent) { 3293 if (!anEvent) {
3294 KNotifyClient::beep(); 3294 KNotifyClient::beep();
3295 return; 3295 return;
3296 } 3296 }
3297 3297
3298 if (anEvent->recurrence()->doesRecur()) { 3298 if (anEvent->recurrence()->doesRecur()) {
3299 QDate itemDate = mViewManager->currentSelectionDate(); 3299 QDate itemDate = mViewManager->currentSelectionDate();
3300 int km; 3300 int km;
3301 if (!itemDate.isValid()) { 3301 if (!itemDate.isValid()) {
3302 //kdDebug() << "Date Not Valid" << endl; 3302 //kdDebug() << "Date Not Valid" << endl;
3303 if (KOPrefs::instance()->mConfirm) { 3303 if (KOPrefs::instance()->mConfirm) {
@@ -3312,356 +3312,356 @@ void CalendarView::deleteEvent(Event *anEvent)
3312 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3312 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3313 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3313 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3314 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3314 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3315 i18n("KO/Pi Confirmation"),i18n("Current"), 3315 i18n("KO/Pi Confirmation"),i18n("Current"),
3316 i18n("All")); 3316 i18n("All"));
3317 } 3317 }
3318 switch(km) { 3318 switch(km) {
3319 3319
3320 case KMessageBox::No: // Continue // all 3320 case KMessageBox::No: // Continue // all
3321 //qDebug("KMessageBox::No "); 3321 //qDebug("KMessageBox::No ");
3322 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3322 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3323 schedule(Scheduler::Cancel,anEvent); 3323 schedule(Scheduler::Cancel,anEvent);
3324 3324
3325 checkExternalId( anEvent); 3325 checkExternalId( anEvent);
3326 mCalendar->deleteEvent(anEvent); 3326 mCalendar->deleteEvent(anEvent);
3327 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3327 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3328 break; 3328 break;
3329 3329
3330 // Disabled because it does not work 3330 // Disabled because it does not work
3331 //#if 0 3331 //#if 0
3332 case KMessageBox::Yes: // just this one 3332 case KMessageBox::Yes: // just this one
3333 //QDate qd = mNavigator->selectedDates().first(); 3333 //QDate qd = mNavigator->selectedDates().first();
3334 //if (!qd.isValid()) { 3334 //if (!qd.isValid()) {
3335 // kdDebug() << "no date selected, or invalid date" << endl; 3335 // kdDebug() << "no date selected, or invalid date" << endl;
3336 // KNotifyClient::beep(); 3336 // KNotifyClient::beep();
3337 // return; 3337 // return;
3338 //} 3338 //}
3339 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3339 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3340 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3340 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3341 anEvent->addExDate(itemDate); 3341 anEvent->addExDate(itemDate);
3342 int duration = anEvent->recurrence()->duration(); 3342 int duration = anEvent->recurrence()->duration();
3343 if ( duration > 0 ) { 3343 if ( duration > 0 ) {
3344 anEvent->recurrence()->setDuration( duration - 1 ); 3344 anEvent->recurrence()->setDuration( duration - 1 );
3345 } 3345 }
3346 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3346 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3347 } 3347 }
3348 break; 3348 break;
3349 //#endif 3349 //#endif
3350 } // switch 3350 } // switch
3351 } else { 3351 } else {
3352 if (KOPrefs::instance()->mConfirm) { 3352 if (KOPrefs::instance()->mConfirm) {
3353 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3353 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3354 i18n("\nAre you sure you want\nto delete this event?"), 3354 i18n("\nAre you sure you want\nto delete this event?"),
3355 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3355 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3356 case KMessageBox::Continue: // OK 3356 case KMessageBox::Continue: // OK
3357 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3357 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3358 schedule(Scheduler::Cancel,anEvent); 3358 schedule(Scheduler::Cancel,anEvent);
3359 checkExternalId( anEvent); 3359 checkExternalId( anEvent);
3360 mCalendar->deleteEvent(anEvent); 3360 mCalendar->deleteEvent(anEvent);
3361 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3361 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3362 break; 3362 break;
3363 } // switch 3363 } // switch
3364 } else { 3364 } else {
3365 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3365 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3366 schedule(Scheduler::Cancel,anEvent); 3366 schedule(Scheduler::Cancel,anEvent);
3367 checkExternalId( anEvent); 3367 checkExternalId( anEvent);
3368 mCalendar->deleteEvent(anEvent); 3368 mCalendar->deleteEvent(anEvent);
3369 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3369 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3370 } 3370 }
3371 } // if-else 3371 } // if-else
3372 emit updateSearchDialog(); 3372 emit updateSearchDialog();
3373} 3373}
3374 3374
3375bool CalendarView::deleteEvent(const QString &uid) 3375bool CalendarView::deleteEvent(const QString &uid)
3376{ 3376{
3377 Event *ev = mCalendar->event(uid); 3377 Event *ev = mCalendar->event(uid);
3378 if (ev) { 3378 if (ev) {
3379 deleteEvent(ev); 3379 deleteEvent(ev);
3380 return true; 3380 return true;
3381 } else { 3381 } else {
3382 return false; 3382 return false;
3383 } 3383 }
3384} 3384}
3385 3385
3386/*****************************************************************************/ 3386/*****************************************************************************/
3387 3387
3388void CalendarView::action_mail() 3388void CalendarView::action_mail()
3389{ 3389{
3390#ifndef KORG_NOMAIL 3390#ifndef KORG_NOMAIL
3391 KOMailClient mailClient; 3391 KOMailClient mailClient;
3392 3392
3393 Incidence *incidence = currentSelection(); 3393 Incidence *incidence = currentSelection();
3394 3394
3395 if (!incidence) { 3395 if (!incidence) {
3396 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3396 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3397 return; 3397 return;
3398 } 3398 }
3399 if(incidence->attendeeCount() == 0 ) { 3399 if(incidence->attendeeCount() == 0 ) {
3400 KMessageBox::sorry(this, 3400 KMessageBox::sorry(this,
3401 i18n("Can't generate mail:\nNo attendees defined.\n")); 3401 i18n("Can't generate mail:\nNo attendees defined.\n"));
3402 return; 3402 return;
3403 } 3403 }
3404 3404
3405 CalendarLocal cal_tmp; 3405 CalendarLocal cal_tmp;
3406 Event *event = 0; 3406 Event *event = 0;
3407 Event *ev = 0; 3407 Event *ev = 0;
3408 if ( incidence && incidence->type() == "Event" ) { 3408 if ( incidence && incidence->typeID() == eventID ) {
3409 event = static_cast<Event *>(incidence); 3409 event = static_cast<Event *>(incidence);
3410 ev = new Event(*event); 3410 ev = new Event(*event);
3411 cal_tmp.addEvent(ev); 3411 cal_tmp.addEvent(ev);
3412 } 3412 }
3413 ICalFormat mForm(); 3413 ICalFormat mForm();
3414 QString attachment = mForm.toString( &cal_tmp ); 3414 QString attachment = mForm.toString( &cal_tmp );
3415 if (ev) delete(ev); 3415 if (ev) delete(ev);
3416 3416
3417 mailClient.mailAttendees(currentSelection(), attachment); 3417 mailClient.mailAttendees(currentSelection(), attachment);
3418 3418
3419#endif 3419#endif
3420 3420
3421#if 0 3421#if 0
3422 Event *anEvent = 0; 3422 Event *anEvent = 0;
3423 if (mViewManager->currentView()->isEventView()) { 3423 if (mViewManager->currentView()->isEventView()) {
3424 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3424 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3425 } 3425 }
3426 3426
3427 if (!anEvent) { 3427 if (!anEvent) {
3428 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3428 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3429 return; 3429 return;
3430 } 3430 }
3431 if(anEvent->attendeeCount() == 0 ) { 3431 if(anEvent->attendeeCount() == 0 ) {
3432 KMessageBox::sorry(this, 3432 KMessageBox::sorry(this,
3433 i18n("Can't generate mail:\nNo attendees defined.\n")); 3433 i18n("Can't generate mail:\nNo attendees defined.\n"));
3434 return; 3434 return;
3435 } 3435 }
3436 3436
3437 mailobject.emailEvent(anEvent); 3437 mailobject.emailEvent(anEvent);
3438#endif 3438#endif
3439} 3439}
3440 3440
3441 3441
3442void CalendarView::schedule_publish(Incidence *incidence) 3442void CalendarView::schedule_publish(Incidence *incidence)
3443{ 3443{
3444 Event *event = 0; 3444 Event *event = 0;
3445 Todo *todo = 0; 3445 Todo *todo = 0;
3446 3446
3447 if (incidence == 0) { 3447 if (incidence == 0) {
3448 incidence = mViewManager->currentView()->selectedIncidences().first(); 3448 incidence = mViewManager->currentView()->selectedIncidences().first();
3449 if (incidence == 0) { 3449 if (incidence == 0) {
3450 incidence = mTodoList->selectedIncidences().first(); 3450 incidence = mTodoList->selectedIncidences().first();
3451 } 3451 }
3452 } 3452 }
3453 if ( incidence && incidence->type() == "Event" ) { 3453 if ( incidence && incidence->typeID() == eventID ) {
3454 event = static_cast<Event *>(incidence); 3454 event = static_cast<Event *>(incidence);
3455 } else { 3455 } else {
3456 if ( incidence && incidence->type() == "Todo" ) { 3456 if ( incidence && incidence->typeID() == todoID ) {
3457 todo = static_cast<Todo *>(incidence); 3457 todo = static_cast<Todo *>(incidence);
3458 } 3458 }
3459 } 3459 }
3460 3460
3461 if (!event && !todo) { 3461 if (!event && !todo) {
3462 KMessageBox::sorry(this,i18n("No event selected.")); 3462 KMessageBox::sorry(this,i18n("No event selected."));
3463 return; 3463 return;
3464 } 3464 }
3465 3465
3466 PublishDialog *publishdlg = new PublishDialog(); 3466 PublishDialog *publishdlg = new PublishDialog();
3467 if (incidence->attendeeCount()>0) { 3467 if (incidence->attendeeCount()>0) {
3468 QPtrList<Attendee> attendees = incidence->attendees(); 3468 QPtrList<Attendee> attendees = incidence->attendees();
3469 attendees.first(); 3469 attendees.first();
3470 while ( attendees.current()!=0 ) { 3470 while ( attendees.current()!=0 ) {
3471 publishdlg->addAttendee(attendees.current()); 3471 publishdlg->addAttendee(attendees.current());
3472 attendees.next(); 3472 attendees.next();
3473 } 3473 }
3474 } 3474 }
3475 bool send = true; 3475 bool send = true;
3476 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3476 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3477 if ( publishdlg->exec() != QDialog::Accepted ) 3477 if ( publishdlg->exec() != QDialog::Accepted )
3478 send = false; 3478 send = false;
3479 } 3479 }
3480 if ( send ) { 3480 if ( send ) {
3481 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3481 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3482 if ( event ) { 3482 if ( event ) {
3483 Event *ev = new Event(*event); 3483 Event *ev = new Event(*event);
3484 ev->registerObserver(0); 3484 ev->registerObserver(0);
3485 ev->clearAttendees(); 3485 ev->clearAttendees();
3486 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3486 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3487 delete(ev); 3487 delete(ev);
3488 } 3488 }
3489 } else { 3489 } else {
3490 if ( todo ) { 3490 if ( todo ) {
3491 Todo *ev = new Todo(*todo); 3491 Todo *ev = new Todo(*todo);
3492 ev->registerObserver(0); 3492 ev->registerObserver(0);
3493 ev->clearAttendees(); 3493 ev->clearAttendees();
3494 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3494 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3495 delete(ev); 3495 delete(ev);
3496 } 3496 }
3497 } 3497 }
3498 } 3498 }
3499 } 3499 }
3500 delete publishdlg; 3500 delete publishdlg;
3501} 3501}
3502 3502
3503void CalendarView::schedule_request(Incidence *incidence) 3503void CalendarView::schedule_request(Incidence *incidence)
3504{ 3504{
3505 schedule(Scheduler::Request,incidence); 3505 schedule(Scheduler::Request,incidence);
3506} 3506}
3507 3507
3508void CalendarView::schedule_refresh(Incidence *incidence) 3508void CalendarView::schedule_refresh(Incidence *incidence)
3509{ 3509{
3510 schedule(Scheduler::Refresh,incidence); 3510 schedule(Scheduler::Refresh,incidence);
3511} 3511}
3512 3512
3513void CalendarView::schedule_cancel(Incidence *incidence) 3513void CalendarView::schedule_cancel(Incidence *incidence)
3514{ 3514{
3515 schedule(Scheduler::Cancel,incidence); 3515 schedule(Scheduler::Cancel,incidence);
3516} 3516}
3517 3517
3518void CalendarView::schedule_add(Incidence *incidence) 3518void CalendarView::schedule_add(Incidence *incidence)
3519{ 3519{
3520 schedule(Scheduler::Add,incidence); 3520 schedule(Scheduler::Add,incidence);
3521} 3521}
3522 3522
3523void CalendarView::schedule_reply(Incidence *incidence) 3523void CalendarView::schedule_reply(Incidence *incidence)
3524{ 3524{
3525 schedule(Scheduler::Reply,incidence); 3525 schedule(Scheduler::Reply,incidence);
3526} 3526}
3527 3527
3528void CalendarView::schedule_counter(Incidence *incidence) 3528void CalendarView::schedule_counter(Incidence *incidence)
3529{ 3529{
3530 schedule(Scheduler::Counter,incidence); 3530 schedule(Scheduler::Counter,incidence);
3531} 3531}
3532 3532
3533void CalendarView::schedule_declinecounter(Incidence *incidence) 3533void CalendarView::schedule_declinecounter(Incidence *incidence)
3534{ 3534{
3535 schedule(Scheduler::Declinecounter,incidence); 3535 schedule(Scheduler::Declinecounter,incidence);
3536} 3536}
3537 3537
3538void CalendarView::schedule_publish_freebusy(int daysToPublish) 3538void CalendarView::schedule_publish_freebusy(int daysToPublish)
3539{ 3539{
3540 QDateTime start = QDateTime::currentDateTime(); 3540 QDateTime start = QDateTime::currentDateTime();
3541 QDateTime end = start.addDays(daysToPublish); 3541 QDateTime end = start.addDays(daysToPublish);
3542 3542
3543 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3543 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3544 freebusy->setOrganizer(KOPrefs::instance()->email()); 3544 freebusy->setOrganizer(KOPrefs::instance()->email());
3545 3545
3546 3546
3547 PublishDialog *publishdlg = new PublishDialog(); 3547 PublishDialog *publishdlg = new PublishDialog();
3548 if ( publishdlg->exec() == QDialog::Accepted ) { 3548 if ( publishdlg->exec() == QDialog::Accepted ) {
3549 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3549 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3550 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3550 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3551 delete(freebusy); 3551 delete(freebusy);
3552 } 3552 }
3553 } 3553 }
3554 delete publishdlg; 3554 delete publishdlg;
3555} 3555}
3556 3556
3557void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3557void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3558{ 3558{
3559 Event *event = 0; 3559 Event *event = 0;
3560 Todo *todo = 0; 3560 Todo *todo = 0;
3561 3561
3562 if (incidence == 0) { 3562 if (incidence == 0) {
3563 incidence = mViewManager->currentView()->selectedIncidences().first(); 3563 incidence = mViewManager->currentView()->selectedIncidences().first();
3564 if (incidence == 0) { 3564 if (incidence == 0) {
3565 incidence = mTodoList->selectedIncidences().first(); 3565 incidence = mTodoList->selectedIncidences().first();
3566 } 3566 }
3567 } 3567 }
3568 if ( incidence && incidence->type() == "Event" ) { 3568 if ( incidence && incidence->typeID() == eventID ) {
3569 event = static_cast<Event *>(incidence); 3569 event = static_cast<Event *>(incidence);
3570 } 3570 }
3571 if ( incidence && incidence->type() == "Todo" ) { 3571 if ( incidence && incidence->typeID() == todoID ) {
3572 todo = static_cast<Todo *>(incidence); 3572 todo = static_cast<Todo *>(incidence);
3573 } 3573 }
3574 3574
3575 if (!event && !todo) { 3575 if (!event && !todo) {
3576 KMessageBox::sorry(this,i18n("No event selected.")); 3576 KMessageBox::sorry(this,i18n("No event selected."));
3577 return; 3577 return;
3578 } 3578 }
3579 3579
3580 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3580 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3581 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3581 KMessageBox::sorry(this,i18n("The event has no attendees."));
3582 return; 3582 return;
3583 } 3583 }
3584 3584
3585 Event *ev = 0; 3585 Event *ev = 0;
3586 if (event) ev = new Event(*event); 3586 if (event) ev = new Event(*event);
3587 Todo *to = 0; 3587 Todo *to = 0;
3588 if (todo) to = new Todo(*todo); 3588 if (todo) to = new Todo(*todo);
3589 3589
3590 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3590 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3591 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3591 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3592 if (!me) { 3592 if (!me) {
3593 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3593 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3594 return; 3594 return;
3595 } 3595 }
3596 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3596 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3597 StatusDialog *statdlg = new StatusDialog(this); 3597 StatusDialog *statdlg = new StatusDialog(this);
3598 if (!statdlg->exec()==QDialog::Accepted) return; 3598 if (!statdlg->exec()==QDialog::Accepted) return;
3599 me->setStatus( statdlg->status() ); 3599 me->setStatus( statdlg->status() );
3600 delete(statdlg); 3600 delete(statdlg);
3601 } 3601 }
3602 Attendee *menew = new Attendee(*me); 3602 Attendee *menew = new Attendee(*me);
3603 if (ev) { 3603 if (ev) {
3604 ev->clearAttendees(); 3604 ev->clearAttendees();
3605 ev->addAttendee(menew,false); 3605 ev->addAttendee(menew,false);
3606 } else { 3606 } else {
3607 if (to) { 3607 if (to) {
3608 todo->clearAttendees(); 3608 todo->clearAttendees();
3609 todo->addAttendee(menew,false); 3609 todo->addAttendee(menew,false);
3610 } 3610 }
3611 } 3611 }
3612 } 3612 }
3613 3613
3614 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3614 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3615 if (ev) { 3615 if (ev) {
3616 if ( !dlg->addMessage(ev,method) ) delete(ev); 3616 if ( !dlg->addMessage(ev,method) ) delete(ev);
3617 } else { 3617 } else {
3618 if (to) { 3618 if (to) {
3619 if ( !dlg->addMessage(to,method) ) delete(to); 3619 if ( !dlg->addMessage(to,method) ) delete(to);
3620 } 3620 }
3621 } 3621 }
3622} 3622}
3623 3623
3624void CalendarView::openAddressbook() 3624void CalendarView::openAddressbook()
3625{ 3625{
3626 KRun::runCommand("kaddressbook"); 3626 KRun::runCommand("kaddressbook");
3627} 3627}
3628 3628
3629void CalendarView::setModified(bool modified) 3629void CalendarView::setModified(bool modified)
3630{ 3630{
3631 if ( modified ) 3631 if ( modified )
3632 emit signalmodified(); 3632 emit signalmodified();
3633 if (mModified != modified) { 3633 if (mModified != modified) {
3634 mModified = modified; 3634 mModified = modified;
3635 emit modifiedChanged(mModified); 3635 emit modifiedChanged(mModified);
3636 } 3636 }
3637} 3637}
3638 3638
3639bool CalendarView::isReadOnly() 3639bool CalendarView::isReadOnly()
3640{ 3640{
3641 return mReadOnly; 3641 return mReadOnly;
3642} 3642}
3643 3643
3644void CalendarView::setReadOnly(bool readOnly) 3644void CalendarView::setReadOnly(bool readOnly)
3645{ 3645{
3646 if (mReadOnly != readOnly) { 3646 if (mReadOnly != readOnly) {
3647 mReadOnly = readOnly; 3647 mReadOnly = readOnly;
3648 emit readOnlyChanged(mReadOnly); 3648 emit readOnlyChanged(mReadOnly);
3649 } 3649 }
3650} 3650}
3651 3651
3652bool CalendarView::isModified() 3652bool CalendarView::isModified()
3653{ 3653{
3654 return mModified; 3654 return mModified;
3655} 3655}
3656void CalendarView::slotprintSelInc() 3656void CalendarView::slotprintSelInc()
3657{ 3657{
3658 if ( currentSelection() == 0 ) { 3658 if ( currentSelection() == 0 ) {
3659 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3659 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3660 return; 3660 return;
3661 } 3661 }
3662 showIncidence(); 3662 showIncidence();
3663 getEventViewerDialog()->print(); 3663 getEventViewerDialog()->print();
3664 3664
3665} 3665}
3666void CalendarView::printSetup() 3666void CalendarView::printSetup()
3667{ 3667{
@@ -3679,231 +3679,231 @@ void CalendarView::print()
3679 3679
3680 DateList tmpDateList = mNavigator->selectedDates(); 3680 DateList tmpDateList = mNavigator->selectedDates();
3681 mCalPrinter->print(CalPrinter::Month, 3681 mCalPrinter->print(CalPrinter::Month,
3682 tmpDateList.first(), tmpDateList.last()); 3682 tmpDateList.first(), tmpDateList.last());
3683#endif 3683#endif
3684} 3684}
3685 3685
3686void CalendarView::printPreview() 3686void CalendarView::printPreview()
3687{ 3687{
3688#ifndef KORG_NOPRINTER 3688#ifndef KORG_NOPRINTER
3689 kdDebug() << "CalendarView::printPreview()" << endl; 3689 kdDebug() << "CalendarView::printPreview()" << endl;
3690 3690
3691 createPrinter(); 3691 createPrinter();
3692 3692
3693 DateList tmpDateList = mNavigator->selectedDates(); 3693 DateList tmpDateList = mNavigator->selectedDates();
3694 3694
3695 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3695 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3696 tmpDateList.last()); 3696 tmpDateList.last());
3697#endif 3697#endif
3698} 3698}
3699 3699
3700void CalendarView::exportICalendar() 3700void CalendarView::exportICalendar()
3701{ 3701{
3702 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3702 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3703 3703
3704 // Force correct extension 3704 // Force correct extension
3705 if (filename.right(4) != ".ics") filename += ".ics"; 3705 if (filename.right(4) != ".ics") filename += ".ics";
3706 3706
3707 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3707 FileStorage storage( mCalendar, filename, new ICalFormat() );
3708 storage.save(); 3708 storage.save();
3709} 3709}
3710 3710
3711bool CalendarView::exportVCalendar( QString filename ) 3711bool CalendarView::exportVCalendar( QString filename )
3712{ 3712{
3713 if (mCalendar->journals().count() > 0) { 3713 if (mCalendar->journals().count() > 0) {
3714 int result = KMessageBox::warningContinueCancel(this, 3714 int result = KMessageBox::warningContinueCancel(this,
3715 i18n("The journal entries can not be\nexported to a vCalendar file."), 3715 i18n("The journal entries can not be\nexported to a vCalendar file."),
3716 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3716 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3717 true); 3717 true);
3718 if (result != KMessageBox::Continue) return false; 3718 if (result != KMessageBox::Continue) return false;
3719 } 3719 }
3720 3720
3721 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3721 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3722 3722
3723 // Force correct extension 3723 // Force correct extension
3724 if (filename.right(4) != ".vcs") filename += ".vcs"; 3724 if (filename.right(4) != ".vcs") filename += ".vcs";
3725 3725
3726 FileStorage storage( mCalendar, filename, new VCalFormat ); 3726 FileStorage storage( mCalendar, filename, new VCalFormat );
3727 return storage.save(); 3727 return storage.save();
3728 3728
3729} 3729}
3730 3730
3731void CalendarView::eventUpdated(Incidence *) 3731void CalendarView::eventUpdated(Incidence *)
3732{ 3732{
3733 setModified(); 3733 setModified();
3734 // Don't call updateView here. The code, which has caused the update of the 3734 // Don't call updateView here. The code, which has caused the update of the
3735 // event is responsible for updating the view. 3735 // event is responsible for updating the view.
3736 // updateView(); 3736 // updateView();
3737} 3737}
3738 3738
3739void CalendarView::adaptNavigationUnits() 3739void CalendarView::adaptNavigationUnits()
3740{ 3740{
3741 if (mViewManager->currentView()->isEventView()) { 3741 if (mViewManager->currentView()->isEventView()) {
3742 int days = mViewManager->currentView()->currentDateCount(); 3742 int days = mViewManager->currentView()->currentDateCount();
3743 if (days == 1) { 3743 if (days == 1) {
3744 emit changeNavStringPrev(i18n("&Previous Day")); 3744 emit changeNavStringPrev(i18n("&Previous Day"));
3745 emit changeNavStringNext(i18n("&Next Day")); 3745 emit changeNavStringNext(i18n("&Next Day"));
3746 } else { 3746 } else {
3747 emit changeNavStringPrev(i18n("&Previous Week")); 3747 emit changeNavStringPrev(i18n("&Previous Week"));
3748 emit changeNavStringNext(i18n("&Next Week")); 3748 emit changeNavStringNext(i18n("&Next Week"));
3749 } 3749 }
3750 } 3750 }
3751} 3751}
3752 3752
3753void CalendarView::processMainViewSelection( Incidence *incidence ) 3753void CalendarView::processMainViewSelection( Incidence *incidence )
3754{ 3754{
3755 if ( incidence ) mTodoList->clearSelection(); 3755 if ( incidence ) mTodoList->clearSelection();
3756 processIncidenceSelection( incidence ); 3756 processIncidenceSelection( incidence );
3757} 3757}
3758 3758
3759void CalendarView::processTodoListSelection( Incidence *incidence ) 3759void CalendarView::processTodoListSelection( Incidence *incidence )
3760{ 3760{
3761 if ( incidence && mViewManager->currentView() ) { 3761 if ( incidence && mViewManager->currentView() ) {
3762 mViewManager->currentView()->clearSelection(); 3762 mViewManager->currentView()->clearSelection();
3763 } 3763 }
3764 processIncidenceSelection( incidence ); 3764 processIncidenceSelection( incidence );
3765} 3765}
3766 3766
3767void CalendarView::processIncidenceSelection( Incidence *incidence ) 3767void CalendarView::processIncidenceSelection( Incidence *incidence )
3768{ 3768{
3769 if ( incidence == mSelectedIncidence ) return; 3769 if ( incidence == mSelectedIncidence ) return;
3770 3770
3771 mSelectedIncidence = incidence; 3771 mSelectedIncidence = incidence;
3772 3772
3773 emit incidenceSelected( mSelectedIncidence ); 3773 emit incidenceSelected( mSelectedIncidence );
3774 3774
3775 if ( incidence && incidence->type() == "Event" ) { 3775 if ( incidence && incidence->typeID() == eventID ) {
3776 Event *event = static_cast<Event *>( incidence ); 3776 Event *event = static_cast<Event *>( incidence );
3777 if ( event->organizer() == KOPrefs::instance()->email() ) { 3777 if ( event->organizer() == KOPrefs::instance()->email() ) {
3778 emit organizerEventsSelected( true ); 3778 emit organizerEventsSelected( true );
3779 } else { 3779 } else {
3780 emit organizerEventsSelected(false); 3780 emit organizerEventsSelected(false);
3781 } 3781 }
3782 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3782 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3783 KOPrefs::instance()->email() ) ) { 3783 KOPrefs::instance()->email() ) ) {
3784 emit groupEventsSelected( true ); 3784 emit groupEventsSelected( true );
3785 } else { 3785 } else {
3786 emit groupEventsSelected(false); 3786 emit groupEventsSelected(false);
3787 } 3787 }
3788 return; 3788 return;
3789 } else { 3789 } else {
3790 if ( incidence && incidence->type() == "Todo" ) { 3790 if ( incidence && incidence->typeID() == todoID ) {
3791 emit todoSelected( true ); 3791 emit todoSelected( true );
3792 Todo *event = static_cast<Todo *>( incidence ); 3792 Todo *event = static_cast<Todo *>( incidence );
3793 if ( event->organizer() == KOPrefs::instance()->email() ) { 3793 if ( event->organizer() == KOPrefs::instance()->email() ) {
3794 emit organizerEventsSelected( true ); 3794 emit organizerEventsSelected( true );
3795 } else { 3795 } else {
3796 emit organizerEventsSelected(false); 3796 emit organizerEventsSelected(false);
3797 } 3797 }
3798 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3798 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3799 KOPrefs::instance()->email() ) ) { 3799 KOPrefs::instance()->email() ) ) {
3800 emit groupEventsSelected( true ); 3800 emit groupEventsSelected( true );
3801 } else { 3801 } else {
3802 emit groupEventsSelected(false); 3802 emit groupEventsSelected(false);
3803 } 3803 }
3804 return; 3804 return;
3805 } else { 3805 } else {
3806 emit todoSelected( false ); 3806 emit todoSelected( false );
3807 emit organizerEventsSelected(false); 3807 emit organizerEventsSelected(false);
3808 emit groupEventsSelected(false); 3808 emit groupEventsSelected(false);
3809 } 3809 }
3810 return; 3810 return;
3811 } 3811 }
3812 3812
3813 /* if ( incidence && incidence->type() == "Todo" ) { 3813 /* if ( incidence && incidence->typeID() == todoID ) {
3814 emit todoSelected( true ); 3814 emit todoSelected( true );
3815 } else { 3815 } else {
3816 emit todoSelected( false ); 3816 emit todoSelected( false );
3817 }*/ 3817 }*/
3818} 3818}
3819 3819
3820 3820
3821void CalendarView::checkClipboard() 3821void CalendarView::checkClipboard()
3822{ 3822{
3823#ifndef KORG_NODND 3823#ifndef KORG_NODND
3824 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3824 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3825 emit pasteEnabled(true); 3825 emit pasteEnabled(true);
3826 } else { 3826 } else {
3827 emit pasteEnabled(false); 3827 emit pasteEnabled(false);
3828 } 3828 }
3829#endif 3829#endif
3830} 3830}
3831 3831
3832void CalendarView::showDates(const DateList &selectedDates) 3832void CalendarView::showDates(const DateList &selectedDates)
3833{ 3833{
3834 // kdDebug() << "CalendarView::selectDates()" << endl; 3834 // kdDebug() << "CalendarView::selectDates()" << endl;
3835 3835
3836 3836
3837 if ( !mBlockShowDates ) { 3837 if ( !mBlockShowDates ) {
3838 if ( mViewManager->currentView() ) { 3838 if ( mViewManager->currentView() ) {
3839 updateView( selectedDates.first(), selectedDates.last() ); 3839 updateView( selectedDates.first(), selectedDates.last() );
3840 } else { 3840 } else {
3841 mViewManager->showAgendaView(); 3841 mViewManager->showAgendaView();
3842 } 3842 }
3843 } 3843 }
3844 3844
3845 QDate date = selectedDates.first(); 3845 QDate date = selectedDates.first();
3846 if ( ! date.isValid() ) { 3846 if ( ! date.isValid() ) {
3847 topLevelWidget()->setCaption(""); 3847 topLevelWidget()->setCaption("");
3848 return; 3848 return;
3849 } 3849 }
3850 3850
3851 QString selDates; 3851 QString selDates;
3852 selDates = KGlobal::locale()->formatDate( date, true); 3852 selDates = KGlobal::locale()->formatDate( date, true);
3853 if (selectedDates.first() < selectedDates.last() ) 3853 if (selectedDates.first() < selectedDates.last() )
3854 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3854 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3855 else { 3855 else {
3856 QString addString; 3856 QString addString;
3857 if ( date == QDateTime::currentDateTime().date() ) 3857 if ( date == QDateTime::currentDateTime().date() )
3858 addString = i18n("Today"); 3858 addString = i18n("Today");
3859 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3859 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3860 addString = i18n("Tomorrow"); 3860 addString = i18n("Tomorrow");
3861 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3861 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3862 addString = i18n("Yesterday"); 3862 addString = i18n("Yesterday");
3863 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3863 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3864 addString = i18n("Day before yesterday"); 3864 addString = i18n("Day before yesterday");
3865 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3865 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3866 addString = i18n("Day after tomorrow"); 3866 addString = i18n("Day after tomorrow");
3867 if ( !addString.isEmpty() ) { 3867 if ( !addString.isEmpty() ) {
3868 topLevelWidget()->setCaption( addString+", " + selDates ); 3868 topLevelWidget()->setCaption( addString+", " + selDates );
3869 return; 3869 return;
3870 } 3870 }
3871 } 3871 }
3872 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3872 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3873 3873
3874} 3874}
3875 3875
3876QPtrList<CalFilter> CalendarView::filters() 3876QPtrList<CalFilter> CalendarView::filters()
3877{ 3877{
3878 return mFilters; 3878 return mFilters;
3879 3879
3880} 3880}
3881void CalendarView::editFilters() 3881void CalendarView::editFilters()
3882{ 3882{
3883 // kdDebug() << "CalendarView::editFilters()" << endl; 3883 // kdDebug() << "CalendarView::editFilters()" << endl;
3884 3884
3885 CalFilter *filter = mFilters.first(); 3885 CalFilter *filter = mFilters.first();
3886 while(filter) { 3886 while(filter) {
3887 kdDebug() << " Filter: " << filter->name() << endl; 3887 kdDebug() << " Filter: " << filter->name() << endl;
3888 filter = mFilters.next(); 3888 filter = mFilters.next();
3889 } 3889 }
3890 3890
3891 mDialogManager->showFilterEditDialog(&mFilters); 3891 mDialogManager->showFilterEditDialog(&mFilters);
3892} 3892}
3893void CalendarView::toggleFilter() 3893void CalendarView::toggleFilter()
3894{ 3894{
3895 showFilter(! mFilterView->isVisible()); 3895 showFilter(! mFilterView->isVisible());
3896} 3896}
3897 3897
3898KOFilterView *CalendarView::filterView() 3898KOFilterView *CalendarView::filterView()
3899{ 3899{
3900 return mFilterView; 3900 return mFilterView;
3901} 3901}
3902void CalendarView::selectFilter( int fil ) 3902void CalendarView::selectFilter( int fil )
3903{ 3903{
3904 mFilterView->setSelectedFilter( fil ); 3904 mFilterView->setSelectedFilter( fil );
3905} 3905}
3906void CalendarView::showFilter(bool visible) 3906void CalendarView::showFilter(bool visible)
3907{ 3907{
3908 if (visible) mFilterView->show(); 3908 if (visible) mFilterView->show();
3909 else mFilterView->hide(); 3909 else mFilterView->hide();
@@ -3972,198 +3972,198 @@ void CalendarView::takeOverCalendar()
3972 todos.at(i)->recreate(); 3972 todos.at(i)->recreate();
3973 todos.at(i)->setReadOnly(false); 3973 todos.at(i)->setReadOnly(false);
3974 } 3974 }
3975 3975
3976 QPtrList<Journal> journals = mCalendar->journals(); 3976 QPtrList<Journal> journals = mCalendar->journals();
3977 for(uint i=0; i<journals.count(); ++i) { 3977 for(uint i=0; i<journals.count(); ++i) {
3978 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3978 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3979 journals.at(i)->recreate(); 3979 journals.at(i)->recreate();
3980 journals.at(i)->setReadOnly(false); 3980 journals.at(i)->setReadOnly(false);
3981 } 3981 }
3982 3982
3983 updateView(); 3983 updateView();
3984} 3984}
3985 3985
3986void CalendarView::showIntro() 3986void CalendarView::showIntro()
3987{ 3987{
3988 kdDebug() << "To be implemented." << endl; 3988 kdDebug() << "To be implemented." << endl;
3989} 3989}
3990 3990
3991QWidgetStack *CalendarView::viewStack() 3991QWidgetStack *CalendarView::viewStack()
3992{ 3992{
3993 return mRightFrame; 3993 return mRightFrame;
3994} 3994}
3995 3995
3996QWidget *CalendarView::leftFrame() 3996QWidget *CalendarView::leftFrame()
3997{ 3997{
3998 return ( QWidget *)mLeftFrame; 3998 return ( QWidget *)mLeftFrame;
3999} 3999}
4000 4000
4001DateNavigator *CalendarView::dateNavigator() 4001DateNavigator *CalendarView::dateNavigator()
4002{ 4002{
4003 return mNavigator; 4003 return mNavigator;
4004} 4004}
4005 4005
4006KDateNavigator* CalendarView::dateNavigatorWidget() 4006KDateNavigator* CalendarView::dateNavigatorWidget()
4007{ 4007{
4008 return mDateNavigator->navigatorView(); 4008 return mDateNavigator->navigatorView();
4009} 4009}
4010void CalendarView::toggleDateNavigatorWidget() 4010void CalendarView::toggleDateNavigatorWidget()
4011{ 4011{
4012 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4012 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4013 4013
4014 if (!KOPrefs::instance()->mShowDateNavigator ) 4014 if (!KOPrefs::instance()->mShowDateNavigator )
4015 mDateNavigator->hide(); 4015 mDateNavigator->hide();
4016 else 4016 else
4017 mDateNavigator->show(); 4017 mDateNavigator->show();
4018} 4018}
4019void CalendarView::addView(KOrg::BaseView *view) 4019void CalendarView::addView(KOrg::BaseView *view)
4020{ 4020{
4021 mViewManager->addView(view); 4021 mViewManager->addView(view);
4022} 4022}
4023 4023
4024void CalendarView::showView(KOrg::BaseView *view) 4024void CalendarView::showView(KOrg::BaseView *view)
4025{ 4025{
4026 mViewManager->showView(view, mLeftFrame->isVisible()); 4026 mViewManager->showView(view, mLeftFrame->isVisible());
4027} 4027}
4028 4028
4029Incidence *CalendarView::currentSelection() 4029Incidence *CalendarView::currentSelection()
4030{ 4030{
4031 return mViewManager->currentSelection(); 4031 return mViewManager->currentSelection();
4032} 4032}
4033void CalendarView::toggleAllDaySize() 4033void CalendarView::toggleAllDaySize()
4034{ 4034{
4035 /* 4035 /*
4036 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4036 if ( KOPrefs::instance()->mAllDaySize > 47 )
4037 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4037 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4038 else 4038 else
4039 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4039 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4040 */ 4040 */
4041 viewManager()->agendaView()->toggleAllDay(); 4041 viewManager()->agendaView()->toggleAllDay();
4042} 4042}
4043void CalendarView::toggleExpand() 4043void CalendarView::toggleExpand()
4044{ 4044{
4045 // if ( mLeftFrame->isHidden() ) { 4045 // if ( mLeftFrame->isHidden() ) {
4046 // mLeftFrame->show(); 4046 // mLeftFrame->show();
4047 // emit calendarViewExpanded( false ); 4047 // emit calendarViewExpanded( false );
4048 // } else { 4048 // } else {
4049 // mLeftFrame->hide(); 4049 // mLeftFrame->hide();
4050 // emit calendarViewExpanded( true ); 4050 // emit calendarViewExpanded( true );
4051 // } 4051 // }
4052 //qDebug(" CalendarView::toggleExpand()"); 4052 //qDebug(" CalendarView::toggleExpand()");
4053 globalFlagBlockAgenda = 1; 4053 globalFlagBlockAgenda = 1;
4054 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4054 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4055 globalFlagBlockAgenda = 5; 4055 globalFlagBlockAgenda = 5;
4056 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4056 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4057 //mViewManager->showView( 0, true ); 4057 //mViewManager->showView( 0, true );
4058} 4058}
4059 4059
4060void CalendarView::calendarModified( bool modified, Calendar * ) 4060void CalendarView::calendarModified( bool modified, Calendar * )
4061{ 4061{
4062 setModified( modified ); 4062 setModified( modified );
4063} 4063}
4064 4064
4065Todo *CalendarView::selectedTodo() 4065Todo *CalendarView::selectedTodo()
4066{ 4066{
4067 Incidence *incidence = currentSelection(); 4067 Incidence *incidence = currentSelection();
4068 if ( incidence && incidence->type() == "Todo" ) { 4068 if ( incidence && incidence->typeID() == todoID ) {
4069 return static_cast<Todo *>( incidence ); 4069 return static_cast<Todo *>( incidence );
4070 } 4070 }
4071 4071
4072 incidence = mTodoList->selectedIncidences().first(); 4072 incidence = mTodoList->selectedIncidences().first();
4073 if ( incidence && incidence->type() == "Todo" ) { 4073 if ( incidence && incidence->typeID() == todoID ) {
4074 return static_cast<Todo *>( incidence ); 4074 return static_cast<Todo *>( incidence );
4075 } 4075 }
4076 4076
4077 return 0; 4077 return 0;
4078} 4078}
4079 4079
4080void CalendarView::dialogClosing(Incidence *in) 4080void CalendarView::dialogClosing(Incidence *in)
4081{ 4081{
4082 // mDialogList.remove(in); 4082 // mDialogList.remove(in);
4083} 4083}
4084 4084
4085void CalendarView::showIncidence() 4085void CalendarView::showIncidence()
4086{ 4086{
4087 mViewerCallerIsSearchDialog = false; 4087 mViewerCallerIsSearchDialog = false;
4088 Incidence *incidence = currentSelection(); 4088 Incidence *incidence = currentSelection();
4089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4090 if ( incidence ) { 4090 if ( incidence ) {
4091 ShowIncidenceVisitor v; 4091 ShowIncidenceVisitor v;
4092 v.act( incidence, this ); 4092 v.act( incidence, this );
4093 } 4093 }
4094} 4094}
4095void CalendarView::editIncidenceDescription() 4095void CalendarView::editIncidenceDescription()
4096{ 4096{
4097 mFlagEditDescription = true; 4097 mFlagEditDescription = true;
4098 editIncidence(); 4098 editIncidence();
4099 mFlagEditDescription = false; 4099 mFlagEditDescription = false;
4100} 4100}
4101void CalendarView::editIncidence() 4101void CalendarView::editIncidence()
4102{ 4102{
4103 // qDebug("editIncidence() "); 4103 // qDebug("editIncidence() ");
4104 Incidence *incidence = currentSelection(); 4104 Incidence *incidence = currentSelection();
4105 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4105 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4106 if ( incidence ) { 4106 if ( incidence ) {
4107 EditIncidenceVisitor v; 4107 EditIncidenceVisitor v;
4108 v.act( incidence, this ); 4108 v.act( incidence, this );
4109 } 4109 }
4110} 4110}
4111 4111
4112void CalendarView::deleteIncidence() 4112void CalendarView::deleteIncidence()
4113{ 4113{
4114 Incidence *incidence = currentSelection(); 4114 Incidence *incidence = currentSelection();
4115 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4115 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4116 if ( incidence ) { 4116 if ( incidence ) {
4117 deleteIncidence(incidence); 4117 deleteIncidence(incidence);
4118 } 4118 }
4119} 4119}
4120void CalendarView::showIncidence(QString uid) 4120void CalendarView::showIncidence(QString uid)
4121{ 4121{
4122 Incidence *inc = mCalendar->incidence( uid ); 4122 Incidence *inc = mCalendar->incidence( uid );
4123 if ( inc ) 4123 if ( inc )
4124 showIncidence( inc ); 4124 showIncidence( inc );
4125} 4125}
4126void CalendarView::showIncidence(Incidence *incidence) 4126void CalendarView::showIncidence(Incidence *incidence)
4127{ 4127{
4128 mViewerCallerIsSearchDialog = false; 4128 mViewerCallerIsSearchDialog = false;
4129 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4129 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4130 if ( sender() && mDialogManager->getSearchDialog() ) { 4130 if ( sender() && mDialogManager->getSearchDialog() ) {
4131 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4131 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4132 mViewerCallerIsSearchDialog = true; 4132 mViewerCallerIsSearchDialog = true;
4133 } 4133 }
4134 } 4134 }
4135 if ( incidence ) { 4135 if ( incidence ) {
4136 ShowIncidenceVisitor v; 4136 ShowIncidenceVisitor v;
4137 v.act( incidence, this ); 4137 v.act( incidence, this );
4138 } 4138 }
4139} 4139}
4140 4140
4141void CalendarView::editIncidence(Incidence *incidence) 4141void CalendarView::editIncidence(Incidence *incidence)
4142{ 4142{
4143 if ( incidence ) { 4143 if ( incidence ) {
4144 4144
4145 EditIncidenceVisitor v; 4145 EditIncidenceVisitor v;
4146 v.act( incidence, this ); 4146 v.act( incidence, this );
4147 4147
4148 } 4148 }
4149} 4149}
4150 4150
4151void CalendarView::deleteIncidence(Incidence *incidence) 4151void CalendarView::deleteIncidence(Incidence *incidence)
4152{ 4152{
4153 //qDebug(" CalendarView::deleteIncidence "); 4153 //qDebug(" CalendarView::deleteIncidence ");
4154 if ( incidence ) { 4154 if ( incidence ) {
4155 DeleteIncidenceVisitor v; 4155 DeleteIncidenceVisitor v;
4156 v.act( incidence, this ); 4156 v.act( incidence, this );
4157 } 4157 }
4158} 4158}
4159 4159
4160 4160
4161void CalendarView::lookForOutgoingMessages() 4161void CalendarView::lookForOutgoingMessages()
4162{ 4162{
4163 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4163 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4164 ogd->loadMessages(); 4164 ogd->loadMessages();
4165} 4165}
4166 4166
4167void CalendarView::lookForIncomingMessages() 4167void CalendarView::lookForIncomingMessages()
4168{ 4168{
4169 IncomingDialog *icd = mDialogManager->incomingDialog(); 4169 IncomingDialog *icd = mDialogManager->incomingDialog();
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 2a2acb1..fc213d8 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -660,352 +660,352 @@ void KOAgenda::startSelectAction(QPoint viewportPos)
660 mSelectionYTop = gy * mGridSpacingY; 660 mSelectionYTop = gy * mGridSpacingY;
661 mSelectionHeight = mGridSpacingY; 661 mSelectionHeight = mGridSpacingY;
662 662
663 // Paint new selection 663 // Paint new selection
664 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 664 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
665 mGridSpacingX-1, mSelectionHeight ); 665 mGridSpacingX-1, mSelectionHeight );
666} 666}
667 667
668void KOAgenda::performSelectAction(QPoint viewportPos) 668void KOAgenda::performSelectAction(QPoint viewportPos)
669{ 669{
670 int x,y; 670 int x,y;
671 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 671 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
672 int gx,gy; 672 int gx,gy;
673 contentsToGrid(x,y,gx,gy); 673 contentsToGrid(x,y,gx,gy);
674 674
675 QPoint clipperPos = clipper()-> 675 QPoint clipperPos = clipper()->
676 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 676 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
677 677
678 // Scroll if cursor was moved to upper or lower end of agenda. 678 // Scroll if cursor was moved to upper or lower end of agenda.
679 if (clipperPos.y() < mScrollBorderWidth) { 679 if (clipperPos.y() < mScrollBorderWidth) {
680 mScrollUpTimer.start(mScrollDelay); 680 mScrollUpTimer.start(mScrollDelay);
681 } else if (visibleHeight() - clipperPos.y() < 681 } else if (visibleHeight() - clipperPos.y() <
682 mScrollBorderWidth) { 682 mScrollBorderWidth) {
683 mScrollDownTimer.start(mScrollDelay); 683 mScrollDownTimer.start(mScrollDelay);
684 } else { 684 } else {
685 mScrollUpTimer.stop(); 685 mScrollUpTimer.stop();
686 mScrollDownTimer.stop(); 686 mScrollDownTimer.stop();
687 } 687 }
688 688
689 if ( gy > mCurrentCellY ) { 689 if ( gy > mCurrentCellY ) {
690 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 690 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
691 691
692 692
693 repaintContents( (KOGlobals::self()->reverseLayout() ? 693 repaintContents( (KOGlobals::self()->reverseLayout() ?
694 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 694 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
695 mGridSpacingX, mSelectionYTop, 695 mGridSpacingX, mSelectionYTop,
696 mGridSpacingX, mSelectionHeight , false); 696 mGridSpacingX, mSelectionHeight , false);
697 697
698 mCurrentCellY = gy; 698 mCurrentCellY = gy;
699 } else if ( gy < mCurrentCellY ) { 699 } else if ( gy < mCurrentCellY ) {
700 if ( gy >= mStartCellY ) { 700 if ( gy >= mStartCellY ) {
701 int selectionHeight = mSelectionHeight; 701 int selectionHeight = mSelectionHeight;
702 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 702 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
703 703
704 repaintContents( (KOGlobals::self()->reverseLayout() ? 704 repaintContents( (KOGlobals::self()->reverseLayout() ?
705 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 705 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
706 mGridSpacingX, mSelectionYTop, 706 mGridSpacingX, mSelectionYTop,
707 mGridSpacingX, selectionHeight,false ); 707 mGridSpacingX, selectionHeight,false );
708 708
709 mCurrentCellY = gy; 709 mCurrentCellY = gy;
710 } else { 710 } else {
711 } 711 }
712 } 712 }
713} 713}
714 714
715void KOAgenda::endSelectAction( bool emitNewEvent ) 715void KOAgenda::endSelectAction( bool emitNewEvent )
716{ 716{
717 mActionType = NOP; 717 mActionType = NOP;
718 mScrollUpTimer.stop(); 718 mScrollUpTimer.stop();
719 mScrollDownTimer.stop(); 719 mScrollDownTimer.stop();
720 720
721 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 721 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
722 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 722 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
723 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 723 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
724 } 724 }
725} 725}
726 726
727void KOAgenda::startItemAction(QPoint viewportPos) 727void KOAgenda::startItemAction(QPoint viewportPos)
728{ 728{
729 int x,y; 729 int x,y;
730 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 730 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
731 int gx,gy; 731 int gx,gy;
732 contentsToGrid(x,y,gx,gy); 732 contentsToGrid(x,y,gx,gy);
733 733
734 mStartCellX = gx; 734 mStartCellX = gx;
735 mStartCellY = gy; 735 mStartCellY = gy;
736 mCurrentCellX = gx; 736 mCurrentCellX = gx;
737 mCurrentCellY = gy; 737 mCurrentCellY = gy;
738 738
739 if (mAllDayMode) { 739 if (mAllDayMode) {
740 int gridDistanceX = (x - gx * mGridSpacingX); 740 int gridDistanceX = (x - gx * mGridSpacingX);
741 if (gridDistanceX < mResizeBorderWidth && 741 if (gridDistanceX < mResizeBorderWidth &&
742 mActionItem->cellX() == mCurrentCellX) { 742 mActionItem->cellX() == mCurrentCellX) {
743 mActionType = RESIZELEFT; 743 mActionType = RESIZELEFT;
744 setCursor(sizeHorCursor); 744 setCursor(sizeHorCursor);
745 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 745 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
746 mActionItem->cellXWidth() == mCurrentCellX) { 746 mActionItem->cellXWidth() == mCurrentCellX) {
747 mActionType = RESIZERIGHT; 747 mActionType = RESIZERIGHT;
748 setCursor(sizeHorCursor); 748 setCursor(sizeHorCursor);
749 } else { 749 } else {
750 mActionType = MOVE; 750 mActionType = MOVE;
751 mActionItem->startMove(); 751 mActionItem->startMove();
752 setCursor(sizeAllCursor); 752 setCursor(sizeAllCursor);
753 } 753 }
754 } else { 754 } else {
755 int gridDistanceY = (y - gy * mGridSpacingY); 755 int gridDistanceY = (y - gy * mGridSpacingY);
756 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 756 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
757 if (allowResize && gridDistanceY < mResizeBorderWidth && 757 if (allowResize && gridDistanceY < mResizeBorderWidth &&
758 mActionItem->cellYTop() == mCurrentCellY && 758 mActionItem->cellYTop() == mCurrentCellY &&
759 !mActionItem->firstMultiItem()) { 759 !mActionItem->firstMultiItem()) {
760 mActionType = RESIZETOP; 760 mActionType = RESIZETOP;
761 setCursor(sizeVerCursor); 761 setCursor(sizeVerCursor);
762 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 762 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
763 mActionItem->cellYBottom() == mCurrentCellY && 763 mActionItem->cellYBottom() == mCurrentCellY &&
764 !mActionItem->lastMultiItem()) { 764 !mActionItem->lastMultiItem()) {
765 mActionType = RESIZEBOTTOM; 765 mActionType = RESIZEBOTTOM;
766 setCursor(sizeVerCursor); 766 setCursor(sizeVerCursor);
767 } else { 767 } else {
768 mActionType = MOVE; 768 mActionType = MOVE;
769 mActionItem->startMove(); 769 mActionItem->startMove();
770 setCursor(sizeAllCursor); 770 setCursor(sizeAllCursor);
771 } 771 }
772 } 772 }
773} 773}
774 774
775void KOAgenda::performItemAction(QPoint viewportPos) 775void KOAgenda::performItemAction(QPoint viewportPos)
776{ 776{
777// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 777// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
778// QPoint point = viewport()->mapToGlobal(viewportPos); 778// QPoint point = viewport()->mapToGlobal(viewportPos);
779// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 779// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
780// point = clipper()->mapFromGlobal(point); 780// point = clipper()->mapFromGlobal(point);
781// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 781// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
782// kdDebug() << "visible height: " << visibleHeight() << endl; 782// kdDebug() << "visible height: " << visibleHeight() << endl;
783 int x,y; 783 int x,y;
784 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 784 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
785// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 785// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
786 int gx,gy; 786 int gx,gy;
787 contentsToGrid(x,y,gx,gy); 787 contentsToGrid(x,y,gx,gy);
788 QPoint clipperPos = clipper()-> 788 QPoint clipperPos = clipper()->
789 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 789 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
790 790
791 // Cursor left active agenda area. 791 // Cursor left active agenda area.
792 // This starts a drag. 792 // This starts a drag.
793 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 793 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
794 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 794 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
795 if ( mActionType == MOVE ) { 795 if ( mActionType == MOVE ) {
796 mScrollUpTimer.stop(); 796 mScrollUpTimer.stop();
797 mScrollDownTimer.stop(); 797 mScrollDownTimer.stop();
798 mActionItem->resetMove(); 798 mActionItem->resetMove();
799 placeSubCells( mActionItem ); 799 placeSubCells( mActionItem );
800 // emit startDragSignal( mActionItem->incidence() ); 800 // emit startDragSignal( mActionItem->incidence() );
801 setCursor( arrowCursor ); 801 setCursor( arrowCursor );
802 mActionItem = 0; 802 mActionItem = 0;
803 mActionType = NOP; 803 mActionType = NOP;
804 mItemMoved = 0; 804 mItemMoved = 0;
805 return; 805 return;
806 } 806 }
807 } else { 807 } else {
808 switch ( mActionType ) { 808 switch ( mActionType ) {
809 case MOVE: 809 case MOVE:
810 setCursor( sizeAllCursor ); 810 setCursor( sizeAllCursor );
811 break; 811 break;
812 case RESIZETOP: 812 case RESIZETOP:
813 case RESIZEBOTTOM: 813 case RESIZEBOTTOM:
814 setCursor( sizeVerCursor ); 814 setCursor( sizeVerCursor );
815 break; 815 break;
816 case RESIZELEFT: 816 case RESIZELEFT:
817 case RESIZERIGHT: 817 case RESIZERIGHT:
818 setCursor( sizeHorCursor ); 818 setCursor( sizeHorCursor );
819 break; 819 break;
820 default: 820 default:
821 setCursor( arrowCursor ); 821 setCursor( arrowCursor );
822 } 822 }
823 } 823 }
824 824
825 // Scroll if item was moved to upper or lower end of agenda. 825 // Scroll if item was moved to upper or lower end of agenda.
826 if (clipperPos.y() < mScrollBorderWidth) { 826 if (clipperPos.y() < mScrollBorderWidth) {
827 mScrollUpTimer.start(mScrollDelay); 827 mScrollUpTimer.start(mScrollDelay);
828 } else if (visibleHeight() - clipperPos.y() < 828 } else if (visibleHeight() - clipperPos.y() <
829 mScrollBorderWidth) { 829 mScrollBorderWidth) {
830 mScrollDownTimer.start(mScrollDelay); 830 mScrollDownTimer.start(mScrollDelay);
831 } else { 831 } else {
832 mScrollUpTimer.stop(); 832 mScrollUpTimer.stop();
833 mScrollDownTimer.stop(); 833 mScrollDownTimer.stop();
834 } 834 }
835 835
836 // Move or resize item if necessary 836 // Move or resize item if necessary
837 if (mCurrentCellX != gx || mCurrentCellY != gy) { 837 if (mCurrentCellX != gx || mCurrentCellY != gy) {
838 mItemMoved = true; 838 mItemMoved = true;
839 mActionItem->raise(); 839 mActionItem->raise();
840 if (mActionType == MOVE) { 840 if (mActionType == MOVE) {
841 // Move all items belonging to a multi item 841 // Move all items belonging to a multi item
842 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 842 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
843 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 843 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
844 if (!moveItem) moveItem = mActionItem; 844 if (!moveItem) moveItem = mActionItem;
845 while (moveItem) { 845 while (moveItem) {
846 int dy; 846 int dy;
847 if (isMultiItem) dy = 0; 847 if (isMultiItem) dy = 0;
848 else dy = gy - mCurrentCellY; 848 else dy = gy - mCurrentCellY;
849 moveItem->moveRelative(gx - mCurrentCellX,dy); 849 moveItem->moveRelative(gx - mCurrentCellX,dy);
850 int x,y; 850 int x,y;
851 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 851 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
852 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 852 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
853 mGridSpacingY * moveItem->cellHeight()); 853 mGridSpacingY * moveItem->cellHeight());
854 moveChild(moveItem,x,y); 854 moveChild(moveItem,x,y);
855 moveItem = moveItem->nextMultiItem(); 855 moveItem = moveItem->nextMultiItem();
856 } 856 }
857 } else if (mActionType == RESIZETOP) { 857 } else if (mActionType == RESIZETOP) {
858 if (mCurrentCellY <= mActionItem->cellYBottom()) { 858 if (mCurrentCellY <= mActionItem->cellYBottom()) {
859 mActionItem->expandTop(gy - mCurrentCellY); 859 mActionItem->expandTop(gy - mCurrentCellY);
860 mActionItem->resize(mActionItem->width(), 860 mActionItem->resize(mActionItem->width(),
861 mGridSpacingY * mActionItem->cellHeight()); 861 mGridSpacingY * mActionItem->cellHeight());
862 int x,y; 862 int x,y;
863 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 863 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
864 //moveChild(mActionItem,childX(mActionItem),y); 864 //moveChild(mActionItem,childX(mActionItem),y);
865 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 865 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
866 } 866 }
867 } else if (mActionType == RESIZEBOTTOM) { 867 } else if (mActionType == RESIZEBOTTOM) {
868 if (mCurrentCellY >= mActionItem->cellYTop()) { 868 if (mCurrentCellY >= mActionItem->cellYTop()) {
869 mActionItem->expandBottom(gy - mCurrentCellY); 869 mActionItem->expandBottom(gy - mCurrentCellY);
870 mActionItem->resize(mActionItem->width(), 870 mActionItem->resize(mActionItem->width(),
871 mGridSpacingY * mActionItem->cellHeight()); 871 mGridSpacingY * mActionItem->cellHeight());
872 } 872 }
873 } else if (mActionType == RESIZELEFT) { 873 } else if (mActionType == RESIZELEFT) {
874 if (mCurrentCellX <= mActionItem->cellXWidth()) { 874 if (mCurrentCellX <= mActionItem->cellXWidth()) {
875 mActionItem->expandLeft(gx - mCurrentCellX); 875 mActionItem->expandLeft(gx - mCurrentCellX);
876 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 876 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
877 mActionItem->height()); 877 mActionItem->height());
878 int x,y; 878 int x,y;
879 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 879 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
880 moveChild(mActionItem,x,childY(mActionItem)); 880 moveChild(mActionItem,x,childY(mActionItem));
881 } 881 }
882 } else if (mActionType == RESIZERIGHT) { 882 } else if (mActionType == RESIZERIGHT) {
883 if (mCurrentCellX >= mActionItem->cellX()) { 883 if (mCurrentCellX >= mActionItem->cellX()) {
884 mActionItem->expandRight(gx - mCurrentCellX); 884 mActionItem->expandRight(gx - mCurrentCellX);
885 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 885 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
886 mActionItem->height()); 886 mActionItem->height());
887 } 887 }
888 } 888 }
889 mCurrentCellX = gx; 889 mCurrentCellX = gx;
890 mCurrentCellY = gy; 890 mCurrentCellY = gy;
891 } 891 }
892} 892}
893 893
894void KOAgenda::endItemAction() 894void KOAgenda::endItemAction()
895{ 895{
896 896
897 if ( mItemMoved ) { 897 if ( mItemMoved ) {
898 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 898 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
899 if ( !placeItem ) { 899 if ( !placeItem ) {
900 placeItem = mActionItem; 900 placeItem = mActionItem;
901 } 901 }
902 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 902 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
903 Incidence* oldInc = placeItem->incidence(); 903 Incidence* oldInc = placeItem->incidence();
904 placeItem->recreateIncidence(); 904 placeItem->recreateIncidence();
905 emit addToCalSignal(placeItem->incidence(), oldInc ); 905 emit addToCalSignal(placeItem->incidence(), oldInc );
906 } 906 }
907 int type = mActionType; 907 int type = mActionType;
908 if ( mAllDayMode ) 908 if ( mAllDayMode )
909 type = -1; 909 type = -1;
910 KOAgendaItem *modifiedItem = placeItem; 910 KOAgendaItem *modifiedItem = placeItem;
911 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 911 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
912 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 912 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
913 KOAgendaItem *item; 913 KOAgendaItem *item;
914 914
915 if ( placeItem->incidence()->type() == "Todo" ) { 915 if ( placeItem->incidence()->typeID() == todoID ) {
916 mSelectedItem = 0; 916 mSelectedItem = 0;
917 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 917 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
918 modifiedItem->mLastMoveXPos = mCurrentCellX; 918 modifiedItem->mLastMoveXPos = mCurrentCellX;
919 emit itemModified( modifiedItem, mActionType ); 919 emit itemModified( modifiedItem, mActionType );
920 } 920 }
921 else { 921 else {
922 922
923 923
924 globalFlagBlockAgendaItemPaint = 1; 924 globalFlagBlockAgendaItemPaint = 1;
925 for ( item=oldconflictItems.first(); item != 0; 925 for ( item=oldconflictItems.first(); item != 0;
926 item=oldconflictItems.next() ) { 926 item=oldconflictItems.next() ) {
927 placeSubCells(item); 927 placeSubCells(item);
928 } 928 }
929 while ( placeItem ) { 929 while ( placeItem ) {
930 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 930 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
931 oldconflictItems = placeItem->conflictItems(); 931 oldconflictItems = placeItem->conflictItems();
932 for ( item=oldconflictItems.first(); item != 0; 932 for ( item=oldconflictItems.first(); item != 0;
933 item=oldconflictItems.next() ) { 933 item=oldconflictItems.next() ) {
934 placeSubCells(item); 934 placeSubCells(item);
935 } 935 }
936 placeSubCells( placeItem ); 936 placeSubCells( placeItem );
937 placeItem = placeItem->nextMultiItem(); 937 placeItem = placeItem->nextMultiItem();
938 } 938 }
939 globalFlagBlockAgendaItemPaint = 0; 939 globalFlagBlockAgendaItemPaint = 0;
940 for ( item=oldconflictItems.first(); item != 0; 940 for ( item=oldconflictItems.first(); item != 0;
941 item=oldconflictItems.next() ) { 941 item=oldconflictItems.next() ) {
942 globalFlagBlockAgendaItemUpdate = 0; 942 globalFlagBlockAgendaItemUpdate = 0;
943 item->repaintMe(); 943 item->repaintMe();
944 globalFlagBlockAgendaItemUpdate = 1; 944 globalFlagBlockAgendaItemUpdate = 1;
945 item->repaint( false ); 945 item->repaint( false );
946 } 946 }
947 placeItem = modifiedItem; 947 placeItem = modifiedItem;
948 948
949 while ( placeItem ) { 949 while ( placeItem ) {
950 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 950 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
951 globalFlagBlockAgendaItemUpdate = 0; 951 globalFlagBlockAgendaItemUpdate = 0;
952 placeItem->repaintMe(); 952 placeItem->repaintMe();
953 globalFlagBlockAgendaItemUpdate = 1; 953 globalFlagBlockAgendaItemUpdate = 1;
954 placeItem->repaint(false); 954 placeItem->repaint(false);
955 placeItem = placeItem->nextMultiItem(); 955 placeItem = placeItem->nextMultiItem();
956 } 956 }
957 emit itemModified( modifiedItem, mActionType ); 957 emit itemModified( modifiedItem, mActionType );
958 958
959 959
960 placeItem = modifiedItem; 960 placeItem = modifiedItem;
961 while ( placeItem ) { 961 while ( placeItem ) {
962 oldconflictItems = placeItem->conflictItems(); 962 oldconflictItems = placeItem->conflictItems();
963 for ( item=oldconflictItems.first(); item != 0; 963 for ( item=oldconflictItems.first(); item != 0;
964 item=oldconflictItems.next() ) { 964 item=oldconflictItems.next() ) {
965 placeSubCells(item); 965 placeSubCells(item);
966 } 966 }
967 placeSubCells( placeItem ); 967 placeSubCells( placeItem );
968 placeItem = placeItem->nextMultiItem(); 968 placeItem = placeItem->nextMultiItem();
969 969
970 } 970 }
971 placeItem = modifiedItem; 971 placeItem = modifiedItem;
972 while ( placeItem ) { 972 while ( placeItem ) {
973 oldconflictItems = placeItem->conflictItems(); 973 oldconflictItems = placeItem->conflictItems();
974 for ( item=oldconflictItems.first(); item != 0; 974 for ( item=oldconflictItems.first(); item != 0;
975 item=oldconflictItems.next() ) { 975 item=oldconflictItems.next() ) {
976 globalFlagBlockAgendaItemUpdate = 0; 976 globalFlagBlockAgendaItemUpdate = 0;
977 item->repaintMe(); 977 item->repaintMe();
978 globalFlagBlockAgendaItemUpdate = 1; 978 globalFlagBlockAgendaItemUpdate = 1;
979 item->repaint(false); 979 item->repaint(false);
980 } 980 }
981 placeItem = placeItem->nextMultiItem(); 981 placeItem = placeItem->nextMultiItem();
982 } 982 }
983 /* 983 /*
984 984
985 oldconflictItems = modifiedItem->conflictItems(); 985 oldconflictItems = modifiedItem->conflictItems();
986 for ( item=oldconflictItems.first(); item != 0; 986 for ( item=oldconflictItems.first(); item != 0;
987 item=oldconflictItems.next() ) { 987 item=oldconflictItems.next() ) {
988 globalFlagBlockAgendaItemUpdate = 0; 988 globalFlagBlockAgendaItemUpdate = 0;
989 item->paintMe(false); 989 item->paintMe(false);
990 globalFlagBlockAgendaItemUpdate = 1; 990 globalFlagBlockAgendaItemUpdate = 1;
991 item->repaint(false); 991 item->repaint(false);
992 } 992 }
993 */ 993 */
994 994
995 995
996 } 996 }
997 997
998 } 998 }
999 999
1000 mScrollUpTimer.stop(); 1000 mScrollUpTimer.stop();
1001 mScrollDownTimer.stop(); 1001 mScrollDownTimer.stop();
1002 setCursor( arrowCursor ); 1002 setCursor( arrowCursor );
1003 mActionItem = 0; 1003 mActionItem = 0;
1004 mActionType = NOP; 1004 mActionType = NOP;
1005 mItemMoved = 0; 1005 mItemMoved = 0;
1006 1006
1007} 1007}
1008 1008
1009void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1009void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1010{ 1010{
1011// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1011// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index df2e478..5a3c4d2 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -13,211 +13,211 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100void KOAgendaItem::init ( Incidence *incidence, QDate qd )
101{ 101{
102 mIncidence = incidence; 102 mIncidence = incidence;
103 mDate = qd; 103 mDate = qd;
104 mFirstMultiItem = 0; 104 mFirstMultiItem = 0;
105 mNextMultiItem = 0; 105 mNextMultiItem = 0;
106 mLastMultiItem = 0; 106 mLastMultiItem = 0;
107 computeText(); 107 computeText();
108 108
109 if ( (incidence->type() == "Todo") && 109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 114 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 116 }
117 else { 117 else {
118 QStringList categories = mIncidence->categories(); 118 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 119 QString cat = categories.first();
120 if (cat.isEmpty()) { 120 if (cat.isEmpty()) {
121 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 123 else
124 mBackgroundColor =KOPrefs::instance()->mEventColor; 124 mBackgroundColor =KOPrefs::instance()->mEventColor;
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 129 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
130 } 130 }
131 } 131 }
132 132
133 } 133 }
134 mColorGroup = QColorGroup( mBackgroundColor.light(), 134 mColorGroup = QColorGroup( mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor.light(), 135 mBackgroundColor.dark(),mBackgroundColor.light(),
136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
137 setBackgroundColor( mBackgroundColor ); 137 setBackgroundColor( mBackgroundColor );
138 138
139 mConflictItems.clear(); 139 mConflictItems.clear();
140 setCellXY(0,0,1); 140 setCellXY(0,0,1);
141 setCellXWidth(0); 141 setCellXWidth(0);
142 setSubCell(0); 142 setSubCell(0);
143 setSubCells(1); 143 setSubCells(1);
144 setMultiItem(0,0,0); 144 setMultiItem(0,0,0);
145 startMove(); 145 startMove();
146 mSelected = true; 146 mSelected = true;
147 select(false); 147 select(false);
148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
149 mFontPixelSize = fontinf.height();; 149 mFontPixelSize = fontinf.height();;
150 hide(); 150 hide();
151 xPaintCoord = -1; 151 xPaintCoord = -1;
152 yPaintCoord = -1; 152 yPaintCoord = -1;
153} 153}
154 154
155 155
156KOAgendaItem::~KOAgendaItem() 156KOAgendaItem::~KOAgendaItem()
157{ 157{
158#if QT_VERSION >= 0x030000 158#if QT_VERSION >= 0x030000
159 159
160#else 160#else
161 delete mKOAgendaItemWhatsThis; 161 delete mKOAgendaItemWhatsThis;
162#endif 162#endif
163 163
164} 164}
165 165
166void KOAgendaItem::recreateIncidence() 166void KOAgendaItem::recreateIncidence()
167{ 167{
168#if 0 168#if 0
169 Incidence* newInc = mIncidence->clone(); 169 Incidence* newInc = mIncidence->clone();
170 newInc->recreate(); 170 newInc->recreate();
171 if ( mIncidence->doesRecur() ) { 171 if ( mIncidence->doesRecur() ) {
172 mIncidence->addExDate( mDate ); 172 mIncidence->addExDate( mDate );
173 newInc->recurrence()->unsetRecurs(); 173 newInc->recurrence()->unsetRecurs();
174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
175 QTime tim = mIncidence->dtStart().time(); 175 QTime tim = mIncidence->dtStart().time();
176 newInc->setDtStart( QDateTime(mDate, tim) ); 176 newInc->setDtStart( QDateTime(mDate, tim) );
177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
178 } 178 }
179#endif 179#endif
180 mIncidence = mIncidence->recreateCloneException( mDate ); 180 mIncidence = mIncidence->recreateCloneException( mDate );
181} 181}
182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
183{ 183{
184 int size = AGENDA_ICON_SIZE; 184 int size = AGENDA_ICON_SIZE;
185 185
186 int yOff = 0; 186 int yOff = 0;
187 int xOff = 0; 187 int xOff = 0;
188 int x = pos().x() +3; 188 int x = pos().x() +3;
189 int y; 189 int y;
190 if ( mAllDay ) 190 if ( mAllDay )
191 y = pos().y()+3; 191 y = pos().y()+3;
192 else 192 else
193 y = mCellYTop * ( height() / cellHeight() ) +3; 193 y = mCellYTop * ( height() / cellHeight() ) +3;
194 if (mIncidence->cancelled()) { 194 if (mIncidence->cancelled()) {
195 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 195 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
196 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 196 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
197 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 197 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
198 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 198 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
199 if ( horLayout ) 199 if ( horLayout )
200 ++xOff; 200 ++xOff;
201 else 201 else
202 ++yOff; 202 ++yOff;
203 } 203 }
204 if (mIncidence->isAlarmEnabled()) { 204 if (mIncidence->isAlarmEnabled()) {
205 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 205 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
206 if ( horLayout ) 206 if ( horLayout )
207 ++xOff; 207 ++xOff;
208 else 208 else
209 ++yOff; 209 ++yOff;
210 } 210 }
211 if (mIncidence->recurrence()->doesRecur()) { 211 if (mIncidence->recurrence()->doesRecur()) {
212 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 212 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
213 if ( horLayout ) 213 if ( horLayout )
214 ++xOff; 214 ++xOff;
215 else 215 else
216 ++yOff; 216 ++yOff;
217 } 217 }
218 if (mIncidence->description().length() > 0) { 218 if (mIncidence->description().length() > 0) {
219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
220 if ( horLayout ) 220 if ( horLayout )
221 ++xOff; 221 ++xOff;
222 else 222 else
223 ++yOff; 223 ++yOff;
@@ -266,422 +266,422 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
266 266
267void KOAgendaItem::select(bool selected) 267void KOAgendaItem::select(bool selected)
268{ 268{
269 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 269 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
270 if (mSelected == selected) return; 270 if (mSelected == selected) return;
271 mSelected = selected; 271 mSelected = selected;
272 if ( ! isVisible() ) 272 if ( ! isVisible() )
273 return; 273 return;
274 if ( firstMultiItem() ) 274 if ( firstMultiItem() )
275 firstMultiItem()->select( selected ); 275 firstMultiItem()->select( selected );
276 if ( !firstMultiItem() && nextMultiItem() ) { 276 if ( !firstMultiItem() && nextMultiItem() ) {
277 KOAgendaItem * placeItem = nextMultiItem(); 277 KOAgendaItem * placeItem = nextMultiItem();
278 while ( placeItem ) { 278 while ( placeItem ) {
279 placeItem->select( selected ); 279 placeItem->select( selected );
280 placeItem = placeItem->nextMultiItem(); 280 placeItem = placeItem->nextMultiItem();
281 } 281 }
282 } 282 }
283 globalFlagBlockAgendaItemUpdate = 0; 283 globalFlagBlockAgendaItemUpdate = 0;
284 paintMe( selected ); 284 paintMe( selected );
285 globalFlagBlockAgendaItemUpdate = 1; 285 globalFlagBlockAgendaItemUpdate = 1;
286 repaint( false ); 286 repaint( false );
287} 287}
288 288
289 289
290/* 290/*
291 The eventFilter has to filter the mouse events of the agenda item childs. The 291 The eventFilter has to filter the mouse events of the agenda item childs. The
292 events are fed into the event handling method of KOAgendaItem. This allows the 292 events are fed into the event handling method of KOAgendaItem. This allows the
293 KOAgenda to handle the KOAgendaItems by using an eventFilter. 293 KOAgenda to handle the KOAgendaItems by using an eventFilter.
294*/ 294*/
295bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 295bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
296{ 296{
297 if (e->type() == QEvent::MouseButtonPress || 297 if (e->type() == QEvent::MouseButtonPress ||
298 e->type() == QEvent::MouseButtonDblClick || 298 e->type() == QEvent::MouseButtonDblClick ||
299 e->type() == QEvent::MouseButtonRelease || 299 e->type() == QEvent::MouseButtonRelease ||
300 e->type() == QEvent::MouseMove) { 300 e->type() == QEvent::MouseMove) {
301 QMouseEvent *me = (QMouseEvent *)e; 301 QMouseEvent *me = (QMouseEvent *)e;
302 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 302 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
303 mapToGlobal(me->pos())); 303 mapToGlobal(me->pos()));
304 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 304 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
305 return event(&returnEvent); 305 return event(&returnEvent);
306 } else { 306 } else {
307 return false; 307 return false;
308 } 308 }
309} 309}
310void KOAgendaItem::repaintMe( ) 310void KOAgendaItem::repaintMe( )
311{ 311{
312 paintMe ( mSelected ); 312 paintMe ( mSelected );
313} 313}
314void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 314void KOAgendaItem::paintMe( bool selected, QPainter* paint )
315{ 315{
316 if ( globalFlagBlockAgendaItemUpdate && ! selected) 316 if ( globalFlagBlockAgendaItemUpdate && ! selected)
317 return; 317 return;
318 QPainter pa; 318 QPainter pa;
319 319
320 if ( mSelected ) { 320 if ( mSelected ) {
321 pa.begin( paintPixSel() ); 321 pa.begin( paintPixSel() );
322 } else { 322 } else {
323 if ( mAllDay ) 323 if ( mAllDay )
324 pa.begin( paintPixAllday() ); 324 pa.begin( paintPixAllday() );
325 else 325 else
326 pa.begin( paintPix() ); 326 pa.begin( paintPix() );
327 } 327 }
328 int x, yy, w, h; 328 int x, yy, w, h;
329 float nfh = 7.0; 329 float nfh = 7.0;
330 x = pos().x(); w = width(); h = height (); 330 x = pos().x(); w = width(); h = height ();
331 if ( mAllDay ) 331 if ( mAllDay )
332 yy = y(); 332 yy = y();
333 else 333 else
334 yy = mCellYTop * ( height() / cellHeight() ); 334 yy = mCellYTop * ( height() / cellHeight() );
335 xPaintCoord= x; 335 xPaintCoord= x;
336 yPaintCoord = yy; 336 yPaintCoord = yy;
337 wPaintCoord = width(); 337 wPaintCoord = width();
338 hPaintCoord = height(); 338 hPaintCoord = height();
339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
340 if ( paint == 0 ) 340 if ( paint == 0 )
341 paint = &pa; 341 paint = &pa;
342 bool horLayout = ( w < h ); 342 bool horLayout = ( w < h );
343 int maxhei = mFontPixelSize+4; 343 int maxhei = mFontPixelSize+4;
344 if ( horLayout ) 344 if ( horLayout )
345 maxhei += AGENDA_ICON_SIZE -4; 345 maxhei += AGENDA_ICON_SIZE -4;
346 bool small = ( h < maxhei ); 346 bool small = ( h < maxhei );
347 if ( ! small ) 347 if ( ! small )
348 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 348 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
349 else { 349 else {
350 QFont f = KOPrefs::instance()->mAgendaViewFont; 350 QFont f = KOPrefs::instance()->mAgendaViewFont;
351 f.setBold( false ); 351 f.setBold( false );
352 int fh = f.pointSize(); 352 int fh = f.pointSize();
353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
354 if ( nfh < 6 ) 354 if ( nfh < 6 )
355 nfh = 6; 355 nfh = 6;
356 f.setPointSize( nfh ); 356 f.setPointSize( nfh );
357 paint->setFont(f); 357 paint->setFont(f);
358 } 358 }
359 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 359 paint->fillRect ( x, yy, w, h, mBackgroundColor );
360 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 360 static const QPixmap completedPxmp = SmallIcon("greenhook16");
361 static const QPixmap overduePxmp = SmallIcon("redcross16"); 361 static const QPixmap overduePxmp = SmallIcon("redcross16");
362 if ( mIncidence->type() == "Todo" ) { 362 if ( mIncidence->typeID() == todoID ) {
363 Todo* tempTodo = static_cast<Todo*>(mIncidence); 363 Todo* tempTodo = static_cast<Todo*>(mIncidence);
364 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 364 int xx = pos().x()+(width()-completedPxmp.width()-3 );
365 int yyy = yy+3; 365 int yyy = yy+3;
366 if ( tempTodo->isCompleted() ) 366 if ( tempTodo->isCompleted() )
367 paint->drawPixmap ( xx, yyy, completedPxmp ); 367 paint->drawPixmap ( xx, yyy, completedPxmp );
368 else { 368 else {
369 paint->drawPixmap ( xx, yyy, overduePxmp ); 369 paint->drawPixmap ( xx, yyy, overduePxmp );
370 370
371 } 371 }
372 } 372 }
373 bool addIcon = false; 373 bool addIcon = false;
374 if ( ! small || w > 3 * h || h > 3* w ) 374 if ( ! small || w > 3 * h || h > 3* w )
375 addIcon = updateIcons( paint, horLayout ); 375 addIcon = updateIcons( paint, horLayout );
376 376
377 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 377 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
378 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 378 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
379 if ( ! small ) { 379 if ( ! small ) {
380 x += 3; yy += 3;w -= 6; h-= 5; 380 x += 3; yy += 3;w -= 6; h-= 5;
381 } else { 381 } else {
382 x += 2; yy += 1;w -= 4; h-= 4; 382 x += 2; yy += 1;w -= 4; h-= 4;
383 if ( nfh < 6.01 ) { 383 if ( nfh < 6.01 ) {
384 yy -= 2; 384 yy -= 2;
385 h += 4; 385 h += 4;
386 } 386 }
387 else 387 else
388 if ( nfh < h -2 ) 388 if ( nfh < h -2 )
389 ++yy; 389 ++yy;
390 } 390 }
391 int align; 391 int align;
392#ifndef DESKTOP_VERSION 392#ifndef DESKTOP_VERSION
393 align = ( AlignLeft|WordBreak|AlignTop); 393 align = ( AlignLeft|WordBreak|AlignTop);
394#else 394#else
395 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 395 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
396#endif 396#endif
397 if ( addIcon ) { 397 if ( addIcon ) {
398 if ( ! horLayout ) { 398 if ( ! horLayout ) {
399 x += AGENDA_ICON_SIZE+3; 399 x += AGENDA_ICON_SIZE+3;
400 w -= (AGENDA_ICON_SIZE+3); 400 w -= (AGENDA_ICON_SIZE+3);
401 } 401 }
402 else { 402 else {
403 yy+= AGENDA_ICON_SIZE+2; 403 yy+= AGENDA_ICON_SIZE+2;
404 h -=(AGENDA_ICON_SIZE+3); 404 h -=(AGENDA_ICON_SIZE+3);
405 } 405 }
406 } 406 }
407 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 407 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
408 if ( colsum < 250 ) 408 if ( colsum < 250 )
409 paint->setPen ( white); 409 paint->setPen ( white);
410 if ( x < 0 ) { 410 if ( x < 0 ) {
411 w = w+x-3; 411 w = w+x-3;
412 x = 3; 412 x = 3;
413 if ( w > parentWidget()->width() ){ 413 if ( w > parentWidget()->width() ){
414 w = parentWidget()->width() - 6; 414 w = parentWidget()->width() - 6;
415#ifndef DESKTOP_VERSION 415#ifndef DESKTOP_VERSION
416 align = ( AlignHCenter|WordBreak|AlignTop); 416 align = ( AlignHCenter|WordBreak|AlignTop);
417#else 417#else
418 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 418 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
419#endif 419#endif
420 420
421 } 421 }
422 } 422 }
423 QRect dr; 423 QRect dr;
424 if ( w + x > parentWidget()->width() ) 424 if ( w + x > parentWidget()->width() )
425 w = parentWidget()->width()-x; 425 w = parentWidget()->width()-x;
426 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 426 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
427 //qDebug("%d %d %d %d ", x, yy, w, h ); 427 //qDebug("%d %d %d %d ", x, yy, w, h );
428 if ( mIncidence->cancelled() ){ 428 if ( mIncidence->cancelled() ){
429 429
430 430
431 small = ( height() < 20 ); 431 small = ( height() < 20 );
432 432
433 if ( ! small ) { 433 if ( ! small ) {
434 QFontMetrics fm ( paint->font() ); 434 QFontMetrics fm ( paint->font() );
435 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 435 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
436 } 436 }
437 437
438 } 438 }
439 pa.end(); 439 pa.end();
440 440
441} 441}
442void KOAgendaItem::resizePixmap( int w , int h ) 442void KOAgendaItem::resizePixmap( int w , int h )
443{ 443{
444 paintPix()->resize( w, h ); 444 paintPix()->resize( w, h );
445 paintPixSel()->resize( w, h ); 445 paintPixSel()->resize( w, h );
446 446
447} 447}
448QPixmap * KOAgendaItem::paintPix() 448QPixmap * KOAgendaItem::paintPix()
449{ 449{
450 static QPixmap* mPaintPix = 0; 450 static QPixmap* mPaintPix = 0;
451 if ( ! mPaintPix ) { 451 if ( ! mPaintPix ) {
452 int w = QApplication::desktop()->width(); 452 int w = QApplication::desktop()->width();
453 int h = QApplication::desktop()->height(); 453 int h = QApplication::desktop()->height();
454 mPaintPix = new QPixmap(w,h); 454 mPaintPix = new QPixmap(w,h);
455 } 455 }
456 return mPaintPix ; 456 return mPaintPix ;
457} 457}
458QPixmap * KOAgendaItem::paintPixAllday() 458QPixmap * KOAgendaItem::paintPixAllday()
459{ 459{
460 static QPixmap* mPaintPixA = 0; 460 static QPixmap* mPaintPixA = 0;
461 if ( ! mPaintPixA ) { 461 if ( ! mPaintPixA ) {
462 int w = QApplication::desktop()->width(); 462 int w = QApplication::desktop()->width();
463 int h = QApplication::desktop()->height()/3; 463 int h = QApplication::desktop()->height()/3;
464 mPaintPixA = new QPixmap(w,h); 464 mPaintPixA = new QPixmap(w,h);
465 } 465 }
466 return mPaintPixA ; 466 return mPaintPixA ;
467} 467}
468QPixmap * KOAgendaItem::paintPixSel() 468QPixmap * KOAgendaItem::paintPixSel()
469{ 469{
470 static QPixmap* mPaintPixSel = 0; 470 static QPixmap* mPaintPixSel = 0;
471 if ( ! mPaintPixSel ) { 471 if ( ! mPaintPixSel ) {
472 int w = QApplication::desktop()->width(); 472 int w = QApplication::desktop()->width();
473 int h = QApplication::desktop()->height(); 473 int h = QApplication::desktop()->height();
474 mPaintPixSel = new QPixmap(w,h); 474 mPaintPixSel = new QPixmap(w,h);
475 } 475 }
476 return mPaintPixSel ; 476 return mPaintPixSel ;
477} 477}
478void KOAgendaItem::paintEvent ( QPaintEvent *e ) 478void KOAgendaItem::paintEvent ( QPaintEvent *e )
479{ 479{
480 480
481 if ( globalFlagBlockAgendaItemPaint ) 481 if ( globalFlagBlockAgendaItemPaint )
482 return; 482 return;
483 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 483 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
484 return; 484 return;
485 int yy; 485 int yy;
486 if ( mAllDay ) 486 if ( mAllDay )
487 yy = y(); 487 yy = y();
488 else 488 else
489 yy = mCellYTop * ( height() / cellHeight() ); 489 yy = mCellYTop * ( height() / cellHeight() );
490 int xx = x(); 490 int xx = x();
491 491
492 if ( xPaintCoord != xx || yPaintCoord != yy || 492 if ( xPaintCoord != xx || yPaintCoord != yy ||
493 wPaintCoord != width() || hPaintCoord != height()) { 493 wPaintCoord != width() || hPaintCoord != height()) {
494 xPaintCoord= xx; 494 xPaintCoord= xx;
495 yPaintCoord = yy; 495 yPaintCoord = yy;
496 wPaintCoord = width(); 496 wPaintCoord = width();
497 hPaintCoord = height(); 497 hPaintCoord = height();
498 globalFlagBlockAgendaItemUpdate = 0; 498 globalFlagBlockAgendaItemUpdate = 0;
499 paintMe( mSelected ); 499 paintMe( mSelected );
500 //qDebug("calling paintMe "); 500 //qDebug("calling paintMe ");
501 globalFlagBlockAgendaItemUpdate = 1; 501 globalFlagBlockAgendaItemUpdate = 1;
502 } 502 }
503 int rx, ry, rw, rh; 503 int rx, ry, rw, rh;
504 rx = e->rect().x(); 504 rx = e->rect().x();
505 ry = e->rect().y(); 505 ry = e->rect().y();
506 rw = e->rect().width(); 506 rw = e->rect().width();
507 rh = e->rect().height(); 507 rh = e->rect().height();
508 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 508 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
509 509
510 QPixmap* paintFrom ; 510 QPixmap* paintFrom ;
511 if ( mSelected ) { 511 if ( mSelected ) {
512 paintFrom = paintPixSel(); 512 paintFrom = paintPixSel();
513 } else { 513 } else {
514 if ( mAllDay ) 514 if ( mAllDay )
515 paintFrom = paintPixAllday(); 515 paintFrom = paintPixAllday();
516 else 516 else
517 paintFrom = paintPix(); 517 paintFrom = paintPix();
518 } 518 }
519 xx += rx; 519 xx += rx;
520 520
521 if ( xx < 0 ) { 521 if ( xx < 0 ) {
522 rw = rw + xx; 522 rw = rw + xx;
523 rx -= xx; 523 rx -= xx;
524 xx = 0; 524 xx = 0;
525 if ( rw <= 1 ) { 525 if ( rw <= 1 ) {
526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
527 return; 527 return;
528 } 528 }
529 } 529 }
530 if ( paintFrom->width() < xx+rw ) { 530 if ( paintFrom->width() < xx+rw ) {
531 rw = paintFrom->width() - xx; 531 rw = paintFrom->width() - xx;
532 if ( rw <= 1 ) { 532 if ( rw <= 1 ) {
533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
534 return; 534 return;
535 } 535 }
536 } 536 }
537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
539} 539}
540void KOAgendaItem::computeText() 540void KOAgendaItem::computeText()
541{ 541{
542 mDisplayedText = mIncidence->summary(); 542 mDisplayedText = mIncidence->summary();
543 if ( (mIncidence->type() == "Todo") ) { 543 if ( (mIncidence->typeID() == todoID ) ) {
544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
547 else if ( !(mIncidence->doesFloat())) 547 else if ( !(mIncidence->doesFloat()))
548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
549 } 549 }
550 } else { 550 } else {
551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
553 553
554 if ( mAllDay ) { 554 if ( mAllDay ) {
555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
556 if ( mIncidence->doesRecur() ) { 556 if ( mIncidence->doesRecur() ) {
557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
558 } else { 558 } else {
559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
560 } 560 }
561 } 561 }
562 } 562 }
563 } 563 }
564 564
565 if ( !mIncidence->location().isEmpty() ) { 565 if ( !mIncidence->location().isEmpty() ) {
566 if ( mAllDay ) 566 if ( mAllDay )
567 mDisplayedText += " ("; 567 mDisplayedText += " (";
568 else 568 else
569 mDisplayedText += "\n("; 569 mDisplayedText += "\n(";
570 mDisplayedText += mIncidence->location() +")"; 570 mDisplayedText += mIncidence->location() +")";
571 } 571 }
572#ifdef DESKTOP_VERSION 572#ifdef DESKTOP_VERSION
573 QString tipText = mIncidence->summary(); 573 QString tipText = mIncidence->summary();
574 if ( !mIncidence->doesFloat() ) { 574 if ( !mIncidence->doesFloat() ) {
575 if ( mIncidence->type() == "Event" ) { 575 if ( mIncidence->typeID() == eventID ) {
576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
579 } 579 }
580 else { 580 else {
581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
583 } 583 }
584 } 584 }
585 else if ( mIncidence->type() == "Todo" ) { 585 else if ( mIncidence->typeID() == todoID ) {
586 if (mIncidence->hasStartDate()) 586 if (mIncidence->hasStartDate())
587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
588 if (((Todo*)mIncidence)->hasDueDate()) 588 if (((Todo*)mIncidence)->hasDueDate())
589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
590 } 590 }
591 } else if ( mIncidence->type() == "Todo" ) { 591 } else if ( mIncidence->typeID() == todoID ) {
592 if (mIncidence->hasStartDate()) 592 if (mIncidence->hasStartDate())
593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
594 if (((Todo*)mIncidence)->hasDueDate()) 594 if (((Todo*)mIncidence)->hasDueDate())
595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
596 } 596 }
597 597
598 if (!mIncidence->location().isEmpty()) { 598 if (!mIncidence->location().isEmpty()) {
599 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 599 tipText += "\n"+i18n("Location: ")+mIncidence->location();
600 } 600 }
601 QToolTip::add(this,tipText,toolTipGroup(),""); 601 QToolTip::add(this,tipText,toolTipGroup(),"");
602#endif 602#endif
603} 603}
604void KOAgendaItem::updateItem() 604void KOAgendaItem::updateItem()
605{ 605{
606 computeText(); 606 computeText();
607 607
608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
609 paintMe( mSelected ); 609 paintMe( mSelected );
610 repaint( false); 610 repaint( false);
611} 611}
612 612
613void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 613void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
614{ 614{
615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
616 paintMe( mSelected ); 616 paintMe( mSelected );
617 repaint( false ); 617 repaint( false );
618} 618}
619 619
620/* 620/*
621 Return height of item in units of agenda cells 621 Return height of item in units of agenda cells
622*/ 622*/
623int KOAgendaItem::cellHeight() 623int KOAgendaItem::cellHeight()
624{ 624{
625 int ret = mCellYBottom - mCellYTop + 1; 625 int ret = mCellYBottom - mCellYTop + 1;
626 if ( ret <= 0 ) { 626 if ( ret <= 0 ) {
627 ret = 1; 627 ret = 1;
628 mCellYBottom = 0; 628 mCellYBottom = 0;
629 mCellYTop = 0; 629 mCellYTop = 0;
630 } 630 }
631 return ret; 631 return ret;
632} 632}
633 633
634/* 634/*
635 Return height of item in units of agenda cells 635 Return height of item in units of agenda cells
636*/ 636*/
637int KOAgendaItem::cellWidth() 637int KOAgendaItem::cellWidth()
638{ 638{
639 return mCellXWidth - mCellX + 1; 639 return mCellXWidth - mCellX + 1;
640} 640}
641 641
642void KOAgendaItem::setItemDate(QDate qd) 642void KOAgendaItem::setItemDate(QDate qd)
643{ 643{
644 mDate = qd; 644 mDate = qd;
645} 645}
646 646
647void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 647void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
648{ 648{
649 mCellX = X; 649 mCellX = X;
650 mCellYTop = YTop; 650 mCellYTop = YTop;
651 mCellYBottom = YBottom; 651 mCellYBottom = YBottom;
652} 652}
653 653
654void KOAgendaItem::setCellXWidth(int xwidth) 654void KOAgendaItem::setCellXWidth(int xwidth)
655{ 655{
656 mCellXWidth = xwidth; 656 mCellXWidth = xwidth;
657} 657}
658 658
659void KOAgendaItem::setCellX(int XLeft, int XRight) 659void KOAgendaItem::setCellX(int XLeft, int XRight)
660{ 660{
661 mCellX = XLeft; 661 mCellX = XLeft;
662 mCellXWidth = XRight; 662 mCellXWidth = XRight;
663} 663}
664 664
665void KOAgendaItem::setCellY(int YTop, int YBottom) 665void KOAgendaItem::setCellY(int YTop, int YBottom)
666{ 666{
667 mCellYTop = YTop; 667 mCellYTop = YTop;
668 mCellYBottom = YBottom; 668 mCellYBottom = YBottom;
669} 669}
670 670
671void KOAgendaItem::setSubCell(int subCell) 671void KOAgendaItem::setSubCell(int subCell)
672{ 672{
673 mSubCell = subCell; 673 mSubCell = subCell;
674} 674}
675 675
676void KOAgendaItem::setSubCells(int subCells) 676void KOAgendaItem::setSubCells(int subCells)
677{ 677{
678 mSubCells = subCells; 678 mSubCells = subCells;
679} 679}
680 680
681void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 681void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
682 KOAgendaItem *last) 682 KOAgendaItem *last)
683{ 683{
684 mFirstMultiItem = first; 684 mFirstMultiItem = first;
685 mNextMultiItem = next; 685 mNextMultiItem = next;
686 mLastMultiItem = last; 686 mLastMultiItem = last;
687} 687}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 7022e02..be51694 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -307,462 +307,462 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Add Categ. to selected..."),this, 308 i18n("Add Categ. to selected..."),this,
309 SLOT(addCat()),true); 309 SLOT(addCat()),true);
310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
311 i18n("Set Categ. for selected..."),this, 311 i18n("Set Categ. for selected..."),this,
312 SLOT(setCat()),true); 312 SLOT(setCat()),true);
313 //mPopupMenu->insertSeparator(); 313 //mPopupMenu->insertSeparator();
314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
315 i18n("Set alarm for selected..."),this, 315 i18n("Set alarm for selected..."),this,
316 SLOT(setAlarm()),true); 316 SLOT(setAlarm()),true);
317 317
318 318
319#ifndef DESKTOP_VERSION 319#ifndef DESKTOP_VERSION
320 mPopupMenu->insertSeparator(); 320 mPopupMenu->insertSeparator();
321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
322 i18n("Beam selected via IR"),this, 322 i18n("Beam selected via IR"),this,
323 SLOT(beamSelected()),true); 323 SLOT(beamSelected()),true);
324#endif 324#endif
325 /* 325 /*
326 mPopupMenu = new QPopupMenu; 326 mPopupMenu = new QPopupMenu;
327 mPopupMenu->insertItem(i18n("Edit Event"), this, 327 mPopupMenu->insertItem(i18n("Edit Event"), this,
328 SLOT (editEvent())); 328 SLOT (editEvent()));
329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
330 SLOT (deleteEvent())); 330 SLOT (deleteEvent()));
331 mPopupMenu->insertSeparator(); 331 mPopupMenu->insertSeparator();
332 mPopupMenu->insertItem(i18n("Show Dates"), this, 332 mPopupMenu->insertItem(i18n("Show Dates"), this,
333 SLOT(showDates())); 333 SLOT(showDates()));
334 mPopupMenu->insertItem(i18n("Hide Dates"), this, 334 mPopupMenu->insertItem(i18n("Hide Dates"), this,
335 SLOT(hideDates())); 335 SLOT(hideDates()));
336 */ 336 */
337 QObject::connect(mListView,SIGNAL( newEvent()), 337 QObject::connect(mListView,SIGNAL( newEvent()),
338 this,SIGNAL(signalNewEvent())); 338 this,SIGNAL(signalNewEvent()));
339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
340 this,SLOT(defaultItemAction(QListViewItem *))); 340 this,SLOT(defaultItemAction(QListViewItem *)));
341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
342 const QPoint &, int )), 342 const QPoint &, int )),
343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
345 SLOT(processSelectionChange(QListViewItem *))); 345 SLOT(processSelectionChange(QListViewItem *)));
346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
347 SIGNAL(showIncidenceSignal(Incidence *)) ); 347 SIGNAL(showIncidenceSignal(Incidence *)) );
348 348
349 readSettings(KOGlobals::config(),"KOListView Layout"); 349 readSettings(KOGlobals::config(),"KOListView Layout");
350} 350}
351 351
352KOListView::~KOListView() 352KOListView::~KOListView()
353{ 353{
354 delete mPopupMenu; 354 delete mPopupMenu;
355#if QT_VERSION >= 0x030000 355#if QT_VERSION >= 0x030000
356 356
357#else 357#else
358 delete mKOListViewWhatsThis; 358 delete mKOListViewWhatsThis;
359#endif 359#endif
360} 360}
361 361
362QString KOListView::getWhatsThisText(QPoint p) 362QString KOListView::getWhatsThisText(QPoint p)
363{ 363{
364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
365 if ( item ) 365 if ( item )
366 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 366 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
367 KOPrefs::instance()->mWTshowDetails, 367 KOPrefs::instance()->mWTshowDetails,
368 KOPrefs::instance()->mWTshowCreated, 368 KOPrefs::instance()->mWTshowCreated,
369 KOPrefs::instance()->mWTshowChanged); 369 KOPrefs::instance()->mWTshowChanged);
370 return i18n("That is the list view" ); 370 return i18n("That is the list view" );
371 371
372} 372}
373 373
374void KOListView::updateList() 374void KOListView::updateList()
375{ 375{
376 // qDebug(" KOListView::updateList() "); 376 // qDebug(" KOListView::updateList() ");
377 377
378} 378}
379 379
380void KOListView::clearList() 380void KOListView::clearList()
381{ 381{
382 clear (); 382 clear ();
383} 383}
384void KOListView::addCat( ) 384void KOListView::addCat( )
385{ 385{
386 setCategories( false ); 386 setCategories( false );
387} 387}
388void KOListView::setCat() 388void KOListView::setCat()
389{ 389{
390 setCategories( true ); 390 setCategories( true );
391} 391}
392void KOListView::setAlarm() 392void KOListView::setAlarm()
393{ 393{
394 KOAlarmPrefs kap( this); 394 KOAlarmPrefs kap( this);
395 if ( !kap.exec() ) 395 if ( !kap.exec() )
396 return; 396 return;
397 QStringList itemList; 397 QStringList itemList;
398 QPtrList<KOListViewItem> sel ; 398 QPtrList<KOListViewItem> sel ;
399 QListViewItem *qitem = mListView->firstChild (); 399 QListViewItem *qitem = mListView->firstChild ();
400 while ( qitem ) { 400 while ( qitem ) {
401 if ( qitem->isSelected() ) { 401 if ( qitem->isSelected() ) {
402 Incidence* inc = ((KOListViewItem *) qitem)->data(); 402 Incidence* inc = ((KOListViewItem *) qitem)->data();
403 if ( inc->type() != "Journal" ) { 403 if ( inc->typeID() != journalID ) {
404 if ( inc->type() == "Todo" ) { 404 if ( inc->typeID() == todoID ) {
405 if ( ((Todo*)inc)->hasDueDate() ) 405 if ( ((Todo*)inc)->hasDueDate() )
406 sel.append(((KOListViewItem *)qitem)); 406 sel.append(((KOListViewItem *)qitem));
407 } else 407 } else
408 sel.append(((KOListViewItem *)qitem)); 408 sel.append(((KOListViewItem *)qitem));
409 } 409 }
410 } 410 }
411 qitem = qitem->nextSibling(); 411 qitem = qitem->nextSibling();
412 } 412 }
413 int count = 0; 413 int count = 0;
414 KOListViewItem * item, *temp; 414 KOListViewItem * item, *temp;
415 item = sel.first(); 415 item = sel.first();
416 Incidence* inc; 416 Incidence* inc;
417 while ( item ) { 417 while ( item ) {
418 inc = item->data(); 418 inc = item->data();
419 ++count; 419 ++count;
420 if (kap.mAlarmButton->isChecked()) { 420 if (kap.mAlarmButton->isChecked()) {
421 if (inc->alarms().count() == 0) 421 if (inc->alarms().count() == 0)
422 inc->newAlarm(); 422 inc->newAlarm();
423 QPtrList<Alarm> alarms = inc->alarms(); 423 QPtrList<Alarm> alarms = inc->alarms();
424 Alarm *alarm; 424 Alarm *alarm;
425 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 425 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
426 alarm->setEnabled(true); 426 alarm->setEnabled(true);
427 int j = kap.mAlarmTimeEdit->value()* -60; 427 int j = kap.mAlarmTimeEdit->value()* -60;
428 if (kap.mAlarmIncrCombo->currentItem() == 1) 428 if (kap.mAlarmIncrCombo->currentItem() == 1)
429 j = j * 60; 429 j = j * 60;
430 else if (kap.mAlarmIncrCombo->currentItem() == 2) 430 else if (kap.mAlarmIncrCombo->currentItem() == 2)
431 j = j * (60 * 24); 431 j = j * (60 * 24);
432 alarm->setStartOffset( j ); 432 alarm->setStartOffset( j );
433 433
434 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 434 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
435 alarm->setProcedureAlarm(kap.mAlarmProgram); 435 alarm->setProcedureAlarm(kap.mAlarmProgram);
436 } 436 }
437 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 437 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
438 alarm->setAudioAlarm(kap.mAlarmSound); 438 alarm->setAudioAlarm(kap.mAlarmSound);
439 else 439 else
440 alarm->setType(Alarm::Invalid); 440 alarm->setType(Alarm::Invalid);
441 //alarm->setAudioAlarm("default"); 441 //alarm->setAudioAlarm("default");
442 // TODO: Deal with multiple alarms 442 // TODO: Deal with multiple alarms
443 break; // For now, stop after the first alarm 443 break; // For now, stop after the first alarm
444 } 444 }
445 } else { 445 } else {
446 Alarm* alarm = inc->alarms().first(); 446 Alarm* alarm = inc->alarms().first();
447 if ( alarm ) { 447 if ( alarm ) {
448 alarm->setEnabled(false); 448 alarm->setEnabled(false);
449 alarm->setType(Alarm::Invalid); 449 alarm->setType(Alarm::Invalid);
450 } 450 }
451 } 451 }
452 ListItemVisitor v(item, mStartDate ); 452 ListItemVisitor v(item, mStartDate );
453 inc->accept(v); 453 inc->accept(v);
454 item = sel.next(); 454 item = sel.next();
455 } 455 }
456 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 456 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
457 qDebug("KO: Set alarm for %d items", count); 457 qDebug("KO: Set alarm for %d items", count);
458 calendar()->reInitAlarmSettings(); 458 calendar()->reInitAlarmSettings();
459 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 459 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
460} 460}
461void KOListView::setCategories( bool removeOld ) 461void KOListView::setCategories( bool removeOld )
462{ 462{
463 463
464 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 464 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
465 csd->setColorEnabled(); 465 csd->setColorEnabled();
466 if (! csd->exec()) { 466 if (! csd->exec()) {
467 delete csd; 467 delete csd;
468 return; 468 return;
469 } 469 }
470 QStringList catList = csd->selectedCategories(); 470 QStringList catList = csd->selectedCategories();
471 delete csd; 471 delete csd;
472 // if ( catList.count() == 0 ) 472 // if ( catList.count() == 0 )
473 // return; 473 // return;
474 //catList.sort(); 474 //catList.sort();
475 QString categoriesStr = catList.join(","); 475 QString categoriesStr = catList.join(",");
476 int i; 476 int i;
477 QStringList itemList; 477 QStringList itemList;
478 QPtrList<KOListViewItem> sel ; 478 QPtrList<KOListViewItem> sel ;
479 QListViewItem *qitem = mListView->firstChild (); 479 QListViewItem *qitem = mListView->firstChild ();
480 while ( qitem ) { 480 while ( qitem ) {
481 if ( qitem->isSelected() ) { 481 if ( qitem->isSelected() ) {
482 sel.append(((KOListViewItem *)qitem)); 482 sel.append(((KOListViewItem *)qitem));
483 } 483 }
484 qitem = qitem->nextSibling(); 484 qitem = qitem->nextSibling();
485 } 485 }
486 KOListViewItem * item, *temp; 486 KOListViewItem * item, *temp;
487 item = sel.first(); 487 item = sel.first();
488 if( item ) { 488 if( item ) {
489 Incidence* inc = item->data() ; 489 Incidence* inc = item->data() ;
490 bool setSub = false; 490 bool setSub = false;
491 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { 491 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
492 int result = KMessageBox::warningYesNoCancel(this, 492 int result = KMessageBox::warningYesNoCancel(this,
493 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 493 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
494 i18n("Todo has subtodos"), 494 i18n("Todo has subtodos"),
495 i18n("Yes"), 495 i18n("Yes"),
496 i18n("No")); 496 i18n("No"));
497 if (result == KMessageBox::Cancel) item = 0; 497 if (result == KMessageBox::Cancel) item = 0;
498 if (result == KMessageBox::Yes) setSub = true; 498 if (result == KMessageBox::Yes) setSub = true;
499 } 499 }
500 while ( item ) { 500 while ( item ) {
501 inc = item->data(); 501 inc = item->data();
502 if ( removeOld ) { 502 if ( removeOld ) {
503 inc->setCategories( catList, setSub ); 503 inc->setCategories( catList, setSub );
504 } else { 504 } else {
505 inc->addCategories( catList, setSub ); 505 inc->addCategories( catList, setSub );
506 } 506 }
507 ListItemVisitor v(item, mStartDate ); 507 ListItemVisitor v(item, mStartDate );
508 inc->accept(v); 508 inc->accept(v);
509 item = sel.next(); 509 item = sel.next();
510 } 510 }
511 } 511 }
512 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 512 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
513} 513}
514 514
515void KOListView::beamSelected() 515void KOListView::beamSelected()
516{ 516{
517 int icount = 0; 517 int icount = 0;
518 QPtrList<Incidence> delSel ; 518 QPtrList<Incidence> delSel ;
519 QListViewItem *item = mListView->firstChild (); 519 QListViewItem *item = mListView->firstChild ();
520 while ( item ) { 520 while ( item ) {
521 if ( item->isSelected() ) { 521 if ( item->isSelected() ) {
522 delSel.append(((KOListViewItem *)item)->data()); 522 delSel.append(((KOListViewItem *)item)->data());
523 ++icount; 523 ++icount;
524 } 524 }
525 525
526 item = item->nextSibling(); 526 item = item->nextSibling();
527 } 527 }
528 if ( icount ) { 528 if ( icount ) {
529 emit beamIncidenceList( delSel ); 529 emit beamIncidenceList( delSel );
530 return; 530 return;
531 QString fn ; 531 QString fn ;
532 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 532 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
533 QString mes; 533 QString mes;
534 bool createbup = true; 534 bool createbup = true;
535 if ( createbup ) { 535 if ( createbup ) {
536 QString description = "\n"; 536 QString description = "\n";
537 CalendarLocal* cal = new CalendarLocal(); 537 CalendarLocal* cal = new CalendarLocal();
538 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 538 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
539 Incidence *incidence = delSel.first(); 539 Incidence *incidence = delSel.first();
540 while ( incidence ) { 540 while ( incidence ) {
541 Incidence *in = incidence->clone(); 541 Incidence *in = incidence->clone();
542 description += in->summary() + "\n"; 542 description += in->summary() + "\n";
543 cal->addIncidence( in ); 543 cal->addIncidence( in );
544 incidence = delSel.next(); 544 incidence = delSel.next();
545 } 545 }
546 FileStorage storage( cal, fn, new VCalFormat ); 546 FileStorage storage( cal, fn, new VCalFormat );
547 storage.save(); 547 storage.save();
548 delete cal; 548 delete cal;
549 mes = i18n("KO/Pi: Ready for beaming"); 549 mes = i18n("KO/Pi: Ready for beaming");
550 topLevelWidget()->setCaption(mes); 550 topLevelWidget()->setCaption(mes);
551 551
552#ifndef DESKTOP_VERSION 552#ifndef DESKTOP_VERSION
553 Ir *ir = new Ir( this ); 553 Ir *ir = new Ir( this );
554 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 554 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
555 ir->send( fn, description, "text/x-vCalendar" ); 555 ir->send( fn, description, "text/x-vCalendar" );
556#endif 556#endif
557 } 557 }
558 } 558 }
559} 559}
560void KOListView::beamDone( Ir *ir ) 560void KOListView::beamDone( Ir *ir )
561{ 561{
562#ifndef DESKTOP_VERSION 562#ifndef DESKTOP_VERSION
563 delete ir; 563 delete ir;
564#endif 564#endif
565 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 565 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
566} 566}
567 567
568void KOListView::saveDescriptionToFile() 568void KOListView::saveDescriptionToFile()
569{ 569{
570 570
571 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 571 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
572 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 572 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
573 i18n("Continue"), i18n("Cancel"), 0, 573 i18n("Continue"), i18n("Cancel"), 0,
574 0, 1 ); 574 0, 1 );
575 if ( result != 0 ) { 575 if ( result != 0 ) {
576 return; 576 return;
577 } 577 }
578 int icount = 0; 578 int icount = 0;
579 QPtrList<Incidence> delSel ; 579 QPtrList<Incidence> delSel ;
580 QListViewItem *item = mListView->firstChild (); 580 QListViewItem *item = mListView->firstChild ();
581 while ( item ) { 581 while ( item ) {
582 if ( item->isSelected() ) { 582 if ( item->isSelected() ) {
583 delSel.append(((KOListViewItem *)item)->data()); 583 delSel.append(((KOListViewItem *)item)->data());
584 ++icount; 584 ++icount;
585 } 585 }
586 586
587 item = item->nextSibling(); 587 item = item->nextSibling();
588 } 588 }
589 if ( icount ) { 589 if ( icount ) {
590 QString fn = KOPrefs::instance()->mLastSaveFile; 590 QString fn = KOPrefs::instance()->mLastSaveFile;
591 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 591 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
592 592
593 if ( fn == "" ) 593 if ( fn == "" )
594 return; 594 return;
595 QFileInfo info; 595 QFileInfo info;
596 info.setFile( fn ); 596 info.setFile( fn );
597 QString mes; 597 QString mes;
598 bool createbup = true; 598 bool createbup = true;
599 if ( info. exists() ) { 599 if ( info. exists() ) {
600 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 600 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
601 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 601 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
602 i18n("Overwrite!"), i18n("Cancel"), 0, 602 i18n("Overwrite!"), i18n("Cancel"), 0,
603 0, 1 ); 603 0, 1 );
604 if ( result != 0 ) { 604 if ( result != 0 ) {
605 createbup = false; 605 createbup = false;
606 } 606 }
607 } 607 }
608 if ( createbup ) { 608 if ( createbup ) {
609 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 609 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
610 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 610 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
611 Incidence *incidence = delSel.first(); 611 Incidence *incidence = delSel.first();
612 icount = 0; 612 icount = 0;
613 while ( incidence ) { 613 while ( incidence ) {
614 if ( incidence->type() == "Journal" ) { 614 if ( incidence->typeID() == journalID ) {
615 text += "\n************************************\n"; 615 text += "\n************************************\n";
616 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 616 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
617 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 617 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
618 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 618 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
619 ++icount; 619 ++icount;
620 620
621 } else { 621 } else {
622 if ( !incidence->description().isEmpty() ) { 622 if ( !incidence->description().isEmpty() ) {
623 text += "\n************************************\n"; 623 text += "\n************************************\n";
624 if ( incidence->type() == "Todo" ) 624 if ( incidence->typeID() == todoID )
625 text += i18n("To-Do: "); 625 text += i18n("To-Do: ");
626 text += incidence->summary(); 626 text += incidence->summary();
627 if ( incidence->hasStartDate() ) 627 if ( incidence->hasStartDate() )
628 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 628 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
629 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 629 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
630 if ( !incidence->location().isEmpty() ) 630 if ( !incidence->location().isEmpty() )
631 text += "\n" +i18n("Location: ") + incidence->location(); 631 text += "\n" +i18n("Location: ") + incidence->location();
632 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 632 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
633 ++icount; 633 ++icount;
634 634
635 } 635 }
636 } 636 }
637 incidence = delSel.next(); 637 incidence = delSel.next();
638 } 638 }
639 QFile file( fn ); 639 QFile file( fn );
640 if (!file.open( IO_WriteOnly ) ) { 640 if (!file.open( IO_WriteOnly ) ) {
641 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 641 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
642 return; 642 return;
643 } 643 }
644 QTextStream ts( &file ); 644 QTextStream ts( &file );
645 ts << text; 645 ts << text;
646 file.close(); 646 file.close();
647 //qDebug("%s ", text.latin1()); 647 //qDebug("%s ", text.latin1());
648 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 648 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
649 KOPrefs::instance()->mLastSaveFile = fn; 649 KOPrefs::instance()->mLastSaveFile = fn;
650 topLevelWidget()->setCaption(mes); 650 topLevelWidget()->setCaption(mes);
651 } 651 }
652 } 652 }
653} 653}
654void KOListView::saveToFileVCS() 654void KOListView::saveToFileVCS()
655{ 655{
656 writeToFile( false ); 656 writeToFile( false );
657} 657}
658void KOListView::saveToFile() 658void KOListView::saveToFile()
659{ 659{
660 writeToFile( true ); 660 writeToFile( true );
661} 661}
662void KOListView::writeToFile( bool iCal ) 662void KOListView::writeToFile( bool iCal )
663{ 663{
664 664
665 int icount = 0; 665 int icount = 0;
666 QPtrList<Incidence> delSel ; 666 QPtrList<Incidence> delSel ;
667 QListViewItem *item = mListView->firstChild (); 667 QListViewItem *item = mListView->firstChild ();
668 bool journal = iCal; // warn only for vCal 668 bool journal = iCal; // warn only for vCal
669 while ( item ) { 669 while ( item ) {
670 if ( item->isSelected() ) { 670 if ( item->isSelected() ) {
671 if ( !journal ) 671 if ( !journal )
672 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 672 if ( ((KOListViewItem *)item)->data()->typeID() == journalID )
673 journal = true; 673 journal = true;
674 delSel.append(((KOListViewItem *)item)->data()); 674 delSel.append(((KOListViewItem *)item)->data());
675 ++icount; 675 ++icount;
676 } 676 }
677 677
678 item = item->nextSibling(); 678 item = item->nextSibling();
679 } 679 }
680 if ( !iCal && journal ) { 680 if ( !iCal && journal ) {
681 int result = KMessageBox::warningContinueCancel(this, 681 int result = KMessageBox::warningContinueCancel(this,
682 i18n("The journal entries can not be\nexported to a vCalendar file."), 682 i18n("The journal entries can not be\nexported to a vCalendar file."),
683 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 683 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
684 true); 684 true);
685 if (result != KMessageBox::Continue) return; 685 if (result != KMessageBox::Continue) return;
686 } 686 }
687 if ( icount ) { 687 if ( icount ) {
688 QString fn = KOPrefs::instance()->mLastSaveFile; 688 QString fn = KOPrefs::instance()->mLastSaveFile;
689 QString extension; 689 QString extension;
690 if ( iCal ) { 690 if ( iCal ) {
691 if ( fn.right( 4 ).lower() == ".vcs" ) { 691 if ( fn.right( 4 ).lower() == ".vcs" ) {
692 fn = fn.left( fn.length() -3) + "ics"; 692 fn = fn.left( fn.length() -3) + "ics";
693 } 693 }
694 } else { 694 } else {
695 if ( fn.right( 4 ).lower() == ".ics" ) { 695 if ( fn.right( 4 ).lower() == ".ics" ) {
696 fn = fn.left( fn.length() -3) + "vcs"; 696 fn = fn.left( fn.length() -3) + "vcs";
697 } 697 }
698 } 698 }
699 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 699 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
700 700
701 if ( fn == "" ) 701 if ( fn == "" )
702 return; 702 return;
703 QFileInfo info; 703 QFileInfo info;
704 info.setFile( fn ); 704 info.setFile( fn );
705 QString mes; 705 QString mes;
706 bool createbup = true; 706 bool createbup = true;
707 if ( info. exists() ) { 707 if ( info. exists() ) {
708 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 708 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
709 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 709 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
710 i18n("Overwrite!"), i18n("Cancel"), 0, 710 i18n("Overwrite!"), i18n("Cancel"), 0,
711 0, 1 ); 711 0, 1 );
712 if ( result != 0 ) { 712 if ( result != 0 ) {
713 createbup = false; 713 createbup = false;
714 } 714 }
715 } 715 }
716 if ( createbup ) { 716 if ( createbup ) {
717 CalendarLocal cal; 717 CalendarLocal cal;
718 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 718 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
719 Incidence *incidence = delSel.first(); 719 Incidence *incidence = delSel.first();
720 while ( incidence ) { 720 while ( incidence ) {
721 cal.addIncidence( incidence->clone() ); 721 cal.addIncidence( incidence->clone() );
722 incidence = delSel.next(); 722 incidence = delSel.next();
723 } 723 }
724 if ( iCal ) { 724 if ( iCal ) {
725 ICalFormat format; 725 ICalFormat format;
726 format.save( &cal, fn ); 726 format.save( &cal, fn );
727 } else { 727 } else {
728 728
729 VCalFormat format; 729 VCalFormat format;
730 format.save( &cal, fn ); 730 format.save( &cal, fn );
731 } 731 }
732 mes = i18n("KO/Pi:Saved %1").arg(fn ); 732 mes = i18n("KO/Pi:Saved %1").arg(fn );
733 KOPrefs::instance()->mLastSaveFile = fn; 733 KOPrefs::instance()->mLastSaveFile = fn;
734 topLevelWidget()->setCaption(mes); 734 topLevelWidget()->setCaption(mes);
735 } 735 }
736 } 736 }
737 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 737 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
738} 738}
739void KOListView::hideAll() 739void KOListView::hideAll()
740{ 740{
741 QPtrList<QListViewItem> delSel ; 741 QPtrList<QListViewItem> delSel ;
742 QListViewItem *item = mListView->firstChild (); 742 QListViewItem *item = mListView->firstChild ();
743 while ( item ) { 743 while ( item ) {
744 if ( item->isSelected() ) { 744 if ( item->isSelected() ) {
745 delSel.append(item); 745 delSel.append(item);
746 } 746 }
747 item = item->nextSibling(); 747 item = item->nextSibling();
748 } 748 }
749 item = delSel.first() ; 749 item = delSel.first() ;
750 while ( item ) { 750 while ( item ) {
751 QListViewItem * del = item; 751 QListViewItem * del = item;
752 item = delSel.next(); 752 item = delSel.next();
753 delete del; 753 delete del;
754 } 754 }
755} 755}
756void KOListView::printList() 756void KOListView::printList()
757{ 757{
758 mListView->printList(); 758 mListView->printList();
759} 759}
760void KOListView::deleteAll() 760void KOListView::deleteAll()
761{ 761{
762 int icount = 0; 762 int icount = 0;
763 QPtrList<Incidence> delSel ; 763 QPtrList<Incidence> delSel ;
764 QListViewItem *item = mListView->firstChild (); 764 QListViewItem *item = mListView->firstChild ();
765 while ( item ) { 765 while ( item ) {
766 if ( item->isSelected() ) { 766 if ( item->isSelected() ) {
767 delSel.append(((KOListViewItem *)item)->data()); 767 delSel.append(((KOListViewItem *)item)->data());
768 ++icount; 768 ++icount;
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 5aaf360..2602487 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -609,335 +609,335 @@ QString KOTodoView::getWhatsThisText(QPoint p)
609 KOPrefs::instance()->mWTshowDetails, 609 KOPrefs::instance()->mWTshowDetails,
610 KOPrefs::instance()->mWTshowCreated, 610 KOPrefs::instance()->mWTshowCreated,
611 KOPrefs::instance()->mWTshowChanged); 611 KOPrefs::instance()->mWTshowChanged);
612 return i18n("That is the todo view" ); 612 return i18n("That is the todo view" );
613 613
614} 614}
615 615
616void KOTodoView::jumpToDate () 616void KOTodoView::jumpToDate ()
617{ 617{
618 // if (mActiveItem) { 618 // if (mActiveItem) {
619// mActiveItem->todo()); 619// mActiveItem->todo());
620// if ( mActiveItem->todo()->hasDueDate() ) 620// if ( mActiveItem->todo()->hasDueDate() )
621// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 621// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
622} 622}
623void KOTodoView::paintNeeded() 623void KOTodoView::paintNeeded()
624{ 624{
625 if ( mPendingUpdateBeforeRepaint ) { 625 if ( mPendingUpdateBeforeRepaint ) {
626 updateView(); 626 updateView();
627 mPendingUpdateBeforeRepaint = false; 627 mPendingUpdateBeforeRepaint = false;
628 } 628 }
629} 629}
630void KOTodoView::paintEvent(QPaintEvent * pevent) 630void KOTodoView::paintEvent(QPaintEvent * pevent)
631{ 631{
632 if ( mPendingUpdateBeforeRepaint ) { 632 if ( mPendingUpdateBeforeRepaint ) {
633 updateView(); 633 updateView();
634 mPendingUpdateBeforeRepaint = false; 634 mPendingUpdateBeforeRepaint = false;
635 } 635 }
636 KOrg::BaseView::paintEvent( pevent); 636 KOrg::BaseView::paintEvent( pevent);
637} 637}
638 638
639void KOTodoView::updateView() 639void KOTodoView::updateView()
640{ 640{
641 pendingSubtodo = 0; 641 pendingSubtodo = 0;
642 if ( mBlockUpdate ) { 642 if ( mBlockUpdate ) {
643 return; 643 return;
644 } 644 }
645 if ( !isVisible() ) { 645 if ( !isVisible() ) {
646 mPendingUpdateBeforeRepaint = true; 646 mPendingUpdateBeforeRepaint = true;
647 return; 647 return;
648 } 648 }
649 storeCurrentItem(); 649 storeCurrentItem();
650 //qDebug("KOTodoView::updateView() %x", this); 650 //qDebug("KOTodoView::updateView() %x", this);
651 if ( isFlatDisplay ) { 651 if ( isFlatDisplay ) {
652 displayAllFlat(); 652 displayAllFlat();
653 resetCurrentItem(); 653 resetCurrentItem();
654 return; 654 return;
655 } 655 }
656 //qDebug("update "); 656 //qDebug("update ");
657// kdDebug() << "KOTodoView::updateView()" << endl; 657// kdDebug() << "KOTodoView::updateView()" << endl;
658 QFont fo = KOPrefs::instance()->mTodoViewFont; 658 QFont fo = KOPrefs::instance()->mTodoViewFont;
659 659
660 660
661 mTodoListView->clear(); 661 mTodoListView->clear();
662 if ( mName == "todolistsmall" ) { 662 if ( mName == "todolistsmall" ) {
663 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 663 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
664 int ps = fo.pointSize() -2; 664 int ps = fo.pointSize() -2;
665 if ( ps > 12 ) 665 if ( ps > 12 )
666 ps -= 2; 666 ps -= 2;
667 fo.setPointSize( ps ); 667 fo.setPointSize( ps );
668 } 668 }
669 } 669 }
670 670
671 mTodoListView->setFont( fo ); 671 mTodoListView->setFont( fo );
672 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 672 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
673 //mTodoListView->header()->setMaximumHeight(fm.height()); 673 //mTodoListView->header()->setMaximumHeight(fm.height());
674 QPtrList<Todo> todoList = calendar()->todos(); 674 QPtrList<Todo> todoList = calendar()->todos();
675 675
676/* 676/*
677 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 677 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
678 Event *t; 678 Event *t;
679 for(t = todoList.first(); t; t = todoList.next()) { 679 for(t = todoList.first(); t; t = todoList.next()) {
680 kdDebug() << " " << t->getSummary() << endl; 680 kdDebug() << " " << t->getSummary() << endl;
681 681
682 if (t->getRelatedTo()) { 682 if (t->getRelatedTo()) {
683 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 683 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
684 } 684 }
685 685
686 QPtrList<Event> l = t->getRelations(); 686 QPtrList<Event> l = t->getRelations();
687 Event *c; 687 Event *c;
688 for(c=l.first();c;c=l.next()) { 688 for(c=l.first();c;c=l.next()) {
689 kdDebug() << " - relation: " << c->getSummary() << endl; 689 kdDebug() << " - relation: " << c->getSummary() << endl;
690 } 690 }
691 } 691 }
692*/ 692*/
693 693
694 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 694 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
695 // specific order of events. That means that we have to generate parent items 695 // specific order of events. That means that we have to generate parent items
696 // recursively for proper hierarchical display of Todos. 696 // recursively for proper hierarchical display of Todos.
697 mTodoMap.clear(); 697 mTodoMap.clear();
698 Todo *todo; 698 Todo *todo;
699 todo = todoList.first();// todo; todo = todoList.next()) { 699 todo = todoList.first();// todo; todo = todoList.next()) {
700 while ( todo ) { 700 while ( todo ) {
701 bool next = true; 701 bool next = true;
702 // qDebug("todo %s ", todo->summary().latin1()); 702 // qDebug("todo %s ", todo->summary().latin1());
703 Incidence *incidence = todo->relatedTo(); 703 Incidence *incidence = todo->relatedTo();
704 while ( incidence ) { 704 while ( incidence ) {
705 if ( incidence->type() == "Todo") { 705 if ( incidence->typeID() == todoID ) {
706 //qDebug("related %s ",incidence->summary().latin1() ); 706 //qDebug("related %s ",incidence->summary().latin1() );
707 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 707 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
708 //qDebug("related not found "); 708 //qDebug("related not found ");
709 todoList.remove( ); 709 todoList.remove( );
710 todo = todoList.current(); 710 todo = todoList.current();
711 next = false; 711 next = false;
712 incidence = 0; 712 incidence = 0;
713 713
714 } else { 714 } else {
715 //qDebug("related found "); 715 //qDebug("related found ");
716 incidence = incidence->relatedTo(); 716 incidence = incidence->relatedTo();
717 } 717 }
718 } else 718 } else
719 incidence = 0; 719 incidence = 0;
720 } 720 }
721 if ( next ) 721 if ( next )
722 todo = todoList.next(); 722 todo = todoList.next();
723 } 723 }
724 724
725 for(todo = todoList.first(); todo; todo = todoList.next()) { 725 for(todo = todoList.first(); todo; todo = todoList.next()) {
726 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 726 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
727 { 727 {
728 insertTodoItem(todo); 728 insertTodoItem(todo);
729 } 729 }
730 } 730 }
731 // Restore opened/closed state 731 // Restore opened/closed state
732 mTodoListView->blockSignals( true ); 732 mTodoListView->blockSignals( true );
733 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 733 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
734 mTodoListView->blockSignals( false ); 734 mTodoListView->blockSignals( false );
735 resetCurrentItem(); 735 resetCurrentItem();
736 processSelectionChange(); 736 processSelectionChange();
737} 737}
738 738
739void KOTodoView::storeCurrentItem() 739void KOTodoView::storeCurrentItem()
740{ 740{
741 mCurItem = 0; 741 mCurItem = 0;
742 mCurItemRootParent = 0; 742 mCurItemRootParent = 0;
743 mCurItemParent = 0; 743 mCurItemParent = 0;
744 mCurItemAbove = 0; 744 mCurItemAbove = 0;
745 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 745 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
746 if (mActiveItem) { 746 if (mActiveItem) {
747 mCurItem = mActiveItem->todo(); 747 mCurItem = mActiveItem->todo();
748 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 748 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
749 if ( activeItemAbove ) 749 if ( activeItemAbove )
750 mCurItemAbove = activeItemAbove->todo(); 750 mCurItemAbove = activeItemAbove->todo();
751 mCurItemRootParent = mCurItem; 751 mCurItemRootParent = mCurItem;
752 mCurItemParent = mCurItemRootParent->relatedTo(); 752 mCurItemParent = mCurItemRootParent->relatedTo();
753 while ( mCurItemRootParent->relatedTo() != 0 ) 753 while ( mCurItemRootParent->relatedTo() != 0 )
754 mCurItemRootParent = mCurItemRootParent->relatedTo(); 754 mCurItemRootParent = mCurItemRootParent->relatedTo();
755 } 755 }
756 mActiveItem = 0; 756 mActiveItem = 0;
757} 757}
758 758
759void KOTodoView::resetCurrentItem() 759void KOTodoView::resetCurrentItem()
760{ 760{
761 mTodoListView->setFocus(); 761 mTodoListView->setFocus();
762 KOTodoViewItem* foundItem = 0; 762 KOTodoViewItem* foundItem = 0;
763 KOTodoViewItem* foundItemRoot = 0; 763 KOTodoViewItem* foundItemRoot = 0;
764 KOTodoViewItem* foundItemParent = 0; 764 KOTodoViewItem* foundItemParent = 0;
765 KOTodoViewItem* foundItemAbove = 0; 765 KOTodoViewItem* foundItemAbove = 0;
766 if ( mTodoListView->firstChild () ) { 766 if ( mTodoListView->firstChild () ) {
767 if ( mCurItem ) { 767 if ( mCurItem ) {
768 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 768 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
769 while ( item ) { 769 while ( item ) {
770 if ( item->todo() == mCurItem ) { 770 if ( item->todo() == mCurItem ) {
771 foundItem = item; 771 foundItem = item;
772 break; 772 break;
773 } else if ( item->todo() == mCurItemAbove ) { 773 } else if ( item->todo() == mCurItemAbove ) {
774 foundItemAbove = item; 774 foundItemAbove = item;
775 775
776 } 776 }
777 if ( item->todo() == mCurItemRootParent ) { 777 if ( item->todo() == mCurItemRootParent ) {
778 foundItemRoot = item; 778 foundItemRoot = item;
779 } 779 }
780 if ( item->todo() == mCurItemParent ) { 780 if ( item->todo() == mCurItemParent ) {
781 foundItemParent = item; 781 foundItemParent = item;
782 } 782 }
783 item = (KOTodoViewItem*)item->itemBelow(); 783 item = (KOTodoViewItem*)item->itemBelow();
784 } 784 }
785 if ( ! foundItem ) { 785 if ( ! foundItem ) {
786 if ( foundItemParent ) { 786 if ( foundItemParent ) {
787 foundItem = foundItemParent; 787 foundItem = foundItemParent;
788 } else { 788 } else {
789 if ( foundItemRoot ) 789 if ( foundItemRoot )
790 foundItem = foundItemRoot; 790 foundItem = foundItemRoot;
791 else 791 else
792 foundItem = foundItemAbove; 792 foundItem = foundItemAbove;
793 } 793 }
794 } 794 }
795 } 795 }
796 if ( foundItem ) { 796 if ( foundItem ) {
797 mTodoListView->setCurrentItem( foundItem ); 797 mTodoListView->setCurrentItem( foundItem );
798 mTodoListView->ensureItemVisible( foundItem ); 798 mTodoListView->ensureItemVisible( foundItem );
799 } else { 799 } else {
800 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 800 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
801 } 801 }
802 } 802 }
803 mTodoListView->setFocus(); 803 mTodoListView->setFocus();
804} 804}
805//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 805//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
806bool KOTodoView::checkTodo( Todo * todo ) 806bool KOTodoView::checkTodo( Todo * todo )
807{ 807{
808 808
809 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 809 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
810 return false; 810 return false;
811 if ( !todo->isCompleted() ) { 811 if ( !todo->isCompleted() ) {
812 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 812 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
813 return true; 813 return true;
814 } 814 }
815 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 815 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
816 if ( todo->hasStartDate() ) 816 if ( todo->hasStartDate() )
817 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 817 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
818 return false; 818 return false;
819 if ( todo->hasDueDate() ) 819 if ( todo->hasDueDate() )
820 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 820 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
821 return false; 821 return false;
822 } 822 }
823 return true; 823 return true;
824} 824}
825 825
826void KOTodoView::restoreItemState( QListViewItem *item ) 826void KOTodoView::restoreItemState( QListViewItem *item )
827{ 827{
828 pendingSubtodo = 0; 828 pendingSubtodo = 0;
829 while( item ) { 829 while( item ) {
830 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 830 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
831 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 831 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
832 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 832 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
833 item = item->nextSibling(); 833 item = item->nextSibling();
834 } 834 }
835} 835}
836 836
837 837
838QMap<Todo *,KOTodoViewItem *>::ConstIterator 838QMap<Todo *,KOTodoViewItem *>::ConstIterator
839 KOTodoView::insertTodoItem(Todo *todo) 839 KOTodoView::insertTodoItem(Todo *todo)
840{ 840{
841 841
842// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 842// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
843 // TODO: Check, if dynmaic cast is necessary 843 // TODO: Check, if dynmaic cast is necessary
844 844
845 pendingSubtodo = 0; 845 pendingSubtodo = 0;
846 Incidence *incidence = todo->relatedTo(); 846 Incidence *incidence = todo->relatedTo();
847 if (incidence && incidence->type() == "Todo") { 847 if (incidence && incidence->typeID() == todoID ) {
848 Todo *relatedTodo = static_cast<Todo *>(incidence); 848 Todo *relatedTodo = static_cast<Todo *>(incidence);
849 849
850// kdDebug() << " has Related" << endl; 850// kdDebug() << " has Related" << endl;
851 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 851 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
852 itemIterator = mTodoMap.find(relatedTodo); 852 itemIterator = mTodoMap.find(relatedTodo);
853 if (itemIterator == mTodoMap.end()) { 853 if (itemIterator == mTodoMap.end()) {
854// kdDebug() << " related not yet in list" << endl; 854// kdDebug() << " related not yet in list" << endl;
855 itemIterator = insertTodoItem (relatedTodo); 855 itemIterator = insertTodoItem (relatedTodo);
856 } 856 }
857 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 857 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
858 // and one into the map. Sure finding is more easy but why? -zecke 858 // and one into the map. Sure finding is more easy but why? -zecke
859 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 859 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
860 return mTodoMap.insert(todo,todoItem); 860 return mTodoMap.insert(todo,todoItem);
861 } else { 861 } else {
862// kdDebug() << " no Related" << endl; 862// kdDebug() << " no Related" << endl;
863 // see above -zecke 863 // see above -zecke
864 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 864 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
865 return mTodoMap.insert(todo,todoItem); 865 return mTodoMap.insert(todo,todoItem);
866 } 866 }
867} 867}
868 868
869 869
870void KOTodoView::updateConfig() 870void KOTodoView::updateConfig()
871{ 871{
872 updateView(); 872 updateView();
873 mTodoListView->repaintContents(); 873 mTodoListView->repaintContents();
874} 874}
875 875
876QPtrList<Incidence> KOTodoView::selectedIncidences() 876QPtrList<Incidence> KOTodoView::selectedIncidences()
877{ 877{
878 QPtrList<Incidence> selected; 878 QPtrList<Incidence> selected;
879 879
880 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 880 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
881// if (!item) item = mActiveItem; 881// if (!item) item = mActiveItem;
882 if (item) selected.append(item->todo()); 882 if (item) selected.append(item->todo());
883 883
884 return selected; 884 return selected;
885} 885}
886 886
887QPtrList<Todo> KOTodoView::selectedTodos() 887QPtrList<Todo> KOTodoView::selectedTodos()
888{ 888{
889 QPtrList<Todo> selected; 889 QPtrList<Todo> selected;
890 890
891 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 891 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
892// if (!item) item = mActiveItem; 892// if (!item) item = mActiveItem;
893 if (item) selected.append(item->todo()); 893 if (item) selected.append(item->todo());
894 894
895 return selected; 895 return selected;
896} 896}
897 897
898void KOTodoView::changeEventDisplay(Event *, int) 898void KOTodoView::changeEventDisplay(Event *, int)
899{ 899{
900 updateView(); 900 updateView();
901} 901}
902 902
903void KOTodoView::showDates(const QDate &, const QDate &) 903void KOTodoView::showDates(const QDate &, const QDate &)
904{ 904{
905} 905}
906 906
907void KOTodoView::showEvents(QPtrList<Event>) 907void KOTodoView::showEvents(QPtrList<Event>)
908{ 908{
909 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 909 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
910} 910}
911 911
912void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 912void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
913 const QDate &td) 913 const QDate &td)
914{ 914{
915#ifndef KORG_NOPRINTER 915#ifndef KORG_NOPRINTER
916 calPrinter->preview(CalPrinter::Todolist, fd, td); 916 calPrinter->preview(CalPrinter::Todolist, fd, td);
917#endif 917#endif
918} 918}
919 919
920void KOTodoView::editItem(QListViewItem *item ) 920void KOTodoView::editItem(QListViewItem *item )
921{ 921{
922 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 922 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
923} 923}
924 924
925void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 925void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
926{ 926{
927 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 927 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
928} 928}
929 929
930void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 930void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
931{ 931{
932 pendingSubtodo = 0; 932 pendingSubtodo = 0;
933 mActiveItem = (KOTodoViewItem *)item; 933 mActiveItem = (KOTodoViewItem *)item;
934 if (item) { 934 if (item) {
935 switch (column){ 935 switch (column){
936 case 1: 936 case 1:
937 mPriorityPopupMenu->popup(QCursor::pos ()); break; 937 mPriorityPopupMenu->popup(QCursor::pos ()); break;
938 case 2: 938 case 2:
939 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 939 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
940 case 3: 940 case 3:
941 moveTodo(); 941 moveTodo();
942 break; 942 break;
943 case 8: 943 case 8:
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 62d7ede..e8574a0 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -396,335 +396,335 @@ void KOWhatsNextView::updateView()
396 396
397 // QPixmap bPix = SmallIcon( "back" ); 397 // QPixmap bPix = SmallIcon( "back" );
398 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 398 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
399 // QWidget* test = new QWidget(); 399 // QWidget* test = new QWidget();
400 // test->setBackgroundMode(FixedPixmap ); 400 // test->setBackgroundMode(FixedPixmap );
401 // test->setBackgroundPixmap ( bPix ); 401 // test->setBackgroundPixmap ( bPix );
402 // test->resize( 300, 400 ); 402 // test->resize( 300, 400 );
403 // test->show(); 403 // test->show();
404 // mView->setBackgroundMode(FixedPixmap ); 404 // mView->setBackgroundMode(FixedPixmap );
405 // mView->setBackgroundPixmap ( bPix ); 405 // mView->setBackgroundPixmap ( bPix );
406 // qDebug("%s ",mText.latin1()); 406 // qDebug("%s ",mText.latin1());
407} 407}
408 408
409void KOWhatsNextView::appendDay( int i, QDate eventDate ) 409void KOWhatsNextView::appendDay( int i, QDate eventDate )
410{ 410{
411 QString date; 411 QString date;
412 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 412 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
413 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 413 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
414 if ( i == 0 ) { 414 if ( i == 0 ) {
415 //mText += "<table>\n"; 415 //mText += "<table>\n";
416 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 416 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
417 } 417 }
418 else if ( i == 1 ) 418 else if ( i == 1 )
419 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 419 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
420 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 420 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
421 mText += "<h2>" + date + "</h2>\n"; 421 mText += "<h2>" + date + "</h2>\n";
422 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 422 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
423 mText += "<table>\n"; 423 mText += "<table>\n";
424 424
425 425
426 426
427 } else { 427 } else {
428 if ( i == 0 ) { 428 if ( i == 0 ) {
429 //mText += "<table>\n"; 429 //mText += "<table>\n";
430 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 430 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
431 } 431 }
432 432
433#ifdef DESKTOP_VERSION 433#ifdef DESKTOP_VERSION
434 else if ( i == 1 ) { 434 else if ( i == 1 ) {
435 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 435 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
436 } 436 }
437 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 437 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
438#else 438#else
439 else if ( i == 1 ) { 439 else if ( i == 1 ) {
440 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 440 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
441 } 441 }
442 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 442 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
443 443
444#endif 444#endif
445 mText += "<h2>" + date + "</h2>\n"; 445 mText += "<h2>" + date + "</h2>\n";
446 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 446 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
447 mText += "<table>\n"; 447 mText += "<table>\n";
448 } 448 }
449} 449}
450 450
451 451
452void KOWhatsNextView::showDates(const QDate &, const QDate &) 452void KOWhatsNextView::showDates(const QDate &, const QDate &)
453{ 453{
454 updateView(); 454 updateView();
455} 455}
456 456
457void KOWhatsNextView::showEvents(QPtrList<Event>) 457void KOWhatsNextView::showEvents(QPtrList<Event>)
458{ 458{
459} 459}
460 460
461void KOWhatsNextView::changeEventDisplay(Event *, int action) 461void KOWhatsNextView::changeEventDisplay(Event *, int action)
462{ 462{
463 switch(action) { 463 switch(action) {
464 case KOGlobals::EVENTADDED: 464 case KOGlobals::EVENTADDED:
465 updateView(); 465 updateView();
466 break; 466 break;
467 case KOGlobals::EVENTEDITED: 467 case KOGlobals::EVENTEDITED:
468 updateView(); 468 updateView();
469 break; 469 break;
470 case KOGlobals::EVENTDELETED: 470 case KOGlobals::EVENTDELETED:
471 updateView(); 471 updateView();
472 break; 472 break;
473 default: 473 default:
474 updateView(); 474 updateView();
475 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 475 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
476 } 476 }
477} 477}
478 478
479bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 479bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
480{ 480{
481 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 481 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
482 return false; 482 return false;
483 QDateTime cdt = QDateTime::currentDateTime(); 483 QDateTime cdt = QDateTime::currentDateTime();
484 QDateTime noc; 484 QDateTime noc;
485 QString tempText; 485 QString tempText;
486 if ( appendTable && !notRed ) { 486 if ( appendTable && !notRed ) {
487 tempText = "<table>"; 487 tempText = "<table>";
488 } 488 }
489 bool ok = true; 489 bool ok = true;
490 if ( reply ) { 490 if ( reply ) {
491 noc = ev->getNextOccurence( cdt, &ok ); 491 noc = ev->getNextOccurence( cdt, &ok );
492 if (! ok && ev->type() == "Event") 492 if (! ok && ev->typeID() == eventID)
493 return false; 493 return false;
494 } 494 }
495 bool bDay = false; 495 bool bDay = false;
496 if ( ev->isBirthday() || ev->isAnniversary() ) 496 if ( ev->isBirthday() || ev->isAnniversary() )
497 bDay = true; 497 bDay = true;
498 tempText += "<tr><td><b>"; 498 tempText += "<tr><td><b>";
499 if (ev->type()=="Event") { 499 if (ev->typeID() == eventID ) {
500 if (reply) { 500 if (reply) {
501 if (!ev->doesFloat()) 501 if (!ev->doesFloat())
502 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 502 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
503 else 503 else
504 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 504 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
505 505
506 } else { 506 } else {
507 if (!ev->doesFloat()) { 507 if (!ev->doesFloat()) {
508 Event *event = static_cast<Event *>(ev); 508 Event *event = static_cast<Event *>(ev);
509 QDateTime st,end; 509 QDateTime st,end;
510 if ( event->recurrence()->doesRecur() ) { 510 if ( event->recurrence()->doesRecur() ) {
511 QDate recDate= mEventDate; 511 QDate recDate= mEventDate;
512 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 512 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
513 while ( ! event->recursOn( recDate ) ) { 513 while ( ! event->recursOn( recDate ) ) {
514 recDate = recDate.addDays( -1 ); 514 recDate = recDate.addDays( -1 );
515 515
516 } 516 }
517 st = QDateTime ( recDate, event->dtStart().time() ); 517 st = QDateTime ( recDate, event->dtStart().time() );
518 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 518 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
519 } 519 }
520 else { 520 else {
521 st = event->dtStart(); 521 st = event->dtStart();
522 end = event->dtEnd(); 522 end = event->dtEnd();
523 } 523 }
524 524
525 525
526 QString dateText; 526 QString dateText;
527 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 527 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
528 if ( st.date() < mEventDate ) 528 if ( st.date() < mEventDate )
529 dateText = "++:++-"; 529 dateText = "++:++-";
530 else 530 else
531 dateText = event->dtStartTimeStr() + "-"; 531 dateText = event->dtStartTimeStr() + "-";
532 if ( end.date() > mEventDate ) 532 if ( end.date() > mEventDate )
533 dateText += "++:++"; 533 dateText += "++:++";
534 else 534 else
535 dateText += event->dtEndTimeStr(); 535 dateText += event->dtEndTimeStr();
536 if ( notRed ) 536 if ( notRed )
537 tempText += dateText; 537 tempText += dateText;
538 else { 538 else {
539 if ( end < cdt ) { 539 if ( end < cdt ) {
540 if ( !KOPrefs::instance()->mWNViewShowsPast ) 540 if ( !KOPrefs::instance()->mWNViewShowsPast )
541 return false; 541 return false;
542 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 542 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
543 } 543 }
544 else if ( st < cdt ) 544 else if ( st < cdt )
545 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 545 tempText += "<font color=\"#008000\">" + dateText + "</font>";
546 else 546 else
547 tempText += dateText; 547 tempText += dateText;
548 548
549 } 549 }
550 550
551 } else { 551 } else {
552 if ( bDay ) { 552 if ( bDay ) {
553 553
554 if ( ev->isBirthday()) 554 if ( ev->isBirthday())
555 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; 555 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>";
556 else 556 else
557 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; 557 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>";
558 } else { 558 } else {
559 tempText += i18n("Allday:"); 559 tempText += i18n("Allday:");
560 } 560 }
561 561
562 } 562 }
563 } 563 }
564 } else { 564 } else {
565 mTodos.append( ev ); 565 mTodos.append( ev );
566 tempText += i18n("ToDo:"); 566 tempText += i18n("ToDo:");
567 if (reply) { 567 if (reply) {
568 tempText += " "; 568 tempText += " ";
569 if ( noc != cdt ) { 569 if ( noc != cdt ) {
570 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 570 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
571 } 571 }
572 } else { 572 } else {
573 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 573 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
574 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 574 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
575 QString dfs = KGlobal::locale()->dateFormatShort(); 575 QString dfs = KGlobal::locale()->dateFormatShort();
576 KGlobal::locale()->setDateFormatShort("%d.%b"); 576 KGlobal::locale()->setDateFormatShort("%d.%b");
577 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 577 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
578 KGlobal::locale()->setDateFormatShort(dfs); 578 KGlobal::locale()->setDateFormatShort(dfs);
579 } else { 579 } else {
580 if (!ev->doesFloat() ) 580 if (!ev->doesFloat() )
581 if( ( (Todo*)ev)->dtDue() < cdt ) { 581 if( ( (Todo*)ev)->dtDue() < cdt ) {
582 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 582 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
583 583
584 584
585 } else 585 } else
586 tempText +=((Todo*)ev)->dtDueTimeStr(); 586 tempText +=((Todo*)ev)->dtDueTimeStr();
587 mTodos.append( ev ); 587 mTodos.append( ev );
588 } 588 }
589 } 589 }
590 } 590 }
591 tempText += "</b></td><td>"; 591 tempText += "</b></td><td>";
592 bool needClose = false; 592 bool needClose = false;
593 if ( ev->cancelled() ) { 593 if ( ev->cancelled() ) {
594 tempText += "<font color=\"#F00000\">[c"; 594 tempText += "<font color=\"#F00000\">[c";
595 needClose =true; 595 needClose =true;
596 596
597 } 597 }
598 if ( ev->isAlarmEnabled() ) { 598 if ( ev->isAlarmEnabled() ) {
599 if ( !needClose) 599 if ( !needClose)
600 tempText +="["; 600 tempText +="[";
601 tempText += "a"; 601 tempText += "a";
602 needClose =true; 602 needClose =true;
603 603
604 } 604 }
605 if ( ev->description().length() > 0 ) { 605 if ( ev->description().length() > 0 ) {
606 if ( !needClose) 606 if ( !needClose)
607 tempText +="["; 607 tempText +="[";
608 tempText += "i"; 608 tempText += "i";
609 needClose =true; 609 needClose =true;
610 } 610 }
611 if ( ev->recurrence()->doesRecur() ) { 611 if ( ev->recurrence()->doesRecur() ) {
612 if ( !needClose) 612 if ( !needClose)
613 tempText +="["; 613 tempText +="[";
614 tempText += "r"; 614 tempText += "r";
615 needClose =true; 615 needClose =true;
616 } 616 }
617 if ( needClose ) { 617 if ( needClose ) {
618 tempText += "] "; 618 tempText += "] ";
619 } 619 }
620 if ( ev->cancelled() ) 620 if ( ev->cancelled() )
621 tempText += "</font>"; 621 tempText += "</font>";
622 tempText += "<a "; 622 tempText += "<a ";
623 if (ev->type()=="Event") tempText += "href=\"event:"; 623 if (ev->typeID() == eventID ) tempText += "href=\"event:";
624 if (ev->type()=="Todo") tempText += "href=\"todo:"; 624 if (ev->typeID() == todoID ) tempText += "href=\"todo:";
625 tempText += ev->uid() + "\">"; 625 tempText += ev->uid() + "\">";
626 if ( ev->summary().length() > 0 ) 626 if ( ev->summary().length() > 0 )
627 tempText += ev->summary(); 627 tempText += ev->summary();
628 else 628 else
629 tempText += i18n("-no summary-"); 629 tempText += i18n("-no summary-");
630 if ( bDay ) { 630 if ( bDay ) {
631 noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); 631 noc = ev->getNextOccurence( cdt.addDays(-1), &ok );
632 if ( ok ) { 632 if ( ok ) {
633 int years = 0; 633 int years = 0;
634 if ( ev->type() =="Todo" ) { 634 if ( ev->typeID() == todoID ) {
635 years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); 635 years = noc.date().year() -((Todo*)ev)->dtDue().date().year();
636 } else 636 } else
637 years = noc.date().year() - ev->dtStart().date().year(); 637 years = noc.date().year() - ev->dtStart().date().year();
638 tempText += i18n(" (%1 y.)"). arg( years ); 638 tempText += i18n(" (%1 y.)"). arg( years );
639 } 639 }
640 } 640 }
641 641
642 tempText += "</a>"; 642 tempText += "</a>";
643 if ( KOPrefs::instance()->mWNViewShowLocation ) 643 if ( KOPrefs::instance()->mWNViewShowLocation )
644 if ( !ev->location().isEmpty() ) 644 if ( !ev->location().isEmpty() )
645 tempText += " ("+ev->location() +")"; 645 tempText += " ("+ev->location() +")";
646 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 646 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
647 tempText += " ["+ev->relatedTo()->summary() +"]"; 647 tempText += " ["+ev->relatedTo()->summary() +"]";
648 tempText += "</td></tr>\n"; 648 tempText += "</td></tr>\n";
649 mText += tempText; 649 mText += tempText;
650 return true; 650 return true;
651} 651}
652 652
653bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 653bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
654{ 654{
655 if ( mTodos.find( ev ) != mTodos.end() ) return false; 655 if ( mTodos.find( ev ) != mTodos.end() ) return false;
656 656
657 mTodos.append( ev ); 657 mTodos.append( ev );
658 if ( !isSub ) 658 if ( !isSub )
659 mText += "<p>"; 659 mText += "<p>";
660 else 660 else
661 mText += "<li>"; 661 mText += "<li>";
662 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 662 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
663 663
664 664
665 mText += ind; 665 mText += ind;
666 bool needClose = false; 666 bool needClose = false;
667 if ( ev->cancelled() ) { 667 if ( ev->cancelled() ) {
668 mText += "<font color=\"#F00000\">[c"; 668 mText += "<font color=\"#F00000\">[c";
669 needClose =true; 669 needClose =true;
670 670
671 } 671 }
672 if ( ev->isAlarmEnabled() ) { 672 if ( ev->isAlarmEnabled() ) {
673 if ( !needClose) 673 if ( !needClose)
674 mText +="["; 674 mText +="[";
675 mText += "a"; 675 mText += "a";
676 needClose =true; 676 needClose =true;
677 677
678 } 678 }
679 679
680 if ( ev->description().length() > 0 ) { 680 if ( ev->description().length() > 0 ) {
681 if ( !needClose) 681 if ( !needClose)
682 mText +="["; 682 mText +="[";
683 mText += "i"; 683 mText += "i";
684 needClose =true; 684 needClose =true;
685 } 685 }
686 if ( ev->doesRecur() ) { 686 if ( ev->doesRecur() ) {
687 if ( !needClose) 687 if ( !needClose)
688 mText +="["; 688 mText +="[";
689 mText += "r"; 689 mText += "r";
690 needClose =true; 690 needClose =true;
691 } 691 }
692 // if ( ev->recurrence()->doesRecur() ) { 692 // if ( ev->recurrence()->doesRecur() ) {
693 // if ( !needClose) 693 // if ( !needClose)
694 // mText +="("; 694 // mText +="(";
695 // mText += "r"; 695 // mText += "r";
696 // needClose =true; 696 // needClose =true;
697 // } 697 // }
698 if ( needClose ) 698 if ( needClose )
699 mText += "] "; 699 mText += "] ";
700 if ( ev->cancelled() ) 700 if ( ev->cancelled() )
701 mText += "</font>"; 701 mText += "</font>";
702 mText += "<a href=\"todo:" + ev->uid() + "\">"; 702 mText += "<a href=\"todo:" + ev->uid() + "\">";
703 if ( ev->summary().length() > 0 ) 703 if ( ev->summary().length() > 0 )
704 mText += ev->summary(); 704 mText += ev->summary();
705 else 705 else
706 mText += i18n("-no summary-"); 706 mText += i18n("-no summary-");
707 mText += "</a>"; 707 mText += "</a>";
708 if ( ((Todo*)ev)->hasDueDate () ) { 708 if ( ((Todo*)ev)->hasDueDate () ) {
709 QString year = ""; 709 QString year = "";
710 int ye = ((Todo*)ev)->dtDue().date().year(); 710 int ye = ((Todo*)ev)->dtDue().date().year();
711 if ( QDateTime::currentDateTime().date().year() != ye ) 711 if ( QDateTime::currentDateTime().date().year() != ye )
712 year = QString::number( ye ); 712 year = QString::number( ye );
713 QString dfs = KGlobal::locale()->dateFormatShort(); 713 QString dfs = KGlobal::locale()->dateFormatShort();
714 KGlobal::locale()->setDateFormatShort("%d.%b"); 714 KGlobal::locale()->setDateFormatShort("%d.%b");
715 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 715 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
716 KGlobal::locale()->setDateFormatShort(dfs); 716 KGlobal::locale()->setDateFormatShort(dfs);
717 } 717 }
718 if ( KOPrefs::instance()->mWNViewShowLocation ) 718 if ( KOPrefs::instance()->mWNViewShowLocation )
719 if ( !ev->location().isEmpty() ) 719 if ( !ev->location().isEmpty() )
720 mText += " ("+ev->location() +")"; 720 mText += " ("+ev->location() +")";
721 if ( !isSub ) { 721 if ( !isSub ) {
722 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 722 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
723 mText += " ["+ev->relatedTo()->summary() +"]"; 723 mText += " ["+ev->relatedTo()->summary() +"]";
724 mText += "</p>\n"; 724 mText += "</p>\n";
725 } 725 }
726 else { 726 else {
727 ind += "-"; 727 ind += "-";
728 mText += "</li>\n"; 728 mText += "</li>\n";
729 } 729 }
730 QPtrList<Incidence> Relations = ev->relations(); 730 QPtrList<Incidence> Relations = ev->relations();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 53b65b2..481eab4 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1239,197 +1239,197 @@ void MainWindow::initActions()
1239 if (p-> mShowIconDay5) 1239 if (p-> mShowIconDay5)
1240 configureToolBarMenu->setItemChecked( 50, true ); 1240 configureToolBarMenu->setItemChecked( 50, true );
1241 if (p-> mShowIconDay6) 1241 if (p-> mShowIconDay6)
1242 configureToolBarMenu->setItemChecked( 75, true ); 1242 configureToolBarMenu->setItemChecked( 75, true );
1243 if (p-> mShowIconDay7) 1243 if (p-> mShowIconDay7)
1244 configureToolBarMenu->setItemChecked( 60, true ); 1244 configureToolBarMenu->setItemChecked( 60, true );
1245 if (p-> mShowIconMonth) 1245 if (p-> mShowIconMonth)
1246 configureToolBarMenu->setItemChecked( 70, true ); 1246 configureToolBarMenu->setItemChecked( 70, true );
1247 if (p-> mShowIconTodoview) 1247 if (p-> mShowIconTodoview)
1248 configureToolBarMenu->setItemChecked( 80, true ); 1248 configureToolBarMenu->setItemChecked( 80, true );
1249 if (p-> mShowIconBackFast) 1249 if (p-> mShowIconBackFast)
1250 configureToolBarMenu->setItemChecked( 200, true ); 1250 configureToolBarMenu->setItemChecked( 200, true );
1251 if (p-> mShowIconBack) 1251 if (p-> mShowIconBack)
1252 configureToolBarMenu->setItemChecked( 210, true ); 1252 configureToolBarMenu->setItemChecked( 210, true );
1253 if (p-> mShowIconToday) 1253 if (p-> mShowIconToday)
1254 configureToolBarMenu->setItemChecked( 130, true ); 1254 configureToolBarMenu->setItemChecked( 130, true );
1255 if (p-> mShowIconForward) 1255 if (p-> mShowIconForward)
1256 configureToolBarMenu->setItemChecked( 220, true ); 1256 configureToolBarMenu->setItemChecked( 220, true );
1257 if (p-> mShowIconForwardFast) 1257 if (p-> mShowIconForwardFast)
1258 configureToolBarMenu->setItemChecked( 230, true ); 1258 configureToolBarMenu->setItemChecked( 230, true );
1259 if (p-> mShowIconNextDays) 1259 if (p-> mShowIconNextDays)
1260 configureToolBarMenu->setItemChecked( 100, true ); 1260 configureToolBarMenu->setItemChecked( 100, true );
1261 if (p-> mShowIconNext) 1261 if (p-> mShowIconNext)
1262 configureToolBarMenu->setItemChecked( 110, true ); 1262 configureToolBarMenu->setItemChecked( 110, true );
1263 if (p-> mShowIconJournal) 1263 if (p-> mShowIconJournal)
1264 configureToolBarMenu->setItemChecked( 90, true ); 1264 configureToolBarMenu->setItemChecked( 90, true );
1265 if (p-> mShowIconWhatsThis) 1265 if (p-> mShowIconWhatsThis)
1266 configureToolBarMenu->setItemChecked( 300, true ); 1266 configureToolBarMenu->setItemChecked( 300, true );
1267 if (p-> mShowIconWeekNum) 1267 if (p-> mShowIconWeekNum)
1268 configureToolBarMenu->setItemChecked( 400, true ); 1268 configureToolBarMenu->setItemChecked( 400, true );
1269 if (!p-> mShowIconStretch) { 1269 if (!p-> mShowIconStretch) {
1270 QLabel* dummy = new QLabel( iconToolBar ); 1270 QLabel* dummy = new QLabel( iconToolBar );
1271 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1271 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1272 dummy->setMinimumWidth( 0 ); 1272 dummy->setMinimumWidth( 0 );
1273 iconToolBar->setStretchableWidget ( dummy ) ; 1273 iconToolBar->setStretchableWidget ( dummy ) ;
1274 } 1274 }
1275 else { 1275 else {
1276 iconToolBar->setHorizontalStretchable (true ); 1276 iconToolBar->setHorizontalStretchable (true );
1277 viewToolBar->setHorizontalStretchable (true ); 1277 viewToolBar->setHorizontalStretchable (true );
1278 navigatorToolBar->setHorizontalStretchable (true ); 1278 navigatorToolBar->setHorizontalStretchable (true );
1279 iconToolBar->setVerticalStretchable (true ); 1279 iconToolBar->setVerticalStretchable (true );
1280 viewToolBar->setVerticalStretchable (true ); 1280 viewToolBar->setVerticalStretchable (true );
1281 navigatorToolBar->setVerticalStretchable (true ); 1281 navigatorToolBar->setVerticalStretchable (true );
1282 configureToolBarMenu->setItemChecked( 5, true ); 1282 configureToolBarMenu->setItemChecked( 5, true );
1283 } 1283 }
1284 if (p-> mShowIconFilter) 1284 if (p-> mShowIconFilter)
1285 configureToolBarMenu->setItemChecked( 7, true ); 1285 configureToolBarMenu->setItemChecked( 7, true );
1286 if (p-> mShowIconOnetoolbar) 1286 if (p-> mShowIconOnetoolbar)
1287 configureToolBarMenu->setItemChecked( 6, true ); 1287 configureToolBarMenu->setItemChecked( 6, true );
1288 1288
1289 1289
1290 if ( filterMenubar ) { 1290 if ( filterMenubar ) {
1291 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1291 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1292 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1292 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1293 } 1293 }
1294 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1294 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1295 configureAgenda( p->mHourSize ); 1295 configureAgenda( p->mHourSize );
1296 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1296 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1297} 1297}
1298 1298
1299void MainWindow::exportToPhone( int mode ) 1299void MainWindow::exportToPhone( int mode )
1300{ 1300{
1301 1301
1302 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1302 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1303 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1303 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1304 KOex2phonePrefs ex2phone; 1304 KOex2phonePrefs ex2phone;
1305 1305
1306 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1306 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1307 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1307 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1308 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1308 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1309 if ( mode == 1 ) 1309 if ( mode == 1 )
1310 ex2phone.setCaption(i18n("Export complete calendar")); 1310 ex2phone.setCaption(i18n("Export complete calendar"));
1311 if ( mode == 2 ) 1311 if ( mode == 2 )
1312 ex2phone.setCaption(i18n("Export filtered calendar")); 1312 ex2phone.setCaption(i18n("Export filtered calendar"));
1313 1313
1314 if ( !ex2phone.exec() ) { 1314 if ( !ex2phone.exec() ) {
1315 return; 1315 return;
1316 } 1316 }
1317 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1317 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1318 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1318 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1319 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1319 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1320 1320
1321 int inFuture = 0; 1321 int inFuture = 0;
1322 if ( ex2phone.mWriteBackFuture->isChecked() ) 1322 if ( ex2phone.mWriteBackFuture->isChecked() )
1323 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1323 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1324 QPtrList<Incidence> delSel; 1324 QPtrList<Incidence> delSel;
1325 if ( mode == 1 ) 1325 if ( mode == 1 )
1326 delSel = mCalendar->rawIncidences(); 1326 delSel = mCalendar->rawIncidences();
1327 if ( mode == 2 ) 1327 if ( mode == 2 )
1328 delSel = mCalendar->incidences(); 1328 delSel = mCalendar->incidences();
1329 CalendarLocal* cal = new CalendarLocal(); 1329 CalendarLocal* cal = new CalendarLocal();
1330 cal->setLocalTime(); 1330 cal->setLocalTime();
1331 Incidence *incidence = delSel.first(); 1331 Incidence *incidence = delSel.first();
1332 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1332 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1333 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1333 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1334 while ( incidence ) { 1334 while ( incidence ) {
1335 if ( incidence->type() != "Journal" ) { 1335 if ( incidence->typeID() != journalID ) {
1336 bool add = true; 1336 bool add = true;
1337 if ( inFuture ) { 1337 if ( inFuture ) {
1338 QDateTime dt; 1338 QDateTime dt;
1339 if ( incidence->type() == "Todo" ) { 1339 if ( incidence->typeID() == todoID ) {
1340 Todo * t = (Todo*)incidence; 1340 Todo * t = (Todo*)incidence;
1341 if ( t->hasDueDate() ) 1341 if ( t->hasDueDate() )
1342 dt = t->dtDue(); 1342 dt = t->dtDue();
1343 else 1343 else
1344 dt = cur.addSecs( 62 ); 1344 dt = cur.addSecs( 62 );
1345 } 1345 }
1346 else { 1346 else {
1347 bool ok; 1347 bool ok;
1348 dt = incidence->getNextOccurence( cur, &ok ); 1348 dt = incidence->getNextOccurence( cur, &ok );
1349 if ( !ok ) 1349 if ( !ok )
1350 dt = cur.addSecs( -62 ); 1350 dt = cur.addSecs( -62 );
1351 } 1351 }
1352 if ( dt < cur || dt > end ) { 1352 if ( dt < cur || dt > end ) {
1353 add = false; 1353 add = false;
1354 } 1354 }
1355 } 1355 }
1356 if ( add ) { 1356 if ( add ) {
1357 Incidence *in = incidence->clone(); 1357 Incidence *in = incidence->clone();
1358 cal->addIncidence( in ); 1358 cal->addIncidence( in );
1359 } 1359 }
1360 } 1360 }
1361 incidence = delSel.next(); 1361 incidence = delSel.next();
1362 } 1362 }
1363 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1363 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1364 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1364 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1365 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1365 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1366 1366
1367 setCaption( i18n("Writing to phone...")); 1367 setCaption( i18n("Writing to phone..."));
1368 if ( PhoneFormat::writeToPhone( cal ) ) 1368 if ( PhoneFormat::writeToPhone( cal ) )
1369 setCaption( i18n("Export to phone successful!")); 1369 setCaption( i18n("Export to phone successful!"));
1370 else 1370 else
1371 setCaption( i18n("Error exporting to phone!")); 1371 setCaption( i18n("Error exporting to phone!"));
1372 delete cal; 1372 delete cal;
1373} 1373}
1374 1374
1375 1375
1376void MainWindow::setDefaultPreferences() 1376void MainWindow::setDefaultPreferences()
1377{ 1377{
1378 KOPrefs *p = KOPrefs::instance(); 1378 KOPrefs *p = KOPrefs::instance();
1379 1379
1380 p->mCompactDialogs = true; 1380 p->mCompactDialogs = true;
1381 p->mConfirm = true; 1381 p->mConfirm = true;
1382 // p->mEnableQuickTodo = false; 1382 // p->mEnableQuickTodo = false;
1383 1383
1384} 1384}
1385 1385
1386QString MainWindow::resourcePath() 1386QString MainWindow::resourcePath()
1387{ 1387{
1388 return KGlobal::iconLoader()->iconPath(); 1388 return KGlobal::iconLoader()->iconPath();
1389} 1389}
1390 1390
1391void MainWindow::displayText( QString text ,QString cap ) 1391void MainWindow::displayText( QString text ,QString cap )
1392{ 1392{
1393 QDialog dia( this, "name", true ); ; 1393 QDialog dia( this, "name", true ); ;
1394 dia.setCaption( cap ); 1394 dia.setCaption( cap );
1395 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1395 QVBoxLayout* lay = new QVBoxLayout( &dia );
1396 lay->setSpacing( 3 ); 1396 lay->setSpacing( 3 );
1397 lay->setMargin( 3 ); 1397 lay->setMargin( 3 );
1398 QTextBrowser tb ( &dia ); 1398 QTextBrowser tb ( &dia );
1399 lay->addWidget( &tb ); 1399 lay->addWidget( &tb );
1400 tb.setText( text ); 1400 tb.setText( text );
1401#ifdef DESKTOP_VERSION 1401#ifdef DESKTOP_VERSION
1402 dia.resize( 640, 480); 1402 dia.resize( 640, 480);
1403#else 1403#else
1404 dia.showMaximized(); 1404 dia.showMaximized();
1405#endif 1405#endif
1406 dia.exec(); 1406 dia.exec();
1407} 1407}
1408 1408
1409void MainWindow::features() 1409void MainWindow::features()
1410{ 1410{
1411 1411
1412 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1412 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1413} 1413}
1414 1414
1415void MainWindow::usertrans() 1415void MainWindow::usertrans()
1416{ 1416{
1417 1417
1418 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1418 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1419} 1419}
1420 1420
1421void MainWindow::storagehowto() 1421void MainWindow::storagehowto()
1422{ 1422{
1423 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1423 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1424} 1424}
1425void MainWindow::timetrackinghowto() 1425void MainWindow::timetrackinghowto()
1426{ 1426{
1427 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1427 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1428} 1428}
1429void MainWindow::kdesynchowto() 1429void MainWindow::kdesynchowto()
1430{ 1430{
1431 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1431 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1432} 1432}
1433void MainWindow::multisynchowto() 1433void MainWindow::multisynchowto()
1434{ 1434{
1435 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1435 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
@@ -1503,237 +1503,237 @@ void MainWindow::keyBindings()
1503 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1503 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1504 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1504 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1505 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1505 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1506 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1506 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1507 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1507 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1508 i18n("<p><h3>In list view:</h3></p>\n") + 1508 i18n("<p><h3>In list view:</h3></p>\n") +
1509 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1509 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1510 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1510 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1511 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1511 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1512 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1512 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1513 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1513 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1514 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1514 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1515 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1515 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1516 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1516 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1517 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1517 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1518 i18n("<p><b>E</b>: Edit item</p>\n") + 1518 i18n("<p><b>E</b>: Edit item</p>\n") +
1519 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1519 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1520 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1520 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1521 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1521 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1522 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1522 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1523 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1523 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1524 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1524 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1525 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1525 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1526 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1526 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1527 i18n("<p><b>White</b>: Item readonly</p>\n"); 1527 i18n("<p><b>White</b>: Item readonly</p>\n");
1528 displayText( text, cap); 1528 displayText( text, cap);
1529} 1529}
1530void MainWindow::aboutAutoSaving() 1530void MainWindow::aboutAutoSaving()
1531{ 1531{
1532 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1532 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1533 1533
1534 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1534 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1535 1535
1536} 1536}
1537void MainWindow::aboutKnownBugs() 1537void MainWindow::aboutKnownBugs()
1538{ 1538{
1539 QMessageBox* msg; 1539 QMessageBox* msg;
1540 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1540 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1541 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1541 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1542 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1542 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1543 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1543 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1544 i18n("\nor report them in the bugtracker on\n") + 1544 i18n("\nor report them in the bugtracker on\n") +
1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1546 QMessageBox::NoIcon, 1546 QMessageBox::NoIcon,
1547 QMessageBox::Ok, 1547 QMessageBox::Ok,
1548 QMessageBox::NoButton, 1548 QMessageBox::NoButton,
1549 QMessageBox::NoButton); 1549 QMessageBox::NoButton);
1550 msg->exec(); 1550 msg->exec();
1551 delete msg; 1551 delete msg;
1552 1552
1553} 1553}
1554 1554
1555QString MainWindow::defaultFileName() 1555QString MainWindow::defaultFileName()
1556{ 1556{
1557 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1557 return locateLocal( "data", "korganizer/mycalendar.ics" );
1558} 1558}
1559QString MainWindow::syncFileName() 1559QString MainWindow::syncFileName()
1560{ 1560{
1561#ifdef DESKTOP_VERSION 1561#ifdef DESKTOP_VERSION
1562 return locateLocal( "tmp", "synccalendar.ics" ); 1562 return locateLocal( "tmp", "synccalendar.ics" );
1563#else 1563#else
1564 return QString( "/tmp/synccalendar.ics" ); 1564 return QString( "/tmp/synccalendar.ics" );
1565#endif 1565#endif
1566} 1566}
1567#include "koglobals.h" 1567#include "koglobals.h"
1568#include <kcalendarsystem.h> 1568#include <kcalendarsystem.h>
1569void MainWindow::updateWeek(QDate seda) 1569void MainWindow::updateWeek(QDate seda)
1570{ 1570{
1571 int weekNum = KGlobal::locale()->weekNum ( seda ); 1571 int weekNum = KGlobal::locale()->weekNum ( seda );
1572 mWeekPixmap.fill( mWeekBgColor ); 1572 mWeekPixmap.fill( mWeekBgColor );
1573 QPainter p ( &mWeekPixmap ); 1573 QPainter p ( &mWeekPixmap );
1574 p.setFont( mWeekFont ); 1574 p.setFont( mWeekFont );
1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1576 p.end(); 1576 p.end();
1577 QIconSet icon3 ( mWeekPixmap ); 1577 QIconSet icon3 ( mWeekPixmap );
1578 mWeekAction->setIconSet ( icon3 ); 1578 mWeekAction->setIconSet ( icon3 );
1579 1579
1580} 1580}
1581void MainWindow::updateWeekNum(const DateList &selectedDates) 1581void MainWindow::updateWeekNum(const DateList &selectedDates)
1582{ 1582{
1583 updateWeek( selectedDates.first() ); 1583 updateWeek( selectedDates.first() );
1584} 1584}
1585void MainWindow::processIncidenceSelection( Incidence *incidence ) 1585void MainWindow::processIncidenceSelection( Incidence *incidence )
1586{ 1586{
1587 1587
1588 if ( !incidence ) { 1588 if ( !incidence ) {
1589 enableIncidenceActions( false ); 1589 enableIncidenceActions( false );
1590 1590
1591 mNewSubTodoAction->setEnabled( false ); 1591 mNewSubTodoAction->setEnabled( false );
1592 setCaptionToDates(); 1592 setCaptionToDates();
1593 return; 1593 return;
1594 1594
1595 } 1595 }
1596 1596
1597 //KGlobal::locale()->formatDateTime(nextA, true); 1597 //KGlobal::locale()->formatDateTime(nextA, true);
1598 QString startString = ""; 1598 QString startString = "";
1599 if ( incidence->type() != "Todo" ) { 1599 if ( incidence->typeID() != todoID ) {
1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1601 if ( incidence->doesFloat() ) { 1601 if ( incidence->doesFloat() ) {
1602 startString += ": "+incidence->dtStartDateStr( true ); 1602 startString += ": "+incidence->dtStartDateStr( true );
1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1604 1604
1605 } else { 1605 } else {
1606 startString = ": "+incidence->dtStartStr(true); 1606 startString = ": "+incidence->dtStartStr(true);
1607 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1607 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1608 1608
1609 } 1609 }
1610 1610
1611 } else { 1611 } else {
1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1615 1615
1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1617 bool ok; 1617 bool ok;
1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1619 if ( ok ) { 1619 if ( ok ) {
1620 int years = noc.date().year() - incidence->dtStart().date().year(); 1620 int years = noc.date().year() - incidence->dtStart().date().year();
1621 startString += i18n(" (%1 y.)"). arg( years ); 1621 startString += i18n(" (%1 y.)"). arg( years );
1622 } 1622 }
1623 } 1623 }
1624 else 1624 else
1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1626 } 1626 }
1627 1627
1628 } 1628 }
1629 else 1629 else
1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1631 if ( !incidence->location().isEmpty() ) 1631 if ( !incidence->location().isEmpty() )
1632 startString += " (" +incidence->location()+")"; 1632 startString += " (" +incidence->location()+")";
1633 setCaption( incidence->summary()+startString); 1633 setCaption( incidence->summary()+startString);
1634 1634
1635 enableIncidenceActions( true ); 1635 enableIncidenceActions( true );
1636 1636
1637 if ( incidence->type() == "Event" ) { 1637 if ( incidence->typeID() == eventID ) {
1638 mShowAction->setText( i18n("Show Event...") ); 1638 mShowAction->setText( i18n("Show Event...") );
1639 mEditAction->setText( i18n("Edit Event...") ); 1639 mEditAction->setText( i18n("Edit Event...") );
1640 mDeleteAction->setText( i18n("Delete Event...") ); 1640 mDeleteAction->setText( i18n("Delete Event...") );
1641 1641
1642 mNewSubTodoAction->setEnabled( false ); 1642 mNewSubTodoAction->setEnabled( false );
1643 } else if ( incidence->type() == "Todo" ) { 1643 } else if ( incidence->typeID() == todoID ) {
1644 mShowAction->setText( i18n("Show Todo...") ); 1644 mShowAction->setText( i18n("Show Todo...") );
1645 mEditAction->setText( i18n("Edit Todo...") ); 1645 mEditAction->setText( i18n("Edit Todo...") );
1646 mDeleteAction->setText( i18n("Delete Todo...") ); 1646 mDeleteAction->setText( i18n("Delete Todo...") );
1647 1647
1648 mNewSubTodoAction->setEnabled( true ); 1648 mNewSubTodoAction->setEnabled( true );
1649 } else { 1649 } else {
1650 mShowAction->setText( i18n("Show...") ); 1650 mShowAction->setText( i18n("Show...") );
1651 mShowAction->setText( i18n("Edit...") ); 1651 mShowAction->setText( i18n("Edit...") );
1652 mShowAction->setText( i18n("Delete...") ); 1652 mShowAction->setText( i18n("Delete...") );
1653 1653
1654 mNewSubTodoAction->setEnabled( false ); 1654 mNewSubTodoAction->setEnabled( false );
1655 } 1655 }
1656} 1656}
1657 1657
1658void MainWindow::enableIncidenceActions( bool enabled ) 1658void MainWindow::enableIncidenceActions( bool enabled )
1659{ 1659{
1660 mShowAction->setEnabled( enabled ); 1660 mShowAction->setEnabled( enabled );
1661 mEditAction->setEnabled( enabled ); 1661 mEditAction->setEnabled( enabled );
1662 mDeleteAction->setEnabled( enabled ); 1662 mDeleteAction->setEnabled( enabled );
1663 1663
1664 mCloneAction->setEnabled( enabled ); 1664 mCloneAction->setEnabled( enabled );
1665 mMoveAction->setEnabled( enabled ); 1665 mMoveAction->setEnabled( enabled );
1666 mBeamAction->setEnabled( enabled ); 1666 mBeamAction->setEnabled( enabled );
1667 mCancelAction->setEnabled( enabled ); 1667 mCancelAction->setEnabled( enabled );
1668} 1668}
1669 1669
1670void MainWindow::importOL() 1670void MainWindow::importOL()
1671{ 1671{
1672#ifdef _OL_IMPORT_ 1672#ifdef _OL_IMPORT_
1673 mView->clearAllViews(); 1673 mView->clearAllViews();
1674 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1674 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1675 id->exec(); 1675 id->exec();
1676 delete id; 1676 delete id;
1677 mView->calendar()->checkAlarmForIncidence( 0, true ); 1677 mView->calendar()->checkAlarmForIncidence( 0, true );
1678 mView->updateView(); 1678 mView->updateView();
1679#endif 1679#endif
1680} 1680}
1681void MainWindow::importBday() 1681void MainWindow::importBday()
1682{ 1682{
1683 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1683 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1684 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1684 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1685 i18n("Import!"), i18n("Cancel"), 0, 1685 i18n("Import!"), i18n("Cancel"), 0,
1686 0, 1 ); 1686 0, 1 );
1687 if ( result == 0 ) { 1687 if ( result == 0 ) {
1688 mView->importBday(); 1688 mView->importBday();
1689 1689
1690 } 1690 }
1691 1691
1692 1692
1693} 1693}
1694void MainWindow::importQtopia() 1694void MainWindow::importQtopia()
1695{ 1695{
1696 //#ifndef DESKTOP_VERSION 1696 //#ifndef DESKTOP_VERSION
1697 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1697 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1698#ifdef DESKTOP_VERSION 1698#ifdef DESKTOP_VERSION
1699 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1699 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1700#endif 1700#endif
1701 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1701 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1702 i18n("Import!"), i18n("Cancel"), 0, 1702 i18n("Import!"), i18n("Cancel"), 0,
1703 0, 1 ); 1703 0, 1 );
1704 if ( result == 0 ) { 1704 if ( result == 0 ) {
1705#ifndef DESKTOP_VERSION 1705#ifndef DESKTOP_VERSION
1706 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1706 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1707 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1707 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1708 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1708 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1709#else 1709#else
1710 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1710 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1711 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1711 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1712 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1712 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1713#endif 1713#endif
1714 mView->importQtopia( categories, datebook, todolist ); 1714 mView->importQtopia( categories, datebook, todolist );
1715 } 1715 }
1716 mView->calendar()->reInitAlarmSettings(); 1716 mView->calendar()->reInitAlarmSettings();
1717#if 0 1717#if 0
1718 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1718 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1719 i18n("Not supported \non desktop!\n"), 1719 i18n("Not supported \non desktop!\n"),
1720 i18n("Ok"), i18n("Cancel"), 0, 1720 i18n("Ok"), i18n("Cancel"), 0,
1721 0, 1 ); 1721 0, 1 );
1722 1722
1723#endif 1723#endif
1724} 1724}
1725 1725
1726void MainWindow::saveOnClose() 1726void MainWindow::saveOnClose()
1727{ 1727{
1728 KOPrefs *p = KOPrefs::instance(); 1728 KOPrefs *p = KOPrefs::instance();
1729 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1729 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1730 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1730 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1731 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1731 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1732 if ( filterToolBar ) { 1732 if ( filterToolBar ) {
1733 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1733 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1734 } 1734 }
1735#ifdef DESKTOP_VERSION 1735#ifdef DESKTOP_VERSION
1736 1736
1737 QPoint myP; 1737 QPoint myP;
1738 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1738 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1739 if ( p->mToolBarHor ) 1739 if ( p->mToolBarHor )
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index ed39ddb..7e8e2c5 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -260,197 +260,197 @@ QPtrList<Incidence> Calendar::incidences()
260} 260}
261 261
262void Calendar::resetPilotStat(int id ) 262void Calendar::resetPilotStat(int id )
263{ 263{
264 QPtrList<Incidence> incidences; 264 QPtrList<Incidence> incidences;
265 265
266 Incidence *i; 266 Incidence *i;
267 267
268 QPtrList<Event> e = rawEvents(); 268 QPtrList<Event> e = rawEvents();
269 for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); 269 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
270 270
271 QPtrList<Todo> t = rawTodos(); 271 QPtrList<Todo> t = rawTodos();
272 for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); 272 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
273 273
274 QPtrList<Journal> j = journals(); 274 QPtrList<Journal> j = journals();
275 for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); 275 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
276} 276}
277void Calendar::resetTempSyncStat() 277void Calendar::resetTempSyncStat()
278{ 278{
279 QPtrList<Incidence> incidences; 279 QPtrList<Incidence> incidences;
280 280
281 Incidence *i; 281 Incidence *i;
282 282
283 QPtrList<Event> e = rawEvents(); 283 QPtrList<Event> e = rawEvents();
284 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 284 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
285 285
286 QPtrList<Todo> t = rawTodos(); 286 QPtrList<Todo> t = rawTodos();
287 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 287 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
288 288
289 QPtrList<Journal> j = journals(); 289 QPtrList<Journal> j = journals();
290 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 290 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
291} 291}
292QPtrList<Incidence> Calendar::rawIncidences() 292QPtrList<Incidence> Calendar::rawIncidences()
293{ 293{
294 QPtrList<Incidence> incidences; 294 QPtrList<Incidence> incidences;
295 295
296 Incidence *i; 296 Incidence *i;
297 297
298 QPtrList<Event> e = rawEvents(); 298 QPtrList<Event> e = rawEvents();
299 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 299 for( i = e.first(); i; i = e.next() ) incidences.append( i );
300 300
301 QPtrList<Todo> t = rawTodos(); 301 QPtrList<Todo> t = rawTodos();
302 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 302 for( i = t.first(); i; i = t.next() ) incidences.append( i );
303 303
304 QPtrList<Journal> j = journals(); 304 QPtrList<Journal> j = journals();
305 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 305 for( i = j.first(); i; i = j.next() ) incidences.append( i );
306 306
307 return incidences; 307 return incidences;
308} 308}
309 309
310QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 310QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
311{ 311{
312 QPtrList<Event> el = rawEventsForDate(date,sorted); 312 QPtrList<Event> el = rawEventsForDate(date,sorted);
313 mFilter->apply(&el); 313 mFilter->apply(&el);
314 return el; 314 return el;
315} 315}
316 316
317QPtrList<Event> Calendar::events( const QDateTime &qdt ) 317QPtrList<Event> Calendar::events( const QDateTime &qdt )
318{ 318{
319 QPtrList<Event> el = rawEventsForDate(qdt); 319 QPtrList<Event> el = rawEventsForDate(qdt);
320 mFilter->apply(&el); 320 mFilter->apply(&el);
321 return el; 321 return el;
322} 322}
323 323
324QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 324QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
325 bool inclusive) 325 bool inclusive)
326{ 326{
327 QPtrList<Event> el = rawEvents(start,end,inclusive); 327 QPtrList<Event> el = rawEvents(start,end,inclusive);
328 mFilter->apply(&el); 328 mFilter->apply(&el);
329 return el; 329 return el;
330} 330}
331 331
332QPtrList<Event> Calendar::events() 332QPtrList<Event> Calendar::events()
333{ 333{
334 QPtrList<Event> el = rawEvents(); 334 QPtrList<Event> el = rawEvents();
335 mFilter->apply(&el); 335 mFilter->apply(&el);
336 return el; 336 return el;
337} 337}
338void Calendar::addIncidenceBranch(Incidence *i) 338void Calendar::addIncidenceBranch(Incidence *i)
339{ 339{
340 addIncidence( i ); 340 addIncidence( i );
341 Incidence * inc; 341 Incidence * inc;
342 QPtrList<Incidence> Relations = i->relations(); 342 QPtrList<Incidence> Relations = i->relations();
343 for (inc=Relations.first();inc;inc=Relations.next()) { 343 for (inc=Relations.first();inc;inc=Relations.next()) {
344 addIncidenceBranch( inc ); 344 addIncidenceBranch( inc );
345 } 345 }
346} 346}
347 347
348bool Calendar::addIncidence(Incidence *i) 348bool Calendar::addIncidence(Incidence *i)
349{ 349{
350 Incidence::AddVisitor<Calendar> v(this); 350 Incidence::AddVisitor<Calendar> v(this);
351 351
352 return i->accept(v); 352 return i->accept(v);
353} 353}
354void Calendar::deleteIncidence(Incidence *in) 354void Calendar::deleteIncidence(Incidence *in)
355{ 355{
356 if ( in->type() == "Event" ) 356 if ( in->typeID() == eventID )
357 deleteEvent( (Event*) in ); 357 deleteEvent( (Event*) in );
358 else if ( in->type() =="Todo" ) 358 else if ( in->typeID() == todoID )
359 deleteTodo( (Todo*) in); 359 deleteTodo( (Todo*) in);
360 else if ( in->type() =="Journal" ) 360 else if ( in->typeID() == journalID )
361 deleteJournal( (Journal*) in ); 361 deleteJournal( (Journal*) in );
362} 362}
363 363
364Incidence* Calendar::incidence( const QString& uid ) 364Incidence* Calendar::incidence( const QString& uid )
365{ 365{
366 Incidence* i; 366 Incidence* i;
367 367
368 if( (i = todo( uid )) != 0 ) 368 if( (i = todo( uid )) != 0 )
369 return i; 369 return i;
370 if( (i = event( uid )) != 0 ) 370 if( (i = event( uid )) != 0 )
371 return i; 371 return i;
372 if( (i = journal( uid )) != 0 ) 372 if( (i = journal( uid )) != 0 )
373 return i; 373 return i;
374 374
375 return 0; 375 return 0;
376} 376}
377 377
378QPtrList<Todo> Calendar::todos() 378QPtrList<Todo> Calendar::todos()
379{ 379{
380 QPtrList<Todo> tl = rawTodos(); 380 QPtrList<Todo> tl = rawTodos();
381 mFilter->apply( &tl ); 381 mFilter->apply( &tl );
382 return tl; 382 return tl;
383} 383}
384 384
385// When this is called, the todo have already been added to the calendar. 385// When this is called, the todo have already been added to the calendar.
386// This method is only about linking related todos 386// This method is only about linking related todos
387void Calendar::setupRelations( Incidence *incidence ) 387void Calendar::setupRelations( Incidence *incidence )
388{ 388{
389 QString uid = incidence->uid(); 389 QString uid = incidence->uid();
390 //qDebug("Calendar::setupRelations "); 390 //qDebug("Calendar::setupRelations ");
391 // First, go over the list of orphans and see if this is their parent 391 // First, go over the list of orphans and see if this is their parent
392 while( Incidence* i = mOrphans[ uid ] ) { 392 while( Incidence* i = mOrphans[ uid ] ) {
393 mOrphans.remove( uid ); 393 mOrphans.remove( uid );
394 i->setRelatedTo( incidence ); 394 i->setRelatedTo( incidence );
395 incidence->addRelation( i ); 395 incidence->addRelation( i );
396 mOrphanUids.remove( i->uid() ); 396 mOrphanUids.remove( i->uid() );
397 } 397 }
398 398
399 // Now see about this incidences parent 399 // Now see about this incidences parent
400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
401 // This incidence has a uid it is related to, but is not registered to it yet 401 // This incidence has a uid it is related to, but is not registered to it yet
402 // Try to find it 402 // Try to find it
403 Incidence* parent = this->incidence( incidence->relatedToUid() ); 403 Incidence* parent = this->incidence( incidence->relatedToUid() );
404 if( parent ) { 404 if( parent ) {
405 // Found it 405 // Found it
406 incidence->setRelatedTo( parent ); 406 incidence->setRelatedTo( parent );
407 parent->addRelation( incidence ); 407 parent->addRelation( incidence );
408 } else { 408 } else {
409 // Not found, put this in the mOrphans list 409 // Not found, put this in the mOrphans list
410 mOrphans.insert( incidence->relatedToUid(), incidence ); 410 mOrphans.insert( incidence->relatedToUid(), incidence );
411 mOrphanUids.insert( incidence->uid(), incidence ); 411 mOrphanUids.insert( incidence->uid(), incidence );
412 } 412 }
413 } 413 }
414} 414}
415 415
416// If a task with subtasks is deleted, move it's subtasks to the orphans list 416// If a task with subtasks is deleted, move it's subtasks to the orphans list
417void Calendar::removeRelations( Incidence *incidence ) 417void Calendar::removeRelations( Incidence *incidence )
418{ 418{
419 // qDebug("Calendar::removeRelations "); 419 // qDebug("Calendar::removeRelations ");
420 QString uid = incidence->uid(); 420 QString uid = incidence->uid();
421 421
422 QPtrList<Incidence> relations = incidence->relations(); 422 QPtrList<Incidence> relations = incidence->relations();
423 for( Incidence* i = relations.first(); i; i = relations.next() ) 423 for( Incidence* i = relations.first(); i; i = relations.next() )
424 if( !mOrphanUids.find( i->uid() ) ) { 424 if( !mOrphanUids.find( i->uid() ) ) {
425 mOrphans.insert( uid, i ); 425 mOrphans.insert( uid, i );
426 mOrphanUids.insert( i->uid(), i ); 426 mOrphanUids.insert( i->uid(), i );
427 i->setRelatedTo( 0 ); 427 i->setRelatedTo( 0 );
428 i->setRelatedToUid( uid ); 428 i->setRelatedToUid( uid );
429 } 429 }
430 430
431 // If this incidence is related to something else, tell that about it 431 // If this incidence is related to something else, tell that about it
432 if( incidence->relatedTo() ) 432 if( incidence->relatedTo() )
433 incidence->relatedTo()->removeRelation( incidence ); 433 incidence->relatedTo()->removeRelation( incidence );
434 434
435 // Remove this one from the orphans list 435 // Remove this one from the orphans list
436 if( mOrphanUids.remove( uid ) ) 436 if( mOrphanUids.remove( uid ) )
437 // This incidence is located in the orphans list - it should be removed 437 // This incidence is located in the orphans list - it should be removed
438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
439 // Removing wasn't that easy 439 // Removing wasn't that easy
440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
441 if( it.current()->uid() == uid ) { 441 if( it.current()->uid() == uid ) {
442 mOrphans.remove( it.currentKey() ); 442 mOrphans.remove( it.currentKey() );
443 break; 443 break;
444 } 444 }
445 } 445 }
446 } 446 }
447} 447}
448 448
449void Calendar::registerObserver( Observer *observer ) 449void Calendar::registerObserver( Observer *observer )
450{ 450{
451 mObserver = observer; 451 mObserver = observer;
452 mNewObserver = true; 452 mNewObserver = true;
453} 453}
454 454
455void Calendar::setModified( bool modified ) 455void Calendar::setModified( bool modified )
456{ 456{
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index bc76c0b..fe74052 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -365,224 +365,220 @@ void CalendarLocal::registerAlarm()
365{ 365{
366 mLastAlarmNotificationString = getAlarmNotification(); 366 mLastAlarmNotificationString = getAlarmNotification();
367 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 367 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
368 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 368 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
369// #ifndef DESKTOP_VERSION 369// #ifndef DESKTOP_VERSION
370// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 370// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
371// #endif 371// #endif
372} 372}
373void CalendarLocal::deRegisterAlarm() 373void CalendarLocal::deRegisterAlarm()
374{ 374{
375 if ( mLastAlarmNotificationString.isNull() ) 375 if ( mLastAlarmNotificationString.isNull() )
376 return; 376 return;
377 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 377 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
378 378
379 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 379 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
380 mNextAlarmEventDateTime = QDateTime(); 380 mNextAlarmEventDateTime = QDateTime();
381// #ifndef DESKTOP_VERSION 381// #ifndef DESKTOP_VERSION
382// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 382// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
383// #endif 383// #endif
384} 384}
385 385
386QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 386QPtrList<Todo> CalendarLocal::todos( const QDate &date )
387{ 387{
388 QPtrList<Todo> todos; 388 QPtrList<Todo> todos;
389 389
390 Todo *todo; 390 Todo *todo;
391 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 391 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
392 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 392 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
393 todos.append( todo ); 393 todos.append( todo );
394 } 394 }
395 } 395 }
396 396
397 filter()->apply( &todos ); 397 filter()->apply( &todos );
398 return todos; 398 return todos;
399} 399}
400void CalendarLocal::reInitAlarmSettings() 400void CalendarLocal::reInitAlarmSettings()
401{ 401{
402 if ( !mNextAlarmIncidence ) { 402 if ( !mNextAlarmIncidence ) {
403 nextAlarm( 1000 ); 403 nextAlarm( 1000 );
404 } 404 }
405 deRegisterAlarm(); 405 deRegisterAlarm();
406 mNextAlarmIncidence = 0; 406 mNextAlarmIncidence = 0;
407 checkAlarmForIncidence( 0, false ); 407 checkAlarmForIncidence( 0, false );
408 408
409} 409}
410 410
411 411
412 412
413QDateTime CalendarLocal::nextAlarm( int daysTo ) 413QDateTime CalendarLocal::nextAlarm( int daysTo )
414{ 414{
415 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); 415 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo );
416 QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); 416 QDateTime start = QDateTime::currentDateTime().addSecs( 30 );
417 QDateTime next; 417 QDateTime next;
418 Event *e; 418 Event *e;
419 bool ok; 419 bool ok;
420 bool found = false; 420 bool found = false;
421 int offset; 421 int offset;
422 mNextAlarmIncidence = 0; 422 mNextAlarmIncidence = 0;
423 for( e = mEventList.first(); e; e = mEventList.next() ) { 423 for( e = mEventList.first(); e; e = mEventList.next() ) {
424 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 424 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
425 if ( ok ) { 425 if ( ok ) {
426 if ( next < nextA ) { 426 if ( next < nextA ) {
427 nextA = next; 427 nextA = next;
428 found = true; 428 found = true;
429 mNextSummary = e->summary(); 429 mNextSummary = e->summary();
430 mNextAlarmEventDateTime = next.addSecs(offset ) ; 430 mNextAlarmEventDateTime = next.addSecs(offset ) ;
431 mNextAlarmIncidence = (Incidence *) e; 431 mNextAlarmIncidence = (Incidence *) e;
432 } 432 }
433 } 433 }
434 } 434 }
435 Todo *t; 435 Todo *t;
436 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 436 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
437 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 437 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
438 if ( ok ) { 438 if ( ok ) {
439 if ( next < nextA ) { 439 if ( next < nextA ) {
440 nextA = next; 440 nextA = next;
441 found = true; 441 found = true;
442 mNextSummary = t->summary(); 442 mNextSummary = t->summary();
443 mNextAlarmEventDateTime = next.addSecs(offset ); 443 mNextAlarmEventDateTime = next.addSecs(offset );
444 mNextAlarmIncidence = (Incidence *) t; 444 mNextAlarmIncidence = (Incidence *) t;
445 } 445 }
446 } 446 }
447 } 447 }
448 if ( mNextAlarmIncidence ) { 448 if ( mNextAlarmIncidence ) {
449 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 449 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
450 mNextAlarmDateTime = nextA; 450 mNextAlarmDateTime = nextA;
451 } 451 }
452 return nextA; 452 return nextA;
453} 453}
454Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) 454Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
455{ 455{
456 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); 456 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
457} 457}
458 458
459Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 459Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
460{ 460{
461 kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " 461
462 << to.toString() << ")\n";
463
464 Alarm::List alarms; 462 Alarm::List alarms;
465 463
466 Event *e; 464 Event *e;
467 465
468 for( e = mEventList.first(); e; e = mEventList.next() ) { 466 for( e = mEventList.first(); e; e = mEventList.next() ) {
469 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); 467 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
470 else appendAlarms( alarms, e, from, to ); 468 else appendAlarms( alarms, e, from, to );
471 } 469 }
472 470
473 Todo *t; 471 Todo *t;
474 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 472 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
475 appendAlarms( alarms, t, from, to ); 473 appendAlarms( alarms, t, from, to );
476 } 474 }
477 475
478 return alarms; 476 return alarms;
479} 477}
480 478
481void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 479void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
482 const QDateTime &from, const QDateTime &to ) 480 const QDateTime &from, const QDateTime &to )
483{ 481{
484 QPtrList<Alarm> alarmList = incidence->alarms(); 482 QPtrList<Alarm> alarmList = incidence->alarms();
485 Alarm *alarm; 483 Alarm *alarm;
486 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 484 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
487// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 485// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
488// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 486// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
489 if ( alarm->enabled() ) { 487 if ( alarm->enabled() ) {
490 if ( alarm->time() >= from && alarm->time() <= to ) { 488 if ( alarm->time() >= from && alarm->time() <= to ) {
491 kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary()
492 << "': " << alarm->time().toString() << endl;
493 alarms.append( alarm ); 489 alarms.append( alarm );
494 } 490 }
495 } 491 }
496 } 492 }
497} 493}
498 494
499void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 495void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
500 Incidence *incidence, 496 Incidence *incidence,
501 const QDateTime &from, 497 const QDateTime &from,
502 const QDateTime &to ) 498 const QDateTime &to )
503{ 499{
504 500
505 QPtrList<Alarm> alarmList = incidence->alarms(); 501 QPtrList<Alarm> alarmList = incidence->alarms();
506 Alarm *alarm; 502 Alarm *alarm;
507 QDateTime qdt; 503 QDateTime qdt;
508 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 504 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
509 if (incidence->recursOn(from.date())) { 505 if (incidence->recursOn(from.date())) {
510 qdt.setTime(alarm->time().time()); 506 qdt.setTime(alarm->time().time());
511 qdt.setDate(from.date()); 507 qdt.setDate(from.date());
512 } 508 }
513 else qdt = alarm->time(); 509 else qdt = alarm->time();
514 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 510 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
515 if ( alarm->enabled() ) { 511 if ( alarm->enabled() ) {
516 if ( qdt >= from && qdt <= to ) { 512 if ( qdt >= from && qdt <= to ) {
517 alarms.append( alarm ); 513 alarms.append( alarm );
518 } 514 }
519 } 515 }
520 } 516 }
521} 517}
522 518
523 519
524/****************************** PROTECTED METHODS ****************************/ 520/****************************** PROTECTED METHODS ****************************/
525 521
526// after changes are made to an event, this should be called. 522// after changes are made to an event, this should be called.
527void CalendarLocal::update( IncidenceBase *incidence ) 523void CalendarLocal::update( IncidenceBase *incidence )
528{ 524{
529 incidence->setSyncStatus( Event::SYNCMOD ); 525 incidence->setSyncStatus( Event::SYNCMOD );
530 incidence->setLastModified( QDateTime::currentDateTime() ); 526 incidence->setLastModified( QDateTime::currentDateTime() );
531 // we should probably update the revision number here, 527 // we should probably update the revision number here,
532 // or internally in the Event itself when certain things change. 528 // or internally in the Event itself when certain things change.
533 // need to verify with ical documentation. 529 // need to verify with ical documentation.
534 530
535 setModified( true ); 531 setModified( true );
536} 532}
537 533
538void CalendarLocal::insertEvent( Event *event ) 534void CalendarLocal::insertEvent( Event *event )
539{ 535{
540 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 536 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
541} 537}
542 538
543 539
544QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 540QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
545{ 541{
546 QPtrList<Event> eventList; 542 QPtrList<Event> eventList;
547 543
548 Event *event; 544 Event *event;
549 for( event = mEventList.first(); event; event = mEventList.next() ) { 545 for( event = mEventList.first(); event; event = mEventList.next() ) {
550 if ( event->doesRecur() ) { 546 if ( event->doesRecur() ) {
551 if ( event->isMultiDay() ) { 547 if ( event->isMultiDay() ) {
552 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 548 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
553 int i; 549 int i;
554 for ( i = 0; i <= extraDays; i++ ) { 550 for ( i = 0; i <= extraDays; i++ ) {
555 if ( event->recursOn( qd.addDays( -i ) ) ) { 551 if ( event->recursOn( qd.addDays( -i ) ) ) {
556 eventList.append( event ); 552 eventList.append( event );
557 break; 553 break;
558 } 554 }
559 } 555 }
560 } else { 556 } else {
561 if ( event->recursOn( qd ) ) 557 if ( event->recursOn( qd ) )
562 eventList.append( event ); 558 eventList.append( event );
563 } 559 }
564 } else { 560 } else {
565 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 561 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
566 eventList.append( event ); 562 eventList.append( event );
567 } 563 }
568 } 564 }
569 } 565 }
570 566
571 if ( !sorted ) { 567 if ( !sorted ) {
572 return eventList; 568 return eventList;
573 } 569 }
574 570
575 // kdDebug(5800) << "Sorting events for date\n" << endl; 571 // kdDebug(5800) << "Sorting events for date\n" << endl;
576 // now, we have to sort it based on dtStart.time() 572 // now, we have to sort it based on dtStart.time()
577 QPtrList<Event> eventListSorted; 573 QPtrList<Event> eventListSorted;
578 Event *sortEvent; 574 Event *sortEvent;
579 for ( event = eventList.first(); event; event = eventList.next() ) { 575 for ( event = eventList.first(); event; event = eventList.next() ) {
580 sortEvent = eventListSorted.first(); 576 sortEvent = eventListSorted.first();
581 int i = 0; 577 int i = 0;
582 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 578 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
583 { 579 {
584 i++; 580 i++;
585 sortEvent = eventListSorted.next(); 581 sortEvent = eventListSorted.next();
586 } 582 }
587 eventListSorted.insert( i, event ); 583 eventListSorted.insert( i, event );
588 } 584 }
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c425dfc..20078a7 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -1,181 +1,181 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22 22
23#include "calfilter.h" 23#include "calfilter.h"
24 24
25using namespace KCal; 25using namespace KCal;
26 26
27CalFilter::CalFilter() 27CalFilter::CalFilter()
28{ 28{
29 mEnabled = true; 29 mEnabled = true;
30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
31} 31}
32 32
33CalFilter::CalFilter(const QString &name) 33CalFilter::CalFilter(const QString &name)
34{ 34{
35 mName = name; 35 mName = name;
36 mEnabled = true; 36 mEnabled = true;
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38} 38}
39 39
40CalFilter::~CalFilter() 40CalFilter::~CalFilter()
41{ 41{
42} 42}
43 43
44void CalFilter::apply(QPtrList<Event> *eventlist) 44void CalFilter::apply(QPtrList<Event> *eventlist)
45{ 45{
46 if (!mEnabled) return; 46 if (!mEnabled) return;
47 47
48// kdDebug(5800) << "CalFilter::apply()" << endl; 48// kdDebug(5800) << "CalFilter::apply()" << endl;
49 49
50 Event *event = eventlist->first(); 50 Event *event = eventlist->first();
51 while(event) { 51 while(event) {
52 if (!filterEvent(event)) { 52 if (!filterEvent(event)) {
53 eventlist->remove(); 53 eventlist->remove();
54 event = eventlist->current(); 54 event = eventlist->current();
55 } else { 55 } else {
56 event = eventlist->next(); 56 event = eventlist->next();
57 } 57 }
58 } 58 }
59 59
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 60// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 61}
62 62
63// TODO: avoid duplicating apply() code 63// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 64void CalFilter::apply(QPtrList<Todo> *eventlist)
65{ 65{
66 if (!mEnabled) return; 66 if (!mEnabled) return;
67 Todo *event = eventlist->first(); 67 Todo *event = eventlist->first();
68 while(event) { 68 while(event) {
69 if (!filterTodo(event)) { 69 if (!filterTodo(event)) {
70 eventlist->remove(); 70 eventlist->remove();
71 event = eventlist->current(); 71 event = eventlist->current();
72 } else { 72 } else {
73 event = eventlist->next(); 73 event = eventlist->next();
74 } 74 }
75 } 75 }
76 76
77// kdDebug(5800) << "CalFilter::apply() done" << endl; 77// kdDebug(5800) << "CalFilter::apply() done" << endl;
78} 78}
79bool CalFilter::filterCalendarItem(Incidence *in) 79bool CalFilter::filterCalendarItem(Incidence *in)
80{ 80{
81 if ( in->type() == "Event" ) 81 if ( in->typeID() == eventID )
82 return filterEvent( (Event*) in ); 82 return filterEvent( (Event*) in );
83 else if ( in->type() =="Todo" ) 83 else if ( in->typeID() == todoID )
84 return filterTodo( (Todo*) in); 84 return filterTodo( (Todo*) in);
85 else if ( in->type() =="Journal" ) 85 else if ( in->typeID () == journalID )
86 return filterJournal( (Journal*) in ); 86 return filterJournal( (Journal*) in );
87 return false; 87 return false;
88} 88}
89bool CalFilter::filterEvent(Event *event) 89bool CalFilter::filterEvent(Event *event)
90{ 90{
91 if (mCriteria & HideEvents) 91 if (mCriteria & HideEvents)
92 return false; 92 return false;
93 if (mCriteria & HideRecurring) { 93 if (mCriteria & HideRecurring) {
94 if (event->recurrence()->doesRecur()) return false; 94 if (event->recurrence()->doesRecur()) return false;
95 } 95 }
96 96
97 return filterIncidence(event); 97 return filterIncidence(event);
98} 98}
99bool CalFilter::filterJournal(Journal *j) 99bool CalFilter::filterJournal(Journal *j)
100{ 100{
101 if (mCriteria & HideJournals) 101 if (mCriteria & HideJournals)
102 return false; 102 return false;
103 return true; 103 return true;
104} 104}
105bool CalFilter::filterTodo(Todo *todo) 105bool CalFilter::filterTodo(Todo *todo)
106{ 106{
107 if (mCriteria & HideTodos) 107 if (mCriteria & HideTodos)
108 return false; 108 return false;
109 if (mCriteria & HideCompleted) { 109 if (mCriteria & HideCompleted) {
110 if (todo->isCompleted()) return false; 110 if (todo->isCompleted()) return false;
111 } 111 }
112 112
113 return filterIncidence(todo); 113 return filterIncidence(todo);
114} 114}
115bool CalFilter::showCategories() 115bool CalFilter::showCategories()
116{ 116{
117 return mCriteria & ShowCategories; 117 return mCriteria & ShowCategories;
118} 118}
119int CalFilter::getSecrecy() 119int CalFilter::getSecrecy()
120{ 120{
121 if ( (mCriteria & ShowPublic )) 121 if ( (mCriteria & ShowPublic ))
122 return Incidence::SecrecyPublic; 122 return Incidence::SecrecyPublic;
123 if ( (mCriteria & ShowPrivate )) 123 if ( (mCriteria & ShowPrivate ))
124 return Incidence::SecrecyPrivate; 124 return Incidence::SecrecyPrivate;
125 if ( (mCriteria & ShowConfidential )) 125 if ( (mCriteria & ShowConfidential ))
126 return Incidence::SecrecyConfidential; 126 return Incidence::SecrecyConfidential;
127 return Incidence::SecrecyPublic; 127 return Incidence::SecrecyPublic;
128} 128}
129bool CalFilter::filterIncidence(Incidence *incidence) 129bool CalFilter::filterIncidence(Incidence *incidence)
130{ 130{
131 if ( mCriteria > 7 ) { 131 if ( mCriteria > 7 ) {
132 switch (incidence->secrecy()) { 132 switch (incidence->secrecy()) {
133 case Incidence::SecrecyPublic: 133 case Incidence::SecrecyPublic:
134 if (! (mCriteria & ShowPublic )) 134 if (! (mCriteria & ShowPublic ))
135 return false; 135 return false;
136 break; 136 break;
137 case Incidence::SecrecyPrivate: 137 case Incidence::SecrecyPrivate:
138 if (! (mCriteria & ShowPrivate )) 138 if (! (mCriteria & ShowPrivate ))
139 return false; 139 return false;
140 break; 140 break;
141 case Incidence::SecrecyConfidential: 141 case Incidence::SecrecyConfidential:
142 if (! (mCriteria & ShowConfidential )) 142 if (! (mCriteria & ShowConfidential ))
143 return false; 143 return false;
144 break; 144 break;
145 default: 145 default:
146 return false; 146 return false;
147 break; 147 break;
148 } 148 }
149 } 149 }
150 150
151 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 151 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
152 152
153 if (mCriteria & ShowCategories) { 153 if (mCriteria & ShowCategories) {
154 for (QStringList::Iterator it = mCategoryList.begin(); 154 for (QStringList::Iterator it = mCategoryList.begin();
155 it != mCategoryList.end(); ++it ) { 155 it != mCategoryList.end(); ++it ) {
156 QStringList incidenceCategories = incidence->categories(); 156 QStringList incidenceCategories = incidence->categories();
157 for (QStringList::Iterator it2 = incidenceCategories.begin(); 157 for (QStringList::Iterator it2 = incidenceCategories.begin();
158 it2 != incidenceCategories.end(); ++it2 ) { 158 it2 != incidenceCategories.end(); ++it2 ) {
159 if ((*it) == (*it2)) { 159 if ((*it) == (*it2)) {
160 return true; 160 return true;
161 } 161 }
162 } 162 }
163 } 163 }
164 return false; 164 return false;
165 } else { 165 } else {
166 for (QStringList::Iterator it = mCategoryList.begin(); 166 for (QStringList::Iterator it = mCategoryList.begin();
167 it != mCategoryList.end(); ++it ) { 167 it != mCategoryList.end(); ++it ) {
168 QStringList incidenceCategories = incidence->categories(); 168 QStringList incidenceCategories = incidence->categories();
169 for (QStringList::Iterator it2 = incidenceCategories.begin(); 169 for (QStringList::Iterator it2 = incidenceCategories.begin();
170 it2 != incidenceCategories.end(); ++it2 ) { 170 it2 != incidenceCategories.end(); ++it2 ) {
171 if ((*it) == (*it2)) { 171 if ((*it) == (*it2)) {
172 return false; 172 return false;
173 } 173 }
174 } 174 }
175 } 175 }
176 return true; 176 return true;
177 } 177 }
178 178
179// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; 179// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
180 180
181 return true; 181 return true;
diff --git a/libkcal/event.h b/libkcal/event.h
index 8729956..287d403 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -1,90 +1,91 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef EVENT_H 21#ifndef EVENT_H
22#define EVENT_H 22#define EVENT_H
23// 23//
24// Event component, representing a VEVENT object 24// Event component, representing a VEVENT object
25// 25//
26 26
27#include "incidence.h" 27#include "incidence.h"
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides an Event in the sense of RFC2445. 31 This class provides an Event in the sense of RFC2445.
32*/ 32*/
33class Event : public Incidence 33class Event : public Incidence
34{ 34{
35 public: 35 public:
36 enum Transparency { Opaque, Transparent }; 36 enum Transparency { Opaque, Transparent };
37 typedef ListBase<Event> List; 37 typedef ListBase<Event> List;
38 Event(); 38 Event();
39 Event(const Event &); 39 Event(const Event &);
40 ~Event(); 40 ~Event();
41 41
42 QCString type() const { return "Event"; } 42 QCString type() const { return "Event"; }
43 IncTypeID typeID() const { return eventID; }
43 44
44 Incidence *clone(); 45 Incidence *clone();
45 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 46 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
46 47
47 /** for setting an event's ending date/time with a QDateTime. */ 48 /** for setting an event's ending date/time with a QDateTime. */
48 void setDtEnd(const QDateTime &dtEnd); 49 void setDtEnd(const QDateTime &dtEnd);
49 /** Return the event's ending date/time as a QDateTime. */ 50 /** Return the event's ending date/time as a QDateTime. */
50 virtual QDateTime dtEnd() const; 51 virtual QDateTime dtEnd() const;
51 /** returns an event's end time as a string formatted according to the 52 /** returns an event's end time as a string formatted according to the
52 users locale settings */ 53 users locale settings */
53 QString dtEndTimeStr() const; 54 QString dtEndTimeStr() const;
54 /** returns an event's end date as a string formatted according to the 55 /** returns an event's end date as a string formatted according to the
55 users locale settings */ 56 users locale settings */
56 QString dtEndDateStr(bool shortfmt=true) const; 57 QString dtEndDateStr(bool shortfmt=true) const;
57 /** returns an event's end date and time as a string formatted according 58 /** returns an event's end date and time as a string formatted according
58 to the users locale settings */ 59 to the users locale settings */
59 QString dtEndStr(bool shortfmt=true) const; 60 QString dtEndStr(bool shortfmt=true) const;
60 void setHasEndDate(bool); 61 void setHasEndDate(bool);
61 /** Return whether the event has an end date/time. */ 62 /** Return whether the event has an end date/time. */
62 bool hasEndDate() const; 63 bool hasEndDate() const;
63 64
64 /** Return true if the event spans multiple days, otherwise return false. */ 65 /** Return true if the event spans multiple days, otherwise return false. */
65 bool isMultiDay() const; 66 bool isMultiDay() const;
66 67
67 /** set the event's time transparency level. */ 68 /** set the event's time transparency level. */
68 void setTransparency(Transparency transparency); 69 void setTransparency(Transparency transparency);
69 /** get the event's time transparency level. */ 70 /** get the event's time transparency level. */
70 Transparency transparency() const; 71 Transparency transparency() const;
71 72
72 void setDuration(int seconds); 73 void setDuration(int seconds);
73 74
74 bool contains ( Event*); 75 bool contains ( Event*);
75 76
76 private: 77 private:
77 bool accept(Visitor &v) { return v.visit(this); } 78 bool accept(Visitor &v) { return v.visit(this); }
78 79
79 QDateTime mDtEnd; 80 QDateTime mDtEnd;
80 bool mHasEndDate; 81 bool mHasEndDate;
81 Transparency mTransparency; 82 Transparency mTransparency;
82}; 83};
83 84
84bool operator==( const Event&, const Event& ); 85bool operator==( const Event&, const Event& );
85 86
86 87
87} 88}
88 89
89 90
90#endif 91#endif
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h
index 054feda..d741c72 100644
--- a/libkcal/freebusy.h
+++ b/libkcal/freebusy.h
@@ -1,72 +1,73 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_FREEBUSY_H 20#ifndef KCAL_FREEBUSY_H
21#define KCAL_FREEBUSY_H 21#define KCAL_FREEBUSY_H
22// 22//
23// FreeBusy - information about free/busy times 23// FreeBusy - information about free/busy times
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qvaluelist.h> 27#include <qvaluelist.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29 29
30#include "period.h" 30#include "period.h"
31#include "calendar.h" 31#include "calendar.h"
32 32
33#include "incidencebase.h" 33#include "incidencebase.h"
34 34
35namespace KCal { 35namespace KCal {
36 36
37/** 37/**
38 This class provides information about free/busy time of a calendar user. 38 This class provides information about free/busy time of a calendar user.
39*/ 39*/
40class FreeBusy : public IncidenceBase 40class FreeBusy : public IncidenceBase
41{ 41{
42 public: 42 public:
43 FreeBusy(); 43 FreeBusy();
44 FreeBusy(const QDateTime &start, const QDateTime &end); 44 FreeBusy(const QDateTime &start, const QDateTime &end);
45 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end); 45 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end);
46 FreeBusy(QValueList<Period> busyPeriods); 46 FreeBusy(QValueList<Period> busyPeriods);
47 47
48 ~FreeBusy(); 48 ~FreeBusy();
49 49
50 QCString type() const { return "FreeBusy"; } 50 QCString type() const { return "FreeBusy"; }
51 IncTypeID typeID() const { return freebusyID; }
51 52
52 virtual QDateTime dtEnd() const; 53 virtual QDateTime dtEnd() const;
53 bool setDtEnd( const QDateTime &end ); 54 bool setDtEnd( const QDateTime &end );
54 55
55 QValueList<Period> busyPeriods() const; 56 QValueList<Period> busyPeriods() const;
56 57
57 void addPeriod(const QDateTime &start, const QDateTime &end); 58 void addPeriod(const QDateTime &start, const QDateTime &end);
58 void sortList(); 59 void sortList();
59 60
60 private: 61 private:
61 62
62 //This is used for creating a freebusy object for the current user 63 //This is used for creating a freebusy object for the current user
63 bool addLocalPeriod(const QDateTime &start, const QDateTime &end); 64 bool addLocalPeriod(const QDateTime &start, const QDateTime &end);
64 65
65 QDateTime mDtEnd; 66 QDateTime mDtEnd;
66 QValueList<Period> mBusyPeriods; 67 QValueList<Period> mBusyPeriods;
67 Calendar *mCalendar; 68 Calendar *mCalendar;
68}; 69};
69 70
70} 71}
71 72
72#endif 73#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 3a2aac6..d9fe40b 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -291,170 +291,170 @@ QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
291} 291}
292 292
293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, 293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
294 const QString &messageText ) 294 const QString &messageText )
295{ 295{
296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
297 clearException(); 297 clearException();
298 298
299 if (messageText.isEmpty()) return 0; 299 if (messageText.isEmpty()) return 0;
300 300
301 icalcomponent *message; 301 icalcomponent *message;
302 message = icalparser_parse_string(messageText.local8Bit()); 302 message = icalparser_parse_string(messageText.local8Bit());
303 303
304 if (!message) return 0; 304 if (!message) return 0;
305 305
306 icalproperty *m = icalcomponent_get_first_property(message, 306 icalproperty *m = icalcomponent_get_first_property(message,
307 ICAL_METHOD_PROPERTY); 307 ICAL_METHOD_PROPERTY);
308 308
309 if (!m) return 0; 309 if (!m) return 0;
310 310
311 icalcomponent *c; 311 icalcomponent *c;
312 312
313 IncidenceBase *incidence = 0; 313 IncidenceBase *incidence = 0;
314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); 314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT);
315 if (c) { 315 if (c) {
316 incidence = mImpl->readEvent(c); 316 incidence = mImpl->readEvent(c);
317 } 317 }
318 318
319 if (!incidence) { 319 if (!incidence) {
320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); 320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT);
321 if (c) { 321 if (c) {
322 incidence = mImpl->readTodo(c); 322 incidence = mImpl->readTodo(c);
323 } 323 }
324 } 324 }
325 325
326 if (!incidence) { 326 if (!incidence) {
327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); 327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT);
328 if (c) { 328 if (c) {
329 incidence = mImpl->readFreeBusy(c); 329 incidence = mImpl->readFreeBusy(c);
330 } 330 }
331 } 331 }
332 332
333 if (!incidence) { 333 if (!incidence) {
334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; 334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl;
335 return 0; 335 return 0;
336 } 336 }
337 337
338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; 338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl;
339 339
340 icalproperty_method icalmethod = icalproperty_get_method(m); 340 icalproperty_method icalmethod = icalproperty_get_method(m);
341 Scheduler::Method method; 341 Scheduler::Method method;
342 342
343 switch (icalmethod) { 343 switch (icalmethod) {
344 case ICAL_METHOD_PUBLISH: 344 case ICAL_METHOD_PUBLISH:
345 method = Scheduler::Publish; 345 method = Scheduler::Publish;
346 break; 346 break;
347 case ICAL_METHOD_REQUEST: 347 case ICAL_METHOD_REQUEST:
348 method = Scheduler::Request; 348 method = Scheduler::Request;
349 break; 349 break;
350 case ICAL_METHOD_REFRESH: 350 case ICAL_METHOD_REFRESH:
351 method = Scheduler::Refresh; 351 method = Scheduler::Refresh;
352 break; 352 break;
353 case ICAL_METHOD_CANCEL: 353 case ICAL_METHOD_CANCEL:
354 method = Scheduler::Cancel; 354 method = Scheduler::Cancel;
355 break; 355 break;
356 case ICAL_METHOD_ADD: 356 case ICAL_METHOD_ADD:
357 method = Scheduler::Add; 357 method = Scheduler::Add;
358 break; 358 break;
359 case ICAL_METHOD_REPLY: 359 case ICAL_METHOD_REPLY:
360 method = Scheduler::Reply; 360 method = Scheduler::Reply;
361 break; 361 break;
362 case ICAL_METHOD_COUNTER: 362 case ICAL_METHOD_COUNTER:
363 method = Scheduler::Counter; 363 method = Scheduler::Counter;
364 break; 364 break;
365 case ICAL_METHOD_DECLINECOUNTER: 365 case ICAL_METHOD_DECLINECOUNTER:
366 method = Scheduler::Declinecounter; 366 method = Scheduler::Declinecounter;
367 break; 367 break;
368 default: 368 default:
369 method = Scheduler::NoMethod; 369 method = Scheduler::NoMethod;
370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; 370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
371 break; 371 break;
372 } 372 }
373 373
374 374
375 if (!icalrestriction_check(message)) { 375 if (!icalrestriction_check(message)) {
376 setException(new ErrorFormat(ErrorFormat::Restriction, 376 setException(new ErrorFormat(ErrorFormat::Restriction,
377 Scheduler::translatedMethodName(method) + ": " + 377 Scheduler::translatedMethodName(method) + ": " +
378 mImpl->extractErrorProperty(c))); 378 mImpl->extractErrorProperty(c)));
379 return 0; 379 return 0;
380 } 380 }
381 381
382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); 382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
383 383
384 Incidence *existingIncidence = cal->event(incidence->uid()); 384 Incidence *existingIncidence = cal->event(incidence->uid());
385 if (existingIncidence) { 385 if (existingIncidence) {
386 // TODO: check, if cast is required, or if it can be done by virtual funcs. 386 // TODO: check, if cast is required, or if it can be done by virtual funcs.
387 if (existingIncidence->type() == "Todo") { 387 if (existingIncidence->typeID() == todoID ) {
388 Todo *todo = static_cast<Todo *>(existingIncidence); 388 Todo *todo = static_cast<Todo *>(existingIncidence);
389 icalcomponent_add_component(calendarComponent, 389 icalcomponent_add_component(calendarComponent,
390 mImpl->writeTodo(todo)); 390 mImpl->writeTodo(todo));
391 } 391 }
392 if (existingIncidence->type() == "Event") { 392 if (existingIncidence->typeID() == eventID ) {
393 Event *event = static_cast<Event *>(existingIncidence); 393 Event *event = static_cast<Event *>(existingIncidence);
394 icalcomponent_add_component(calendarComponent, 394 icalcomponent_add_component(calendarComponent,
395 mImpl->writeEvent(event)); 395 mImpl->writeEvent(event));
396 } 396 }
397 } else { 397 } else {
398 calendarComponent = 0; 398 calendarComponent = 0;
399 } 399 }
400 qDebug("icalclassify commented out "); 400 qDebug("icalclassify commented out ");
401 ScheduleMessage::Status status; 401 ScheduleMessage::Status status;
402#if 0 402#if 0
403 403
404 icalclass result = icalclassify(message,calendarComponent,(char *)""); 404 icalclass result = icalclassify(message,calendarComponent,(char *)"");
405 405
406 406
407 407
408 switch (result) { 408 switch (result) {
409 case ICAL_PUBLISH_NEW_CLASS: 409 case ICAL_PUBLISH_NEW_CLASS:
410 status = ScheduleMessage::PublishNew; 410 status = ScheduleMessage::PublishNew;
411 break; 411 break;
412 case ICAL_OBSOLETE_CLASS: 412 case ICAL_OBSOLETE_CLASS:
413 status = ScheduleMessage::Obsolete; 413 status = ScheduleMessage::Obsolete;
414 break; 414 break;
415 case ICAL_REQUEST_NEW_CLASS: 415 case ICAL_REQUEST_NEW_CLASS:
416 status = ScheduleMessage::RequestNew; 416 status = ScheduleMessage::RequestNew;
417 break; 417 break;
418 case ICAL_REQUEST_UPDATE_CLASS: 418 case ICAL_REQUEST_UPDATE_CLASS:
419 status = ScheduleMessage::RequestUpdate; 419 status = ScheduleMessage::RequestUpdate;
420 break; 420 break;
421 case ICAL_UNKNOWN_CLASS: 421 case ICAL_UNKNOWN_CLASS:
422 default: 422 default:
423 status = ScheduleMessage::Unknown; 423 status = ScheduleMessage::Unknown;
424 break; 424 break;
425 } 425 }
426#endif 426#endif
427 status = ScheduleMessage::RequestUpdate; 427 status = ScheduleMessage::RequestUpdate;
428 return new ScheduleMessage(incidence,method,status); 428 return new ScheduleMessage(incidence,method,status);
429} 429}
430 430
431void ICalFormat::setTimeZone( const QString &id, bool utc ) 431void ICalFormat::setTimeZone( const QString &id, bool utc )
432{ 432{
433 433
434 434
435 mTimeZoneId = id; 435 mTimeZoneId = id;
436 mUtc = utc; 436 mUtc = utc;
437 437
438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); 438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId);
439 439
440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); 440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin);
441} 441}
442 442
443QString ICalFormat::timeZoneId() const 443QString ICalFormat::timeZoneId() const
444{ 444{
445 return mTimeZoneId; 445 return mTimeZoneId;
446} 446}
447 447
448bool ICalFormat::utc() const 448bool ICalFormat::utc() const
449{ 449{
450 return mUtc; 450 return mUtc;
451} 451}
452int ICalFormat::timeOffset() 452int ICalFormat::timeOffset()
453{ 453{
454 return tzOffsetMin; 454 return tzOffsetMin;
455} 455}
456const char *ICalFormat::tzString() 456const char *ICalFormat::tzString()
457{ 457{
458 const char* ret = (const char* ) mTzString; 458 const char* ret = (const char* ) mTzString;
459 return ret; 459 return ret;
460} 460}
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2405682..3e28714 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -2062,111 +2062,111 @@ QString ICalFormatImpl::extractErrorProperty(icalcomponent *c)
2062 2062
2063 icalproperty *error; 2063 icalproperty *error;
2064 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); 2064 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY);
2065 while(error) { 2065 while(error) {
2066 errorMessage += icalproperty_get_xlicerror(error); 2066 errorMessage += icalproperty_get_xlicerror(error);
2067 errorMessage += "\n"; 2067 errorMessage += "\n";
2068 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); 2068 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY);
2069 } 2069 }
2070 2070
2071// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; 2071// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl;
2072 2072
2073 return errorMessage; 2073 return errorMessage;
2074} 2074}
2075 2075
2076void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) 2076void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r)
2077{ 2077{
2078 int i; 2078 int i;
2079 2079
2080 2080
2081 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2081 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2082 int index = 0; 2082 int index = 0;
2083 QString out = " By Day: "; 2083 QString out = " By Day: ";
2084 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2084 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2085 out.append(QString::number(i) + " "); 2085 out.append(QString::number(i) + " ");
2086 } 2086 }
2087 } 2087 }
2088 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2088 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2089 int index = 0; 2089 int index = 0;
2090 QString out = " By Month Day: "; 2090 QString out = " By Month Day: ";
2091 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2091 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2092 out.append(QString::number(i) + " "); 2092 out.append(QString::number(i) + " ");
2093 } 2093 }
2094 } 2094 }
2095 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2095 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2096 int index = 0; 2096 int index = 0;
2097 QString out = " By Year Day: "; 2097 QString out = " By Year Day: ";
2098 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2098 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2099 out.append(QString::number(i) + " "); 2099 out.append(QString::number(i) + " ");
2100 } 2100 }
2101 } 2101 }
2102 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2102 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2103 int index = 0; 2103 int index = 0;
2104 QString out = " By Month: "; 2104 QString out = " By Month: ";
2105 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2105 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2106 out.append(QString::number(i) + " "); 2106 out.append(QString::number(i) + " ");
2107 } 2107 }
2108 } 2108 }
2109 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2109 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2110 int index = 0; 2110 int index = 0;
2111 QString out = " By Set Pos: "; 2111 QString out = " By Set Pos: ";
2112 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2112 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2113 out.append(QString::number(i) + " "); 2113 out.append(QString::number(i) + " ");
2114 } 2114 }
2115 } 2115 }
2116} 2116}
2117 2117
2118icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, 2118icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence,
2119 Scheduler::Method method) 2119 Scheduler::Method method)
2120{ 2120{
2121 icalcomponent *message = createCalendarComponent(); 2121 icalcomponent *message = createCalendarComponent();
2122 2122
2123 icalproperty_method icalmethod = ICAL_METHOD_NONE; 2123 icalproperty_method icalmethod = ICAL_METHOD_NONE;
2124 2124
2125 switch (method) { 2125 switch (method) {
2126 case Scheduler::Publish: 2126 case Scheduler::Publish:
2127 icalmethod = ICAL_METHOD_PUBLISH; 2127 icalmethod = ICAL_METHOD_PUBLISH;
2128 break; 2128 break;
2129 case Scheduler::Request: 2129 case Scheduler::Request:
2130 icalmethod = ICAL_METHOD_REQUEST; 2130 icalmethod = ICAL_METHOD_REQUEST;
2131 break; 2131 break;
2132 case Scheduler::Refresh: 2132 case Scheduler::Refresh:
2133 icalmethod = ICAL_METHOD_REFRESH; 2133 icalmethod = ICAL_METHOD_REFRESH;
2134 break; 2134 break;
2135 case Scheduler::Cancel: 2135 case Scheduler::Cancel:
2136 icalmethod = ICAL_METHOD_CANCEL; 2136 icalmethod = ICAL_METHOD_CANCEL;
2137 break; 2137 break;
2138 case Scheduler::Add: 2138 case Scheduler::Add:
2139 icalmethod = ICAL_METHOD_ADD; 2139 icalmethod = ICAL_METHOD_ADD;
2140 break; 2140 break;
2141 case Scheduler::Reply: 2141 case Scheduler::Reply:
2142 icalmethod = ICAL_METHOD_REPLY; 2142 icalmethod = ICAL_METHOD_REPLY;
2143 break; 2143 break;
2144 case Scheduler::Counter: 2144 case Scheduler::Counter:
2145 icalmethod = ICAL_METHOD_COUNTER; 2145 icalmethod = ICAL_METHOD_COUNTER;
2146 break; 2146 break;
2147 case Scheduler::Declinecounter: 2147 case Scheduler::Declinecounter:
2148 icalmethod = ICAL_METHOD_DECLINECOUNTER; 2148 icalmethod = ICAL_METHOD_DECLINECOUNTER;
2149 break; 2149 break;
2150 default: 2150 default:
2151 2151
2152 return message; 2152 return message;
2153 } 2153 }
2154 2154
2155 icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); 2155 icalcomponent_add_property(message,icalproperty_new_method(icalmethod));
2156 2156
2157 // TODO: check, if dynamic cast is required 2157 // TODO: check, if dynamic cast is required
2158 if(incidence->type() == "Todo") { 2158 if(incidence->typeID() == todoID ) {
2159 Todo *todo = static_cast<Todo *>(incidence); 2159 Todo *todo = static_cast<Todo *>(incidence);
2160 icalcomponent_add_component(message,writeTodo(todo)); 2160 icalcomponent_add_component(message,writeTodo(todo));
2161 } 2161 }
2162 if(incidence->type() == "Event") { 2162 if(incidence->typeID() == eventID ) {
2163 Event *event = static_cast<Event *>(incidence); 2163 Event *event = static_cast<Event *>(incidence);
2164 icalcomponent_add_component(message,writeEvent(event)); 2164 icalcomponent_add_component(message,writeEvent(event));
2165 } 2165 }
2166 if(incidence->type() == "FreeBusy") { 2166 if(incidence->typeID() == freebusyID) {
2167 FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); 2167 FreeBusy *freebusy = static_cast<FreeBusy *>(incidence);
2168 icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); 2168 icalcomponent_add_component(message,writeFreeBusy(freebusy, method));
2169 } 2169 }
2170 2170
2171 return message; 2171 return message;
2172} 2172}
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 762103f..f446197 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -143,193 +143,193 @@ void Incidence::setCancelled( bool b )
143 updated(); 143 updated();
144} 144}
145bool Incidence::hasStartDate() const 145bool Incidence::hasStartDate() const
146{ 146{
147 return mHasStartDate; 147 return mHasStartDate;
148} 148}
149 149
150void Incidence::setHasStartDate(bool f) 150void Incidence::setHasStartDate(bool f)
151{ 151{
152 if (mReadOnly) return; 152 if (mReadOnly) return;
153 mHasStartDate = f; 153 mHasStartDate = f;
154 updated(); 154 updated();
155} 155}
156 156
157// A string comparison that considers that null and empty are the same 157// A string comparison that considers that null and empty are the same
158static bool stringCompare( const QString& s1, const QString& s2 ) 158static bool stringCompare( const QString& s1, const QString& s2 )
159{ 159{
160 if ( s1.isEmpty() && s2.isEmpty() ) 160 if ( s1.isEmpty() && s2.isEmpty() )
161 return true; 161 return true;
162 return s1 == s2; 162 return s1 == s2;
163} 163}
164 164
165bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 165bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
166{ 166{
167 167
168 if( i1.alarms().count() != i2.alarms().count() ) { 168 if( i1.alarms().count() != i2.alarms().count() ) {
169 return false; // no need to check further 169 return false; // no need to check further
170 } 170 }
171 if ( i1.alarms().count() > 0 ) { 171 if ( i1.alarms().count() > 0 ) {
172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
173 { 173 {
174 qDebug("alarm not equal "); 174 qDebug("alarm not equal ");
175 return false; 175 return false;
176 } 176 }
177 } 177 }
178#if 0 178#if 0
179 QPtrListIterator<Alarm> a1( i1.alarms() ); 179 QPtrListIterator<Alarm> a1( i1.alarms() );
180 QPtrListIterator<Alarm> a2( i2.alarms() ); 180 QPtrListIterator<Alarm> a2( i2.alarms() );
181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
182 if( *a1.current() == *a2.current() ) { 182 if( *a1.current() == *a2.current() ) {
183 continue; 183 continue;
184 } 184 }
185 else { 185 else {
186 return false; 186 return false;
187 } 187 }
188 } 188 }
189#endif 189#endif
190 190
191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
192 if ( i1.hasRecurrenceID() ) { 192 if ( i1.hasRecurrenceID() ) {
193 if ( i1.recurrenceID() != i2.recurrenceID() ) 193 if ( i1.recurrenceID() != i2.recurrenceID() )
194 return false; 194 return false;
195 } 195 }
196 196
197 } else { 197 } else {
198 return false; 198 return false;
199 } 199 }
200 200
201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
202 return false; 202 return false;
203 if ( i1.hasStartDate() == i2.hasStartDate() ) { 203 if ( i1.hasStartDate() == i2.hasStartDate() ) {
204 if ( i1.hasStartDate() ) { 204 if ( i1.hasStartDate() ) {
205 if ( i1.dtStart() != i2.dtStart() ) 205 if ( i1.dtStart() != i2.dtStart() )
206 return false; 206 return false;
207 } 207 }
208 } else { 208 } else {
209 return false; 209 return false;
210 } 210 }
211 if (!( *i1.recurrence() == *i2.recurrence()) ) { 211 if (!( *i1.recurrence() == *i2.recurrence()) ) {
212 qDebug("recurrence is NOT equal "); 212 qDebug("recurrence is NOT equal ");
213 return false; 213 return false;
214 } 214 }
215 return 215 return
216 // i1.created() == i2.created() && 216 // i1.created() == i2.created() &&
217 stringCompare( i1.description(), i2.description() ) && 217 stringCompare( i1.description(), i2.description() ) &&
218 stringCompare( i1.summary(), i2.summary() ) && 218 stringCompare( i1.summary(), i2.summary() ) &&
219 i1.categories() == i2.categories() && 219 i1.categories() == i2.categories() &&
220 // no need to compare mRelatedTo 220 // no need to compare mRelatedTo
221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
222 // i1.relations() == i2.relations() && 222 // i1.relations() == i2.relations() &&
223 i1.exDates() == i2.exDates() && 223 i1.exDates() == i2.exDates() &&
224 i1.attachments() == i2.attachments() && 224 i1.attachments() == i2.attachments() &&
225 i1.resources() == i2.resources() && 225 i1.resources() == i2.resources() &&
226 i1.secrecy() == i2.secrecy() && 226 i1.secrecy() == i2.secrecy() &&
227 i1.priority() == i2.priority() && 227 i1.priority() == i2.priority() &&
228 i1.cancelled() == i2.cancelled() && 228 i1.cancelled() == i2.cancelled() &&
229 stringCompare( i1.location(), i2.location() ); 229 stringCompare( i1.location(), i2.location() );
230} 230}
231 231
232Incidence* Incidence::recreateCloneException( QDate d ) 232Incidence* Incidence::recreateCloneException( QDate d )
233{ 233{
234 Incidence* newInc = clone(); 234 Incidence* newInc = clone();
235 newInc->recreate(); 235 newInc->recreate();
236 if ( doesRecur() ) { 236 if ( doesRecur() ) {
237 addExDate( d ); 237 addExDate( d );
238 newInc->recurrence()->unsetRecurs(); 238 newInc->recurrence()->unsetRecurs();
239 if ( type() == "Event") { 239 if ( typeID() == eventID ) {
240 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 240 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
241 QTime tim = dtStart().time(); 241 QTime tim = dtStart().time();
242 newInc->setDtStart( QDateTime(d, tim) ); 242 newInc->setDtStart( QDateTime(d, tim) );
243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
244 } else { 244 } else {
245 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 245 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
246 QTime tim = ((Todo*)this)->dtDue().time(); 246 QTime tim = ((Todo*)this)->dtDue().time();
247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
249 ((Todo*)this)->setRecurDates(); 249 ((Todo*)this)->setRecurDates();
250 } 250 }
251 newInc->setExDates( DateList () ); 251 newInc->setExDates( DateList () );
252 } 252 }
253 return newInc; 253 return newInc;
254} 254}
255 255
256void Incidence::recreate() 256void Incidence::recreate()
257{ 257{
258 setCreated(QDateTime::currentDateTime()); 258 setCreated(QDateTime::currentDateTime());
259 259
260 setUid(CalFormat::createUniqueId()); 260 setUid(CalFormat::createUniqueId());
261 261
262 setRevision(0); 262 setRevision(0);
263 setIDStr( ":" ); 263 setIDStr( ":" );
264 setLastModified(QDateTime::currentDateTime()); 264 setLastModified(QDateTime::currentDateTime());
265} 265}
266void Incidence::cloneRelations( Incidence * newInc ) 266void Incidence::cloneRelations( Incidence * newInc )
267{ 267{
268 // newInc is already a clone of this incidence 268 // newInc is already a clone of this incidence
269 Incidence * inc; 269 Incidence * inc;
270 Incidence * cloneInc; 270 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations(); 271 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) { 272 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone(); 273 cloneInc = inc->clone();
274 cloneInc->recreate(); 274 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc ); 275 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc ); 276 inc->cloneRelations( cloneInc );
277 } 277 }
278} 278}
279void Incidence::setReadOnly( bool readOnly ) 279void Incidence::setReadOnly( bool readOnly )
280{ 280{
281 IncidenceBase::setReadOnly( readOnly ); 281 IncidenceBase::setReadOnly( readOnly );
282 recurrence()->setRecurReadOnly( readOnly); 282 recurrence()->setRecurReadOnly( readOnly);
283} 283}
284 284
285void Incidence::setCreated(QDateTime created) 285void Incidence::setCreated(QDateTime created)
286{ 286{
287 if (mReadOnly) return; 287 if (mReadOnly) return;
288 mCreated = getEvenTime(created); 288 mCreated = getEvenTime(created);
289} 289}
290 290
291QDateTime Incidence::created() const 291QDateTime Incidence::created() const
292{ 292{
293 return mCreated; 293 return mCreated;
294} 294}
295 295
296void Incidence::setRevision(int rev) 296void Incidence::setRevision(int rev)
297{ 297{
298 if (mReadOnly) return; 298 if (mReadOnly) return;
299 mRevision = rev; 299 mRevision = rev;
300 300
301 updated(); 301 updated();
302} 302}
303 303
304int Incidence::revision() const 304int Incidence::revision() const
305{ 305{
306 return mRevision; 306 return mRevision;
307} 307}
308 308
309void Incidence::setDtStart(const QDateTime &dtStart) 309void Incidence::setDtStart(const QDateTime &dtStart)
310{ 310{
311 311
312 QDateTime dt = getEvenTime(dtStart); 312 QDateTime dt = getEvenTime(dtStart);
313 recurrence()->setRecurStart( dt); 313 recurrence()->setRecurStart( dt);
314 IncidenceBase::setDtStart( dt ); 314 IncidenceBase::setDtStart( dt );
315} 315}
316 316
317void Incidence::setDescription(const QString &description) 317void Incidence::setDescription(const QString &description)
318{ 318{
319 if (mReadOnly) return; 319 if (mReadOnly) return;
320 mDescription = description; 320 mDescription = description;
321 updated(); 321 updated();
322} 322}
323 323
324QString Incidence::description() const 324QString Incidence::description() const
325{ 325{
326 return mDescription; 326 return mDescription;
327} 327}
328 328
329 329
330void Incidence::setSummary(const QString &summary) 330void Incidence::setSummary(const QString &summary)
331{ 331{
332 if (mReadOnly) return; 332 if (mReadOnly) return;
333 mSummary = summary; 333 mSummary = summary;
334 updated(); 334 updated();
335} 335}
@@ -631,114 +631,114 @@ Alarm* Incidence::newAlarm()
631{ 631{
632 Alarm* alarm = new Alarm(this); 632 Alarm* alarm = new Alarm(this);
633 mAlarms.append(alarm); 633 mAlarms.append(alarm);
634// updated(); 634// updated();
635 return alarm; 635 return alarm;
636} 636}
637 637
638void Incidence::addAlarm(Alarm *alarm) 638void Incidence::addAlarm(Alarm *alarm)
639{ 639{
640 mAlarms.append(alarm); 640 mAlarms.append(alarm);
641 updated(); 641 updated();
642} 642}
643 643
644void Incidence::removeAlarm(Alarm *alarm) 644void Incidence::removeAlarm(Alarm *alarm)
645{ 645{
646 mAlarms.removeRef(alarm); 646 mAlarms.removeRef(alarm);
647 updated(); 647 updated();
648} 648}
649 649
650void Incidence::clearAlarms() 650void Incidence::clearAlarms()
651{ 651{
652 mAlarms.clear(); 652 mAlarms.clear();
653 updated(); 653 updated();
654} 654}
655 655
656bool Incidence::isAlarmEnabled() const 656bool Incidence::isAlarmEnabled() const
657{ 657{
658 Alarm* alarm; 658 Alarm* alarm;
659 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 659 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
660 if (alarm->enabled()) 660 if (alarm->enabled())
661 return true; 661 return true;
662 } 662 }
663 return false; 663 return false;
664} 664}
665 665
666Recurrence *Incidence::recurrence() const 666Recurrence *Incidence::recurrence() const
667{ 667{
668 return mRecurrence; 668 return mRecurrence;
669} 669}
670void Incidence::setRecurrence( Recurrence * r) 670void Incidence::setRecurrence( Recurrence * r)
671{ 671{
672 delete mRecurrence; 672 delete mRecurrence;
673 mRecurrence = r; 673 mRecurrence = r;
674} 674}
675 675
676void Incidence::setLocation(const QString &location) 676void Incidence::setLocation(const QString &location)
677{ 677{
678 if (mReadOnly) return; 678 if (mReadOnly) return;
679 mLocation = location; 679 mLocation = location;
680 updated(); 680 updated();
681} 681}
682 682
683QString Incidence::location() const 683QString Incidence::location() const
684{ 684{
685 return mLocation; 685 return mLocation;
686} 686}
687 687
688ushort Incidence::doesRecur() const 688ushort Incidence::doesRecur() const
689{ 689{
690 if ( mRecurrence ) return mRecurrence->doesRecur(); 690 if ( mRecurrence ) return mRecurrence->doesRecur();
691 else return Recurrence::rNone; 691 else return Recurrence::rNone;
692} 692}
693 693
694QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 694QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
695{ 695{
696 QDateTime incidenceStart = dt; 696 QDateTime incidenceStart = dt;
697 *ok = false; 697 *ok = false;
698 if ( doesRecur() ) { 698 if ( doesRecur() ) {
699 bool last; 699 bool last;
700 recurrence()->getPreviousDateTime( incidenceStart , &last ); 700 recurrence()->getPreviousDateTime( incidenceStart , &last );
701 int count = 0; 701 int count = 0;
702 if ( !last ) { 702 if ( !last ) {
703 while ( !last ) { 703 while ( !last ) {
704 ++count; 704 ++count;
705 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 705 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
706 if ( recursOn( incidenceStart.date() ) ) { 706 if ( recursOn( incidenceStart.date() ) ) {
707 last = true; // exit while llop 707 last = true; // exit while llop
708 } else { 708 } else {
709 if ( last ) { // no alarm on last recurrence 709 if ( last ) { // no alarm on last recurrence
710 return QDateTime (); 710 return QDateTime ();
711 } 711 }
712 int year = incidenceStart.date().year(); 712 int year = incidenceStart.date().year();
713 // workaround for bug in recurrence 713 // workaround for bug in recurrence
714 if ( count == 100 || year < 1000 || year > 5000 ) { 714 if ( count == 100 || year < 1000 || year > 5000 ) {
715 return QDateTime (); 715 return QDateTime ();
716 } 716 }
717 incidenceStart = incidenceStart.addSecs( 1 ); 717 incidenceStart = incidenceStart.addSecs( 1 );
718 } 718 }
719 } 719 }
720 } else { 720 } else {
721 return QDateTime (); 721 return QDateTime ();
722 } 722 }
723 } else { 723 } else {
724 if ( hasStartDate () ) { 724 if ( hasStartDate () ) {
725 incidenceStart = dtStart(); 725 incidenceStart = dtStart();
726 } 726 }
727 if ( type() =="Todo" ) { 727 if ( typeID() == todoID ) {
728 if ( ((Todo*)this)->hasDueDate() ) 728 if ( ((Todo*)this)->hasDueDate() )
729 incidenceStart = ((Todo*)this)->dtDue(); 729 incidenceStart = ((Todo*)this)->dtDue();
730 } 730 }
731 } 731 }
732 if ( incidenceStart > dt ) 732 if ( incidenceStart > dt )
733 *ok = true; 733 *ok = true;
734 return incidenceStart; 734 return incidenceStart;
735} 735}
736QDateTime Incidence::dtStart() const 736QDateTime Incidence::dtStart() const
737{ 737{
738 if ( doesRecur() ) { 738 if ( doesRecur() ) {
739 if ( type() == "Todo" ) { 739 if ( typeID() == todoID ) {
740 ((Todo*)this)->checkSetCompletedFalse(); 740 ((Todo*)this)->checkSetCompletedFalse();
741 } 741 }
742 } 742 }
743 return mDtStart; 743 return mDtStart;
744} 744}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 8624786..05209e0 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,149 +1,151 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID };
37 38
38/** 39/**
39 This class provides the base class common to all calendar components. 40 This class provides the base class common to all calendar components.
40*/ 41*/
41class IncidenceBase : public CustomProperties 42class IncidenceBase : public CustomProperties
42{ 43{
43 public: 44 public:
44 class Observer { 45 class Observer {
45 public: 46 public:
46 virtual void incidenceUpdated( IncidenceBase * ) = 0; 47 virtual void incidenceUpdated( IncidenceBase * ) = 0;
47 }; 48 };
48 49
49 IncidenceBase(); 50 IncidenceBase();
50 IncidenceBase(const IncidenceBase &); 51 IncidenceBase(const IncidenceBase &);
51 virtual ~IncidenceBase(); 52 virtual ~IncidenceBase();
52 53
53 virtual QCString type() const = 0; 54 virtual QCString type() const = 0;
55 virtual IncTypeID typeID() const = 0;
54 56
55 /** Set the unique id for the event */ 57 /** Set the unique id for the event */
56 void setUid(const QString &); 58 void setUid(const QString &);
57 /** Return the unique id for the event */ 59 /** Return the unique id for the event */
58 QString uid() const; 60 QString uid() const;
59 61
60 /** Sets the time the incidence was last modified. */ 62 /** Sets the time the incidence was last modified. */
61 void setLastModified(const QDateTime &lm); 63 void setLastModified(const QDateTime &lm);
62 /** Return the time the incidence was last modified. */ 64 /** Return the time the incidence was last modified. */
63 QDateTime lastModified() const; 65 QDateTime lastModified() const;
64 66
65 /** sets the organizer for the event */ 67 /** sets the organizer for the event */
66 void setOrganizer(const QString &o); 68 void setOrganizer(const QString &o);
67 QString organizer() const; 69 QString organizer() const;
68 70
69 /** Set readonly status. */ 71 /** Set readonly status. */
70 virtual void setReadOnly( bool ); 72 virtual void setReadOnly( bool );
71 /** Return if the object is read-only. */ 73 /** Return if the object is read-only. */
72 bool isReadOnly() const { return mReadOnly; } 74 bool isReadOnly() const { return mReadOnly; }
73 75
74 /** for setting the event's starting date/time with a QDateTime. */ 76 /** for setting the event's starting date/time with a QDateTime. */
75 virtual void setDtStart(const QDateTime &dtStart); 77 virtual void setDtStart(const QDateTime &dtStart);
76 /** returns an event's starting date/time as a QDateTime. */ 78 /** returns an event's starting date/time as a QDateTime. */
77 virtual QDateTime dtStart() const; 79 virtual QDateTime dtStart() const;
78 /** returns an event's starting time as a string formatted according to the 80 /** returns an event's starting time as a string formatted according to the
79 users locale settings */ 81 users locale settings */
80 QString dtStartTimeStr() const; 82 QString dtStartTimeStr() const;
81 /** returns an event's starting date as a string formatted according to the 83 /** returns an event's starting date as a string formatted according to the
82 users locale settings */ 84 users locale settings */
83 QString dtStartDateStr(bool shortfmt=true) const; 85 QString dtStartDateStr(bool shortfmt=true) const;
84 /** returns an event's starting date and time as a string formatted according 86 /** returns an event's starting date and time as a string formatted according
85 to the users locale settings */ 87 to the users locale settings */
86 QString dtStartStr(bool shortfmt=true) const; 88 QString dtStartStr(bool shortfmt=true) const;
87 89
88 virtual void setDuration(int seconds); 90 virtual void setDuration(int seconds);
89 int duration() const; 91 int duration() const;
90 void setHasDuration(bool); 92 void setHasDuration(bool);
91 bool hasDuration() const; 93 bool hasDuration() const;
92 94
93 /** Return true or false depending on whether the incidence "floats," 95 /** Return true or false depending on whether the incidence "floats,"
94 * i.e. has a date but no time attached to it. */ 96 * i.e. has a date but no time attached to it. */
95 bool doesFloat() const; 97 bool doesFloat() const;
96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
97 void setFloats(bool f); 99 void setFloats(bool f);
98 100
99 /** 101 /**
100 Add Attendee to this incidence. IncidenceBase takes ownership of the 102 Add Attendee to this incidence. IncidenceBase takes ownership of the
101 Attendee object. 103 Attendee object.
102 */ 104 */
103 bool addAttendee(Attendee *a, bool doupdate=true ); 105 bool addAttendee(Attendee *a, bool doupdate=true );
104// void removeAttendee(Attendee *a); 106// void removeAttendee(Attendee *a);
105// void removeAttendee(const char *n); 107// void removeAttendee(const char *n);
106 /** Remove all Attendees. */ 108 /** Remove all Attendees. */
107 void clearAttendees(); 109 void clearAttendees();
108 /** Return list of attendees. */ 110 /** Return list of attendees. */
109 QPtrList<Attendee> attendees() const { return mAttendees; }; 111 QPtrList<Attendee> attendees() const { return mAttendees; };
110 /** Return number of attendees. */ 112 /** Return number of attendees. */
111 int attendeeCount() const { return mAttendees.count(); }; 113 int attendeeCount() const { return mAttendees.count(); };
112 /** Return the Attendee with this email */ 114 /** Return the Attendee with this email */
113 Attendee* attendeeByMail(const QString &); 115 Attendee* attendeeByMail(const QString &);
114 /** Return first Attendee with one of this emails */ 116 /** Return first Attendee with one of this emails */
115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
116 118
117 /** pilot syncronization states */ 119 /** pilot syncronization states */
118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
119 /** Set synchronisation satus. */ 121 /** Set synchronisation satus. */
120 void setSyncStatus(int stat); 122 void setSyncStatus(int stat);
121 /** Return synchronisation status. */ 123 /** Return synchronisation status. */
122 int syncStatus() const; 124 int syncStatus() const;
123 125
124 /** Set Pilot Id. */ 126 /** Set Pilot Id. */
125 void setPilotId(int id); 127 void setPilotId(int id);
126 /** Return Pilot Id. */ 128 /** Return Pilot Id. */
127 int pilotId() const; 129 int pilotId() const;
128 130
129 void setTempSyncStat(int id); 131 void setTempSyncStat(int id);
130 int tempSyncStat() const; 132 int tempSyncStat() const;
131 void setIDStr( const QString & ); 133 void setIDStr( const QString & );
132 QString IDStr() const; 134 QString IDStr() const;
133 void setID( const QString &, const QString & ); 135 void setID( const QString &, const QString & );
134 QString getID( const QString & ); 136 QString getID( const QString & );
135 void setCsum( const QString &, const QString & ); 137 void setCsum( const QString &, const QString & );
136 QString getCsum( const QString & ); 138 QString getCsum( const QString & );
137 void removeID(const QString &); 139 void removeID(const QString &);
138 140
139 void registerObserver( Observer * ); 141 void registerObserver( Observer * );
140 void unRegisterObserver( Observer * ); 142 void unRegisterObserver( Observer * );
141 void updated(); 143 void updated();
142 144
143 protected: 145 protected:
144 QDateTime mDtStart; 146 QDateTime mDtStart;
145 bool mReadOnly; 147 bool mReadOnly;
146 QDateTime getEvenTime( QDateTime ); 148 QDateTime getEvenTime( QDateTime );
147 149
148 private: 150 private:
149 // base components 151 // base components
diff --git a/libkcal/journal.h b/libkcal/journal.h
index 2c1d7ea..1cd0a22 100644
--- a/libkcal/journal.h
+++ b/libkcal/journal.h
@@ -1,50 +1,51 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef JOURNAL_H 20#ifndef JOURNAL_H
21#define JOURNAL_H 21#define JOURNAL_H
22// 22//
23// Journal component, representing a VJOURNAL object 23// Journal component, representing a VJOURNAL object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides a Journal in the sense of RFC2445. 31 This class provides a Journal in the sense of RFC2445.
32*/ 32*/
33class Journal : public Incidence 33class Journal : public Incidence
34{ 34{
35 public: 35 public:
36 Journal(); 36 Journal();
37 ~Journal(); 37 ~Journal();
38 38
39 QCString type() const { return "Journal"; } 39 QCString type() const { return "Journal"; }
40 IncTypeID typeID() const { return journalID; }
40 41
41 Incidence *clone(); 42 Incidence *clone();
42 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 43 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
43private: 44private:
44 bool accept(Visitor &v) { return v.visit(this); } 45 bool accept(Visitor &v) { return v.visit(this); }
45}; 46};
46 47
47 bool operator==( const Journal&, const Journal& ); 48 bool operator==( const Journal&, const Journal& );
48} 49}
49 50
50#endif 51#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 7d61b7f..d1ace4f 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,122 +1,122 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details; 20 mDetails = details;
21 mCreated = created ; 21 mCreated = created ;
22 mModified = modified; 22 mModified = modified;
23 mText = ""; 23 mText = "";
24 if ( inc->type() == "Event" ) 24 if ( inc->typeID() == eventID )
25 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
26 else if ( inc->type() == "Todo" ) 26 else if ( inc->typeID() == todoID )
27 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
28 return mText; 28 return mText;
29} 29}
30 30
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
32{ 32{
33 if (!mInstance) { 33 if (!mInstance) {
34 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
35 } 35 }
36 return mInstance; 36 return mInstance;
37} 37}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~KIncidenceFormatter()
39{ 39{
40 if (mInstance == this) 40 if (mInstance == this)
41 mInstance = insd.setObject(0); 41 mInstance = insd.setObject(0);
42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
43} 43}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",deTag(event->summary())); 54 addTag("h3",deTag(event->summary()));
55 } 55 }
56 else { 56 else {
57 if ( mColorMode == 1 ) { 57 if ( mColorMode == 1 ) {
58 mText +="<font color=\"#00A000\">"; 58 mText +="<font color=\"#00A000\">";
59 } 59 }
60 if ( mColorMode == 2 ) { 60 if ( mColorMode == 2 ) {
61 mText +="<font color=\"#C00000\">"; 61 mText +="<font color=\"#C00000\">";
62 } 62 }
63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
64 if ( mode == 1 ) { 64 if ( mode == 1 ) {
65 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 65 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
66 } else { 66 } else {
67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
68 } 68 }
69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
70 if ( mColorMode ) 70 if ( mColorMode )
71 mText += "</font>"; 71 mText += "</font>";
72 } 72 }
73 if (event->cancelled ()) { 73 if (event->cancelled ()) {
74 mText +="<font color=\"#B00000\">"; 74 mText +="<font color=\"#B00000\">";
75 addTag("i",i18n("This event has been cancelled!")); 75 addTag("i",i18n("This event has been cancelled!"));
76 mText.append("<br>"); 76 mText.append("<br>");
77 mText += "</font>"; 77 mText += "</font>";
78 } 78 }
79 if (event->doesFloat()) { 79 if (event->doesFloat()) {
80 if (event->isMultiDay()) { 80 if (event->isMultiDay()) {
81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
82 .arg(event->dtStartDateStr(shortDate)) 82 .arg(event->dtStartDateStr(shortDate))
83 .arg(event->dtEndDateStr(shortDate))); 83 .arg(event->dtEndDateStr(shortDate)));
84 } else { 84 } else {
85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
86 } 86 }
87 } else { 87 } else {
88 if (event->isMultiDay()) { 88 if (event->isMultiDay()) {
89 mText.append(i18n("<p><b>From:</b> %1</p> ") 89 mText.append(i18n("<p><b>From:</b> %1</p> ")
90 .arg(event->dtStartStr( shortDate))); 90 .arg(event->dtStartStr( shortDate)));
91 mText.append(i18n("<p><b>To:</b> %1</p>") 91 mText.append(i18n("<p><b>To:</b> %1</p>")
92 .arg(event->dtEndStr(shortDate))); 92 .arg(event->dtEndStr(shortDate)));
93 } else { 93 } else {
94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
95 .arg(event->dtStartTimeStr()) 95 .arg(event->dtStartTimeStr())
96 .arg(event->dtEndTimeStr())); 96 .arg(event->dtEndTimeStr()));
97 mText.append(i18n("<p><b>On:</b> %1</p> ") 97 mText.append(i18n("<p><b>On:</b> %1</p> ")
98 .arg(event->dtStartDateStr( shortDate ))); 98 .arg(event->dtStartDateStr( shortDate )));
99 } 99 }
100 } 100 }
101 if (!event->location().isEmpty()) { 101 if (!event->location().isEmpty()) {
102 addTag("b",i18n("Location: ")); 102 addTag("b",i18n("Location: "));
103 mText.append(deTag(event->location())+"<br>"); 103 mText.append(deTag(event->location())+"<br>");
104 } 104 }
105 105
106 if (event->recurrence()->doesRecur()) { 106 if (event->recurrence()->doesRecur()) {
107 107
108 QString recurText = event->recurrence()->recurrenceText(); 108 QString recurText = event->recurrence()->recurrenceText();
109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
110 110
111 bool ok; 111 bool ok;
112 QDate start = QDate::currentDate(); 112 QDate start = QDate::currentDate();
113 QDateTime next; 113 QDateTime next;
114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
115 if ( ok ) { 115 if ( ok ) {
116 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 116 addTag("p",i18n("<b>Next recurrence is on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
118 118
119 } else { 119 } else {
120 bool last; 120 bool last;
121 QDate nextd; 121 QDate nextd;
122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 38ba2c7..c97a61e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -37,193 +37,193 @@ Todo::Todo(): QObject(), Incidence()
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::setRunning( bool run ) 72void Todo::setRunning( bool run )
73{ 73{
74 if ( run == mRunning ) 74 if ( run == mRunning )
75 return; 75 return;
76 //qDebug("Todo::setRunning %d ", run); 76 //qDebug("Todo::setRunning %d ", run);
77 if ( !mRunSaveTimer ) { 77 if ( !mRunSaveTimer ) {
78 mRunSaveTimer = new QTimer ( this ); 78 mRunSaveTimer = new QTimer ( this );
79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
80 } 80 }
81 mRunning = run; 81 mRunning = run;
82 if ( mRunning ) { 82 if ( mRunning ) {
83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
84 mRunStart = QDateTime::currentDateTime(); 84 mRunStart = QDateTime::currentDateTime();
85 } else { 85 } else {
86 mRunSaveTimer->stop(); 86 mRunSaveTimer->stop();
87 saveRunningInfoToFile(); 87 saveRunningInfoToFile();
88 } 88 }
89} 89}
90 90
91void Todo::saveRunningInfoToFile( QString comment ) 91void Todo::saveRunningInfoToFile( QString comment )
92{ 92{
93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
95 qDebug("Running time < 30 seconds. Skipped. "); 95 qDebug("Running time < 30 seconds. Skipped. ");
96 return; 96 return;
97 } 97 }
98 QString dir = KGlobalSettings::timeTrackerDir(); 98 QString dir = KGlobalSettings::timeTrackerDir();
99 //qDebug("%s ", dir.latin1()); 99 //qDebug("%s ", dir.latin1());
100 QString file = "%1%2%3-%4%5%6-"; 100 QString file = "%1%2%3-%4%5%6-";
101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
102 file.replace ( QRegExp (" "), "0" ); 102 file.replace ( QRegExp (" "), "0" );
103 file += uid(); 103 file += uid();
104 //qDebug("File %s ",file.latin1() ); 104 //qDebug("File %s ",file.latin1() );
105 CalendarLocal cal; 105 CalendarLocal cal;
106 cal.setLocalTime(); 106 cal.setLocalTime();
107 Todo * to = (Todo*) clone(); 107 Todo * to = (Todo*) clone();
108 to->setFloats( false ); 108 to->setFloats( false );
109 to->setDtStart( mRunStart ); 109 to->setDtStart( mRunStart );
110 to->setHasStartDate( true ); 110 to->setHasStartDate( true );
111 to->setDtDue( QDateTime::currentDateTime() ); 111 to->setDtDue( QDateTime::currentDateTime() );
112 to->setHasDueDate( true ); 112 to->setHasDueDate( true );
113 to->setUid( file ); 113 to->setUid( file );
114 if ( !comment.isEmpty() ) { 114 if ( !comment.isEmpty() ) {
115 QString des = to->description(); 115 QString des = to->description();
116 if ( des.isEmpty () ) 116 if ( des.isEmpty () )
117 to->setDescription( "TT-Note: " + comment ); 117 to->setDescription( "TT-Note: " + comment );
118 else 118 else
119 to->setDescription( "TT-Note: " + comment +"\n" + des ); 119 to->setDescription( "TT-Note: " + comment +"\n" + des );
120 } 120 }
121 cal.addIncidence( to ); 121 cal.addIncidence( to );
122 ICalFormat format; 122 ICalFormat format;
123 file = dir +"/" +file +".ics"; 123 file = dir +"/" +file +".ics";
124 format.save( &cal, file ); 124 format.save( &cal, file );
125 saveParents(); 125 saveParents();
126 126
127} 127}
128void Todo::saveParents() 128void Todo::saveParents()
129{ 129{
130 if (!relatedTo() ) 130 if (!relatedTo() )
131 return; 131 return;
132 Incidence * inc = relatedTo(); 132 Incidence * inc = relatedTo();
133 if ( inc->type() != "Todo" ) 133 if ( inc->typeID() != todoID )
134 return; 134 return;
135 Todo* to = (Todo*)inc; 135 Todo* to = (Todo*)inc;
136 bool saveTodo = false; 136 bool saveTodo = false;
137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
138 QFileInfo fi ( file ); 138 QFileInfo fi ( file );
139 if ( fi.exists() ) { 139 if ( fi.exists() ) {
140 if ( fi.lastModified () < to->lastModified ()) 140 if ( fi.lastModified () < to->lastModified ())
141 saveTodo = true; 141 saveTodo = true;
142 } else { 142 } else {
143 saveTodo = true; 143 saveTodo = true;
144 } 144 }
145 if ( saveTodo ) { 145 if ( saveTodo ) {
146 CalendarLocal cal; 146 CalendarLocal cal;
147 cal.setLocalTime(); 147 cal.setLocalTime();
148 Todo * par = (Todo *) to->clone(); 148 Todo * par = (Todo *) to->clone();
149 cal.addIncidence( par ); 149 cal.addIncidence( par );
150 ICalFormat format; 150 ICalFormat format;
151 format.save( &cal, file ); 151 format.save( &cal, file );
152 } 152 }
153 to->saveParents(); 153 to->saveParents();
154} 154}
155 155
156int Todo::runTime() 156int Todo::runTime()
157{ 157{
158 if ( !mRunning ) 158 if ( !mRunning )
159 return 0; 159 return 0;
160 return mRunStart.secsTo( QDateTime::currentDateTime() ); 160 return mRunStart.secsTo( QDateTime::currentDateTime() );
161} 161}
162bool Todo::hasRunningSub() 162bool Todo::hasRunningSub()
163{ 163{
164 if ( mRunning ) 164 if ( mRunning )
165 return true; 165 return true;
166 Incidence *aTodo; 166 Incidence *aTodo;
167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
168 if ( ((Todo*)aTodo)->hasRunningSub() ) 168 if ( ((Todo*)aTodo)->hasRunningSub() )
169 return true; 169 return true;
170 } 170 }
171 return false; 171 return false;
172} 172}
173Incidence *Todo::clone() 173Incidence *Todo::clone()
174{ 174{
175 return new Todo(*this); 175 return new Todo(*this);
176} 176}
177 177
178bool Todo::contains ( Todo* from ) 178bool Todo::contains ( Todo* from )
179{ 179{
180 180
181 if ( !from->summary().isEmpty() ) 181 if ( !from->summary().isEmpty() )
182 if ( !summary().startsWith( from->summary() )) 182 if ( !summary().startsWith( from->summary() ))
183 return false; 183 return false;
184 if ( from->hasStartDate() ) { 184 if ( from->hasStartDate() ) {
185 if ( !hasStartDate() ) 185 if ( !hasStartDate() )
186 return false; 186 return false;
187 if ( from->dtStart() != dtStart()) 187 if ( from->dtStart() != dtStart())
188 return false; 188 return false;
189 } 189 }
190 if ( from->hasDueDate() ){ 190 if ( from->hasDueDate() ){
191 if ( !hasDueDate() ) 191 if ( !hasDueDate() )
192 return false; 192 return false;
193 if ( from->dtDue() != dtDue()) 193 if ( from->dtDue() != dtDue())
194 return false; 194 return false;
195 } 195 }
196 if ( !from->location().isEmpty() ) 196 if ( !from->location().isEmpty() )
197 if ( !location().startsWith( from->location() ) ) 197 if ( !location().startsWith( from->location() ) )
198 return false; 198 return false;
199 if ( !from->description().isEmpty() ) 199 if ( !from->description().isEmpty() )
200 if ( !description().startsWith( from->description() )) 200 if ( !description().startsWith( from->description() ))
201 return false; 201 return false;
202 if ( from->alarms().count() ) { 202 if ( from->alarms().count() ) {
203 Alarm *a = from->alarms().first(); 203 Alarm *a = from->alarms().first();
204 if ( a->enabled() ){ 204 if ( a->enabled() ){
205 if ( !alarms().count() ) 205 if ( !alarms().count() )
206 return false; 206 return false;
207 Alarm *b = alarms().first(); 207 Alarm *b = alarms().first();
208 if( ! b->enabled() ) 208 if( ! b->enabled() )
209 return false; 209 return false;
210 if ( ! (a->offset() == b->offset() )) 210 if ( ! (a->offset() == b->offset() ))
211 return false; 211 return false;
212 } 212 }
213 } 213 }
214 214
215 QStringList cat = categories(); 215 QStringList cat = categories();
216 QStringList catFrom = from->categories(); 216 QStringList catFrom = from->categories();
217 QString nCat; 217 QString nCat;
218 unsigned int iii; 218 unsigned int iii;
219 for ( iii = 0; iii < catFrom.count();++iii ) { 219 for ( iii = 0; iii < catFrom.count();++iii ) {
220 nCat = catFrom[iii]; 220 nCat = catFrom[iii];
221 if ( !nCat.isEmpty() ) 221 if ( !nCat.isEmpty() )
222 if ( !cat.contains( nCat )) { 222 if ( !cat.contains( nCat )) {
223 return false; 223 return false;
224 } 224 }
225 } 225 }
226 if ( from->isCompleted() ) { 226 if ( from->isCompleted() ) {
227 if ( !isCompleted() ) 227 if ( !isCompleted() )
228 return false; 228 return false;
229 } 229 }
@@ -471,110 +471,111 @@ void Todo::setCompleted(const QDateTime &completed)
471 mHasCompletedDate = true; 471 mHasCompletedDate = true;
472 mPercentComplete = 100; 472 mPercentComplete = 100;
473 mCompleted = getEvenTime(completed); 473 mCompleted = getEvenTime(completed);
474 updated(); 474 updated();
475} 475}
476 476
477bool Todo::hasCompletedDate() const 477bool Todo::hasCompletedDate() const
478{ 478{
479 return mHasCompletedDate; 479 return mHasCompletedDate;
480} 480}
481 481
482int Todo::percentComplete() const 482int Todo::percentComplete() const
483{ 483{
484 return mPercentComplete; 484 return mPercentComplete;
485} 485}
486bool Todo::setRecurDates() 486bool Todo::setRecurDates()
487{ 487{
488 if ( !mHasRecurrenceID ) 488 if ( !mHasRecurrenceID )
489 return true; 489 return true;
490 int secs = mDtStart.secsTo( dtDue() ); 490 int secs = mDtStart.secsTo( dtDue() );
491 bool ok; 491 bool ok;
492 qDebug("T:setRecurDates() "); 492 qDebug("T:setRecurDates() ");
493 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 493 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
494 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 494 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
495 if ( ok ) { 495 if ( ok ) {
496 mRecurrenceID = next; 496 mRecurrenceID = next;
497 mDtStart = next; 497 mDtStart = next;
498 setDtDue( next.addSecs( secs ) ); 498 setDtDue( next.addSecs( secs ) );
499 if ( QDateTime::currentDateTime() > next) 499 if ( QDateTime::currentDateTime() > next)
500 return false; 500 return false;
501 } else { 501 } else {
502 setHasRecurrenceID( false ); 502 setHasRecurrenceID( false );
503 recurrence()->unsetRecurs(); 503 recurrence()->unsetRecurs();
504 } 504 }
505 return true; 505 return true;
506} 506}
507void Todo::setPercentComplete(int v) 507void Todo::setPercentComplete(int v)
508{ 508{
509 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 509 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
510 if ( !setRecurDates() ) 510 if ( !setRecurDates() )
511 v = 0; 511 v = 0;
512 } 512 }
513 mPercentComplete = v; 513 mPercentComplete = v;
514 if ( v != 100 ) 514 if ( v != 100 )
515 mHasCompletedDate = false; 515 mHasCompletedDate = false;
516 updated(); 516 updated();
517} 517}
518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
519{ 519{
520 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 520 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
521 *ok = false; 521 *ok = false;
522 return QDateTime (); 522 return QDateTime ();
523 } 523 }
524 QDateTime incidenceStart; 524 QDateTime incidenceStart;
525 incidenceStart = dtDue(); 525 incidenceStart = dtDue();
526 bool enabled = false; 526 bool enabled = false;
527 Alarm* alarm; 527 Alarm* alarm;
528 int off = 0; 528 int off = 0;
529 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 529 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
530 // if ( QDateTime::currentDateTime() > incidenceStart ){ 530 // if ( QDateTime::currentDateTime() > incidenceStart ){
531// *ok = false; 531// *ok = false;
532// return incidenceStart; 532// return incidenceStart;
533// } 533// }
534 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 534 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
535 if (alarm->enabled()) { 535 if (alarm->enabled()) {
536 if ( alarm->hasTime () ) { 536 if ( alarm->hasTime () ) {
537 if ( alarm->time() < alarmStart ) { 537 if ( alarm->time() < alarmStart ) {
538 alarmStart = alarm->time(); 538 alarmStart = alarm->time();
539 enabled = true; 539 enabled = true;
540 off = alarmStart.secsTo( incidenceStart ); 540 off = alarmStart.secsTo( incidenceStart );
541 } 541 }
542 542
543 } else { 543 } else {
544 int secs = alarm->startOffset().asSeconds(); 544 int secs = alarm->startOffset().asSeconds();
545 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 545 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
546 alarmStart = incidenceStart.addSecs( secs ); 546 alarmStart = incidenceStart.addSecs( secs );
547 enabled = true; 547 enabled = true;
548 off = -secs; 548 off = -secs;
549 } 549 }
550 } 550 }
551 } 551 }
552 } 552 }
553 if ( enabled ) { 553 if ( enabled ) {
554 if ( alarmStart > start_dt ) { 554 if ( alarmStart > start_dt ) {
555 *ok = true; 555 *ok = true;
556 * offset = off; 556 * offset = off;
557 return alarmStart; 557 return alarmStart;
558 } 558 }
559 } 559 }
560 *ok = false; 560 *ok = false;
561 return QDateTime (); 561 return QDateTime ();
562 562
563} 563}
564 564
565void Todo::checkSetCompletedFalse() 565void Todo::checkSetCompletedFalse()
566{ 566{
567 if ( !hasRecurrenceID() ) { 567 if ( !mHasRecurrenceID ) {
568 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 568 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
569 return;
569 } 570 }
570 // qDebug("Todo::checkSetCompletedFalse()"); 571 // qDebug("Todo::checkSetCompletedFalse()");
571 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 572 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
572 if ( mPercentComplete == 100 ) { 573 if ( mPercentComplete == 100 ) {
573 QDateTime dt = QDateTime::currentDateTime(); 574 QDateTime dt = QDateTime::currentDateTime();
574 if ( dt > mDtStart && dt > mRecurrenceID ) { 575 if ( dt > mDtStart && dt > mRecurrenceID ) {
575 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 576 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
576 setCompleted( false ); 577 setCompleted( false );
577 qDebug("Todo::checkSetCompletedFalse "); 578 qDebug("Todo::checkSetCompletedFalse ");
578 } 579 }
579 } 580 }
580} 581}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index ab8fdf1..501c2ba 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,139 +1,140 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; }
44 45
45 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
46 Incidence *clone(); 47 Incidence *clone();
47 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
48 49
49 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
50 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
51 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
52 QDateTime dtDue() const; 53 QDateTime dtDue() const;
53 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
54 users locale settings */ 55 users locale settings */
55 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
56 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
57 users locale settings */ 58 users locale settings */
58 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
59 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
60 to the users locale settings */ 61 to the users locale settings */
61 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
62 63
63 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
64 bool hasDueDate() const; 65 bool hasDueDate() const;
65 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
66 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
67 68
68 /* 69 /*
69 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
70 - overdue, or 71 - overdue, or
71 - due today. 72 - due today.
72 It returns 0 for nothing found, 73 It returns 0 for nothing found,
73 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
74 2 for found a overdue todo 75 2 for found a overdue todo
75 */ 76 */
76 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
77 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
78 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
79 80
80 81
81 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
82 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
83 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
84// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
85 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
86 * above for possible values. */ 87 * above for possible values. */
87// void setStatus(int); 88// void setStatus(int);
88 /** return the event's status. */ 89 /** return the event's status. */
89// int status() const; 90// int status() const;
90 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
91// QString statusStr() const; 92// QString statusStr() const;
92 93
93 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
94 bool isCompleted() const; 95 bool isCompleted() const;
95 /** set completed state of this todo */ 96 /** set completed state of this todo */
96 void setCompleted(bool); 97 void setCompleted(bool);
97 98
98 /** 99 /**
99 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
100 between 0 and 100. 101 between 0 and 100.
101 */ 102 */
102 int percentComplete() const; 103 int percentComplete() const;
103 /** 104 /**
104 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
105 range from 0 to 100. 106 range from 0 to 100.
106 */ 107 */
107 void setPercentComplete(int); 108 void setPercentComplete(int);
108 109
109 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
110 QDateTime completed() const; 111 QDateTime completed() const;
111 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
112 /** set date and time of completion */ 113 /** set date and time of completion */
113 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
114 115
115 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
116 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
117 bool contains ( Todo*); 118 bool contains ( Todo*);
118 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
119 bool setRecurDates(); 120 bool setRecurDates();
120 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
121 bool hasRunningSub(); 122 bool hasRunningSub();
122 void setRunning( bool ); 123 void setRunning( bool );
123 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
124 int runTime(); 125 int runTime();
125 QDateTime runStart () const { return mRunStart;} 126 QDateTime runStart () const { return mRunStart;}
126 public slots: 127 public slots:
127 void saveRunningInfoToFile( QString st = QString::null ); 128 void saveRunningInfoToFile( QString st = QString::null );
128 void saveParents(); 129 void saveParents();
129 private: 130 private:
130 bool mRunning; 131 bool mRunning;
131 QTimer * mRunSaveTimer; 132 QTimer * mRunSaveTimer;
132 QDateTime mRunStart; 133 QDateTime mRunStart;
133 bool accept(Visitor &v) { return v.visit(this); } 134 bool accept(Visitor &v) { return v.visit(this); }
134 135
135 QDateTime mDtDue; // due date of todo 136 QDateTime mDtDue; // due date of todo
136 137
137 bool mHasDueDate; // if todo has associated due date 138 bool mHasDueDate; // if todo has associated due date
138 139
139// int mStatus; // confirmed/delegated/tentative/etc 140// int mStatus; // confirmed/delegated/tentative/etc