summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-13 13:57:22 (UTC)
committer zautrix <zautrix>2005-06-13 13:57:22 (UTC)
commit56de219c5ce910a470a01a0e5003d1a113837ef4 (patch) (unidiff)
tree3393cb306cec8dcdc05d6ed0fae3ae7d374f2794
parent4f3ff02932b39bf16b9692c3cb69c101a28b4616 (diff)
downloadkdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.zip
kdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.tar.gz
kdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt2
-rw-r--r--korganizer/calendarview.cpp8
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/koagendaitem.cpp6
-rw-r--r--korganizer/kofilterview.cpp4
-rw-r--r--korganizer/kofilterview.h1
-rw-r--r--korganizer/komonthview.cpp4
-rw-r--r--korganizer/kotodoview.cpp52
-rw-r--r--korganizer/kotodoviewitem.cpp2
-rw-r--r--korganizer/kowhatsnextview.cpp4
-rw-r--r--libkcal/alarm.cpp2
-rw-r--r--libkcal/calendar.cpp54
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp56
-rw-r--r--libkcal/calendarlocal.h1
15 files changed, 137 insertions, 61 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index acf17b2..8651a49 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1191,200 +1191,200 @@
1191{ "This month","Dieser Monat" }, 1191{ "This month","Dieser Monat" },
1192{ "Journal view","Journal" }, 1192{ "Journal view","Journal" },
1193{ "Display all opened","Zeige alle geöffnet" }, 1193{ "Display all opened","Zeige alle geöffnet" },
1194{ "Display all closed","Zeige alle geschlossen" }, 1194{ "Display all closed","Zeige alle geschlossen" },
1195{ "Display all flat","Zeige alle flach" }, 1195{ "Display all flat","Zeige alle flach" },
1196{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" }, 1196{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" },
1197{ "Default todo done color:","Standard Todo erledigt Farbe" }, 1197{ "Default todo done color:","Standard Todo erledigt Farbe" },
1198{ "Select week %1-%2","Wähle Woche %1-%2" }, 1198{ "Select week %1-%2","Wähle Woche %1-%2" },
1199{ "Select Week","Wähle Woche" }, 1199{ "Select Week","Wähle Woche" },
1200{ "Set alarm for selected...","Setze Alarm für Selekt..." }, 1200{ "Set alarm for selected...","Setze Alarm für Selekt..." },
1201{ "Set Alarm!","Setze Alarm!" }, 1201{ "Set Alarm!","Setze Alarm!" },
1202{ "Changed alarm for %1 items","Alarm für %1 Items geändert" }, 1202{ "Changed alarm for %1 items","Alarm für %1 Items geändert" },
1203{ " and "," und " }, 1203{ " and "," und " },
1204{ "<IMG src="%1"> only )","nur <IMG src="%1"> )" }, 1204{ "<IMG src="%1"> only )","nur <IMG src="%1"> )" },
1205{ "Mail to selected","Mail an Ausgewählte" }, 1205{ "Mail to selected","Mail an Ausgewählte" },
1206{ "Mail to all","Mail an Alle" }, 1206{ "Mail to all","Mail an Alle" },
1207{ "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" }, 1207{ "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" },
1208{ "Set reminder ON with offset to:","Alarm AN mit Offset auf:" }, 1208{ "Set reminder ON with offset to:","Alarm AN mit Offset auf:" },
1209{ " on"," am" }, 1209{ " on"," am" },
1210{ " completed on "," erledigt am " }, 1210{ " completed on "," erledigt am " },
1211{ "Save as Event template","Speichere als Vorlage" }, 1211{ "Save as Event template","Speichere als Vorlage" },
1212{ "Load Event template","Lade Termin Vorlage" }, 1212{ "Load Event template","Lade Termin Vorlage" },
1213{ "Save as Journal template","Speichere als Journal Vorlage" }, 1213{ "Save as Journal template","Speichere als Journal Vorlage" },
1214{ "Insert Journal template","Füge Journal Vorlage ein" }, 1214{ "Insert Journal template","Füge Journal Vorlage ein" },
1215{ "Sub todos:<br>","Unter Todos:<br>" }, 1215{ "Sub todos:<br>","Unter Todos:<br>" },
1216{ "Parent todo:<br>","Über Todo:<br>" }, 1216{ "Parent todo:<br>","Über Todo:<br>" },
1217{ "Set current as color category","Setze Gewählte als Farbkategorie" }, 1217{ "Set current as color category","Setze Gewählte als Farbkategorie" },
1218{ " completed"," erledigt" }, 1218{ " completed"," erledigt" },
1219{ "(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!","(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi basiert auf KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) und das KDE Team.\nKOrganizer/Pi ist lizensiert unter der GPL.\nKO/Pi kann kompiliert werden für\nLinux, Zaurus-PDA und Windows\nwww.pi-sync.info --- www.korganizer.org\nBesonderen Dank an Michael und Ben\nfür intensives Testen!" }, 1219{ "(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!","(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi basiert auf KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) und das KDE Team.\nKOrganizer/Pi ist lizensiert unter der GPL.\nKO/Pi kann kompiliert werden für\nLinux, Zaurus-PDA und Windows\nwww.pi-sync.info --- www.korganizer.org\nBesonderen Dank an Michael und Ben\nfür intensives Testen!" },
1220{ "Syncing aborted. Nothing synced.","Syncing abgebrochen.Nichts wurde gesynct." }, 1220{ "Syncing aborted. Nothing synced.","Syncing abgebrochen.Nichts wurde gesynct." },
1221{ "Connected! Sending request for remote file ...","Verbunden! Sende Daten Anfrage..." }, 1221{ "Connected! Sending request for remote file ...","Verbunden! Sende Daten Anfrage..." },
1222{ "Trying to connect to remote...","Versuche mit Gegenstelle zu verbinden..." }, 1222{ "Trying to connect to remote...","Versuche mit Gegenstelle zu verbinden..." },
1223{ "Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?","Verbindungsversuch wegen\nZeitüberschreitung gescheitert!\nWurde vergessen Pi-Sync auf\nder Gegenstelle anzuschalten?" }, 1223{ "Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?","Verbindungsversuch wegen\nZeitüberschreitung gescheitert!\nWurde vergessen Pi-Sync auf\nder Gegenstelle anzuschalten?" },
1224{ "ERROR: Receiving remote file failed.","FEHLER: Empfang der entfernten Daten fehlgeschlagen." }, 1224{ "ERROR: Receiving remote file failed.","FEHLER: Empfang der entfernten Daten fehlgeschlagen." },
1225{ "Error","Fehler" }, 1225{ "Error","Fehler" },
1226{ ""You entered an invalid date!\n Date changed to current date.","Ungültiges Datum eingegeben.\nSetze heutiges Datum." }, 1226{ ""You entered an invalid date!\n Date changed to current date.","Ungültiges Datum eingegeben.\nSetze heutiges Datum." },
1227{ "You entered an invalid date!\n Will use current date instead.","Ungültiges Datum eingegeben.\nSetze stattdessen heutiges Datum." }, 1227{ "You entered an invalid date!\n Will use current date instead.","Ungültiges Datum eingegeben.\nSetze stattdessen heutiges Datum." },
1228{ "Warning","Warnung" }, 1228{ "Warning","Warnung" },
1229{ "Select week number","Wähle Wochen Nummer" }, 1229{ "Select week number","Wähle Wochen Nummer" },
1230{ "Februar","Februar" }, 1230{ "Februar","Februar" },
1231{ "Click on the week number to\nshow week zoomed","Klicke auf die Wochennummer\num die Woche groß zu zeigen" }, 1231{ "Click on the week number to\nshow week zoomed","Klicke auf die Wochennummer\num die Woche groß zu zeigen" },
1232{ "W","W" }, 1232{ "W","W" },
1233{ "Click on this to\nselect week number","Klicke hierauf um\ndie Woche auszuwählen" }, 1233{ "Click on this to\nselect week number","Klicke hierauf um\ndie Woche auszuwählen" },
1234{ "T: %1","T: %1" }, 1234{ "T: %1","T: %1" },
1235{ "Start: ","Start: " }, 1235{ "Start: ","Start: " },
1236{ "Pi-Sync options for device: ","Pi-Sync Einstellungen für Gerät: " }, 1236{ "Pi-Sync options for device: ","Pi-Sync Einstellungen für Gerät: " },
1237{ "Password for remote access:","Passwort für fernen Zugriff:" }, 1237{ "Password for remote access:","Passwort für fernen Zugriff:" },
1238{ "Remote IP address:","Ferne IP Adresse:" }, 1238{ "Remote IP address:","Ferne IP Adresse:" },
1239{ "Remote port number:","Ferne Port Nummer:" }, 1239{ "Remote port number:","Ferne Port Nummer:" },
1240{ "Remote file saved to temp file.","Ferne Daten in temp Datei gespeichert." }, 1240{ "Remote file saved to temp file.","Ferne Daten in temp Datei gespeichert." },
1241{ "Remote from: ","Fern von: " }, 1241{ "Remote from: ","Fern von: " },
1242{ "Local from: ","Lokal von: " }, 1242{ "Local from: ","Lokal von: " },
1243{ "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","Synchronisationsübersicht:\n\n %d lokal hinzugefügt\n %d fern hinzugefügt\n %d lokal geändert\n %d fern geändert\n %d lokal gelöscht\n %d fern gelöscht\n %d eingehende ausgefiltert\n %d ausgehende ausgefiltert\n" }, 1243{ "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","Synchronisationsübersicht:\n\n %d lokal hinzugefügt\n %d fern hinzugefügt\n %d lokal geändert\n %d fern geändert\n %d lokal gelöscht\n %d fern gelöscht\n %d eingehende ausgefiltert\n %d ausgehende ausgefiltert\n" },
1244{ "Local calendar changed!\n","Lokaler Kalender geändert!\n" }, 1244{ "Local calendar changed!\n","Lokaler Kalender geändert!\n" },
1245{ "Write back","Schreibe zurück" }, 1245{ "Write back","Schreibe zurück" },
1246{ "KO/Pi Synchronization","KO/Pi Synchronisation" }, 1246{ "KO/Pi Synchronization","KO/Pi Synchronisation" },
1247{ "Pi-Sync succesful!","Pi-Sync erfolgreich!" }, 1247{ "Pi-Sync succesful!","Pi-Sync erfolgreich!" },
1248{ "Received sync request","Sync Anfrage erhalten" }, 1248{ "Received sync request","Sync Anfrage erhalten" },
1249{ "Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog.","Ferne Synchronisation ...\n\nBenutze diese Anwendung nicht!\n\nWenn das Syncen fehlschlägt kann\ndieser Dialog geschlossen werden." }, 1249{ "Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog.","Ferne Synchronisation ...\n\nBenutze diese Anwendung nicht!\n\nWenn das Syncen fehlschlägt kann\ndieser Dialog geschlossen werden." },
1250{ "Saving Data to temp file ...","Speichere Daten in temp Datei..." }, 1250{ "Saving Data to temp file ...","Speichere Daten in temp Datei..." },
1251{ "Data saved to temp file!","Daten in temp Datei gespeichert!" }, 1251{ "Data saved to temp file!","Daten in temp Datei gespeichert!" },
1252{ "Sending file...","Sende Datei..." }, 1252{ "Sending file...","Sende Datei..." },
1253{ "Waiting for synced file...","Warte auf gesyncte Daten..." }, 1253{ "Waiting for synced file...","Warte auf gesyncte Daten..." },
1254{ "Receiving synced file...","Gesyncte Daten erhalten..." }, 1254{ "Receiving synced file...","Gesyncte Daten erhalten..." },
1255{ "Received %1 bytes","%1 Bytes erhalten" }, 1255{ "Received %1 bytes","%1 Bytes erhalten" },
1256{ "Writing file to disk...","Speichere Datei..." }, 1256{ "Writing file to disk...","Speichere Datei..." },
1257{ "Pi-Sync successful!","Pi-Sync erfolgreich!" }, 1257{ "Pi-Sync successful!","Pi-Sync erfolgreich!" },
1258{ "Clock skew of\nsyncing devices\nis %1 seconds!","Uhrzeitunterschied der\nsyncenden Geräte\nist %1 Sekunden!" }, 1258{ "Clock skew of\nsyncing devices\nis %1 seconds!","Uhrzeitunterschied der\nsyncenden Geräte\nist %1 Sekunden!" },
1259{ "Synchronize!","Synchronisiere!" }, 1259{ "Synchronize!","Synchronisiere!" },
1260{ "High clock skew!","Großer Uhrzeitunterschied!" }, 1260{ "High clock skew!","Großer Uhrzeitunterschied!" },
1261{ "ADJUST\nYOUR\nCLOCKS!","JUSTIERE\nDIE\nUHREN!" }, 1261{ "ADJUST\nYOUR\nCLOCKS!","JUSTIERE\nDIE\nUHREN!" },
1262{ "The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!","Die Uhren der syncenden Geräte\nhaben einen Unterschied von\nmehr als 5 Minuten. Bitte die\nUhrzeiten anpassen. Sie können\nfalsche Sync-Resultate erhalten!\nBitte das Syncen bestätigen!" }, 1262{ "The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!","Die Uhren der syncenden Geräte\nhaben einen Unterschied von\nmehr als 5 Minuten. Bitte die\nUhrzeiten anpassen. Sie können\nfalsche Sync-Resultate erhalten!\nBitte das Syncen bestätigen!" },
1263{ "This is a %1 recurring todo.","Das ist eine %1 wiederholende Aufgabe." }, 1263{ "This is a %1 recurring todo.","Das ist eine %1 wiederholende Aufgabe." },
1264{ "<p><b>Start on:</b> %1</p>","<p><b>Start am:</b> %1</p>" }, 1264{ "<p><b>Start on:</b> %1</p>","<p><b>Start am:</b> %1</p>" },
1265{ "List week view","Listenwochenansicht" }, 1265{ "List week view","Listenwochenansicht" },
1266{ "List week","Listenwochenansicht" }, 1266{ "List week","Listenwochenansicht" },
1267{ "Next Week","Nächste Woche" }, 1267{ "Next Week","Nächste Woche" },
1268{ "Previous Week","Vorherige Woche" }, 1268{ "Previous Week","Vorherige Woche" },
1269{ "No items were found matching\nyour search expression.\nUse the wildcard characters\n'*' and '?' where needed.","Keine Einträge gefunden die\ndem Suchausdruck entsprechen.\nBenutze Platzhalter Zeichen\n'*' und '?' wo benötigt." }, 1269{ "No items were found matching\nyour search expression.\nUse the wildcard characters\n'*' and '?' where needed.","Keine Einträge gefunden die\ndem Suchausdruck entsprechen.\nBenutze Platzhalter Zeichen\n'*' und '?' wo benötigt." },
1270{ "Show in todo/event viewer:","Zeige in Termin/Todo Anzeige:" }, 1270{ "Show in todo/event viewer:","Zeige in Termin/Todo Anzeige:" },
1271{ "Details","Details" }, 1271{ "Details","Details" },
1272{ "Created time","Erstellt Zeit" }, 1272{ "Created time","Erstellt Zeit" },
1273{ "Last modified time","Geändert Zeit" }, 1273{ "Last modified time","Geändert Zeit" },
1274{ "Show in What'sThis quick overview:","Zeige in What'sThis Schnellübersicht:" }, 1274{ "Show in What'sThis quick overview:","Zeige in What'sThis Schnellübersicht:" },
1275{ "View Options","Anzeige Optionen" }, 1275{ "View Options","Anzeige Optionen" },
1276{ "<b>Created: ","<b>Erstellt am: " }, 1276{ "<b>Created: ","<b>Erstellt am: " },
1277{ "<b>Last modified: ","<b>Zuletzt geändert am: " }, 1277{ "<b>Last modified: ","<b>Zuletzt geändert am: " },
1278{ "Journal: ","Journal: " }, 1278{ "Journal: ","Journal: " },
1279{ "yearly","jährlich" }, 1279{ "yearly","jährlich" },
1280{ "(%1) ","%1-" }, 1280{ "(%1) ","%1-" },
1281{ "<p><b>K</b>: Week view in Month view syle</p>\n","<p><b>K</b>: Wochenansicht in Art der Monatsansicht</p>\n" }, 1281{ "<p><b>K</b>: Week view in Month view syle</p>\n","<p><b>K</b>: Wochenansicht in Art der Monatsansicht</p>\n" },
1282{ "Enable tooltips displaying summary of ev.","Titel-Tooltips anzeigen" }, 1282{ "Enable tooltips displaying summary of ev.","Titel-Tooltips anzeigen" },
1283{ "Enable scrollbars in month view cells","Scrollbar in Zellen anzeigen" }, 1283{ "Enable scrollbars in month view cells","Scrollbar in Zellen anzeigen" },
1284{ "Summary/Loc.","Titel/Ort" }, 1284{ "Summary/Loc.","Titel/Ort" },
1285{ "No items found. Use '*' and '?' where needed.","Nichts gefunden. Benutze '*' and '?' wo benötigt." }, 1285{ "No items found. Use '*' and '?' where needed.","Nichts gefunden. Benutze '*' and '?' wo benötigt." },
1286{ "Week Number","Wochennummer" }, 1286{ "Week Number","Wochennummer" },
1287{ "Import","Importiere" }, 1287{ "Import","Importiere" },
1288{ "Export","Exportiere" }, 1288{ "Export","Exportiere" },
1289{ "Beam","Beame" }, 1289{ "Beam","Beame" },
1290{ "Export selected","Exportiere Selektierte" }, 1290{ "Export selected","Exportiere Selektierte" },
1291{ "As iCal (ics) file...","Als iCal (ics) Datei..." }, 1291{ "As iCal (ics) file...","Als iCal (ics) Datei..." },
1292{ "As vCal (vcs) file...","Als vCal (vcs) Datei..." }, 1292{ "As vCal (vcs) file...","Als vCal (vcs) Datei..." },
1293{ "Journal/Details...","Journale/Details..." }, 1293{ "Journal/Details...","Journale/Details..." },
1294{ "Agenda View","Agenda Ansicht" }, 1294{ "Agenda View","Agenda Ansicht" },
1295{ "Show current time","Zeige aktuelle Zeit" }, 1295{ "Show current time","Zeige aktuelle Zeit" },
1296{ "Edit new item","Bearbeite neuen Eintrag" }, 1296{ "Edit new item","Bearbeite neuen Eintrag" },
1297{ "Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals","Bitte wählen Sie mindestens\neinen dieser Typen\num darin zu suchen:\n\nTermine\nTodos\nJournale" }, 1297{ "Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals","Bitte wählen Sie mindestens\neinen dieser Typen\num darin zu suchen:\n\nTermine\nTodos\nJournale" },
1298{ "There is no next alarm.","Es gibt keinen nächsten Alarm." }, 1298{ "There is no next alarm.","Es gibt keinen nächsten Alarm." },
1299{ "%1 %2 - %3 (next event/todo with alarm)","%1 %2 - %3 (nächster Termin/Todo mit Alarm)" }, 1299{ "%1 %2 - %3 (next event/todo with alarm)","%1 %2 - %3 (nächster Termin/Todo mit Alarm)" },
1300{ "The next alarm is in:\n","Der nächste Alarm ist in:\n" }, 1300{ "The next alarm is in:\n","Der nächste Alarm ist in:\n" },
1301{ "%1 days\n","%1 Tagen\n" }, 1301{ "%1 days\n","%1 Tagen\n" },
1302{ "1 day\n","1 Tag\n" }, 1302{ "1 day\n","1 Tag\n" },
1303{ "%1 hours\n","%1 Stunden\n" }, 1303{ "%1 hours\n","%1 Stunden\n" },
1304{ "1 hour\n","1 Stunde\n" }, 1304{ "1 hour\n","1 Stunde\n" },
1305{ "%1 minutes\n","%1 Minuten\n" }, 1305{ "%1 minutes\n","%1 Minuten\n" },
1306{ "1 minute\n","1 Minute\n" }, 1306{ "1 minute\n","1 Minute\n" },
1307{ "Only one toolbar","Nur eine Toolbar" }, 1307{ "Only one toolbar","Nur eine Toolbar" },
1308{ "Print","Drucke" }, 1308{ "Print","Drucke" },
1309{ "Print selected event / todo...","Drucke ausgewählten Termin / Todo..." }, 1309{ "Print selected event / todo...","Drucke ausgewählten Termin / Todo..." },
1310{ "There is nothing selected!","Es ist nichts ausgewählt!" }, 1310{ "There is nothing selected!","Es ist nichts ausgewählt!" },
1311{ "\n\nDo you really want to print this item?","\n\nMöchten Sie wirklich diesen Eintrag ausdrucken? " }, 1311{ "\n\nDo you really want to print this item?","\n\nMöchten Sie wirklich diesen Eintrag ausdrucken? " },
1312{ "KO/Pi Print Confirmation","KO/Pi Druckbestätigung" }, 1312{ "KO/Pi Print Confirmation","KO/Pi Druckbestätigung" },
1313{ "This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog.\n","Dies druckt die Ansicht wie man sie sieht.\n(Mit dem kompletten Inhalt natürlich.)\nMan kann das Layout ändern durch ändern der Fenstergröße.\nDrucke unskaliert druckt ggf. mehrere Seiten\nabhängig von der Menge der Daten.\nDrucke runterskaliert um auf eine Seite zu passen\ndruckt alles auf eine Seite.\nDrucke hoch/runterskaliert um genau auf eine Seite zu passen\nvergrößert den Text gegebenenfalls.\nDas Seitenlayout kann im nächsten Dialog gewählt werden.\n" }, 1313{ "This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog.\n","Dies druckt die Ansicht wie man sie sieht.\n(Mit dem kompletten Inhalt natürlich.)\nMan kann das Layout ändern durch ändern der Fenstergröße.\nDrucke unskaliert druckt ggf. mehrere Seiten\nabhängig von der Menge der Daten.\nDrucke runterskaliert um auf eine Seite zu passen\ndruckt alles auf eine Seite.\nDrucke hoch/runterskaliert um genau auf eine Seite zu passen\nvergrößert den Text gegebenenfalls.\nDas Seitenlayout kann im nächsten Dialog gewählt werden.\n" },
1314{ "KO/Pi Printout","KO/Pi Ausdruck" }, 1314{ "KO/Pi Printout","KO/Pi Ausdruck" },
1315{ "Print unscaled","Drucke unskaliert" }, 1315{ "Print unscaled","Drucke unskaliert" },
1316{ "Print scaled down to fit one page","Drucke runterskaliert um auf eine Seite zu passen." }, 1316{ "Print scaled down to fit one page","Drucke runterskaliert um auf eine Seite zu passen." },
1317{ "Print scaled up/down to fit one page","Drucke hoch/runterskaliert um genau auf eine Seite zu passen." }, 1317{ "Print scaled up/down to fit one page","Drucke hoch/runterskaliert um genau auf eine Seite zu passen." },
1318{ "Printout Mode","Druck Modus" }, 1318{ "Printout Mode","Druck Modus" },
1319{ "Filter menu icon","Filtermenu Icon" }, 1319{ "Filter menu icon","Filtermenu Icon" },
1320{ "<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n","<p><b>A+(shift oder ctrl)</b>: Zeige Zeit bis zum nächsten Alarm</p>\n" }, 1320{ "<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n","<p><b>A+(shift oder ctrl)</b>: Zeige Zeit bis zum nächsten Alarm</p>\n" },
1321{ "<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n","<p><b>N</b>: Wechsle zur nächsten Ansicht, die ein Icon in der Toolbar hat</p>\n" }, 1321{ "<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n","<p><b>N</b>: Wechsle zur nächsten Ansicht, die ein Icon in der Toolbar hat</p>\n" },
1322{ "%1d","%1t" }, 1322{ "%1d","%1t" },
1323{ "%1h","%1std" }, 1323{ "%1h","%1std" },
1324{ "%1min","%1min" }, 1324{ "%1min","%1min" },
1325{ "( %1 before )","( %1 vorher )" }, 1325{ "( %1 before )","( %1 vorher )" },
1326{ "The next alarm is in\nless than one minute!","Der nächste Alarm kommt in\nweniger als einer Minute!" }, 1326{ "The next alarm is in\nless than one minute!","Der nächste Alarm kommt in\nweniger als einer Minute!" },
1327{ "\nThe internal alarm notification is disabled!\n","\nDie interne Alarmbenachrichtigung ist ausgeschaltet!\n" }, 1327{ "\nThe internal alarm notification is disabled!\n","\nDie interne Alarmbenachrichtigung ist ausgeschaltet!\n" },
1328{ "Enable it in the settings menu, TAB alarm.","Schalten Sie sie an im Menu Einstellungen, TAB Alarm." }, 1328{ "Enable it in the settings menu, TAB alarm.","Schalten Sie sie an im Menu Einstellungen, TAB Alarm." },
1329{ "Show Sync Events","Zeige Sync-Ereignisse" }, 1329{ "Show Sync Events","Zeige Sync-Ereignisse" },
1330{ "Use short date in WN+Event view","Zeige Kurzdatum in WN+Terminanzeige" }, 1330{ "Use short date in WN+Event view","Zeige Kurzdatum in WN+Terminanzeige" },
1331{ "Number of max.displayed todo prios:","Anzahl max.angezeigter Todo-Prios:" }, 1331{ "Number of max.displayed todo prios:","Anzahl max.angezeigter Todo-Prios:" },
1332{ " on "," am " }, 1332{ " on "," am " },
1333{ "On: ","Am: " }, 1333{ "On: ","Am: " },
1334{ "<i>The recurrence is computed from the start datetime!</i>","<i>Die Wiederholung wird vom Startwert aus berechnet!</i>" }, 1334{ "<i>The recurrence is computed from the start datetime!</i>","<i>Die Wiederholung wird vom Startwert aus berechnet!</i>" },
1335{ "Start/Stop todo...","Starte/Stoppe Todo..." }, 1335{ "Start/Stop todo...","Starte/Stoppe Todo..." },
1336{ "Color for running todos:","Farbe für laufende Todos:" }, 1336{ "Color for running todos:","Farbe für laufende Todos:" },
1337{ "The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?","Das Todo\n%1\nist gestartet.\nWollen Sie es\nauf gestoppt setzen?" }, 1337{ "The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?","Das Todo\n%1\nist gestartet.\nWollen Sie es\nauf gestoppt setzen?" },
1338{ "Todo is started","Todo ist gestartet" }, 1338{ "Todo is started","Todo ist gestartet" },
1339{ "Stop todo","Stoppe Todo" }, 1339{ "Stop todo","Stoppe Todo" },
1340{ "Todo is stopped","Todo ist gestoppt" }, 1340{ "Todo is stopped","Todo ist gestoppt" },
1341{ "Start todo","Starte Todo" }, 1341{ "Start todo","Starte Todo" },
1342{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" }, 1342{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" },
1343{ "The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?","Das Todo\n%1\nwird geklont!\nEs hat Untertodos!\nMöchten Sie alle\nUntertodos auch klonen?" }, 1343{ "The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?","Das Todo\n%1\nwird geklont!\nEs hat Untertodos!\nMöchten Sie alle\nUntertodos auch klonen?" },
1344{ "Todo has subtodos","Todo hat Untertodos" }, 1344{ "Todo has subtodos","Todo hat Untertodos" },
1345{ "Block popup until mouse button release","Sperre Popup bis Mausknopf losgelassen" }, 1345{ "Block popup until mouse button release","Sperre Popup bis Mausknopf losgelassen" },
1346{ "Colors","Farben" }, 1346{ "Colors","Farben" },
1347{ "Click on new parent item","Klicke auf neues Übertodo" }, 1347{ "Click on new parent item","Klicke auf neues Übertodo" },
1348{ "Reparenting aborted!","Übertodo setzen abgebrochen" }, 1348{ "Reparenting aborted!","Übertodo setzen abgebrochen" },
1349{ "Cannot move Todo to itself\nor a child of itself","Kann nicht Todo auf\nsich selbst oder\nein Untertodo verschieben" }, 1349{ "Cannot move Todo to itself\nor a child of itself","Kann nicht Todo auf\nsich selbst oder\nein Untertodo verschieben" },
1350{ "Recursive reparenting not possible!","Rekursives Verschieben nicht möglich" }, 1350{ "Recursive reparenting not possible!","Rekursives Verschieben nicht möglich" },
1351{ "Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)","Entferne alle erledigten Todos?\n(Erledigte wiederholende Todos\nwerden nicht gelöscht!)" }, 1351{ "Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)","Entferne alle erledigten Todos?\n(Erledigte wiederholende Todos\nwerden nicht gelöscht!)" },
1352{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" }, 1352{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" },
1353{ "times","Zeiten" }, 1353{ "times","Zeiten" },
1354{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" }, 1354{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" },
1355{ "Backup enabled","Backup angeschaltet" }, 1355{ "Backup enabled","Backup angeschaltet" },
1356{ "Use standard backup dir","Standard Backupverzeichnis" }, 1356{ "Use standard backup dir","Standard Backupverzeichnis" },
1357{ "Number of Backups:","Anzahl der Backups" }, 1357{ "Number of Backups:","Anzahl der Backups" },
1358{ "Make backup every ","Mache ein Backup alle " }, 1358{ "Make backup every ","Mache ein Backup alle " },
1359{ " days"," Tage" }, 1359{ " days"," Tage" },
1360{ "Creating backup ... please wait ...","Erzeuge Backup ... bitte warten ..." }, 1360{ "Creating backup ... please wait ...","Erzeuge Backup ... bitte warten ..." },
1361{ "Backup Failed!","Backup Problem!" }, 1361{ "Backup Failed!","Backup Problem!" },
1362{ "Try again now","Versuche jetzt nochmal" }, 1362{ "Try again now","Versuche jetzt nochmal" },
1363{ "Try again later","Versuche später nochmal" }, 1363{ "Try again later","Versuche später nochmal" },
1364{ "Try again tomorrow","Versuche morgen nochmal" }, 1364{ "Try again tomorrow","Versuche morgen nochmal" },
1365{ "Disable backup","Schalte Backup ab" }, 1365{ "Disable backup","Schalte Backup ab" },
1366{ "<b>Backup directory does not exist: </b>","<b>Backup Verzeichnis existiert nicht: </b>" }, 1366{ "<b>Backup directory does not exist: </b>","<b>Backup Verzeichnis existiert nicht: </b>" },
1367{ "<b>The backup copy command failed!</b>","<b>Das Backup Kopierkommando is fehlgeschlagen!</b>" }, 1367{ "<b>The backup copy command failed!</b>","<b>Das Backup Kopierkommando is fehlgeschlagen!</b>" },
1368{ "Choose action","Wähle Aktion" }, 1368{ "Choose action","Wähle Aktion" },
1369{ "Comment for todo:","Kommentar zum Todo:" }, 1369{ "Comment for todo:","Kommentar zum Todo:" },
1370{ "Stop+note","Stop+Notiz" }, 1370{ "Stop+note","Stop+Notiz" },
1371{ "Agenda view shows completed todos","Agenda Ansicht zeigt erledigte Todos" }, 1371{ "Agenda view shows completed todos","Agenda Ansicht zeigt erledigte Todos" },
1372{ "KO/Pi: Missing alarms!","KO/Pi: Verpasste Alarme!" }, 1372{ "KO/Pi: Missing alarms!","KO/Pi: Verpasste Alarme!" },
1373{ "You missed the alarms for the following events or todos:","Sie verpassten die Alarme für folgende Termine oder Todos:" }, 1373{ "You missed the alarms for the following events or todos:","Sie verpassten die Alarme für folgende Termine oder Todos:" },
1374{ "Print complete list","Drucke komplette Liste" }, 1374{ "Print complete list","Drucke komplette Liste" },
1375{ "Hide all selected","Verstecke Selektierte" }, 1375{ "Hide all selected","Verstecke Selektierte" },
1376{ "Add items","hinzufügen" }, 1376{ "Add items","hinzufügen" },
1377{ "One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?","Ein (oder mehrere) ausgewähltes\nTodo hat Untertodos!\nMöchten Sie der Auswahlliste\nalle Untertodos von allen\nausgewählten Todos hinzufügen?" }, 1377{ "One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?","Ein (oder mehrere) ausgewähltes\nTodo hat Untertodos!\nMöchten Sie der Auswahlliste\nalle Untertodos von allen\nausgewählten Todos hinzufügen?" },
1378{ "Print List View...","Drucke Listenansicht..." }, 1378{ "Print List View...","Drucke Listenansicht..." },
1379{ "You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.","Sie können die <b>Listenansicht</b> und die Listenansicht im <b>Suchdialog</b> ausdrucken! Um das zu machen gehen Sie bitte zur <b>Listenansicht</b> oder zum <b>Suchdialog</b>. Rechtsklicken Sie auf die Liste. Wählen Sie im Popupmenu den Eintrag <b>Drucke komplette Liste</b>. Das druckt die Liste so, wie man sie sieht. Sie können Listeneinträge entfernen ohne die korrespondierenden Ereignisse/Todos zu löschen! Selektieren sie einfach alle Einträge, die sie nicht ausdrucken möchten. Dann Rechtsklicken Sie auf einen Eintrag und wählen <b>Verstecke Selektierte</b>. Danach können Sie die Liste ohne diese Einträge ausdrucken." }, 1379{ "You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.","Sie können die <b>Listenansicht</b> und die Listenansicht im <b>Suchdialog</b> ausdrucken! Um das zu machen gehen Sie bitte zur <b>Listenansicht</b> oder zum <b>Suchdialog</b>. Rechtsklicken Sie auf die Liste. Wählen Sie im Popupmenu den Eintrag <b>Drucke komplette Liste</b>. Das druckt die Liste so, wie man sie sieht. Sie können Listeneinträge entfernen ohne die korrespondierenden Ereignisse/Todos zu löschen! Selektieren sie einfach alle Einträge, die sie nicht ausdrucken möchten. Dann Rechtsklicken Sie auf einen Eintrag und wählen <b>Verstecke Selektierte</b>. Danach können Sie die Liste ohne diese Einträge ausdrucken." },
1380{ "Configure KO/Pi...","Konfiguriere KO/Pi..." }, 1380{ "Configure KO/Pi...","Konfiguriere KO/Pi..." },
1381{ "Global Settings...","Globale Einstellungen..." }, 1381{ "Global Settings...","Globale Einstellungen..." },
1382{ "<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n","<p><b>R</b>: Zeige Resource Ansicht | <b>F</b>: Editiere Filter </p>\n" }, 1382{ "<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n","<p><b>R</b>: Zeige Resource Ansicht | <b>F</b>: Editiere Filter </p>\n" },
1383{ "","" }, 1383{ "(disabled)","(abgeschaltet)" },
1384{ "","" }, 1384{ "","" },
1385{ "","" }, 1385{ "","" },
1386{ "","" }, 1386{ "","" },
1387{ "","" }, 1387{ "","" },
1388{ "","" }, 1388{ "","" },
1389{ "","" }, 1389{ "","" },
1390{ "","" }, \ No newline at end of file 1390{ "","" }, \ No newline at end of file
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 07ec459..6e60c56 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -274,384 +274,387 @@ class KOBeamPrefs : public QDialog
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 )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
466 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
467 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
468 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
466 mTodoList->setNavigator( mNavigator ); 469 mTodoList->setNavigator( mNavigator );
467#if 0 470#if 0
468 if ( QApplication::desktop()->width() < 480 ) { 471 if ( QApplication::desktop()->width() < 480 ) {
469 leftFrameLayout->addWidget(mFilterView); 472 leftFrameLayout->addWidget(mFilterView);
470 leftFrameLayout->addWidget(mTodoList, 2 ); 473 leftFrameLayout->addWidget(mTodoList, 2 );
471 474
472 } else { 475 } else {
473 leftFrameLayout->addWidget(mTodoList,2 ); 476 leftFrameLayout->addWidget(mTodoList,2 );
474 leftFrameLayout->addWidget(mFilterView ); 477 leftFrameLayout->addWidget(mFilterView );
475 } 478 }
476#endif 479#endif
477 mFilterView->hide(); 480 mFilterView->hide();
478 mCalEditView->hide(); 481 mCalEditView->hide();
479 QWidget *rightBox = new QWidget( mMainFrame ); 482 QWidget *rightBox = new QWidget( mMainFrame );
480 //mainBoxLayout->addWidget ( rightBox, 10 ); 483 //mainBoxLayout->addWidget ( rightBox, 10 );
481 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 484 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
482 mRightFrame = new QWidgetStack( rightBox ); 485 mRightFrame = new QWidgetStack( rightBox );
483 rightLayout->addWidget( mRightFrame, 10 ); 486 rightLayout->addWidget( mRightFrame, 10 );
484 487
485 //mLeftFrame = (QWidget *)leftFrame; 488 //mLeftFrame = (QWidget *)leftFrame;
486 if ( KOPrefs::instance()->mVerticalScreen ) { 489 if ( KOPrefs::instance()->mVerticalScreen ) {
487 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 490 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
488 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 491 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
489 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 492 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
490 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 493 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
491 } else { 494 } else {
492 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 495 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
493 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 496 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
494 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 497 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
495 } 498 }
496 if ( !KOPrefs::instance()->mShowDateNavigator) 499 if ( !KOPrefs::instance()->mShowDateNavigator)
497 mDateNavigator->hide(); 500 mDateNavigator->hide();
498 //qDebug("Calendarview Size %d %d ", width(), height()); 501 //qDebug("Calendarview Size %d %d ", width(), height());
499#endif 502#endif
500 503
501 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
502 SLOT( showDates( const KCal::DateList & ) ) ); 505 SLOT( showDates( const KCal::DateList & ) ) );
503 506
504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 507 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
505 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 508 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
506 509
507 510
508 511
509 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 512 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
510 mViewManager, SLOT( showMonth( const QDate & ) ) ); 513 mViewManager, SLOT( showMonth( const QDate & ) ) );
511 514
512 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 515 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
513 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 516 mNavigator, SLOT( selectWeek( const QDate & ) ) );
514 517
515 connect( mDateNavigator, SIGNAL( goPrevYear() ), 518 connect( mDateNavigator, SIGNAL( goPrevYear() ),
516 mNavigator, SLOT( selectPreviousYear() ) ); 519 mNavigator, SLOT( selectPreviousYear() ) );
517 connect( mDateNavigator, SIGNAL( goNextYear() ), 520 connect( mDateNavigator, SIGNAL( goNextYear() ),
518 mNavigator, SLOT( selectNextYear() ) ); 521 mNavigator, SLOT( selectNextYear() ) );
519 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 522 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
520 mNavigator, SLOT( selectPreviousMonth() ) ); 523 mNavigator, SLOT( selectPreviousMonth() ) );
521 connect( mDateNavigator, SIGNAL( goNextMonth() ), 524 connect( mDateNavigator, SIGNAL( goNextMonth() ),
522 mNavigator, SLOT( selectNextMonth() ) ); 525 mNavigator, SLOT( selectNextMonth() ) );
523 526
524 connect( mDateNavigator, SIGNAL( goPrevious() ), 527 connect( mDateNavigator, SIGNAL( goPrevious() ),
525 mNavigator, SLOT( selectPrevious() ) ); 528 mNavigator, SLOT( selectPrevious() ) );
526 connect( mDateNavigator, SIGNAL( goNext() ), 529 connect( mDateNavigator, SIGNAL( goNext() ),
527 mNavigator, SLOT( selectNext() ) ); 530 mNavigator, SLOT( selectNext() ) );
528 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 531 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
529 mNavigator, SLOT( slotMonthSelect( int ) ) ); 532 mNavigator, SLOT( slotMonthSelect( int ) ) );
530 533
531 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 534 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
532 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 535 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
533#if 0 536#if 0
534 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 537 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
535 SLOT( incidenceAdded( Incidence *) ) ); 538 SLOT( incidenceAdded( Incidence *) ) );
536#endif 539#endif
537 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 540 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
538 541
539 connect( this, SIGNAL( configChanged() ), 542 connect( this, SIGNAL( configChanged() ),
540 mDateNavigator, SLOT( updateConfig() ) ); 543 mDateNavigator, SLOT( updateConfig() ) );
541 544
542 connect( mTodoList, SIGNAL( newTodoSignal() ), 545 connect( mTodoList, SIGNAL( newTodoSignal() ),
543 SLOT( newTodo() ) ); 546 SLOT( newTodo() ) );
544 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 547 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
545 SLOT( newSubTodo( Todo * ) ) ); 548 SLOT( newSubTodo( Todo * ) ) );
546 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 549 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
547 SLOT( editTodo( Todo * ) ) ); 550 SLOT( editTodo( Todo * ) ) );
548 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 551 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
549 SLOT( showTodo( Todo *) ) ); 552 SLOT( showTodo( Todo *) ) );
550 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 553 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
551 SLOT( deleteTodo( Todo *) ) ); 554 SLOT( deleteTodo( Todo *) ) );
552 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 555 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
553 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 556 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
554 SLOT( purgeCompleted() ) ); 557 SLOT( purgeCompleted() ) );
555 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 558 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
556 SIGNAL( todoModified( Todo *, int ) ) ); 559 SIGNAL( todoModified( Todo *, int ) ) );
557 560
558 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 561 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
559 this, SLOT ( cloneIncidence( Incidence * ) ) ); 562 this, SLOT ( cloneIncidence( Incidence * ) ) );
560 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 563 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
561 this, SLOT (cancelIncidence( Incidence * ) ) ); 564 this, SLOT (cancelIncidence( Incidence * ) ) );
562 565
563 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 566 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
564 this, SLOT ( moveIncidence( Incidence * ) ) ); 567 this, SLOT ( moveIncidence( Incidence * ) ) );
565 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 568 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
566 this, SLOT ( beamIncidence( Incidence * ) ) ); 569 this, SLOT ( beamIncidence( Incidence * ) ) );
567 570
568 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 571 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
569 this, SLOT ( todo_unsub( Todo * ) ) ); 572 this, SLOT ( todo_unsub( Todo * ) ) );
570 573
571 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 574 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
572 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 575 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
573 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 576 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
574 SLOT( updateTodo( Todo *, int ) ) ); 577 SLOT( updateTodo( Todo *, int ) ) );
575 connect( this, SIGNAL( todoModified( Todo *, int )), this, 578 connect( this, SIGNAL( todoModified( Todo *, int )), this,
576 SLOT( changeTodoDisplay( Todo *, int ) ) ); 579 SLOT( changeTodoDisplay( Todo *, int ) ) );
577 580
578 581
579 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 582 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
580 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 583 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
581 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 584 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
582 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 585 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
583 586
584 587
585 588
586 589
587 590
588 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 591 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
589 SLOT(checkClipboard())); 592 SLOT(checkClipboard()));
590 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 593 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
591 SLOT( processTodoListSelection( Incidence * ) ) ); 594 SLOT( processTodoListSelection( Incidence * ) ) );
592 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 595 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
593 596
594 // kdDebug() << "CalendarView::CalendarView() done" << endl; 597 // kdDebug() << "CalendarView::CalendarView() done" << endl;
595 598
596 mDateFrame = new QVBox(0,0,WType_Popup); 599 mDateFrame = new QVBox(0,0,WType_Popup);
597 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 600 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
598 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 601 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
599 mDateFrame->setLineWidth(3); 602 mDateFrame->setLineWidth(3);
600 mDateFrame->hide(); 603 mDateFrame->hide();
601 mDateFrame->setCaption( i18n( "Pick a date to display")); 604 mDateFrame->setCaption( i18n( "Pick a date to display"));
602 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 605 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
603 606
604 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 607 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
605 608
606 mEventEditor = mDialogManager->getEventEditor(); 609 mEventEditor = mDialogManager->getEventEditor();
607 mTodoEditor = mDialogManager->getTodoEditor(); 610 mTodoEditor = mDialogManager->getTodoEditor();
608 611
609 mFlagEditDescription = false; 612 mFlagEditDescription = false;
610 613
611 mSuspendTimer = new QTimer( this ); 614 mSuspendTimer = new QTimer( this );
612 mAlarmTimer = new QTimer( this ); 615 mAlarmTimer = new QTimer( this );
613 mRecheckAlarmTimer = new QTimer( this ); 616 mRecheckAlarmTimer = new QTimer( this );
614 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 617 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
615 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 618 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
616 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 619 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
617 mAlarmDialog = new AlarmDialog( this ); 620 mAlarmDialog = new AlarmDialog( this );
618 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 621 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
619 mAlarmDialog->setServerNotification( false ); 622 mAlarmDialog->setServerNotification( false );
620 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 623 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
621 624
622 625
623#ifndef DESKTOP_VERSION 626#ifndef DESKTOP_VERSION
624//US listen for arriving address resultsets 627//US listen for arriving address resultsets
625 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 628 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
626 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 629 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
627#endif 630#endif
628 mDateNavigator->setCalendar( mCalendar ); 631 mDateNavigator->setCalendar( mCalendar );
629} 632}
630 633
631 634
632CalendarView::~CalendarView() 635CalendarView::~CalendarView()
633{ 636{
634 // kdDebug() << "~CalendarView()" << endl; 637 // kdDebug() << "~CalendarView()" << endl;
635 //qDebug("CalendarView::~CalendarView() "); 638 //qDebug("CalendarView::~CalendarView() ");
636 delete mDialogManager; 639 delete mDialogManager;
637 delete mViewManager; 640 delete mViewManager;
638 delete mStorage; 641 delete mStorage;
639 delete mDateFrame ; 642 delete mDateFrame ;
640 delete beamDialog; 643 delete beamDialog;
641 delete mEventViewerDialog; 644 delete mEventViewerDialog;
642 //kdDebug() << "~CalendarView() done" << endl; 645 //kdDebug() << "~CalendarView() done" << endl;
643} 646}
644void CalendarView::checkAlarms() 647void CalendarView::checkAlarms()
645{ 648{
646 KConfig *config = KOGlobals::config(); 649 KConfig *config = KOGlobals::config();
647 config->setGroup( "AppRun" ); 650 config->setGroup( "AppRun" );
648 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 651 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
649 int daysto = dt.daysTo( QDate::currentDate() ); 652 int daysto = dt.daysTo( QDate::currentDate() );
650 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 653 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
651 dt = dt.addDays( days ); 654 dt = dt.addDays( days );
652 int secto = dt.secsTo( QDateTime::currentDateTime() ); 655 int secto = dt.secsTo( QDateTime::currentDateTime() );
653 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 656 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
654 //qDebug("KO: Reading program stop %d ", secs); 657 //qDebug("KO: Reading program stop %d ", secs);
655 //secs -= ( 3600 * 24*3 ); // debug only 658 //secs -= ( 3600 * 24*3 ); // debug only
656 QDateTime latest = dt.addSecs ( secs ); 659 QDateTime latest = dt.addSecs ( secs );
657 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 660 qDebug("KO: Last termination on %s ", latest.toString().latin1());
@@ -1680,384 +1683,389 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1680 int dh = QApplication::desktop()->height(); 1683 int dh = QApplication::desktop()->height();
1681 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1684 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1682 bar.show(); 1685 bar.show();
1683 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1686 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1684 qApp->processEvents(); 1687 qApp->processEvents();
1685 1688
1686 QDate birthday; 1689 QDate birthday;
1687 QDate anniversary; 1690 QDate anniversary;
1688 QString realName; 1691 QString realName;
1689 QString email; 1692 QString email;
1690 QString assembledName; 1693 QString assembledName;
1691 QString uid; 1694 QString uid;
1692 bool ok = true; 1695 bool ok = true;
1693 for ( int i = 0; i < count; i++) 1696 for ( int i = 0; i < count; i++)
1694 { 1697 {
1695 if ( ! bar.isVisible() ) 1698 if ( ! bar.isVisible() )
1696 return; 1699 return;
1697 bar.setProgress( i ); 1700 bar.setProgress( i );
1698 qApp->processEvents(); 1701 qApp->processEvents();
1699 1702
1700 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1703 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1701 if (!ok) { 1704 if (!ok) {
1702 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1705 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1703 } 1706 }
1704 1707
1705 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1708 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1706 if (!ok) { 1709 if (!ok) {
1707 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1710 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1708 } 1711 }
1709 realName = realNameList[i]; 1712 realName = realNameList[i];
1710 email = emailList[i]; 1713 email = emailList[i];
1711 assembledName = assembledNameList[i]; 1714 assembledName = assembledNameList[i];
1712 uid = uidList[i]; 1715 uid = uidList[i];
1713 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1716 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1714 1717
1715 if ( birthday.isValid() ){ 1718 if ( birthday.isValid() ){
1716 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1717 KCal::Attendee::ReqParticipant,uid) ; 1720 KCal::Attendee::ReqParticipant,uid) ;
1718 if ( addAnniversary( birthday, assembledName, a, true ) ) 1721 if ( addAnniversary( birthday, assembledName, a, true ) )
1719 ++addCount; 1722 ++addCount;
1720 } 1723 }
1721 1724
1722 if ( anniversary.isValid() ){ 1725 if ( anniversary.isValid() ){
1723 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1726 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1724 KCal::Attendee::ReqParticipant,uid) ; 1727 KCal::Attendee::ReqParticipant,uid) ;
1725 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1728 if ( addAnniversary( anniversary, assembledName, a, false ) )
1726 ++addCount; 1729 ++addCount;
1727 } 1730 }
1728 } 1731 }
1729 1732
1730 updateView(); 1733 updateView();
1731 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1734 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1732 1735
1733 } 1736 }
1734 1737
1735} 1738}
1736 1739
1737 1740
1738 1741
1739bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1742bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1740{ 1743{
1741 //qDebug("addAnni "); 1744 //qDebug("addAnni ");
1742 Event * ev = new Event(); 1745 Event * ev = new Event();
1743 ev->setOrganizer(KOPrefs::instance()->email()); 1746 ev->setOrganizer(KOPrefs::instance()->email());
1744 if ( a ) { 1747 if ( a ) {
1745 ev->addAttendee( a ); 1748 ev->addAttendee( a );
1746 } 1749 }
1747 QString kind; 1750 QString kind;
1748 if ( birthday ) { 1751 if ( birthday ) {
1749 kind = i18n( "Birthday" ); 1752 kind = i18n( "Birthday" );
1750 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1753 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1751 } 1754 }
1752 else { 1755 else {
1753 kind = i18n( "Anniversary" ); 1756 kind = i18n( "Anniversary" );
1754 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1757 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1755 } 1758 }
1756 ev->setCategories( kind ); 1759 ev->setCategories( kind );
1757 ev->setDtStart( QDateTime(date) ); 1760 ev->setDtStart( QDateTime(date) );
1758 ev->setDtEnd( QDateTime(date) ); 1761 ev->setDtEnd( QDateTime(date) );
1759 ev->setFloats( true ); 1762 ev->setFloats( true );
1760 Recurrence * rec = ev->recurrence(); 1763 Recurrence * rec = ev->recurrence();
1761 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1764 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1762 rec->addYearlyNum( date.month() ); 1765 rec->addYearlyNum( date.month() );
1763 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1766 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1764 delete ev; 1767 delete ev;
1765 return false; 1768 return false;
1766 } 1769 }
1767 return true; 1770 return true;
1768 1771
1769} 1772}
1770bool CalendarView::importQtopia( const QString &categories, 1773bool CalendarView::importQtopia( const QString &categories,
1771 const QString &datebook, 1774 const QString &datebook,
1772 const QString &todolist ) 1775 const QString &todolist )
1773{ 1776{
1774 1777
1775 QtopiaFormat qtopiaFormat; 1778 QtopiaFormat qtopiaFormat;
1776 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1779 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1777 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1780 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1778 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1781 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1779 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1782 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1780 1783
1781 updateView(); 1784 updateView();
1782 return true; 1785 return true;
1783 1786
1784#if 0 1787#if 0
1785 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1788 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1786 mCurrentSyncDevice = "qtopia-XML"; 1789 mCurrentSyncDevice = "qtopia-XML";
1787 if ( mSyncManager->mAskForPreferences ) 1790 if ( mSyncManager->mAskForPreferences )
1788 edit_sync_options(); 1791 edit_sync_options();
1789 qApp->processEvents(); 1792 qApp->processEvents();
1790 CalendarLocal* calendar = new CalendarLocal(); 1793 CalendarLocal* calendar = new CalendarLocal();
1791 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1794 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1792 bool syncOK = false; 1795 bool syncOK = false;
1793 QtopiaFormat qtopiaFormat; 1796 QtopiaFormat qtopiaFormat;
1794 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1797 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1795 bool loadOk = true; 1798 bool loadOk = true;
1796 if ( !categories.isEmpty() ) 1799 if ( !categories.isEmpty() )
1797 loadOk = qtopiaFormat.load( calendar, categories ); 1800 loadOk = qtopiaFormat.load( calendar, categories );
1798 if ( loadOk && !datebook.isEmpty() ) 1801 if ( loadOk && !datebook.isEmpty() )
1799 loadOk = qtopiaFormat.load( calendar, datebook ); 1802 loadOk = qtopiaFormat.load( calendar, datebook );
1800 if ( loadOk && !todolist.isEmpty() ) 1803 if ( loadOk && !todolist.isEmpty() )
1801 loadOk = qtopiaFormat.load( calendar, todolist ); 1804 loadOk = qtopiaFormat.load( calendar, todolist );
1802 1805
1803 if ( loadOk ) { 1806 if ( loadOk ) {
1804 getEventViewerDialog()->setSyncMode( true ); 1807 getEventViewerDialog()->setSyncMode( true );
1805 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1808 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1806 getEventViewerDialog()->setSyncMode( false ); 1809 getEventViewerDialog()->setSyncMode( false );
1807 qApp->processEvents(); 1810 qApp->processEvents();
1808 if ( syncOK ) { 1811 if ( syncOK ) {
1809 if ( mSyncManager->mWriteBackFile ) 1812 if ( mSyncManager->mWriteBackFile )
1810 { 1813 {
1811 // write back XML file 1814 // write back XML file
1812 1815
1813 } 1816 }
1814 setModified( true ); 1817 setModified( true );
1815 } 1818 }
1816 } else { 1819 } else {
1817 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1820 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1818 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1821 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1819 question, i18n("Ok")) ; 1822 question, i18n("Ok")) ;
1820 } 1823 }
1821 delete calendar; 1824 delete calendar;
1822 updateView(); 1825 updateView();
1823 return syncOK; 1826 return syncOK;
1824 1827
1825 1828
1826#endif 1829#endif
1827 1830
1828} 1831}
1829 1832
1830void CalendarView::setSyncEventsReadOnly() 1833void CalendarView::setSyncEventsReadOnly()
1831{ 1834{
1832 Event * ev; 1835 Event * ev;
1833 QPtrList<Event> eL = mCalendar->rawEvents(); 1836 QPtrList<Event> eL = mCalendar->rawEvents();
1834 ev = eL.first(); 1837 ev = eL.first();
1835 while ( ev ) { 1838 while ( ev ) {
1836 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1839 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1837 ev->setReadOnly( true ); 1840 ev->setReadOnly( true );
1838 ev = eL.next(); 1841 ev = eL.next();
1839 } 1842 }
1840} 1843}
1841 1844
1842bool CalendarView::loadCalendars() 1845bool CalendarView::loadCalendars()
1843{ 1846{
1844 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1847 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1845 KopiCalendarFile * cal = calendars.first(); 1848 KopiCalendarFile * cal = calendars.first();
1846 mCalendar->setDefaultCalendar( 1 ); 1849 mCalendar->setDefaultCalendar( 1 );
1847 openCalendar( MainWindow::defaultFileName(), false ); 1850 openCalendar( MainWindow::defaultFileName(), false );
1848 cal = calendars.next(); 1851 cal = calendars.next();
1849 while ( cal ) { 1852 while ( cal ) {
1850 addCalendar( cal ); 1853 addCalendar( cal );
1851 cal = calendars.next(); 1854 cal = calendars.next();
1852 } 1855 }
1853 restoreCalendarSettings(); 1856 restoreCalendarSettings();
1854 mCalendar->reInitAlarmSettings(); 1857 mCalendar->reInitAlarmSettings();
1855 setSyncEventsReadOnly(); 1858 setSyncEventsReadOnly();
1856 updateUnmanagedViews(); 1859 updateUnmanagedViews();
1857 updateView(); 1860 updateView();
1858} 1861}
1859bool CalendarView::restoreCalendarSettings() 1862bool CalendarView::restoreCalendarSettings()
1860{ 1863{
1861 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1864 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1862 KopiCalendarFile * cal = calendars.first(); 1865 KopiCalendarFile * cal = calendars.first();
1863 while ( cal ) { 1866 while ( cal ) {
1864 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1867 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1865 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1868 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1866 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1869 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1867 if ( cal->isStandard ) 1870 if ( cal->isStandard )
1868 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1871 mCalendar->setDefaultCalendar( cal->mCalNumber );
1869 cal = calendars.next(); 1872 cal = calendars.next();
1870 } 1873 }
1871} 1874}
1875void CalendarView::addCalendarId( int id )
1876{
1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1878 addCalendar( cal );
1879}
1872bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1880bool CalendarView::addCalendar( KopiCalendarFile * cal )
1873{ 1881{
1874 1882
1875 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) 1883 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
1876 return true; 1884 return true;
1877 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1885 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1878 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1886 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1879 return false; 1887 return false;
1880} 1888}
1881bool CalendarView::openCalendar(QString filename, bool merge) 1889bool CalendarView::openCalendar(QString filename, bool merge)
1882{ 1890{
1883 1891
1884 if (filename.isEmpty()) { 1892 if (filename.isEmpty()) {
1885 return false; 1893 return false;
1886 } 1894 }
1887 1895
1888 if (!QFile::exists(filename)) { 1896 if (!QFile::exists(filename)) {
1889 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1897 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1890 return false; 1898 return false;
1891 } 1899 }
1892 1900
1893 globalFlagBlockAgenda = 1; 1901 globalFlagBlockAgenda = 1;
1894 clearAllViews(); 1902 clearAllViews();
1895 if (!merge) { 1903 if (!merge) {
1896 mViewManager->setDocumentId( filename ); 1904 mViewManager->setDocumentId( filename );
1897 mCalendar->close(); 1905 mCalendar->close();
1898 } 1906 }
1899 mStorage->setFileName( filename ); 1907 mStorage->setFileName( filename );
1900 1908
1901 if ( mStorage->load() ) { 1909 if ( mStorage->load() ) {
1902 if ( merge ) ;//setModified( true ); 1910 if ( merge ) ;//setModified( true );
1903 else { 1911 else {
1904 //setModified( true ); 1912 //setModified( true );
1905 mViewManager->setDocumentId( filename ); 1913 mViewManager->setDocumentId( filename );
1906 mDialogManager->setDocumentId( filename ); 1914 mDialogManager->setDocumentId( filename );
1907 mTodoList->setDocumentId( filename ); 1915 mTodoList->setDocumentId( filename );
1908 } 1916 }
1909 globalFlagBlockAgenda = 2; 1917 globalFlagBlockAgenda = 2;
1910 // if ( getLastSyncEvent() ) 1918 // if ( getLastSyncEvent() )
1911 // getLastSyncEvent()->setReadOnly( true ); 1919 // getLastSyncEvent()->setReadOnly( true );
1912 mCalendar->reInitAlarmSettings(); 1920 mCalendar->reInitAlarmSettings();
1913 setSyncEventsReadOnly(); 1921 setSyncEventsReadOnly();
1914 updateUnmanagedViews(); 1922 updateUnmanagedViews();
1915 updateView(); 1923 updateView();
1916 if ( filename != MainWindow::defaultFileName() ) { 1924 if ( filename != MainWindow::defaultFileName() ) {
1917 saveCalendar( MainWindow::defaultFileName() ); 1925 saveCalendar( MainWindow::defaultFileName() );
1918 } else { 1926 } else {
1919 QFileInfo finf ( MainWindow::defaultFileName()); 1927 QFileInfo finf ( MainWindow::defaultFileName());
1920 if ( finf.exists() ) { 1928 if ( finf.exists() ) {
1921 setLoadedFileVersion( finf.lastModified () ); 1929 setLoadedFileVersion( finf.lastModified () );
1922 } 1930 }
1923 } 1931 }
1924 return true; 1932 return true;
1925 } else { 1933 } else {
1926 // while failing to load, the calendar object could 1934 // while failing to load, the calendar object could
1927 // have become partially populated. Clear it out. 1935 // have become partially populated. Clear it out.
1928 if ( !merge ) { 1936 if ( !merge ) {
1929 mCalendar->close(); 1937 mCalendar->close();
1930 mViewManager->setDocumentId( filename ); 1938 mViewManager->setDocumentId( filename );
1931 mDialogManager->setDocumentId( filename ); 1939 mDialogManager->setDocumentId( filename );
1932 mTodoList->setDocumentId( filename ); 1940 mTodoList->setDocumentId( filename );
1933 } 1941 }
1934 1942
1935 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1943 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1936 1944
1937 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1945 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1938 globalFlagBlockAgenda = 2; 1946 globalFlagBlockAgenda = 2;
1939 mCalendar->reInitAlarmSettings(); 1947 mCalendar->reInitAlarmSettings();
1940 setSyncEventsReadOnly(); 1948 setSyncEventsReadOnly();
1941 updateUnmanagedViews(); 1949 updateUnmanagedViews();
1942 updateView(); 1950 updateView();
1943 } 1951 }
1944 return false; 1952 return false;
1945} 1953}
1946void CalendarView::showOpenError() 1954void CalendarView::showOpenError()
1947{ 1955{
1948 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1956 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1949} 1957}
1950void CalendarView::setLoadedFileVersion(QDateTime dt) 1958void CalendarView::setLoadedFileVersion(QDateTime dt)
1951{ 1959{
1952 loadedFileVersion = dt; 1960 loadedFileVersion = dt;
1953} 1961}
1954bool CalendarView::checkFileChanged(QString fn) 1962bool CalendarView::checkFileChanged(QString fn)
1955{ 1963{
1956 QFileInfo finf ( fn ); 1964 QFileInfo finf ( fn );
1957 if ( !finf.exists() ) 1965 if ( !finf.exists() )
1958 return true; 1966 return true;
1959 QDateTime dt = finf.lastModified (); 1967 QDateTime dt = finf.lastModified ();
1960 if ( dt <= loadedFileVersion ) 1968 if ( dt <= loadedFileVersion )
1961 return false; 1969 return false;
1962 return true; 1970 return true;
1963 1971
1964} 1972}
1965void CalendarView::watchSavedFile() 1973void CalendarView::watchSavedFile()
1966{ 1974{
1967 QFileInfo finf ( MainWindow::defaultFileName()); 1975 QFileInfo finf ( MainWindow::defaultFileName());
1968 if ( !finf.exists() ) 1976 if ( !finf.exists() )
1969 return; 1977 return;
1970 QDateTime dt = finf.lastModified (); 1978 QDateTime dt = finf.lastModified ();
1971 if ( dt < loadedFileVersion ) { 1979 if ( dt < loadedFileVersion ) {
1972 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1980 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1973 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1981 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1974 return; 1982 return;
1975 } 1983 }
1976 loadedFileVersion = dt; 1984 loadedFileVersion = dt;
1977} 1985}
1978 1986
1979bool CalendarView::checkFileVersion(QString fn) 1987bool CalendarView::checkFileVersion(QString fn)
1980{ 1988{
1981 QFileInfo finf ( fn ); 1989 QFileInfo finf ( fn );
1982 if ( !finf.exists() ) 1990 if ( !finf.exists() )
1983 return true; 1991 return true;
1984 QDateTime dt = finf.lastModified (); 1992 QDateTime dt = finf.lastModified ();
1985 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1993 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1986 //qDebug("file on disk version %s",dt.toString().latin1()); 1994 //qDebug("file on disk version %s",dt.toString().latin1());
1987 if ( dt <= loadedFileVersion ) 1995 if ( dt <= loadedFileVersion )
1988 return true; 1996 return true;
1989 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1997 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1990 i18n("KO/Pi Warning"),i18n("Overwrite"), 1998 i18n("KO/Pi Warning"),i18n("Overwrite"),
1991 i18n("Sync+save")); 1999 i18n("Sync+save"));
1992 2000
1993 if ( km == KMessageBox::Cancel ) 2001 if ( km == KMessageBox::Cancel )
1994 return false; 2002 return false;
1995 if ( km == KMessageBox::Yes ) 2003 if ( km == KMessageBox::Yes )
1996 return true; 2004 return true;
1997 2005
1998 setSyncDevice("deleteaftersync" ); 2006 setSyncDevice("deleteaftersync" );
1999 mSyncManager->mAskForPreferences = true; 2007 mSyncManager->mAskForPreferences = true;
2000 mSyncManager->mSyncAlgoPrefs = 3; 2008 mSyncManager->mSyncAlgoPrefs = 3;
2001 mSyncManager->mWriteBackFile = false; 2009 mSyncManager->mWriteBackFile = false;
2002 mSyncManager->mWriteBackExistingOnly = false; 2010 mSyncManager->mWriteBackExistingOnly = false;
2003 mSyncManager->mShowSyncSummary = false; 2011 mSyncManager->mShowSyncSummary = false;
2004 syncCalendar( fn, 3 ); 2012 syncCalendar( fn, 3 );
2005 Event * e = getLastSyncEvent(); 2013 Event * e = getLastSyncEvent();
2006 if ( e ) 2014 if ( e )
2007 deleteEvent ( e ); 2015 deleteEvent ( e );
2008 updateView(); 2016 updateView();
2009 return true; 2017 return true;
2010} 2018}
2011bool CalendarView::saveCalendars() 2019bool CalendarView::saveCalendars()
2012{ 2020{
2013 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2021 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2014 KopiCalendarFile * cal = calendars.first(); 2022 KopiCalendarFile * cal = calendars.first();
2015 mCalendar->setDefaultCalendar( 1 ); 2023 mCalendar->setDefaultCalendar( 1 );
2016 mCalendar->setDefaultCalendarEnabledOnly(); 2024 mCalendar->setDefaultCalendarEnabledOnly();
2017 saveCalendar( MainWindow::defaultFileName() ); 2025 saveCalendar( MainWindow::defaultFileName() );
2018 cal = calendars.next(); 2026 cal = calendars.next();
2019 while ( cal ) { 2027 while ( cal ) {
2020 if ( !cal->isReadOnly ) { 2028 if ( !cal->isReadOnly ) {
2021 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2029 mCalendar->setDefaultCalendar( cal->mCalNumber );
2022 mCalendar->setDefaultCalendarEnabledOnly(); 2030 mCalendar->setDefaultCalendarEnabledOnly();
2023 saveCalendar( cal->mFileName ); 2031 saveCalendar( cal->mFileName );
2024 } 2032 }
2025 cal = calendars.next(); 2033 cal = calendars.next();
2026 } 2034 }
2027 restoreCalendarSettings(); 2035 restoreCalendarSettings();
2028} 2036}
2029bool CalendarView::saveCalendar( QString filename ) 2037bool CalendarView::saveCalendar( QString filename )
2030{ 2038{
2031 2039
2032 // Store back all unsaved data into calendar object 2040 // Store back all unsaved data into calendar object
2033 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2041 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2034 if ( mViewManager->currentView() ) 2042 if ( mViewManager->currentView() )
2035 mViewManager->currentView()->flushView(); 2043 mViewManager->currentView()->flushView();
2036 2044
2037 2045
2038 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2046 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2039 mStorage->setSaveFormat( new ICalFormat() ); 2047 mStorage->setSaveFormat( new ICalFormat() );
2040 mStorage->setFileName( filename ); 2048 mStorage->setFileName( filename );
2041 bool success; 2049 bool success;
2042 success = mStorage->save(); 2050 success = mStorage->save();
2043 if ( !success ) { 2051 if ( !success ) {
2044 return false; 2052 return false;
2045 } 2053 }
2046 if ( filename == MainWindow::defaultFileName() ) { 2054 if ( filename == MainWindow::defaultFileName() ) {
2047 setLoadedFileVersion( lfv ); 2055 setLoadedFileVersion( lfv );
2048 watchSavedFile(); 2056 watchSavedFile();
2049 } 2057 }
2050 return true; 2058 return true;
2051} 2059}
2052 2060
2053void CalendarView::closeCalendar() 2061void CalendarView::closeCalendar()
2054{ 2062{
2055 2063
2056 // child windows no longer valid 2064 // child windows no longer valid
2057 clearAllViews(); 2065 clearAllViews();
2058 emit closingDown(); 2066 emit closingDown();
2059 2067
2060 mCalendar->close(); 2068 mCalendar->close();
2061 setModified(false); 2069 setModified(false);
2062 updateView(); 2070 updateView();
2063} 2071}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 0144ba4..ec5b7ab 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -38,384 +38,385 @@
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <KDGanttMinimizeSplitter.h> 42#include <KDGanttMinimizeSplitter.h>
43 43
44#include <korganizer/calendarviewbase.h> 44#include <korganizer/calendarviewbase.h>
45 45
46#include <ksyncmanager.h> 46#include <ksyncmanager.h>
47//#include <koprefs.h> 47//#include <koprefs.h>
48 48
49class QWidgetStack; 49class QWidgetStack;
50class QSplitter; 50class QSplitter;
51class KopiCalendarFile; 51class KopiCalendarFile;
52class CalPrinter; 52class CalPrinter;
53class KOFilterView; 53class KOFilterView;
54class KOCalEditView; 54class KOCalEditView;
55class KOViewManager; 55class KOViewManager;
56class KODialogManager; 56class KODialogManager;
57class KOTodoView; 57class KOTodoView;
58class KDateNavigator; 58class KDateNavigator;
59class DateNavigatorContainer; 59class DateNavigatorContainer;
60class DateNavigator; 60class DateNavigator;
61class KOIncidenceEditor; 61class KOIncidenceEditor;
62class KDatePicker; 62class KDatePicker;
63class ResourceView; 63class ResourceView;
64class KOEventEditor; 64class KOEventEditor;
65class KOTodoEditor ; 65class KOTodoEditor ;
66class KOEventViewerDialog; 66class KOEventViewerDialog;
67class KOBeamPrefs; 67class KOBeamPrefs;
68class KSyncProfile; 68class KSyncProfile;
69class AlarmDialog; 69class AlarmDialog;
70class KCal::Attendee; 70class KCal::Attendee;
71 71
72namespace KCal { class FileStorage; } 72namespace KCal { class FileStorage; }
73 73
74using namespace KCal; 74using namespace KCal;
75 75
76/** 76/**
77 This is the main calendar widget. It provides the different vies on t he 77 This is the main calendar widget. It provides the different vies on t he
78 calendar data as well as the date navigator. It also handles synchronisation 78 calendar data as well as the date navigator. It also handles synchronisation
79 of the different views and controls the different dialogs like preferences, 79 of the different views and controls the different dialogs like preferences,
80 event editor, search dialog etc. 80 event editor, search dialog etc.
81 81
82 @short main calendar view widget 82 @short main calendar view widget
83 @author Cornelius Schumacher 83 @author Cornelius Schumacher
84*/ 84*/
85 85
86#include <qtextbrowser.h> 86#include <qtextbrowser.h>
87#include <qtextcodec.h> 87#include <qtextcodec.h>
88 88
89class MissedAlarmTextBrowser : public QTextBrowser { 89class MissedAlarmTextBrowser : public QTextBrowser {
90 Q_OBJECT 90 Q_OBJECT
91 public: 91 public:
92 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 92 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
93 ~MissedAlarmTextBrowser(); 93 ~MissedAlarmTextBrowser();
94 void setSource(const QString & n); 94 void setSource(const QString & n);
95 95
96 private: 96 private:
97 Incidence * getNextInc(QDateTime start ); 97 Incidence * getNextInc(QDateTime start );
98 QPtrList<Incidence> mAlarms; 98 QPtrList<Incidence> mAlarms;
99 signals: 99 signals:
100 void showIncidence( QString uid); 100 void showIncidence( QString uid);
101}; 101};
102 102
103 103
104class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 104class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 public: 107 public:
108 /** 108 /**
109 Constructs a new calendar view widget. 109 Constructs a new calendar view widget.
110 110
111 @param calendar calendar document 111 @param calendar calendar document
112 @param parent parent window 112 @param parent parent window
113 @param name Qt internal widget object name 113 @param name Qt internal widget object name
114 */ 114 */
115 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 115 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
116 const char *name = 0 ); 116 const char *name = 0 );
117 CalendarView( Calendar *calendar, QWidget *parent = 0, 117 CalendarView( Calendar *calendar, QWidget *parent = 0,
118 const char *name = 0 ); 118 const char *name = 0 );
119 virtual ~CalendarView(); 119 virtual ~CalendarView();
120 120
121 Calendar *calendar() { return mCalendar; } 121 Calendar *calendar() { return mCalendar; }
122 122
123 KOViewManager *viewManager(); 123 KOViewManager *viewManager();
124 KODialogManager *dialogManager(); 124 KODialogManager *dialogManager();
125 125
126 QDate startDate(); 126 QDate startDate();
127 QDate endDate(); 127 QDate endDate();
128 128
129 QWidgetStack *viewStack(); 129 QWidgetStack *viewStack();
130 QWidget *leftFrame(); 130 QWidget *leftFrame();
131 131
132 DateNavigator *dateNavigator(); 132 DateNavigator *dateNavigator();
133 KDateNavigator *dateNavigatorWidget(); 133 KDateNavigator *dateNavigatorWidget();
134 134
135 void addView(KOrg::BaseView *); 135 void addView(KOrg::BaseView *);
136 void showView(KOrg::BaseView *); 136 void showView(KOrg::BaseView *);
137 KOEventViewerDialog* getEventViewerDialog(); 137 KOEventViewerDialog* getEventViewerDialog();
138 Incidence *currentSelection(); 138 Incidence *currentSelection();
139 139
140 signals: 140 signals:
141 void save (); 141 void save ();
142 void saveStopTimer (); 142 void saveStopTimer ();
143 void tempDisableBR(bool); 143 void tempDisableBR(bool);
144 /** This todo has been modified */ 144 /** This todo has been modified */
145 void todoModified(Todo *, int); 145 void todoModified(Todo *, int);
146 146
147 /** when change is made to options dialog, the topwidget will catch this 147 /** when change is made to options dialog, the topwidget will catch this
148 * and emit this signal which notifies all widgets which have registered 148 * and emit this signal which notifies all widgets which have registered
149 * for notification to update their settings. */ 149 * for notification to update their settings. */
150 void configChanged(); 150 void configChanged();
151 /** emitted when the topwidget is closing down, so that any attached 151 /** emitted when the topwidget is closing down, so that any attached
152 child windows can also close. */ 152 child windows can also close. */
153 void closingDown(); 153 void closingDown();
154 /** emitted right before we die */ 154 /** emitted right before we die */
155 void closed(QWidget *); 155 void closed(QWidget *);
156 156
157 /** Emitted when state of modified flag changes */ 157 /** Emitted when state of modified flag changes */
158 void modifiedChanged(bool); 158 void modifiedChanged(bool);
159 void signalmodified(); 159 void signalmodified();
160 160
161 /** Emitted when state of read-only flag changes */ 161 /** Emitted when state of read-only flag changes */
162 void readOnlyChanged(bool); 162 void readOnlyChanged(bool);
163 163
164 /** Emitted when the unit of navigation changes */ 164 /** Emitted when the unit of navigation changes */
165 void changeNavStringPrev(const QString &); 165 void changeNavStringPrev(const QString &);
166 void changeNavStringNext(const QString &); 166 void changeNavStringNext(const QString &);
167 167
168 /** Emitted when state of events selection has changed and user is organizer*/ 168 /** Emitted when state of events selection has changed and user is organizer*/
169 void organizerEventsSelected(bool); 169 void organizerEventsSelected(bool);
170 /** Emitted when state of events selection has changed and user is attendee*/ 170 /** Emitted when state of events selection has changed and user is attendee*/
171 void groupEventsSelected(bool); 171 void groupEventsSelected(bool);
172 /** 172 /**
173 Emitted when an incidence gets selected. If the selection is cleared the 173 Emitted when an incidence gets selected. If the selection is cleared the
174 signal is emitted with 0 as argument. 174 signal is emitted with 0 as argument.
175 */ 175 */
176 void incidenceSelected( Incidence * ); 176 void incidenceSelected( Incidence * );
177 /** Emitted, when a todoitem is selected or deselected. */ 177 /** Emitted, when a todoitem is selected or deselected. */
178 void todoSelected( bool ); 178 void todoSelected( bool );
179 179
180 /** 180 /**
181 Emitted, when clipboard content changes. Parameter indicates if paste 181 Emitted, when clipboard content changes. Parameter indicates if paste
182 is possible or not. 182 is possible or not.
183 */ 183 */
184 void pasteEnabled(bool); 184 void pasteEnabled(bool);
185 185
186 /** Emitted, when the number of incoming messages has changed. */ 186 /** Emitted, when the number of incoming messages has changed. */
187 void numIncomingChanged(int); 187 void numIncomingChanged(int);
188 188
189 /** Emitted, when the number of outgoing messages has changed. */ 189 /** Emitted, when the number of outgoing messages has changed. */
190 void numOutgoingChanged(int); 190 void numOutgoingChanged(int);
191 191
192 /** Send status message, which can e.g. be displayed in the status bar. */ 192 /** Send status message, which can e.g. be displayed in the status bar. */
193 void statusMessage(const QString &); 193 void statusMessage(const QString &);
194 194
195 void calendarViewExpanded( bool ); 195 void calendarViewExpanded( bool );
196 void updateSearchDialog(); 196 void updateSearchDialog();
197 197
198 198
199 public slots: 199 public slots:
200 void checkAlarms(); 200 void checkAlarms();
201 void slotprintSelInc(); 201 void slotprintSelInc();
202 void showNextAlarms(); 202 void showNextAlarms();
203 void showOpenError(); 203 void showOpenError();
204 void watchSavedFile(); 204 void watchSavedFile();
205 void recheckTimerAlarm(); 205 void recheckTimerAlarm();
206 void checkNextTimerAlarm(); 206 void checkNextTimerAlarm();
207 void addAlarm(const QDateTime &qdt, const QString &noti ); 207 void addAlarm(const QDateTime &qdt, const QString &noti );
208 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 208 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
209 void removeAlarm(const QDateTime &qdt, const QString &noti ); 209 void removeAlarm(const QDateTime &qdt, const QString &noti );
210 210
211 /** options dialog made a changed to the configuration. we catch this 211 /** options dialog made a changed to the configuration. we catch this
212 * and notify all widgets which need to update their configuration. */ 212 * and notify all widgets which need to update their configuration. */
213 void updateConfig(); 213 void updateConfig();
214 214
215 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 215 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
216 const QStringList& anniversaryList, const QStringList& realNameList, 216 const QStringList& anniversaryList, const QStringList& realNameList,
217 const QStringList& emailList, const QStringList& assembledNameList, 217 const QStringList& emailList, const QStringList& assembledNameList,
218 const QStringList& uidList); 218 const QStringList& uidList);
219 219
220 /** 220 /**
221 Load calendar from file \a filename. If \a merge is true, load 221 Load calendar from file \a filename. If \a merge is true, load
222 calendar into existing one, if it is false, clear calendar, before 222 calendar into existing one, if it is false, clear calendar, before
223 loading. Return true, if calendar could be successfully loaded. 223 loading. Return true, if calendar could be successfully loaded.
224 */ 224 */
225 bool openCalendar(QString filename, bool merge=false); 225 bool openCalendar(QString filename, bool merge=false);
226 bool loadCalendars(); 226 bool loadCalendars();
227 bool saveCalendars(); 227 bool saveCalendars();
228 bool restoreCalendarSettings(); 228 bool restoreCalendarSettings();
229 bool addCalendar( KopiCalendarFile * ); 229 bool addCalendar( KopiCalendarFile * );
230 void addCalendarId( int id );
230 bool syncCalendar(QString filename,int mode = 0 ); 231 bool syncCalendar(QString filename,int mode = 0 );
231 232
232 /** 233 /**
233 Save calendar data to file. Return true if calendar could be 234 Save calendar data to file. Return true if calendar could be
234 successfully saved. 235 successfully saved.
235 */ 236 */
236 bool saveCalendar(QString filename); 237 bool saveCalendar(QString filename);
237 238
238 /** 239 /**
239 Close calendar. Clear calendar data and reset views to display an empty 240 Close calendar. Clear calendar data and reset views to display an empty
240 calendar. 241 calendar.
241 */ 242 */
242 void closeCalendar(); 243 void closeCalendar();
243 244
244 /** Archive old events of calendar */ 245 /** Archive old events of calendar */
245 void archiveCalendar(); 246 void archiveCalendar();
246 247
247 void showIncidence(); 248 void showIncidence();
248 void editIncidence(); 249 void editIncidence();
249 void editIncidenceDescription(); 250 void editIncidenceDescription();
250 void deleteIncidence(); 251 void deleteIncidence();
251 void cloneIncidence(); 252 void cloneIncidence();
252 void moveIncidence(); 253 void moveIncidence();
253 void beamIncidence(); 254 void beamIncidence();
254 void toggleCancelIncidence(); 255 void toggleCancelIncidence();
255 256
256 /** create an editeventwin with supplied date/time, and if bool is true, 257 /** create an editeventwin with supplied date/time, and if bool is true,
257 * make the event take all day. */ 258 * make the event take all day. */
258 void newEvent(QDateTime, QDateTime, bool allDay ); 259 void newEvent(QDateTime, QDateTime, bool allDay );
259 void newEvent(QDateTime, QDateTime); 260 void newEvent(QDateTime, QDateTime);
260 void newEvent(QDateTime fh); 261 void newEvent(QDateTime fh);
261 void newEvent(QDate dt); 262 void newEvent(QDate dt);
262 /** create new event without having a date hint. Takes current date as 263 /** create new event without having a date hint. Takes current date as
263 default hint. */ 264 default hint. */
264 void newEvent(); 265 void newEvent();
265 void newFloatingEvent(); 266 void newFloatingEvent();
266 267
267 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 268 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
268 void showIncidence(Incidence *); 269 void showIncidence(Incidence *);
269 void showIncidence(QString uid); 270 void showIncidence(QString uid);
270 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 271 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
271 void editIncidence(Incidence *); 272 void editIncidence(Incidence *);
272 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 273 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
273 void deleteIncidence(Incidence *); 274 void deleteIncidence(Incidence *);
274 void cloneIncidence(Incidence *); 275 void cloneIncidence(Incidence *);
275 void cancelIncidence(Incidence *); 276 void cancelIncidence(Incidence *);
276 /** Create an editor for the supplied event. */ 277 /** Create an editor for the supplied event. */
277 void editEvent(Event *); 278 void editEvent(Event *);
278 /** Delete the supplied event. */ 279 /** Delete the supplied event. */
279 void deleteEvent(Event *); 280 void deleteEvent(Event *);
280 /** Delete the event with the given unique ID. Returns false, if event wasn't 281 /** Delete the event with the given unique ID. Returns false, if event wasn't
281 found. */ 282 found. */
282 bool deleteEvent(const QString &uid); 283 bool deleteEvent(const QString &uid);
283 /** Create a read-only viewer dialog for the supplied event. */ 284 /** Create a read-only viewer dialog for the supplied event. */
284 void showEvent(Event *); 285 void showEvent(Event *);
285 286
286 void editJournal(Journal *); 287 void editJournal(Journal *);
287 void showJournal(Journal *); 288 void showJournal(Journal *);
288 void deleteJournal(Journal *); 289 void deleteJournal(Journal *);
289 /** Create an editor dialog for a todo */ 290 /** Create an editor dialog for a todo */
290 void editTodo(Todo *); 291 void editTodo(Todo *);
291 /** Create a read-only viewer dialog for the supplied todo */ 292 /** Create a read-only viewer dialog for the supplied todo */
292 void showTodo(Todo *); 293 void showTodo(Todo *);
293 /** create new todo */ 294 /** create new todo */
294 void newTodo(); 295 void newTodo();
295 void newTodoDateTime(QDateTime, bool allday); 296 void newTodoDateTime(QDateTime, bool allday);
296 /** create new todo with a parent todo */ 297 /** create new todo with a parent todo */
297 void newSubTodo(); 298 void newSubTodo();
298 /** create new todo with a parent todo */ 299 /** create new todo with a parent todo */
299 void newSubTodo(Todo *); 300 void newSubTodo(Todo *);
300 /** Delete todo */ 301 /** Delete todo */
301 void deleteTodo(Todo *); 302 void deleteTodo(Todo *);
302 303
303 304
304 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 305 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
305 * emitted as result. */ 306 * emitted as result. */
306 void checkClipboard(); 307 void checkClipboard();
307 308
308 /** using the KConfig associated with the kapp variable, read in the 309 /** using the KConfig associated with the kapp variable, read in the
309 * settings from the config file. 310 * settings from the config file.
310 */ 311 */
311 void readSettings(); 312 void readSettings();
312 313
313 /** write current state to config file. */ 314 /** write current state to config file. */
314 void writeSettings(); 315 void writeSettings();
315 316
316 /** read settings for calendar filters */ 317 /** read settings for calendar filters */
317 void readFilterSettings(KConfig *config); 318 void readFilterSettings(KConfig *config);
318 319
319 /** write settings for calendar filters */ 320 /** write settings for calendar filters */
320 void writeFilterSettings(KConfig *config); 321 void writeFilterSettings(KConfig *config);
321 322
322 /** passes on the message that an event has changed to the currently 323 /** passes on the message that an event has changed to the currently
323 * activated view so that it can make appropriate display changes. */ 324 * activated view so that it can make appropriate display changes. */
324 void changeEventDisplay(Event *, int); 325 void changeEventDisplay(Event *, int);
325 void changeIncidenceDisplay(Incidence *, int); 326 void changeIncidenceDisplay(Incidence *, int);
326 void changeTodoDisplay(Todo *, int); 327 void changeTodoDisplay(Todo *, int);
327 328
328 void eventAdded(Event *); 329 void eventAdded(Event *);
329 void eventChanged(Event *); 330 void eventChanged(Event *);
330 void eventToBeDeleted(Event *); 331 void eventToBeDeleted(Event *);
331 void eventDeleted(); 332 void eventDeleted();
332 333
333 void todoAdded(Todo *); 334 void todoAdded(Todo *);
334 void todoChanged(Todo *); 335 void todoChanged(Todo *);
335 void todoToBeDeleted(Todo *); 336 void todoToBeDeleted(Todo *);
336 void todoDeleted(); 337 void todoDeleted();
337 338
338 void updateView(const QDate &start, const QDate &end); 339 void updateView(const QDate &start, const QDate &end);
339 void updateView(); 340 void updateView();
340 void clearAllViews(); 341 void clearAllViews();
341 342
342 /** Full update of visible todo views */ 343 /** Full update of visible todo views */
343 void updateTodoViews(); 344 void updateTodoViews();
344 345
345 void updateUnmanagedViews(); 346 void updateUnmanagedViews();
346 347
347 /** cut the current appointment to the clipboard */ 348 /** cut the current appointment to the clipboard */
348 void edit_cut(); 349 void edit_cut();
349 350
350 /** copy the current appointment(s) to the clipboard */ 351 /** copy the current appointment(s) to the clipboard */
351 void edit_copy(); 352 void edit_copy();
352 353
353 /** paste the current vobject(s) in the clipboard buffer into calendar */ 354 /** paste the current vobject(s) in the clipboard buffer into calendar */
354 void edit_paste(); 355 void edit_paste();
355 356
356 /** edit viewing and configuration options. */ 357 /** edit viewing and configuration options. */
357 void edit_options(); 358 void edit_options();
358 void edit_global_options(); 359 void edit_global_options();
359 /** 360 /**
360 Functions for printing, previewing a print, and setting up printing 361 Functions for printing, previewing a print, and setting up printing
361 parameters. 362 parameters.
362 */ 363 */
363 void print(); 364 void print();
364 void printSetup(); 365 void printSetup();
365 void printPreview(); 366 void printPreview();
366 367
367 /** Export as iCalendar file */ 368 /** Export as iCalendar file */
368 void exportICalendar(); 369 void exportICalendar();
369 370
370 /** Export as vCalendar file */ 371 /** Export as vCalendar file */
371 bool exportVCalendar( QString fn); 372 bool exportVCalendar( QString fn);
372 373
373 /** pop up a dialog to show an existing appointment. */ 374 /** pop up a dialog to show an existing appointment. */
374 void appointment_show(); 375 void appointment_show();
375 /** 376 /**
376 * pop up an Appointment Dialog to edit an existing appointment.Get 377 * pop up an Appointment Dialog to edit an existing appointment.Get
377 * information on the appointment from the list of unique IDs that is 378 * information on the appointment from the list of unique IDs that is
378 * currently in the View, called currIds. 379 * currently in the View, called currIds.
379 */ 380 */
380 void appointment_edit(); 381 void appointment_edit();
381 /** 382 /**
382 * pop up dialog confirming deletion of currently selected event in the 383 * pop up dialog confirming deletion of currently selected event in the
383 * View. 384 * View.
384 */ 385 */
385 void appointment_delete(); 386 void appointment_delete();
386 387
387 /** mails the currently selected event to a particular user as a vCalendar 388 /** mails the currently selected event to a particular user as a vCalendar
388 attachment. */ 389 attachment. */
389 void action_mail(); 390 void action_mail();
390 391
391 /* frees a subtodo from it's relation */ 392 /* frees a subtodo from it's relation */
392 void todo_unsub( Todo * ); 393 void todo_unsub( Todo * );
393 void todo_resub( Todo * parent, Todo * sub ); 394 void todo_resub( Todo * parent, Todo * sub );
394 395
395 /** Take ownership of selected event. */ 396 /** Take ownership of selected event. */
396 void takeOverEvent(); 397 void takeOverEvent();
397 398
398 /** Take ownership of all events in calendar. */ 399 /** Take ownership of all events in calendar. */
399 void takeOverCalendar(); 400 void takeOverCalendar();
400 401
401 /** query whether or not the calendar is "dirty". */ 402 /** query whether or not the calendar is "dirty". */
402 bool isModified(); 403 bool isModified();
403 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 404 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
404 void setModified(bool modified=true); 405 void setModified(bool modified=true);
405 406
406 /** query if the calendar is read-only. */ 407 /** query if the calendar is read-only. */
407 bool isReadOnly(); 408 bool isReadOnly();
408 /** set state of calendar to read-only */ 409 /** set state of calendar to read-only */
409 void setReadOnly(bool readOnly=true); 410 void setReadOnly(bool readOnly=true);
410 411
411 void eventUpdated(Incidence *); 412 void eventUpdated(Incidence *);
412 413
413 /* iTIP scheduling actions */ 414 /* iTIP scheduling actions */
414 void schedule_publish(Incidence *incidence = 0); 415 void schedule_publish(Incidence *incidence = 0);
415 void schedule_request(Incidence *incidence = 0); 416 void schedule_request(Incidence *incidence = 0);
416 void schedule_refresh(Incidence *incidence = 0); 417 void schedule_refresh(Incidence *incidence = 0);
417 void schedule_cancel(Incidence *incidence = 0); 418 void schedule_cancel(Incidence *incidence = 0);
418 void schedule_add(Incidence *incidence = 0); 419 void schedule_add(Incidence *incidence = 0);
419 void schedule_reply(Incidence *incidence = 0); 420 void schedule_reply(Incidence *incidence = 0);
420 void schedule_counter(Incidence *incidence = 0); 421 void schedule_counter(Incidence *incidence = 0);
421 void schedule_declinecounter(Incidence *incidence = 0); 422 void schedule_declinecounter(Incidence *incidence = 0);
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 5a3c4d2..c7bc6eb 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,396 +1,396 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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->typeID() == todoID ) && 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->typeID() == todoID ) &&((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()->defaultColor( incidence->calID() );
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((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() && mIncidence->alarmEnabled()) {
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;
224 } 224 }
225 if (mIncidence->isReadOnly()) { 225 if (mIncidence->isReadOnly()) {
226 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 226 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
227 if ( horLayout ) 227 if ( horLayout )
228 ++xOff; 228 ++xOff;
229 else 229 else
230 ++yOff; 230 ++yOff;
231 } 231 }
232 232
233 if (mIncidence->attendeeCount()>0) { 233 if (mIncidence->attendeeCount()>0) {
234 234
235 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 235 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
236 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 236 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
237 if ( horLayout ) 237 if ( horLayout )
238 ++xOff; 238 ++xOff;
239 else 239 else
240 ++yOff; 240 ++yOff;
241 } else { 241 } else {
242 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 242 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
243 if (me!=0) { 243 if (me!=0) {
244 244
245 245
246 } else { 246 } else {
247 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 247 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
248 if ( horLayout ) 248 if ( horLayout )
249 ++xOff; 249 ++xOff;
250 else 250 else
251 ++yOff; 251 ++yOff;
252 252
253 } 253 }
254 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 254 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
255 if ( horLayout ) 255 if ( horLayout )
256 ++xOff; 256 ++xOff;
257 else 257 else
258 ++yOff; 258 ++yOff;
259 259
260 } 260 }
261 261
262 } 262 }
263 return ( yOff || xOff ); 263 return ( yOff || xOff );
264} 264}
265 265
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->typeID() == todoID ) { 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
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 29a4393..2b16347 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,383 +1,387 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30 30
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h" 35#include "koprefs.h"
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h> 38#include <kcolorbutton.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41 41
42#include <kurlrequester.h> 42#include <kurlrequester.h>
43#include <klineedit.h> 43#include <klineedit.h>
44 44
45class KONewCalPrefs : public QDialog 45class KONewCalPrefs : public QDialog
46{ 46{
47 public: 47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true ) 49 QDialog( parent, name, true )
50 { 50 {
51 setCaption( i18n("Add new Calendar") ); 51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this ); 52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 ); 53 lay->setSpacing( 3 );
54 lay->setMargin( 3 ); 54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab ); 56 lay->addWidget( lab );
57 nameE = new KLineEdit( this ); 57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE ); 58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); 59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab ); 60 lay->addWidget( lab );
61 url = new KURLRequester ( this ); 61 url = new KURLRequester ( this );
62 lay->addWidget( url ); 62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this ); 63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok ); 64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel ); 66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 //resize( 200, 200 ); 69 //resize( 200, 200 );
70 } 70 }
71 71
72 QString calName() { return nameE->text(); } 72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); } 73 QString calFileName() { return url->url(); }
74private: 74private:
75 KLineEdit* nameE; 75 KLineEdit* nameE;
76 KURLRequester *url; 76 KURLRequester *url;
77}; 77};
78 78
79 79
80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
81 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
82 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
83{ 83{
84 mFilters = filterList; 84 mFilters = filterList;
85 85
86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
89} 89}
90 90
91KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
92{ 92{
93 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
94} 94}
95 95
96bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
97{ 97{
98 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
99} 99}
100 100
101void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
102{ 102{
103 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
104 emit filterChanged(); 104 emit filterChanged();
105} 105}
106 106
107 107
108void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
109{ 109{
110 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
111 111
112 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
113 while(filter) { 113 while(filter) {
114 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
115 filter = mFilters->next(); 115 filter = mFilters->next();
116 } 116 }
117} 117}
118 118
119CalFilter *KOFilterView::selectedFilter() 119CalFilter *KOFilterView::selectedFilter()
120{ 120{
121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
122 return f; 122 return f;
123} 123}
124 124
125void KOFilterView::setSelectedFilter(QString filterName) 125void KOFilterView::setSelectedFilter(QString filterName)
126{ 126{
127 int filter_num = mSelectionCombo->count(); 127 int filter_num = mSelectionCombo->count();
128 int i; 128 int i;
129 for (i=0;i<filter_num;i++) { 129 for (i=0;i<filter_num;i++) {
130 if (mSelectionCombo->text(i)==filterName) 130 if (mSelectionCombo->text(i)==filterName)
131 mSelectionCombo->setCurrentItem(i); 131 mSelectionCombo->setCurrentItem(i);
132 } 132 }
133 emit filterChanged(); 133 emit filterChanged();
134} 134}
135void KOFilterView::setSelectedFilter( int fil ) 135void KOFilterView::setSelectedFilter( int fil )
136{ 136{
137 if ( fil >= mSelectionCombo->count() ) 137 if ( fil >= mSelectionCombo->count() )
138 return; 138 return;
139 mSelectionCombo->setCurrentItem( fil ); 139 mSelectionCombo->setCurrentItem( fil );
140 emit filterChanged(); 140 emit filterChanged();
141} 141}
142 142
143 143
144 144
145KOCalEditView::KOCalEditView(QWidget* parent, 145KOCalEditView::KOCalEditView(QWidget* parent,
146 const char* name ) 146 const char* name )
147 : QWidget(parent,name) 147 : QWidget(parent,name)
148{ 148{
149 mw = 0; 149 mw = 0;
150 ml = new QVBoxLayout ( this ); 150 ml = new QVBoxLayout ( this );
151} 151}
152 152
153KOCalEditView::~KOCalEditView() 153KOCalEditView::~KOCalEditView()
154{ 154{
155 // no need to delete child widgets, Qt does it all for us 155 // no need to delete child widgets, Qt does it all for us
156} 156}
157void KOCalEditView::selectCal(int id ,bool b) 157void KOCalEditView::selectCal(int id ,bool b)
158{ 158{
159 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 159 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
160 emit calendarEnabled ( id, b ); 160 emit calendarEnabled ( id, b );
161 emit needsUpdate();
161 162
162} 163}
163void KOCalEditView::selectStdCal( int id, bool b ) 164void KOCalEditView::selectStdCal( int id, bool b )
164{ 165{
165 166
166 if ( !b ) { 167 if ( !b ) {
167 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 168 KOCalCheckButton* it = (KOCalCheckButton*) sender();
168 if ( it ) { 169 if ( it ) {
169 it->blockSignals( true ); 170 it->blockSignals( true );
170 it->setChecked( true ); 171 it->setChecked( true );
171 it->blockSignals( false ); 172 it->blockSignals( false );
172 return; 173 return;
173 } 174 }
174 return; 175 return;
175 } 176 }
176 KOCalCheckButton* sen = (KOCalCheckButton*) sender(); 177 KOCalCheckButton* sen = (KOCalCheckButton*) sender();
177 KOCalCheckButton* it = mStdandardB.first(); 178 KOCalCheckButton* it = mStdandardB.first();
178 while ( it ) { 179 while ( it ) {
179 if ( it->isChecked() ) { 180 if ( it->isChecked() ) {
180 if ( it != sen ) { 181 if ( it != sen ) {
181 it->blockSignals( true ); 182 it->blockSignals( true );
182 it->setChecked( false ); 183 it->setChecked( false );
183 it->blockSignals( false ); 184 it->blockSignals( false );
184 break; 185 break;
185 } 186 }
186 } 187 }
187 it = mStdandardB.next(); 188 it = mStdandardB.next();
188 } 189 }
189 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 190 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
190 while ( kkf ) { 191 while ( kkf ) {
191 kkf->isStandard = false; 192 kkf->isStandard = false;
192 kkf = KOPrefs::instance()->mCalendars.next(); 193 kkf = KOPrefs::instance()->mCalendars.next();
193 } 194 }
194 KOPrefs::instance()->getCalendar( id )->isStandard = true; 195 KOPrefs::instance()->getCalendar( id )->isStandard = true;
195 emit setCalendarDefault ( id ); 196 emit setCalendarDefault ( id );
196} 197}
197 198
198void KOCalEditView::selectCalAlarm(int id ,bool b ) 199void KOCalEditView::selectCalAlarm(int id ,bool b )
199{ 200{
200 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 201 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
201 emit alarmEnabled ( id , b ); 202 emit alarmEnabled ( id , b );
203 emit needsUpdate();
202} 204}
203void KOCalEditView::selectReadOnly(int id ,bool b ) 205void KOCalEditView::selectReadOnly(int id ,bool b )
204{ 206{
205 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 207 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
206 emit calendarReadonly ( id , b ); 208 emit calendarReadonly ( id , b );
209 emit needsUpdate();
207 210
208} 211}
209void KOCalEditView::setColor( const QColor& c, int id ) 212void KOCalEditView::setColor( const QColor& c, int id )
210{ 213{
211 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 214 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
215 emit needsUpdate();
212} 216}
213void KOCalEditView::deleteCal( int id ) 217void KOCalEditView::deleteCal( int id )
214{ 218{
215 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 219 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
216 QString name = kkf->mName; 220 QString name = kkf->mName;
217 QString file = kkf->mFileName; 221 QString file = kkf->mFileName;
218 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 222 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
219 emit removeCalendar ( id ); 223 emit removeCalendar ( id );
220 KOPrefs::instance()->mCalendars.remove ( kkf ); 224 KOPrefs::instance()->mCalendars.remove ( kkf );
221 readConfig(); 225 readConfig();
222} 226}
223void KOCalEditView::infoCal( int id ) 227void KOCalEditView::infoCal( int id )
224{ 228{
225 QString name = KOPrefs::instance()->getCalendar( id )->mName; 229 QString name = KOPrefs::instance()->getCalendar( id )->mName;
226 QString file = KOPrefs::instance()->getCalendar( id )->mFileName; 230 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
227 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 231 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
228} 232}
229void KOCalEditView::readConfig() 233void KOCalEditView::readConfig()
230{ 234{
231 235
232 mStdandardB.clear(); 236 mStdandardB.clear();
233 mEnabledB.clear(); 237 mEnabledB.clear();
234 mAlarmB.clear(); 238 mAlarmB.clear();
235 mROB.clear(); 239 mROB.clear();
236 240
237 if ( mw ) delete mw; 241 if ( mw ) delete mw;
238 mw = new QWidget ( this ); 242 mw = new QWidget ( this );
239 ml->addWidget ( mw ); 243 ml->addWidget ( mw );
240 244
241 mainLayout = new QGridLayout ( mw , 2, 8 ); 245 mainLayout = new QGridLayout ( mw , 2, 8 );
242 //mainLayout->setSpacing( 3 ); 246 //mainLayout->setSpacing( 3 );
243 QPushButton * addBut = new QPushButton ( mw ); 247 QPushButton * addBut = new QPushButton ( mw );
244 mainLayout->addWidget( addBut,0,0 ); 248 mainLayout->addWidget( addBut,0,0 );
245 addBut->setPixmap ( SmallIcon("plus")); 249 addBut->setPixmap ( SmallIcon("plus"));
246 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 250 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
247 addBut->setMaximumWidth( addBut->sizeHint().height() ); 251 addBut->setMaximumWidth( addBut->sizeHint().height() );
248 252
249 addBut = new QPushButton ( mw ); 253 addBut = new QPushButton ( mw );
250 mainLayout->addWidget( addBut,0,1 ); 254 mainLayout->addWidget( addBut,0,1 );
251 addBut->setPixmap ( SmallIcon("eye")); 255 addBut->setPixmap ( SmallIcon("eye"));
252 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 256 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
253 addBut->setMaximumWidth( addBut->sizeHint().height() ); 257 addBut->setMaximumWidth( addBut->sizeHint().height() );
254 258
255 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); 259 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw );
256 mainLayout->addWidget( lab,0,2 ); 260 mainLayout->addWidget( lab,0,2 );
257 261
258 addBut = new QPushButton ( mw ); 262 addBut = new QPushButton ( mw );
259 mainLayout->addWidget( addBut,0,3 ); 263 mainLayout->addWidget( addBut,0,3 );
260 addBut->setPixmap ( SmallIcon("bell")); 264 addBut->setPixmap ( SmallIcon("bell"));
261 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 265 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
262 addBut->setMaximumWidth( addBut->sizeHint().height() ); 266 addBut->setMaximumWidth( addBut->sizeHint().height() );
263 267
264 addBut = new QPushButton ( mw ); 268 addBut = new QPushButton ( mw );
265 mainLayout->addWidget( addBut,0,4 ); 269 mainLayout->addWidget( addBut,0,4 );
266 addBut->setPixmap ( SmallIcon("pencil")); 270 addBut->setPixmap ( SmallIcon("pencil"));
267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 271 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
268 addBut->setMaximumWidth( addBut->sizeHint().height() ); 272 addBut->setMaximumWidth( addBut->sizeHint().height() );
269 273
270 lab = new QLabel ( i18n(" Color "), mw ); 274 lab = new QLabel ( i18n(" Color "), mw );
271 mainLayout->addWidget( lab,0,5 ); 275 mainLayout->addWidget( lab,0,5 );
272#if 0 276#if 0
273 addBut = new QPushButton ( mw ); 277 addBut = new QPushButton ( mw );
274 mainLayout->addWidget( addBut,0,6 ); 278 mainLayout->addWidget( addBut,0,6 );
275 addBut->setPixmap ( SmallIcon("minus")); 279 addBut->setPixmap ( SmallIcon("minus"));
276 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 280 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
277 addBut->setMaximumWidth( addBut->sizeHint().height() ); 281 addBut->setMaximumWidth( addBut->sizeHint().height() );
278#endif 282#endif
279 283
280 284
281 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 285 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
282 int row = 1; 286 int row = 1;
283 while ( kkf ) { 287 while ( kkf ) {
284 288
285 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 289 KOCalCheckButton* cb = new KOCalCheckButton( mw );
286 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 290 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
287 cb->setChecked( kkf->isStandard ); 291 cb->setChecked( kkf->isStandard );
288 cb->setNum( kkf->mCalNumber ); 292 cb->setNum( kkf->mCalNumber );
289 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 293 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
290 cb = new KOCalCheckButton( mw ); 294 cb = new KOCalCheckButton( mw );
291 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); 295 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
292 cb->setChecked( kkf->isEnabled ); 296 cb->setChecked( kkf->isEnabled );
293 cb->setNum( kkf->mCalNumber ); 297 cb->setNum( kkf->mCalNumber );
294 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 298 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
295 KOCalButton* name = new KOCalButton( mw ); 299 KOCalButton* name = new KOCalButton( mw );
296 name->setNum( kkf->mCalNumber ); 300 name->setNum( kkf->mCalNumber );
297 name->setText( kkf->mName ); 301 name->setText( kkf->mName );
298 mainLayout->addWidget( name,row,2 ); 302 mainLayout->addWidget( name,row,2 );
299 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 303 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
300 cb = new KOCalCheckButton( mw ); 304 cb = new KOCalCheckButton( mw );
301 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); 305 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
302 cb->setChecked( kkf->isAlarmEnabled ); 306 cb->setChecked( kkf->isAlarmEnabled );
303 cb->setNum( kkf->mCalNumber ); 307 cb->setNum( kkf->mCalNumber );
304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 308 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
305 cb = new KOCalCheckButton( mw ); 309 cb = new KOCalCheckButton( mw );
306 mainLayout->addWidget( cb,row,4 );mROB.append( cb ); 310 mainLayout->addWidget( cb,row,4 );mROB.append( cb );
307 cb->setChecked( kkf->isReadOnly ); 311 cb->setChecked( kkf->isReadOnly );
308 cb->setNum( kkf->mCalNumber ); 312 cb->setNum( kkf->mCalNumber );
309 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
310 KColorButton *colb = new KColorButton( mw ); 314 KColorButton *colb = new KColorButton( mw );
311 mainLayout->addWidget( colb,row,5 ); 315 mainLayout->addWidget( colb,row,5 );
312 colb->setID( kkf->mCalNumber ); 316 colb->setID( kkf->mCalNumber );
313 colb->setColor( kkf->mDefaultColor ); 317 colb->setColor( kkf->mDefaultColor );
314 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 318 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
315 if ( row > 1) { 319 if ( row > 1) {
316 KOCalButton* calb = new KOCalButton( mw ); 320 KOCalButton* calb = new KOCalButton( mw );
317 mainLayout->addWidget( calb,row,6 ); 321 mainLayout->addWidget( calb,row,6 );
318 calb->setNum( kkf->mCalNumber ); 322 calb->setNum( kkf->mCalNumber );
319 calb->setPixmap ( SmallIcon("minus")); 323 calb->setPixmap ( SmallIcon("minus"));
320 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 324 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
321 int hei = calb->sizeHint().height(); 325 int hei = calb->sizeHint().height();
322 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 326 //calb->setMaximumSize( hei*9/10, hei*9/10 );
323 } 327 }
324 ++row; 328 ++row;
325 kkf = KOPrefs::instance()->mCalendars.next(); 329 kkf = KOPrefs::instance()->mCalendars.next();
326 } 330 }
327 lab = new QLabel ( "", mw ); 331 lab = new QLabel ( "", mw );
328 mainLayout->addWidget( lab,row,0 ); 332 mainLayout->addWidget( lab,row,0 );
329 mw->show(); 333 mw->show();
330 334
331} 335}
332void KOCalEditView::addCal() 336void KOCalEditView::addCal()
333{ 337{
334 qDebug("addcal "); 338 qDebug("addcal ");
335 KONewCalPrefs prefs ( this ); 339 KONewCalPrefs prefs ( this );
336 if ( ! prefs.exec() ) 340 if ( ! prefs.exec() )
337 return; 341 return;
338 QString name = prefs.calName(); 342 QString name = prefs.calName();
339 QString file = prefs.calFileName(); 343 QString file = prefs.calFileName();
340 QFileInfo fi ( file ); 344 QFileInfo fi ( file );
341 if (!fi.exists() ) { 345 if (!fi.exists() ) {
342 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); 346 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
343 return; 347 return;
344 } 348 }
345 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 349 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
346 kkf->mName = name; 350 kkf->mName = name;
347 kkf->mFileName = file; 351 kkf->mFileName = file;
348 emit calendarAdded( kkf->mCalNumber ); 352 emit calendarAdded( kkf->mCalNumber );
349 readConfig(); 353 readConfig();
350} 354}
351void KOCalEditView::enableAll() 355void KOCalEditView::enableAll()
352{ 356{
353 toggleList( mEnabledB ); 357 toggleList( mEnabledB );
354} 358}
355void KOCalEditView::enableAlarm() 359void KOCalEditView::enableAlarm()
356{ 360{
357 toggleList( mAlarmB ); 361 toggleList( mAlarmB );
358} 362}
359void KOCalEditView::disableRO() 363void KOCalEditView::disableRO()
360{ 364{
361 toggleList( mROB ); 365 toggleList( mROB );
362} 366}
363void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) 367void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
364{ 368{
365 bool dis = false; 369 bool dis = false;
366 KOCalCheckButton* it = list.first(); 370 KOCalCheckButton* it = list.first();
367 while ( it ) { 371 while ( it ) {
368 if ( !it->isChecked() ) { 372 if ( !it->isChecked() ) {
369 dis = true; 373 dis = true;
370 break; 374 break;
371 } 375 }
372 it = list.next(); 376 it = list.next();
373 } 377 }
374 it = list.first(); 378 it = list.first();
375 while ( it ) { 379 while ( it ) {
376 it->setChecked(dis); 380 it->setChecked(dis);
377 it = list.next(); 381 it = list.next();
378 } 382 }
379} 383}
380void KOCalEditView::deleteAll() 384void KOCalEditView::deleteAll()
381{ 385{
382 qDebug("delteAll"); 386 qDebug("delteAll");
383} 387}
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index aaf0eb6..4a0cd8a 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -1,155 +1,156 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOFILTERVIEW_H 23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H 24#define KOFILTERVIEW_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include "kofilterview_base.h" 30#include "kofilterview_base.h"
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34class QGridLayout; 34class QGridLayout;
35 35
36using namespace KCal; 36using namespace KCal;
37class KOCalButton : public QPushButton 37class KOCalButton : public QPushButton
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 public: 40 public:
41 KOCalButton( QWidget *parent=0, const char *name=0 ) : 41 KOCalButton( QWidget *parent=0, const char *name=0 ) :
42 QPushButton( parent, name) 42 QPushButton( parent, name)
43 { 43 {
44 connect( this, SIGNAL( clicked() ), 44 connect( this, SIGNAL( clicked() ),
45 SLOT( bottonClicked() )); 45 SLOT( bottonClicked() ));
46 mNumber = -1; 46 mNumber = -1;
47 } 47 }
48 void setNum ( int num ) {mNumber = num; } 48 void setNum ( int num ) {mNumber = num; }
49 signals: 49 signals:
50 void selectNum ( int ); 50 void selectNum ( int );
51private: 51private:
52 int mNumber; 52 int mNumber;
53 void keyPressEvent ( QKeyEvent * e ) 53 void keyPressEvent ( QKeyEvent * e )
54 { 54 {
55 e->ignore(); 55 e->ignore();
56 } 56 }
57 57
58private slots : 58private slots :
59 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } 59 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); }
60}; 60};
61class KOCalCheckButton : public QCheckBox 61class KOCalCheckButton : public QCheckBox
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : 65 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) :
66 QCheckBox( parent, name) 66 QCheckBox( parent, name)
67 { 67 {
68 connect( this, SIGNAL( toggled ( bool ) ), 68 connect( this, SIGNAL( toggled ( bool ) ),
69 SLOT( bottonClicked( bool ) )); 69 SLOT( bottonClicked( bool ) ));
70 mNumber = -1; 70 mNumber = -1;
71 //setMaximumWidth( 10 ); 71 //setMaximumWidth( 10 );
72 72
73 } 73 }
74 void setNum ( int num ) {mNumber = num; } 74 void setNum ( int num ) {mNumber = num; }
75 signals: 75 signals:
76 void selectNum ( int, bool ); 76 void selectNum ( int, bool );
77private: 77private:
78 int mNumber; 78 int mNumber;
79 void keyPressEvent ( QKeyEvent * e ) 79 void keyPressEvent ( QKeyEvent * e )
80 { 80 {
81 e->ignore(); 81 e->ignore();
82 } 82 }
83 83
84private slots : 84private slots :
85 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } 85 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); }
86}; 86};
87 87
88 88
89 89
90class KOFilterView : public KOFilterView_base 90class KOFilterView : public KOFilterView_base
91{ 91{
92 Q_OBJECT 92 Q_OBJECT
93 public: 93 public:
94 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); 94 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
95 ~KOFilterView(); 95 ~KOFilterView();
96 96
97 void updateFilters(); 97 void updateFilters();
98 98
99 bool filtersEnabled(); 99 bool filtersEnabled();
100 void setFiltersEnabled(bool); 100 void setFiltersEnabled(bool);
101 CalFilter *selectedFilter(); 101 CalFilter *selectedFilter();
102 void setSelectedFilter(QString); 102 void setSelectedFilter(QString);
103 void setSelectedFilter( int ); 103 void setSelectedFilter( int );
104 104
105 signals: 105 signals:
106 void filterChanged(); 106 void filterChanged();
107 void editFilters(); 107 void editFilters();
108 108
109 private: 109 private:
110 QPtrList<CalFilter> *mFilters; 110 QPtrList<CalFilter> *mFilters;
111}; 111};
112 112
113class KOCalEditView : public QWidget 113class KOCalEditView : public QWidget
114{ 114{
115 Q_OBJECT 115 Q_OBJECT
116 public: 116 public:
117 KOCalEditView( QWidget* parent=0,const char* name=0); 117 KOCalEditView( QWidget* parent=0,const char* name=0);
118 ~KOCalEditView(); 118 ~KOCalEditView();
119 119
120 void readConfig(); 120 void readConfig();
121 public slots: 121 public slots:
122 void addCal(); 122 void addCal();
123 void enableAll(); 123 void enableAll();
124 void enableAlarm(); 124 void enableAlarm();
125 void disableRO(); 125 void disableRO();
126 void deleteAll(); 126 void deleteAll();
127 void selectStdCal(int,bool ); 127 void selectStdCal(int,bool );
128 void selectCal(int,bool ); 128 void selectCal(int,bool );
129 void selectCalAlarm(int,bool ); 129 void selectCalAlarm(int,bool );
130 void selectReadOnly(int,bool ); 130 void selectReadOnly(int,bool );
131 void setColor(const QColor &,int) ; 131 void setColor(const QColor &,int) ;
132 void deleteCal(int) ; 132 void deleteCal(int) ;
133 void infoCal(int) ; 133 void infoCal(int) ;
134 signals: 134 signals:
135 void alarmEnabled ( int cal, bool enable ); 135 void alarmEnabled ( int cal, bool enable );
136 void calendarEnabled ( int cal, bool enable ); 136 void calendarEnabled ( int cal, bool enable );
137 void calendarReadonly ( int cal, bool readonly ); 137 void calendarReadonly ( int cal, bool readonly );
138 void setCalendarDefault ( int cal ); 138 void setCalendarDefault ( int cal );
139 void removeCalendar ( int cal ); 139 void removeCalendar ( int cal );
140 void calendarAdded( int ); 140 void calendarAdded( int );
141 void needsUpdate();
141 142
142 private: 143 private:
143 QVBoxLayout* ml; 144 QVBoxLayout* ml;
144 QWidget *mw; 145 QWidget *mw;
145 void toggleList ( QPtrList<KOCalCheckButton> ); 146 void toggleList ( QPtrList<KOCalCheckButton> );
146 QPtrList<KOCalCheckButton> mStdandardB; 147 QPtrList<KOCalCheckButton> mStdandardB;
147 QPtrList<KOCalCheckButton> mEnabledB; 148 QPtrList<KOCalCheckButton> mEnabledB;
148 QPtrList<KOCalCheckButton> mAlarmB; 149 QPtrList<KOCalCheckButton> mAlarmB;
149 QPtrList<KOCalCheckButton> mROB; 150 QPtrList<KOCalCheckButton> mROB;
150 QGridLayout* mainLayout; 151 QGridLayout* mainLayout;
151}; 152};
152 153
153 154
154 155
155#endif // KOFILTERVIEW_H 156#endif // KOFILTERVIEW_H
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index c868270..96f2502 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -559,466 +559,466 @@ void MonthViewCell::setMyPalette()
559 } 559 }
560 } 560 }
561 //QPalette pal = palette(); 561 //QPalette pal = palette();
562 562
563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
564} 564}
565QPalette MonthViewCell::getPalette () 565QPalette MonthViewCell::getPalette ()
566{ 566{
567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
568 return mStandardPalette; 568 return mStandardPalette;
569 if ( mHoliday) { 569 if ( mHoliday) {
570 return mHolidayPalette ; 570 return mHolidayPalette ;
571 } else { 571 } else {
572 if ( mPrimary ) { 572 if ( mPrimary ) {
573 return mPrimaryPalette ; 573 return mPrimaryPalette ;
574 } 574 }
575 } 575 }
576 return mNonPrimaryPalette; 576 return mNonPrimaryPalette;
577} 577}
578bool MonthViewCell::isPrimary() const 578bool MonthViewCell::isPrimary() const
579{ 579{
580 return mPrimary; 580 return mPrimary;
581} 581}
582 582
583void MonthViewCell::setHoliday( bool holiday ) 583void MonthViewCell::setHoliday( bool holiday )
584{ 584{
585 mHoliday = holiday; 585 mHoliday = holiday;
586 //setMyPalette(); 586 //setMyPalette();
587} 587}
588 588
589void MonthViewCell::setHoliday( const QString &holiday ) 589void MonthViewCell::setHoliday( const QString &holiday )
590{ 590{
591 mHolidayString = holiday; 591 mHolidayString = holiday;
592 592
593 if ( !holiday.isEmpty() ) { 593 if ( !holiday.isEmpty() ) {
594 setHoliday( true ); 594 setHoliday( true );
595 } 595 }
596} 596}
597 597
598void MonthViewCell::startUpdateCell() 598void MonthViewCell::startUpdateCell()
599{ 599{
600 mdayCount = 0; 600 mdayCount = 0;
601 setFocusPolicy(NoFocus); 601 setFocusPolicy(NoFocus);
602 if ( !mMonthView->isUpdatePossible() ) 602 if ( !mMonthView->isUpdatePossible() )
603 return; 603 return;
604 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 604 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
605 while ( mitem ) { 605 while ( mitem ) {
606 mitem->setBlockRepaint( true ); 606 mitem->setBlockRepaint( true );
607 mitem = (MonthViewItem *)mitem->next(); 607 mitem = (MonthViewItem *)mitem->next();
608 } 608 }
609 if ( mAvailItemList.count() > 20 ) { 609 if ( mAvailItemList.count() > 20 ) {
610 mAvailItemList.setAutoDelete( true ); 610 mAvailItemList.setAutoDelete( true );
611 mAvailItemList.clear(); 611 mAvailItemList.clear();
612 mAvailItemList.setAutoDelete( false ); 612 mAvailItemList.setAutoDelete( false );
613 } 613 }
614 614
615 setPrimary( mDate.month()%2 ); 615 setPrimary( mDate.month()%2 );
616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
617 if ( mDate == QDate::currentDate() ) { 617 if ( mDate == QDate::currentDate() ) {
618 setLineWidth( 3 ); 618 setLineWidth( 3 );
619 } else { 619 } else {
620 setLineWidth( 1 ); 620 setLineWidth( 1 );
621 } 621 }
622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
623 //clear(); 623 //clear();
624 while ( CurrentAvailItem ) { 624 while ( CurrentAvailItem ) {
625 MonthViewItem *item = CurrentAvailItem; 625 MonthViewItem *item = CurrentAvailItem;
626 CurrentAvailItem = (MonthViewItem *)item->next(); 626 CurrentAvailItem = (MonthViewItem *)item->next();
627 mAvailItemList.append( item ); 627 mAvailItemList.append( item );
628 takeItem ( item ); 628 takeItem ( item );
629 } 629 }
630 630
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 QToolTip::remove(this); 632 QToolTip::remove(this);
633#endif 633#endif
634 mToolTip.clear(); 634 mToolTip.clear();
635 //qApp->processEvents(); 635 //qApp->processEvents();
636#if 0 636#if 0
637 if ( !mHolidayString.isEmpty() ) { 637 if ( !mHolidayString.isEmpty() ) {
638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
639 item->setPalette( mHolidayPalette ); 639 item->setPalette( mHolidayPalette );
640 insertItem( item ); 640 insertItem( item );
641 mToolTip.append ( mHolidayString ); 641 mToolTip.append ( mHolidayString );
642 } 642 }
643#endif 643#endif
644} 644}
645 645
646int MonthViewCell::insertEvent(Event *event) 646int MonthViewCell::insertEvent(Event *event)
647{ 647{
648 bool useToolTips = true; 648 bool useToolTips = true;
649#ifndef DESKTOP_VERSION 649#ifndef DESKTOP_VERSION
650 useToolTips = false; 650 useToolTips = false;
651#endif 651#endif
652 QString mToolTipText; 652 QString mToolTipText;
653 setFocusPolicy(WheelFocus); 653 setFocusPolicy(WheelFocus);
654 if ( !(event->doesRecur() == Recurrence::rNone) ) { 654 if ( !(event->doesRecur() == Recurrence::rNone) ) {
655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
656 return mdayCount; 656 return mdayCount;
657 else 657 else
658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
659 return mdayCount; 659 return mdayCount;
660 } 660 }
661 661
662 if ( event->isHoliday()) { 662 if ( event->isHoliday()) {
663 setHoliday( true ); 663 setHoliday( true );
664 if ( mDate.dayOfWeek() == 7 ) 664 if ( mDate.dayOfWeek() == 7 )
665 setLineWidth( 3 ); 665 setLineWidth( 3 );
666 } 666 }
667 QString text; 667 QString text;
668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
669 if (event->isMultiDay()) { 669 if (event->isMultiDay()) {
670 QString prefix = "<->";multiday = 2; 670 QString prefix = "<->";multiday = 2;
671 QString time; 671 QString time;
672 if ( event->doesRecur() ) { 672 if ( event->doesRecur() ) {
673 if ( event->recursOn( mDate) ) { 673 if ( event->recursOn( mDate) ) {
674 prefix ="->" ;multiday = 1; 674 prefix ="->" ;multiday = 1;
675 } 675 }
676 else { 676 else {
677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
678 if ( event->recursOn( mDate.addDays( -days)) ) { 678 if ( event->recursOn( mDate.addDays( -days)) ) {
679 prefix ="<-" ;multiday = 3; 679 prefix ="<-" ;multiday = 3;
680 } 680 }
681 } 681 }
682 682
683 } else { 683 } else {
684 if (mDate == event->dtStart().date()) { 684 if (mDate == event->dtStart().date()) {
685 prefix ="->" ;multiday = 1; 685 prefix ="->" ;multiday = 1;
686 } else if (mDate == event->dtEnd().date()) { 686 } else if (mDate == event->dtEnd().date()) {
687 prefix ="<-" ;multiday = 3; 687 prefix ="<-" ;multiday = 3;
688 } 688 }
689 } 689 }
690 if ( !event->doesFloat() ) { 690 if ( !event->doesFloat() ) {
691 if ( mDate == event->dtStart().date () ) 691 if ( mDate == event->dtStart().date () )
692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
693 else if ( mDate == event->dtEnd().date () ) 693 else if ( mDate == event->dtEnd().date () )
694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
695 695
696 } 696 }
697 text = time + event->summary(); 697 text = time + event->summary();
698 if ( useToolTips ) 698 if ( useToolTips )
699 mToolTipText += prefix + text; 699 mToolTipText += prefix + text;
700 } else { 700 } else {
701 if (event->doesFloat()) { 701 if (event->doesFloat()) {
702 text = event->summary(); 702 text = event->summary();
703 if ( useToolTips ) 703 if ( useToolTips )
704 mToolTipText += text; 704 mToolTipText += text;
705 } 705 }
706 else { 706 else {
707 text = KGlobal::locale()->formatTime(event->dtStart().time()); 707 text = KGlobal::locale()->formatTime(event->dtStart().time());
708 text += " " + event->summary(); 708 text += " " + event->summary();
709 if ( useToolTips ) 709 if ( useToolTips )
710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
711 } 711 }
712 } 712 }
713 if ( useToolTips && ! event->location().isEmpty() ) { 713 if ( useToolTips && ! event->location().isEmpty() ) {
714 mToolTipText += " (" + event->location() +")"; 714 mToolTipText += " (" + event->location() +")";
715 } 715 }
716 MonthViewItem *item ; 716 MonthViewItem *item ;
717 717
718 if ( mAvailItemList.count() ) { 718 if ( mAvailItemList.count() ) {
719 item = mAvailItemList.first(); 719 item = mAvailItemList.first();
720 mAvailItemList.remove( item ); 720 mAvailItemList.remove( item );
721 item->recycle( event, mDate, text ); 721 item->recycle( event, mDate, text );
722 } else { 722 } else {
723 item = new MonthViewItem( event, mDate, text ); 723 item = new MonthViewItem( event, mDate, text );
724 } 724 }
725 725
726 QPalette pal; 726 QPalette pal;
727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
728 QStringList categories = event->categories(); 728 QStringList categories = event->categories();
729 QString cat = categories.first(); 729 QString cat = categories.first();
730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
731 pal = getPalette(); 731 pal = getPalette();
732 if (cat.isEmpty()) { 732 if (cat.isEmpty()) {
733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
734 } else { 734 } else {
735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
736 } 736 }
737 737
738 } else { 738 } else {
739 if (cat.isEmpty()) { 739 if (cat.isEmpty()) {
740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
741 } else { 741 } else {
742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
743 } 743 }
744 } 744 }
745 745
746 } else { 746 } else {
747 pal = mStandardPalette ; 747 pal = mStandardPalette ;
748 } 748 }
749 item->setPalette( pal ); 749 item->setPalette( pal );
750 item->setRecur( event->recurrence()->doesRecur() ); 750 item->setRecur( event->recurrence()->doesRecur() );
751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
752 item->setMoreInfo( event->description().length() > 0 ); 752 item->setMoreInfo( event->description().length() > 0 );
753#ifdef DESKTOP_VERSION 753#ifdef DESKTOP_VERSION
754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
755 KOPrefs::instance()->email()); 755 KOPrefs::instance()->email());
756 if ( me != 0 ) { 756 if ( me != 0 ) {
757 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 757 if ( me->status() == Attendee::NeedsAction && me->RSVP())
758 item->setReply(true && multiday < 2); 758 item->setReply(true && multiday < 2);
759 else 759 else
760 item->setReply(false); 760 item->setReply(false);
761 } else 761 } else
762 item->setReply(false); 762 item->setReply(false);
763#endif 763#endif
764 item->setMultiDay( multiday ); 764 item->setMultiDay( multiday );
765 if ( multiday ) { 765 if ( multiday ) {
766 insertItem( item ,mdayCount); 766 insertItem( item ,mdayCount);
767 ++mdayCount; 767 ++mdayCount;
768 } else { 768 } else {
769 uint i; 769 uint i;
770 int pos = mdayCount; 770 int pos = mdayCount;
771 for ( i = mdayCount; i < count();++i ) { 771 for ( i = mdayCount; i < count();++i ) {
772 QListBoxItem* it = this->item ( i ); 772 QListBoxItem* it = this->item ( i );
773 if ( it && text < it->text() ) { 773 if ( it && text < it->text() ) {
774 pos = i; 774 pos = i;
775 break; 775 break;
776 } 776 }
777 ++pos; 777 ++pos;
778 } 778 }
779 insertItem( item ,pos); 779 insertItem( item ,pos);
780 } 780 }
781 if ( useToolTips ) { 781 if ( useToolTips ) {
782 mToolTip.append( mToolTipText ); 782 mToolTip.append( mToolTipText );
783 } 783 }
784 return mdayCount; 784 return mdayCount;
785} 785}
786void MonthViewCell::insertTodo(Todo *todo) 786void MonthViewCell::insertTodo(Todo *todo)
787{ 787{
788 setFocusPolicy(WheelFocus); 788 setFocusPolicy(WheelFocus);
789 QString text; 789 QString text;
790 if (todo->hasDueDate()) { 790 if (todo->hasDueDate()) {
791 if (!todo->doesFloat()) { 791 if (!todo->doesFloat()) {
792 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 792 text += KGlobal::locale()->formatTime(todo->dtDue().time());
793 text += " "; 793 text += " ";
794 } 794 }
795 } 795 }
796 text += todo->summary(); 796 text += todo->summary();
797 MonthViewItem *item ; 797 MonthViewItem *item ;
798 if ( mAvailItemList.count() ) { 798 if ( mAvailItemList.count() ) {
799 item = mAvailItemList.first(); 799 item = mAvailItemList.first();
800 mAvailItemList.remove( item ); 800 mAvailItemList.remove( item );
801 item->recycle( todo, mDate, text ); 801 item->recycle( todo, mDate, text );
802 } else { 802 } else {
803 item = new MonthViewItem( todo, mDate, text ); 803 item = new MonthViewItem( todo, mDate, text );
804 } 804 }
805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
806 //item->setPalette( mStandardPalette ); 806 //item->setPalette( mStandardPalette );
807 QPalette pal; 807 QPalette pal;
808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
809 QStringList categories = todo->categories(); 809 QStringList categories = todo->categories();
810 QString cat = categories.first(); 810 QString cat = categories.first();
811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
812 pal = getPalette(); 812 pal = getPalette();
813 if (cat.isEmpty()) { 813 if (cat.isEmpty()) {
814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
815 } else { 815 } else {
816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
817 } 817 }
818 818
819 } else { 819 } else {
820 if (cat.isEmpty()) { 820 if (cat.isEmpty()) {
821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
822 } else { 822 } else {
823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
824 } 824 }
825 } 825 }
826 826
827 } else { 827 } else {
828 pal = mStandardPalette ; 828 pal = mStandardPalette ;
829 } 829 }
830 item->setPalette( pal ); 830 item->setPalette( pal );
831 item->setRecur( todo->recurrence()->doesRecur() ); 831 item->setRecur( todo->recurrence()->doesRecur() );
832 item->setAlarm( todo->isAlarmEnabled() ); 832 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
833 item->setMoreInfo( todo->description().length() > 0 ); 833 item->setMoreInfo( todo->description().length() > 0 );
834 insertItem( item , count()); 834 insertItem( item , count());
835#ifdef DESKTOP_VERSION 835#ifdef DESKTOP_VERSION
836 mToolTip.append( text ); 836 mToolTip.append( text );
837#endif 837#endif
838} 838}
839void MonthViewCell::repaintfinishUpdateCell() 839void MonthViewCell::repaintfinishUpdateCell()
840{ 840{
841 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 841 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
842 while ( mitem ) { 842 while ( mitem ) {
843 mitem->setBlockRepaint( false ); 843 mitem->setBlockRepaint( false );
844 updateItem ( mitem ); 844 updateItem ( mitem );
845 mitem = (MonthViewItem *)mitem->next(); 845 mitem = (MonthViewItem *)mitem->next();
846 } 846 }
847} 847}
848void MonthViewCell::finishUpdateCell() 848void MonthViewCell::finishUpdateCell()
849{ 849{
850 850
851 851
852 852
853#ifdef DESKTOP_VERSION 853#ifdef DESKTOP_VERSION
854 if (mToolTip.count() > 0 ) { 854 if (mToolTip.count() > 0 ) {
855 mToolTip.sort(); 855 mToolTip.sort();
856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
857 } 857 }
858#endif 858#endif
859 //sort(); 859 //sort();
860 //setMyPalette(); 860 //setMyPalette();
861 setMyPalette(); 861 setMyPalette();
862 862
863 resizeEvent( 0 ); 863 resizeEvent( 0 );
864 864
865} 865}
866void MonthViewCell::updateCell() 866void MonthViewCell::updateCell()
867{ 867{
868 if ( !mMonthView->isUpdatePossible() ) 868 if ( !mMonthView->isUpdatePossible() )
869 return; 869 return;
870 startUpdateCell(); 870 startUpdateCell();
871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
873 Event *event; 873 Event *event;
874 for( event = events.first(); event; event = events.next() ) { // for event 874 for( event = events.first(); event; event = events.next() ) { // for event
875 insertEvent(event); 875 insertEvent(event);
876 } 876 }
877 // insert due todos 877 // insert due todos
878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
879 Todo *todo; 879 Todo *todo;
880 for(todo = todos.first(); todo; todo = todos.next()) { 880 for(todo = todos.first(); todo; todo = todos.next()) {
881 insertTodo( todo ); 881 insertTodo( todo );
882 } 882 }
883 finishUpdateCell(); 883 finishUpdateCell();
884 // if ( isVisible()) 884 // if ( isVisible())
885 //qApp->processEvents(); 885 //qApp->processEvents();
886} 886}
887 887
888void MonthViewCell::updateConfig( bool bigFont ) // = false 888void MonthViewCell::updateConfig( bool bigFont ) // = false
889{ 889{
890 890
891 if ( bigFont ) { 891 if ( bigFont ) {
892 QFont fo = KOPrefs::instance()->mMonthViewFont; 892 QFont fo = KOPrefs::instance()->mMonthViewFont;
893 int ps = fo.pointSize() + 2; 893 int ps = fo.pointSize() + 2;
894 if ( ps < 18 ) 894 if ( ps < 18 )
895 ps += 2; 895 ps += 2;
896 fo.setPointSize( ps ); 896 fo.setPointSize( ps );
897 setFont( fo ); 897 setFont( fo );
898 } else 898 } else
899 setFont( KOPrefs::instance()->mMonthViewFont ); 899 setFont( KOPrefs::instance()->mMonthViewFont );
900 900
901 QFontMetrics fm( font() ); 901 QFontMetrics fm( font() );
902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
904 mHolidayPalette = mStandardPalette; 904 mHolidayPalette = mStandardPalette;
905 mPrimaryPalette = mStandardPalette; 905 mPrimaryPalette = mStandardPalette;
906 mNonPrimaryPalette = mStandardPalette; 906 mNonPrimaryPalette = mStandardPalette;
907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
917 } 917 }
918 //updateCell(); 918 //updateCell();
919} 919}
920 920
921void MonthViewCell::enableScrollBars( bool enabled ) 921void MonthViewCell::enableScrollBars( bool enabled )
922{ 922{
923 923
924 return; 924 return;
925 if ( enabled ) { 925 if ( enabled ) {
926 QListBoxItem *fi = firstItem (); 926 QListBoxItem *fi = firstItem ();
927 if (fi ) { 927 if (fi ) {
928 int ihei = fi->height( this ); 928 int ihei = fi->height( this );
929 int hei = numRows () * ihei; 929 int hei = numRows () * ihei;
930 if ( hei < height() - horizontalScrollBar()->height () ) { 930 if ( hei < height() - horizontalScrollBar()->height () ) {
931 setVScrollBarMode(QScrollView::AlwaysOff); 931 setVScrollBarMode(QScrollView::AlwaysOff);
932 } 932 }
933 else 933 else
934 setVScrollBarMode(QScrollView::Auto); 934 setVScrollBarMode(QScrollView::Auto);
935 if ( ihei *3 > height() ) { 935 if ( ihei *3 > height() ) {
936 setHScrollBarMode(QScrollView::AlwaysOff); 936 setHScrollBarMode(QScrollView::AlwaysOff);
937 } 937 }
938 else { 938 else {
939 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
940 } 940 }
941 } else { 941 } else {
942 setVScrollBarMode(QScrollView::Auto); 942 setVScrollBarMode(QScrollView::Auto);
943 setHScrollBarMode(QScrollView::Auto); 943 setHScrollBarMode(QScrollView::Auto);
944 } 944 }
945 } else { 945 } else {
946 setVScrollBarMode(QScrollView::AlwaysOff); 946 setVScrollBarMode(QScrollView::AlwaysOff);
947 setHScrollBarMode(QScrollView::AlwaysOff); 947 setHScrollBarMode(QScrollView::AlwaysOff);
948 } 948 }
949} 949}
950 950
951Incidence *MonthViewCell::selectedIncidence() 951Incidence *MonthViewCell::selectedIncidence()
952{ 952{
953 int index = currentItem(); 953 int index = currentItem();
954 if ( index < 0 ) return 0; 954 if ( index < 0 ) return 0;
955 955
956 MonthViewItem *mitem = 956 MonthViewItem *mitem =
957 static_cast<MonthViewItem *>( item( index ) ); 957 static_cast<MonthViewItem *>( item( index ) );
958 958
959 if ( !mitem ) return 0; 959 if ( !mitem ) return 0;
960 960
961 return mitem->incidence(); 961 return mitem->incidence();
962} 962}
963 963
964QDate MonthViewCell::selectedIncidenceDate() 964QDate MonthViewCell::selectedIncidenceDate()
965{ 965{
966 QDate qd; 966 QDate qd;
967 int index = currentItem(); 967 int index = currentItem();
968 if ( index < 0 ) return qd; 968 if ( index < 0 ) return qd;
969 969
970 MonthViewItem *mitem = 970 MonthViewItem *mitem =
971 static_cast<MonthViewItem *>( item( index ) ); 971 static_cast<MonthViewItem *>( item( index ) );
972 972
973 if ( !mitem ) return qd; 973 if ( !mitem ) return qd;
974 974
975 return mitem->incidenceDate(); 975 return mitem->incidenceDate();
976} 976}
977 977
978void MonthViewCell::deselect() 978void MonthViewCell::deselect()
979{ 979{
980 clearSelection(); 980 clearSelection();
981 enableScrollBars( false ); 981 enableScrollBars( false );
982 // updateCell(); 982 // updateCell();
983} 983}
984void MonthViewCell::select() 984void MonthViewCell::select()
985{ 985{
986 ;// updateCell(); 986 ;// updateCell();
987} 987}
988 988
989void MonthViewCell::resizeEvent ( QResizeEvent * e ) 989void MonthViewCell::resizeEvent ( QResizeEvent * e )
990{ 990{
991 if ( !mMonthView->isUpdatePossible() ) 991 if ( !mMonthView->isUpdatePossible() )
992 return; 992 return;
993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
994 deselect(); 994 deselect();
995 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 995 mLabel->setMaximumHeight( height() - lineWidth()*2 );
996 996
997 QString text; 997 QString text;
998 mLabel->setText( text ); 998 mLabel->setText( text );
999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1002 mLabel->resize( mLabelBigSize ); 1002 mLabel->resize( mLabelBigSize );
1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1004 } else { 1004 } else {
1005 mLabel->resize( mLabelSize ); 1005 mLabel->resize( mLabelSize );
1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1007 } 1007 }
1008 mLabel->setText( text ); 1008 mLabel->setText( text );
1009 1009
1010 int size = height() - mLabel->height() - lineWidth()-1; 1010 int size = height() - mLabel->height() - lineWidth()-1;
1011 //qDebug("LW %d ", lineWidth()); 1011 //qDebug("LW %d ", lineWidth());
1012 if ( size > 0 ) 1012 if ( size > 0 )
1013 verticalScrollBar()->setMaximumHeight( size ); 1013 verticalScrollBar()->setMaximumHeight( size );
1014 size = width() - mLabel->width() -lineWidth()-1; 1014 size = width() - mLabel->width() -lineWidth()-1;
1015 if ( size > 0 ) 1015 if ( size > 0 )
1016 horizontalScrollBar()->setMaximumWidth( size ); 1016 horizontalScrollBar()->setMaximumWidth( size );
1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1019 // mItemList->resize ( width(), height () ); 1019 // mItemList->resize ( width(), height () );
1020 if ( e ) 1020 if ( e )
1021 KNoScrollListBox::resizeEvent ( e ); 1021 KNoScrollListBox::resizeEvent ( e );
1022} 1022}
1023 1023
1024void MonthViewCell::defaultAction( QListBoxItem *item ) 1024void MonthViewCell::defaultAction( QListBoxItem *item )
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 2602487..35c2a9f 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -512,547 +512,549 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
512 mPopupMenu = new QPopupMenu(this); 512 mPopupMenu = new QPopupMenu(this);
513 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 513 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
514 SLOT (newTodo()),0,1); 514 SLOT (newTodo()),0,1);
515 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 515 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
516 this, SLOT(purgeCompleted()),0,2); 516 this, SLOT(purgeCompleted()),0,2);
517 mPopupMenu->insertItem(i18n("Show Completed"), 517 mPopupMenu->insertItem(i18n("Show Completed"),
518 this, SLOT( toggleCompleted() ),0,3 ); 518 this, SLOT( toggleCompleted() ),0,3 );
519 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 519 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
520 this, SLOT( toggleRunning() ),0,5 ); 520 this, SLOT( toggleRunning() ),0,5 );
521 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 521 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
522 this, SLOT( setAllOpen() ),0,6 ); 522 this, SLOT( setAllOpen() ),0,6 );
523 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 523 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
524 this, SLOT( setAllClose() ),0,7 ); 524 this, SLOT( setAllClose() ),0,7 );
525 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 525 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
526 this, SLOT( setAllFlat() ),0,8 ); 526 this, SLOT( setAllFlat() ),0,8 );
527 mPopupMenu->insertSeparator(); 527 mPopupMenu->insertSeparator();
528 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 528 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
529 this, SLOT( toggleQuickTodo() ),0,4 ); 529 this, SLOT( toggleQuickTodo() ),0,4 );
530 mDocPrefs = new DocPrefs( name ); 530 mDocPrefs = new DocPrefs( name );
531 531
532 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 532 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
533 mPopupMenu->setCheckable( true ); 533 mPopupMenu->setCheckable( true );
534 mItemPopupMenu->setCheckable( true ); 534 mItemPopupMenu->setCheckable( true );
535 535
536 536
537 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 537 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
538 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 538 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
539 539
540 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 540 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
541 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 541 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
542 542
543 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 543 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
544 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 544 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
545 545
546 546
547 // Double clicking conflicts with opening/closing the subtree 547 // Double clicking conflicts with opening/closing the subtree
548 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 548 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
549 SLOT( editItem( QListViewItem *) ) ); 549 SLOT( editItem( QListViewItem *) ) );
550 /* 550 /*
551 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 551 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
552 const QPoint &,int ) ), 552 const QPoint &,int ) ),
553 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 553 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
554 */ 554 */
555 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 555 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
556 const QPoint &,int ) ), 556 const QPoint &,int ) ),
557 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 557 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
558 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 558 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
559 SLOT( itemClicked( QListViewItem * ) ) ); 559 SLOT( itemClicked( QListViewItem * ) ) );
560 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 560 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
561 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 561 SLOT( itemDoubleClicked( QListViewItem * ) ) );
562 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 562 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
563 SLOT( updateView() ) ); 563 SLOT( updateView() ) );
564 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 564 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
565 SLOT( todoModified(Todo *, int) ) ); 565 SLOT( todoModified(Todo *, int) ) );
566 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 566 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
567 SLOT( itemStateChanged( QListViewItem * ) ) ); 567 SLOT( itemStateChanged( QListViewItem * ) ) );
568 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 568 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
569 SLOT( itemStateChanged( QListViewItem * ) ) ); 569 SLOT( itemStateChanged( QListViewItem * ) ) );
570 connect( mTodoListView, SIGNAL( paintNeeded() ), 570 connect( mTodoListView, SIGNAL( paintNeeded() ),
571 SLOT( paintNeeded()) ); 571 SLOT( paintNeeded()) );
572 572
573#if 0 573#if 0
574 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 574 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
575 SLOT(selectionChanged(QListViewItem *))); 575 SLOT(selectionChanged(QListViewItem *)));
576 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 576 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
577 SLOT(selectionChanged(QListViewItem *))); 577 SLOT(selectionChanged(QListViewItem *)));
578 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 578 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
579 SLOT(selectionChanged(QListViewItem *))); 579 SLOT(selectionChanged(QListViewItem *)));
580#endif 580#endif
581 581
582 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 582 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
583 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 583 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
584 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 584 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
585 585
586 connect( mTodoListView, SIGNAL(selectionChanged() ), 586 connect( mTodoListView, SIGNAL(selectionChanged() ),
587 SLOT( processSelectionChange() ) ); 587 SLOT( processSelectionChange() ) );
588 connect( mQuickAdd, SIGNAL( returnPressed () ), 588 connect( mQuickAdd, SIGNAL( returnPressed () ),
589 SLOT( addQuickTodo() ) ); 589 SLOT( addQuickTodo() ) );
590 590
591} 591}
592 592
593KOTodoView::~KOTodoView() 593KOTodoView::~KOTodoView()
594{ 594{
595 595
596#if QT_VERSION >= 0x030000 596#if QT_VERSION >= 0x030000
597 597
598#else 598#else
599 delete mKOTodoViewWhatsThis; 599 delete mKOTodoViewWhatsThis;
600#endif 600#endif
601 601
602 delete mDocPrefs; 602 delete mDocPrefs;
603} 603}
604QString KOTodoView::getWhatsThisText(QPoint p) 604QString KOTodoView::getWhatsThisText(QPoint p)
605{ 605{
606 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 606 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
607 if ( item ) 607 if ( item )
608 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 608 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
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->typeID() == todoID ) { 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 ) ) ) && incidence->calEnabled() ) {
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) 839KOTodoView::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->typeID() == todoID ) { 847 while ( incidence && !incidence->calEnabled() )
848 Todo *relatedTodo = static_cast<Todo *>(incidence); 848 incidence = incidence->relatedTo();
849 849 if (incidence && incidence->typeID() == todoID ) {
850// kdDebug() << " has Related" << endl; 850 Todo *relatedTodo = static_cast<Todo *>(incidence);
851 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 851
852 itemIterator = mTodoMap.find(relatedTodo); 852 // kdDebug() << " has Related" << endl;
853 if (itemIterator == mTodoMap.end()) { 853 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
854// kdDebug() << " related not yet in list" << endl; 854 itemIterator = mTodoMap.find(relatedTodo);
855 itemIterator = insertTodoItem (relatedTodo); 855 if (itemIterator == mTodoMap.end()) {
856 // kdDebug() << " related not yet in list" << endl;
857 itemIterator = insertTodoItem (relatedTodo);
858 }
859 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
860 // and one into the map. Sure finding is more easy but why? -zecke
861 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
862 return mTodoMap.insert(todo,todoItem);
863 } else {
864 // kdDebug() << " no Related" << endl;
865 // see above -zecke
866 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
867 return mTodoMap.insert(todo,todoItem);
856 } 868 }
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
859 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
860 return mTodoMap.insert(todo,todoItem);
861 } else {
862// kdDebug() << " no Related" << endl;
863 // see above -zecke
864 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
865 return mTodoMap.insert(todo,todoItem);
866 }
867} 869}
868 870
869 871
870void KOTodoView::updateConfig() 872void KOTodoView::updateConfig()
871{ 873{
872 updateView(); 874 updateView();
873 mTodoListView->repaintContents(); 875 mTodoListView->repaintContents();
874} 876}
875 877
876QPtrList<Incidence> KOTodoView::selectedIncidences() 878QPtrList<Incidence> KOTodoView::selectedIncidences()
877{ 879{
878 QPtrList<Incidence> selected; 880 QPtrList<Incidence> selected;
879 881
880 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 882 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
881// if (!item) item = mActiveItem; 883// if (!item) item = mActiveItem;
882 if (item) selected.append(item->todo()); 884 if (item) selected.append(item->todo());
883 885
884 return selected; 886 return selected;
885} 887}
886 888
887QPtrList<Todo> KOTodoView::selectedTodos() 889QPtrList<Todo> KOTodoView::selectedTodos()
888{ 890{
889 QPtrList<Todo> selected; 891 QPtrList<Todo> selected;
890 892
891 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 893 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
892// if (!item) item = mActiveItem; 894// if (!item) item = mActiveItem;
893 if (item) selected.append(item->todo()); 895 if (item) selected.append(item->todo());
894 896
895 return selected; 897 return selected;
896} 898}
897 899
898void KOTodoView::changeEventDisplay(Event *, int) 900void KOTodoView::changeEventDisplay(Event *, int)
899{ 901{
900 updateView(); 902 updateView();
901} 903}
902 904
903void KOTodoView::showDates(const QDate &, const QDate &) 905void KOTodoView::showDates(const QDate &, const QDate &)
904{ 906{
905} 907}
906 908
907void KOTodoView::showEvents(QPtrList<Event>) 909void KOTodoView::showEvents(QPtrList<Event>)
908{ 910{
909 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 911 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
910} 912}
911 913
912void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 914void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
913 const QDate &td) 915 const QDate &td)
914{ 916{
915#ifndef KORG_NOPRINTER 917#ifndef KORG_NOPRINTER
916 calPrinter->preview(CalPrinter::Todolist, fd, td); 918 calPrinter->preview(CalPrinter::Todolist, fd, td);
917#endif 919#endif
918} 920}
919 921
920void KOTodoView::editItem(QListViewItem *item ) 922void KOTodoView::editItem(QListViewItem *item )
921{ 923{
922 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 924 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
923} 925}
924 926
925void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 927void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
926{ 928{
927 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 929 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
928} 930}
929 931
930void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 932void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
931{ 933{
932 pendingSubtodo = 0; 934 pendingSubtodo = 0;
933 mActiveItem = (KOTodoViewItem *)item; 935 mActiveItem = (KOTodoViewItem *)item;
934 if (item) { 936 if (item) {
935 switch (column){ 937 switch (column){
936 case 1: 938 case 1:
937 mPriorityPopupMenu->popup(QCursor::pos ()); break; 939 mPriorityPopupMenu->popup(QCursor::pos ()); break;
938 case 2: 940 case 2:
939 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 941 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
940 case 3: 942 case 3:
941 moveTodo(); 943 moveTodo();
942 break; 944 break;
943 case 8: 945 case 8:
944 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 946 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
945 default: 947 default:
946 mItemPopupMenu->popup(QCursor::pos()); 948 mItemPopupMenu->popup(QCursor::pos());
947 } 949 }
948 } else mPopupMenu->popup(QCursor::pos()); 950 } else mPopupMenu->popup(QCursor::pos());
949} 951}
950void KOTodoView::newTodo() 952void KOTodoView::newTodo()
951{ 953{
952 emit newTodoSignal(); 954 emit newTodoSignal();
953} 955}
954 956
955void KOTodoView::newSubTodo() 957void KOTodoView::newSubTodo()
956{ 958{
957 if (mActiveItem) { 959 if (mActiveItem) {
958 emit newSubTodoSignal(mActiveItem->todo()); 960 emit newSubTodoSignal(mActiveItem->todo());
959 } 961 }
960} 962}
961void KOTodoView::unparentTodo() 963void KOTodoView::unparentTodo()
962{ 964{
963 if (mActiveItem) { 965 if (mActiveItem) {
964 emit unparentTodoSignal(mActiveItem->todo()); 966 emit unparentTodoSignal(mActiveItem->todo());
965 } 967 }
966} 968}
967 969
968void KOTodoView::reparentTodo() 970void KOTodoView::reparentTodo()
969{ 971{
970 if (mActiveItem) { 972 if (mActiveItem) {
971 topLevelWidget()->setCaption(i18n("Click on new parent item")); 973 topLevelWidget()->setCaption(i18n("Click on new parent item"));
972 pendingSubtodo = mActiveItem; 974 pendingSubtodo = mActiveItem;
973 } 975 }
974} 976}
975void KOTodoView::editTodo() 977void KOTodoView::editTodo()
976{ 978{
977 if (mActiveItem) { 979 if (mActiveItem) {
978 emit editTodoSignal(mActiveItem->todo()); 980 emit editTodoSignal(mActiveItem->todo());
979 } 981 }
980} 982}
981void KOTodoView::cloneTodo() 983void KOTodoView::cloneTodo()
982{ 984{
983 if (mActiveItem) { 985 if (mActiveItem) {
984 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 986 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
985 } 987 }
986} 988}
987void KOTodoView::cancelTodo() 989void KOTodoView::cancelTodo()
988{ 990{
989 if (mActiveItem) { 991 if (mActiveItem) {
990 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 992 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
991 } 993 }
992} 994}
993void KOTodoView::moveTodo() 995void KOTodoView::moveTodo()
994{ 996{
995 if (mActiveItem) { 997 if (mActiveItem) {
996 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 998 emit moveTodoSignal((Incidence*)mActiveItem->todo());
997 } 999 }
998} 1000}
999void KOTodoView::beamTodo() 1001void KOTodoView::beamTodo()
1000{ 1002{
1001 if (mActiveItem) { 1003 if (mActiveItem) {
1002 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1004 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1003 } 1005 }
1004} 1006}
1005 1007
1006 1008
1007void KOTodoView::showTodo() 1009void KOTodoView::showTodo()
1008{ 1010{
1009 if (mActiveItem) { 1011 if (mActiveItem) {
1010 emit showTodoSignal(mActiveItem->todo()); 1012 emit showTodoSignal(mActiveItem->todo());
1011 } 1013 }
1012} 1014}
1013 1015
1014void KOTodoView::deleteTodo() 1016void KOTodoView::deleteTodo()
1015{ 1017{
1016 if (mActiveItem) { 1018 if (mActiveItem) {
1017 emit deleteTodoSignal(mActiveItem->todo()); 1019 emit deleteTodoSignal(mActiveItem->todo());
1018 } 1020 }
1019} 1021}
1020 1022
1021void KOTodoView::setNewPriority(int index) 1023void KOTodoView::setNewPriority(int index)
1022{ 1024{
1023 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1025 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1024 mActiveItem->todo()->setPriority(mPriority[index]); 1026 mActiveItem->todo()->setPriority(mPriority[index]);
1025 mActiveItem->construct(); 1027 mActiveItem->construct();
1026 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1028 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1027 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1029 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1028 } 1030 }
1029} 1031}
1030 1032
1031void KOTodoView::setNewPercentage(int index) 1033void KOTodoView::setNewPercentage(int index)
1032{ 1034{
1033 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1035 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1034 1036
1035 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1037 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1036 mActiveItem->setOn( true ); 1038 mActiveItem->setOn( true );
1037 return; 1039 return;
1038 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1040 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1039 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1041 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1040 if ( par && par->isOn() ) 1042 if ( par && par->isOn() )
1041 par->setOn( false ); 1043 par->setOn( false );
1042 } 1044 }
1043 if (mPercentage[index] == 100) { 1045 if (mPercentage[index] == 100) {
1044 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1046 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1045 } else { 1047 } else {
1046 mActiveItem->todo()->setCompleted(false); 1048 mActiveItem->todo()->setCompleted(false);
1047 } 1049 }
1048 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1050 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1049 mActiveItem->construct(); 1051 mActiveItem->construct();
1050 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1052 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1051 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1053 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1052 } 1054 }
1053} 1055}
1054 1056
1055 1057
1056QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1058QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1057{ 1059{
1058 QPopupMenu* tempMenu = new QPopupMenu (this); 1060 QPopupMenu* tempMenu = new QPopupMenu (this);
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 8cb6b83..f987b63 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -6,385 +6,385 @@
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23#include <kglobal.h> 23#include <kglobal.h>
24 24
25#include <kiconloader.h> 25#include <kiconloader.h>
26#include "kotodoviewitem.h" 26#include "kotodoviewitem.h"
27#include "kotodoview.h" 27#include "kotodoview.h"
28#include "koprefs.h" 28#include "koprefs.h"
29 29
30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
32{ 32{
33 construct(); 33 construct();
34} 34}
35 35
36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
38{ 38{
39 construct(); 39 construct();
40} 40}
41 41
42QString KOTodoViewItem::key(int column,bool) const 42QString KOTodoViewItem::key(int column,bool) const
43{ 43{
44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
45 if (it == mKeyMap.end()) { 45 if (it == mKeyMap.end()) {
46 return text(column).lower(); 46 return text(column).lower();
47 } else { 47 } else {
48 return *it; 48 return *it;
49 } 49 }
50} 50}
51 51
52void KOTodoViewItem:: setup() 52void KOTodoViewItem:: setup()
53{ 53{
54 54
55 int h = 20; 55 int h = 20;
56 if ( listView () ) { 56 if ( listView () ) {
57 QFontMetrics fm ( listView ()->font () ); 57 QFontMetrics fm ( listView ()->font () );
58 h = fm.height(); 58 h = fm.height();
59 } 59 }
60 setHeight( h ); 60 setHeight( h );
61 61
62} 62}
63void KOTodoViewItem::setSortKey(int column,const QString &key) 63void KOTodoViewItem::setSortKey(int column,const QString &key)
64{ 64{
65 mKeyMap.insert(column,key); 65 mKeyMap.insert(column,key);
66} 66}
67 67
68#if QT_VERSION >= 0x030000 68#if QT_VERSION >= 0x030000
69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
70 int y,int h) 70 int y,int h)
71{ 71{
72 QListViewItem::paintBranches(p,cg,w,y,h); 72 QListViewItem::paintBranches(p,cg,w,y,h);
73} 73}
74#else 74#else
75#endif 75#endif
76 76
77void KOTodoViewItem::construct() 77void KOTodoViewItem::construct()
78{ 78{
79 // qDebug("KOTodoViewItem::construct() "); 79 // qDebug("KOTodoViewItem::construct() ");
80 m_init = true; 80 m_init = true;
81 QString keyd = "=="; 81 QString keyd = "==";
82 QString keyt = "=="; 82 QString keyt = "==";
83 QString skeyd = "=="; 83 QString skeyd = "==";
84 QString skeyt = "=="; 84 QString skeyt = "==";
85 85
86 setOn(mTodo->isCompleted()); 86 setOn(mTodo->isCompleted());
87 setText(0,mTodo->summary()); 87 setText(0,mTodo->summary());
88 setText(1,QString::number(mTodo->priority())); 88 setText(1,QString::number(mTodo->priority()));
89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
90 if (mTodo->percentComplete()<100) { 90 if (mTodo->percentComplete()<100) {
91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
92 else setSortKey(2,QString::number(mTodo->percentComplete())); 92 else setSortKey(2,QString::number(mTodo->percentComplete()));
93 } 93 }
94 else { 94 else {
95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
96 else setSortKey(2,QString::number(99)); 96 else setSortKey(2,QString::number(99));
97 } 97 }
98 if (mTodo->hasDueDate()) { 98 if (mTodo->hasDueDate()) {
99 setText(3, mTodo->dtDueDateStr()); 99 setText(3, mTodo->dtDueDateStr());
100 QDate d = mTodo->dtDue().date(); 100 QDate d = mTodo->dtDue().date();
101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
102 // setSortKey(3,keyd); 102 // setSortKey(3,keyd);
103 if (mTodo->doesFloat()) { 103 if (mTodo->doesFloat()) {
104 setText(4,""); 104 setText(4,"");
105 } 105 }
106 else { 106 else {
107 setText(4,mTodo->dtDueTimeStr()); 107 setText(4,mTodo->dtDueTimeStr());
108 QTime t = mTodo->dtDue().time(); 108 QTime t = mTodo->dtDue().time();
109 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 109 keyt.sprintf("%02d%02d",t.hour(),t.minute());
110 //setSortKey(4,keyt); 110 //setSortKey(4,keyt);
111 } 111 }
112 } else { 112 } else {
113 setText(3,""); 113 setText(3,"");
114 setText(4,""); 114 setText(4,"");
115 } 115 }
116 setSortKey(3,keyd); 116 setSortKey(3,keyd);
117 setSortKey(4,keyt); 117 setSortKey(4,keyt);
118 118
119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
121 121
122 122
123 123
124 keyd = ""; 124 keyd = "";
125 keyt = ""; 125 keyt = "";
126 126
127 if (mTodo->isRunning() ) { 127 if (mTodo->isRunning() ) {
128 QDate d = mTodo->runStart().date(); 128 QDate d = mTodo->runStart().date();
129 QTime t = mTodo->runStart().time(); 129 QTime t = mTodo->runStart().time();
130 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 130 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
132 keyd = KGlobal::locale()->formatDate( d , true); 132 keyd = KGlobal::locale()->formatDate( d , true);
133 keyt = KGlobal::locale()->formatTime( t ); 133 keyt = KGlobal::locale()->formatTime( t );
134 134
135 } else { 135 } else {
136 136
137 if (mTodo->hasStartDate()) { 137 if (mTodo->hasStartDate()) {
138 keyd = mTodo->dtStartDateStr(); 138 keyd = mTodo->dtStartDateStr();
139 QDate d = mTodo->dtStart().date(); 139 QDate d = mTodo->dtStart().date();
140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
141 141
142 if ( !mTodo->doesFloat()) { 142 if ( !mTodo->doesFloat()) {
143 keyt = mTodo->dtStartTimeStr(); 143 keyt = mTodo->dtStartTimeStr();
144 QTime t = mTodo->dtStart().time(); 144 QTime t = mTodo->dtStart().time();
145 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 145 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
146 146
147 } 147 }
148 148
149 } 149 }
150 } 150 }
151 setText(5,keyd); 151 setText(5,keyd);
152 setText(6,keyt); 152 setText(6,keyt);
153 setSortKey(5,skeyd); 153 setSortKey(5,skeyd);
154 setSortKey(6,skeyt); 154 setSortKey(6,skeyt);
155 155
156 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 156 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
157 setText(8,mTodo->categoriesStr()); 157 setText(8,mTodo->categoriesStr());
158 158
159#if 0 159#if 0
160 // Find sort id in description. It's the text behind the last '#' character 160 // Find sort id in description. It's the text behind the last '#' character
161 // found in the description. White spaces are removed from beginning and end 161 // found in the description. White spaces are removed from beginning and end
162 // of sort id. 162 // of sort id.
163 int pos = mTodo->description().findRev('#'); 163 int pos = mTodo->description().findRev('#');
164 if (pos < 0) { 164 if (pos < 0) {
165 setText(6,""); 165 setText(6,"");
166 } else { 166 } else {
167 QString str = mTodo->description().mid(pos+1); 167 QString str = mTodo->description().mid(pos+1);
168 str.stripWhiteSpace(); 168 str.stripWhiteSpace();
169 setText(6,str); 169 setText(6,str);
170 } 170 }
171#endif 171#endif
172 172
173 m_known = false; 173 m_known = false;
174 m_init = false; 174 m_init = false;
175 175
176 setMyPixmap(); 176 setMyPixmap();
177 177
178} 178}
179void KOTodoViewItem::setMyPixmap() 179void KOTodoViewItem::setMyPixmap()
180{ 180{
181 int size = 5; 181 int size = 5;
182 QPixmap pixi = QPixmap( 1, 1 ); 182 QPixmap pixi = QPixmap( 1, 1 );
183 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 183 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
184// pixi = SmallIcon("redcross16"); 184// pixi = SmallIcon("redcross16");
185// } else { 185// } else {
186 QPainter p; 186 QPainter p;
187 187
188 int pixSize = 0; 188 int pixSize = 0;
189 QPixmap pPix = QPixmap( size, size ); 189 QPixmap pPix = QPixmap( size, size );
190 if ( mTodo->description().length() > 0 ) { 190 if ( mTodo->description().length() > 0 ) {
191 pixi.resize(size, pixSize+size); 191 pixi.resize(size, pixSize+size);
192 pPix.fill( Qt::darkGreen ); 192 pPix.fill( Qt::darkGreen );
193 p.begin( &pixi ); 193 p.begin( &pixi );
194 p. drawPixmap ( 0, pixSize, pPix); 194 p. drawPixmap ( 0, pixSize, pPix);
195 p.end(); 195 p.end();
196 pixSize += size; 196 pixSize += size;
197 } 197 }
198 if ( mTodo->isAlarmEnabled() ) { 198 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) {
199 pixi.resize(size, pixSize+size); 199 pixi.resize(size, pixSize+size);
200 pPix.fill( Qt::red ); 200 pPix.fill( Qt::red );
201 p.begin( &pixi ); 201 p.begin( &pixi );
202 p. drawPixmap ( 0, pixSize, pPix); 202 p. drawPixmap ( 0, pixSize, pPix);
203 p.end(); 203 p.end();
204 pixSize += size; 204 pixSize += size;
205 } 205 }
206 if ( mTodo->doesRecur() ) { 206 if ( mTodo->doesRecur() ) {
207 pixi.resize(size, pixSize+size); 207 pixi.resize(size, pixSize+size);
208 pPix.fill( Qt::blue ); 208 pPix.fill( Qt::blue );
209 p.begin( &pixi ); 209 p.begin( &pixi );
210 p. drawPixmap ( 0, pixSize, pPix); 210 p. drawPixmap ( 0, pixSize, pPix);
211 p.end(); 211 p.end();
212 pixSize += size; 212 pixSize += size;
213 } 213 }
214 // } 214 // }
215 if ( pixi.width() > 1 ) { 215 if ( pixi.width() > 1 ) {
216 setPixmap ( 0,pixi ) ; 216 setPixmap ( 0,pixi ) ;
217 } else { 217 } else {
218 setPixmap ( 0,QPixmap() ) ; 218 setPixmap ( 0,QPixmap() ) ;
219 } 219 }
220} 220}
221void KOTodoViewItem::stateChange(bool state) 221void KOTodoViewItem::stateChange(bool state)
222{ 222{
223 // qDebug("KOTodoViewItem::stateChange %d ", state); 223 // qDebug("KOTodoViewItem::stateChange %d ", state);
224 // do not change setting on startup 224 // do not change setting on startup
225 if ( m_init ) return; 225 if ( m_init ) return;
226 if (isOn()!=state) { 226 if (isOn()!=state) {
227 setOn(state); 227 setOn(state);
228 //qDebug("SETON "); 228 //qDebug("SETON ");
229 return; 229 return;
230 } 230 }
231 if ( mTodo->isCompleted() == state ) { 231 if ( mTodo->isCompleted() == state ) {
232 //qDebug("STATECHANGE:nothing to do "); 232 //qDebug("STATECHANGE:nothing to do ");
233 return; 233 return;
234 } 234 }
235 QString keyd = "=="; 235 QString keyd = "==";
236 QString keyt = "=="; 236 QString keyt = "==";
237 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 237 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
238 if ( mTodo->doesRecur() ){ 238 if ( mTodo->doesRecur() ){
239 QDateTime start = mTodo->dtStart(); 239 QDateTime start = mTodo->dtStart();
240 mTodo->setCompleted(state); 240 mTodo->setCompleted(state);
241 if ( start != mTodo->dtStart() ) { 241 if ( start != mTodo->dtStart() ) {
242 if ( state && !mTodo->isCompleted() ) { 242 if ( state && !mTodo->isCompleted() ) {
243 setOn( false ); 243 setOn( false );
244 state = false; 244 state = false;
245 } 245 }
246 } 246 }
247 } else 247 } else
248 mTodo->setCompleted(state); 248 mTodo->setCompleted(state);
249 249
250 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 250 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
251 251
252 if (mTodo->hasDueDate()) { 252 if (mTodo->hasDueDate()) {
253 setText(3, mTodo->dtDueDateStr()); 253 setText(3, mTodo->dtDueDateStr());
254 QDate d = mTodo->dtDue().date(); 254 QDate d = mTodo->dtDue().date();
255 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 255 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
256 setSortKey(3,keyd); 256 setSortKey(3,keyd);
257 if (mTodo->doesFloat()) { 257 if (mTodo->doesFloat()) {
258 setText(4,""); 258 setText(4,"");
259 } 259 }
260 else { 260 else {
261 setText(4,mTodo->dtDueTimeStr()); 261 setText(4,mTodo->dtDueTimeStr());
262 QTime t = mTodo->dtDue().time(); 262 QTime t = mTodo->dtDue().time();
263 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 263 keyt.sprintf("%02d%02d",t.hour(),t.minute());
264 setSortKey(4,keyt); 264 setSortKey(4,keyt);
265 } 265 }
266 } 266 }
267 if (mTodo->hasStartDate()) { 267 if (mTodo->hasStartDate()) {
268 QString skeyt = "=="; 268 QString skeyt = "==";
269 QString skeyd = "=="; 269 QString skeyd = "==";
270 setText(5, mTodo->dtStartDateStr()); 270 setText(5, mTodo->dtStartDateStr());
271 QDate d = mTodo->dtStart().date(); 271 QDate d = mTodo->dtStart().date();
272 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 272 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
273 273
274 if (mTodo->doesFloat()) { 274 if (mTodo->doesFloat()) {
275 setText(6,""); 275 setText(6,"");
276 } 276 }
277 else { 277 else {
278 setText(6,mTodo->dtStartTimeStr()); 278 setText(6,mTodo->dtStartTimeStr());
279 QTime t = mTodo->dtStart().time(); 279 QTime t = mTodo->dtStart().time();
280 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 280 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
281 281
282 } 282 }
283 setSortKey(5,skeyd); 283 setSortKey(5,skeyd);
284 setSortKey(6,skeyt); 284 setSortKey(6,skeyt);
285 } 285 }
286 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 286 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
287 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 287 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
288 288
289 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 289 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
290 if (mTodo->percentComplete()<100) { 290 if (mTodo->percentComplete()<100) {
291 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 291 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
292 else setSortKey(2,QString::number(mTodo->percentComplete())); 292 else setSortKey(2,QString::number(mTodo->percentComplete()));
293 } 293 }
294 else { 294 else {
295 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 295 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
296 else setSortKey(2,QString::number(99)); 296 else setSortKey(2,QString::number(99));
297 } 297 }
298 if ( state ) { 298 if ( state ) {
299 QListViewItem * myChild = firstChild(); 299 QListViewItem * myChild = firstChild();
300 KOTodoViewItem *item; 300 KOTodoViewItem *item;
301 while( myChild ) { 301 while( myChild ) {
302 //qDebug("stateCH "); 302 //qDebug("stateCH ");
303 item = static_cast<KOTodoViewItem*>(myChild); 303 item = static_cast<KOTodoViewItem*>(myChild);
304 item->stateChange(state); 304 item->stateChange(state);
305 myChild = myChild->nextSibling(); 305 myChild = myChild->nextSibling();
306 } 306 }
307 } else { 307 } else {
308 QListViewItem * myChild = parent(); 308 QListViewItem * myChild = parent();
309 if ( myChild ) 309 if ( myChild )
310 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 310 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
311 } 311 }
312 mTodoView->modified(true); 312 mTodoView->modified(true);
313 setMyPixmap(); 313 setMyPixmap();
314 mTodoView->setTodoModified( mTodo ); 314 mTodoView->setTodoModified( mTodo );
315} 315}
316 316
317bool KOTodoViewItem::isAlternate() 317bool KOTodoViewItem::isAlternate()
318{ 318{
319 319
320 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 320 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
321 if (lv && lv->alternateBackground().isValid()) 321 if (lv && lv->alternateBackground().isValid())
322 { 322 {
323 KOTodoViewItem *above = 0; 323 KOTodoViewItem *above = 0;
324 above = static_cast<KOTodoViewItem *>(itemAbove()); 324 above = static_cast<KOTodoViewItem *>(itemAbove());
325 m_known = above ? above->m_known : true; 325 m_known = above ? above->m_known : true;
326 if (m_known) 326 if (m_known)
327 { 327 {
328 m_odd = above ? !above->m_odd : false; 328 m_odd = above ? !above->m_odd : false;
329 } 329 }
330 else 330 else
331 { 331 {
332 KOTodoViewItem *item; 332 KOTodoViewItem *item;
333 bool previous = true; 333 bool previous = true;
334 if (QListViewItem::parent()) 334 if (QListViewItem::parent())
335 { 335 {
336 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); 336 item = static_cast<KOTodoViewItem *>(QListViewItem::parent());
337 if (item) 337 if (item)
338 previous = item->m_odd; 338 previous = item->m_odd;
339 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 339 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
340 } 340 }
341 else 341 else
342 { 342 {
343 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 343 item = static_cast<KOTodoViewItem *>(lv->firstChild());
344 } 344 }
345 345
346 while(item) 346 while(item)
347 { 347 {
348 item->m_odd = previous = !previous; 348 item->m_odd = previous = !previous;
349 item->m_known = true; 349 item->m_known = true;
350 item = static_cast<KOTodoViewItem *>(item->nextSibling()); 350 item = static_cast<KOTodoViewItem *>(item->nextSibling());
351 } 351 }
352 } 352 }
353 return m_odd; 353 return m_odd;
354 } 354 }
355 return false; 355 return false;
356} 356}
357 357
358void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 358void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
359{ 359{
360 QColorGroup _cg = cg; 360 QColorGroup _cg = cg;
361 QColorGroup::ColorRole role; 361 QColorGroup::ColorRole role;
362 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 362 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
363 role = QColorGroup::Text; 363 role = QColorGroup::Text;
364 else 364 else
365 role = QColorGroup::Base; 365 role = QColorGroup::Base;
366 //#ifndef KORG_NOLVALTERNATION 366 //#ifndef KORG_NOLVALTERNATION
367 if (isAlternate()) 367 if (isAlternate())
368 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 368 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
369 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 369 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
370 QColor colorToSet; 370 QColor colorToSet;
371 if ( setColor ) { 371 if ( setColor ) {
372 QStringList categories = mTodo->categories(); 372 QStringList categories = mTodo->categories();
373 QString cat = categories.first(); 373 QString cat = categories.first();
374 if ( !cat.isEmpty()) { 374 if ( !cat.isEmpty()) {
375 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 375 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
376 } else 376 } else
377 setColor = false; 377 setColor = false;
378 } 378 }
379 bool openMode = !isOpen(); 379 bool openMode = !isOpen();
380 // maybe we are in flat-display-mode 380 // maybe we are in flat-display-mode
381 if ( !firstChild() ) 381 if ( !firstChild() )
382 openMode = false; 382 openMode = false;
383 bool colorRunning = mTodo->isRunning(); 383 bool colorRunning = mTodo->isRunning();
384 if ( ! colorRunning && openMode ) 384 if ( ! colorRunning && openMode )
385 colorRunning = mTodo->hasRunningSub(); 385 colorRunning = mTodo->hasRunningSub();
386 if ( colorRunning ) { 386 if ( colorRunning ) {
387 setColor = true; 387 setColor = true;
388 colorToSet = KOPrefs::instance()->mTodoRunColor; 388 colorToSet = KOPrefs::instance()->mTodoRunColor;
389 } else { 389 } else {
390 int odue = mTodo->hasDueSubTodo( openMode ); 390 int odue = mTodo->hasDueSubTodo( openMode );
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index e8574a0..221debc 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -406,384 +406,384 @@ void KOWhatsNextView::updateView()
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->typeID() == eventID) 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->typeID() == eventID ) { 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() && ev->alarmEnabled()) {
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->typeID() == eventID ) tempText += "href=\"event:"; 623 if (ev->typeID() == eventID ) tempText += "href=\"event:";
624 if (ev->typeID() == todoID ) 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->typeID() == todoID ) { 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() && ev->alarmEnabled() ) {
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();
731 Incidence *to; 731 Incidence *to;
732 for (to=Relations.first();to;to=Relations.next()) { 732 for (to=Relations.first();to;to=Relations.next()) {
733 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) 733 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio )
734 appendTodo( to, ind , true ); 734 appendTodo( to, ind , true );
735 } 735 }
736 736
737 return true; 737 return true;
738} 738}
739 739
740/* 740/*
741 void KOWhatsNextView::createEventViewer() 741 void KOWhatsNextView::createEventViewer()
742 { 742 {
743 if (!mEventViewer) { 743 if (!mEventViewer) {
744 744
745 mEventViewer = new KOEventViewerDialog(this); 745 mEventViewer = new KOEventViewerDialog(this);
746 } 746 }
747 } 747 }
748*/ 748*/
749void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 749void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
750{ 750{
751 mEventViewer = v; 751 mEventViewer = v;
752} 752}
753 753
754// TODO: Create this function in CalendarView and remove it from here 754// TODO: Create this function in CalendarView and remove it from here
755void KOWhatsNextView::showIncidence(const QString &uid) 755void KOWhatsNextView::showIncidence(const QString &uid)
756{ 756{
757 757
758 if ( !mEventViewer ) { 758 if ( !mEventViewer ) {
759 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 759 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
760 return; 760 return;
761 } 761 }
762 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 762 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
763 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 763 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
764 if (uid.startsWith("event:")) { 764 if (uid.startsWith("event:")) {
765#ifdef DESKTOP_VERSION 765#ifdef DESKTOP_VERSION
766 Event *event = calendar()->event(uid.mid(8)); 766 Event *event = calendar()->event(uid.mid(8));
767#else 767#else
768 Event *event = calendar()->event(uid.mid(6)); 768 Event *event = calendar()->event(uid.mid(6));
769#endif 769#endif
770 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 770 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
771 if (!event) return; 771 if (!event) return;
772 //createEventViewer(); 772 //createEventViewer();
773 mEventViewer->setEvent(event); 773 mEventViewer->setEvent(event);
774 } else if (uid.startsWith("todo:")) { 774 } else if (uid.startsWith("todo:")) {
775#ifdef DESKTOP_VERSION 775#ifdef DESKTOP_VERSION
776 Todo *todo = calendar()->todo(uid.mid(7)); 776 Todo *todo = calendar()->todo(uid.mid(7));
777#else 777#else
778 Todo *todo = calendar()->todo(uid.mid(5)); 778 Todo *todo = calendar()->todo(uid.mid(5));
779#endif 779#endif
780 if (!todo) return; 780 if (!todo) return;
781 //createEventViewer(); 781 //createEventViewer();
782 mEventViewer->setTodo(todo); 782 mEventViewer->setTodo(todo);
783 } else { 783 } else {
784 return; 784 return;
785 785
786 } 786 }
787 mEventViewer->showMe(); 787 mEventViewer->showMe();
788 mEventViewer->raise(); 788 mEventViewer->raise();
789} 789}
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 0afa0a7..79e0464 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -182,300 +182,302 @@ void Alarm::setProcedureAlarm(const QString &programFile, const QString &argumen
182 mType = Procedure; 182 mType = Procedure;
183 mFile = programFile; 183 mFile = programFile;
184 mDescription = arguments; 184 mDescription = arguments;
185 mParent->updated(); 185 mParent->updated();
186} 186}
187 187
188void Alarm::setProgramFile(const QString &programFile) 188void Alarm::setProgramFile(const QString &programFile)
189{ 189{
190 if (mType == Procedure) { 190 if (mType == Procedure) {
191 mFile = programFile; 191 mFile = programFile;
192 mParent->updated(); 192 mParent->updated();
193 } 193 }
194} 194}
195 195
196QString Alarm::programFile() const 196QString Alarm::programFile() const
197{ 197{
198 return (mType == Procedure) ? mFile : QString::null; 198 return (mType == Procedure) ? mFile : QString::null;
199} 199}
200 200
201void Alarm::setProgramArguments(const QString &arguments) 201void Alarm::setProgramArguments(const QString &arguments)
202{ 202{
203 if (mType == Procedure) { 203 if (mType == Procedure) {
204 mDescription = arguments; 204 mDescription = arguments;
205 mParent->updated(); 205 mParent->updated();
206 } 206 }
207} 207}
208 208
209QString Alarm::programArguments() const 209QString Alarm::programArguments() const
210{ 210{
211 return (mType == Procedure) ? mDescription : QString::null; 211 return (mType == Procedure) ? mDescription : QString::null;
212} 212}
213 213
214void Alarm::setEmailAlarm(const QString &subject, const QString &text, 214void Alarm::setEmailAlarm(const QString &subject, const QString &text,
215 const QValueList<Person> &addressees, const QStringList &attachments) 215 const QValueList<Person> &addressees, const QStringList &attachments)
216{ 216{
217 mType = Email; 217 mType = Email;
218 mMailSubject = subject; 218 mMailSubject = subject;
219 mDescription = text; 219 mDescription = text;
220 mMailAddresses = addressees; 220 mMailAddresses = addressees;
221 mMailAttachFiles = attachments; 221 mMailAttachFiles = attachments;
222 mParent->updated(); 222 mParent->updated();
223} 223}
224 224
225void Alarm::setMailAddress(const Person &mailAddress) 225void Alarm::setMailAddress(const Person &mailAddress)
226{ 226{
227 if (mType == Email) { 227 if (mType == Email) {
228 mMailAddresses.clear(); 228 mMailAddresses.clear();
229 mMailAddresses += mailAddress; 229 mMailAddresses += mailAddress;
230 mParent->updated(); 230 mParent->updated();
231 } 231 }
232} 232}
233 233
234void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) 234void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses)
235{ 235{
236 if (mType == Email) { 236 if (mType == Email) {
237 mMailAddresses = mailAddresses; 237 mMailAddresses = mailAddresses;
238 mParent->updated(); 238 mParent->updated();
239 } 239 }
240} 240}
241 241
242void Alarm::addMailAddress(const Person &mailAddress) 242void Alarm::addMailAddress(const Person &mailAddress)
243{ 243{
244 if (mType == Email) { 244 if (mType == Email) {
245 mMailAddresses += mailAddress; 245 mMailAddresses += mailAddress;
246 mParent->updated(); 246 mParent->updated();
247 } 247 }
248} 248}
249 249
250QValueList<Person> Alarm::mailAddresses() const 250QValueList<Person> Alarm::mailAddresses() const
251{ 251{
252 return (mType == Email) ? mMailAddresses : QValueList<Person>(); 252 return (mType == Email) ? mMailAddresses : QValueList<Person>();
253} 253}
254 254
255void Alarm::setMailSubject(const QString &mailAlarmSubject) 255void Alarm::setMailSubject(const QString &mailAlarmSubject)
256{ 256{
257 if (mType == Email) { 257 if (mType == Email) {
258 mMailSubject = mailAlarmSubject; 258 mMailSubject = mailAlarmSubject;
259 mParent->updated(); 259 mParent->updated();
260 } 260 }
261} 261}
262 262
263QString Alarm::mailSubject() const 263QString Alarm::mailSubject() const
264{ 264{
265 return (mType == Email) ? mMailSubject : QString::null; 265 return (mType == Email) ? mMailSubject : QString::null;
266} 266}
267 267
268void Alarm::setMailAttachment(const QString &mailAttachFile) 268void Alarm::setMailAttachment(const QString &mailAttachFile)
269{ 269{
270 if (mType == Email) { 270 if (mType == Email) {
271 mMailAttachFiles.clear(); 271 mMailAttachFiles.clear();
272 mMailAttachFiles += mailAttachFile; 272 mMailAttachFiles += mailAttachFile;
273 mParent->updated(); 273 mParent->updated();
274 } 274 }
275} 275}
276 276
277void Alarm::setMailAttachments(const QStringList &mailAttachFiles) 277void Alarm::setMailAttachments(const QStringList &mailAttachFiles)
278{ 278{
279 if (mType == Email) { 279 if (mType == Email) {
280 mMailAttachFiles = mailAttachFiles; 280 mMailAttachFiles = mailAttachFiles;
281 mParent->updated(); 281 mParent->updated();
282 } 282 }
283} 283}
284 284
285void Alarm::addMailAttachment(const QString &mailAttachFile) 285void Alarm::addMailAttachment(const QString &mailAttachFile)
286{ 286{
287 if (mType == Email) { 287 if (mType == Email) {
288 mMailAttachFiles += mailAttachFile; 288 mMailAttachFiles += mailAttachFile;
289 mParent->updated(); 289 mParent->updated();
290 } 290 }
291} 291}
292 292
293QStringList Alarm::mailAttachments() const 293QStringList Alarm::mailAttachments() const
294{ 294{
295 return (mType == Email) ? mMailAttachFiles : QStringList(); 295 return (mType == Email) ? mMailAttachFiles : QStringList();
296} 296}
297 297
298void Alarm::setMailText(const QString &text) 298void Alarm::setMailText(const QString &text)
299{ 299{
300 if (mType == Email) { 300 if (mType == Email) {
301 mDescription = text; 301 mDescription = text;
302 mParent->updated(); 302 mParent->updated();
303 } 303 }
304} 304}
305 305
306QString Alarm::mailText() const 306QString Alarm::mailText() const
307{ 307{
308 return (mType == Email) ? mDescription : QString::null; 308 return (mType == Email) ? mDescription : QString::null;
309} 309}
310 310
311void Alarm::setDisplayAlarm(const QString &text) 311void Alarm::setDisplayAlarm(const QString &text)
312{ 312{
313 mType = Display; 313 mType = Display;
314 mDescription = text; 314 mDescription = text;
315 mParent->updated(); 315 mParent->updated();
316} 316}
317 317
318void Alarm::setText(const QString &text) 318void Alarm::setText(const QString &text)
319{ 319{
320 if (mType == Display) { 320 if (mType == Display) {
321 mDescription = text; 321 mDescription = text;
322 mParent->updated(); 322 mParent->updated();
323 } 323 }
324} 324}
325 325
326QString Alarm::text() const 326QString Alarm::text() const
327{ 327{
328 return (mType == Display) ? mDescription : QString::null; 328 return (mType == Display) ? mDescription : QString::null;
329} 329}
330 330
331void Alarm::setTime(const QDateTime &alarmTime) 331void Alarm::setTime(const QDateTime &alarmTime)
332{ 332{
333 mAlarmTime = alarmTime; 333 mAlarmTime = alarmTime;
334 mHasTime = true; 334 mHasTime = true;
335 335
336 mParent->updated(); 336 mParent->updated();
337} 337}
338int Alarm::offset() 338int Alarm::offset()
339{ 339{
340 if ( hasTime() ) { 340 if ( hasTime() ) {
341 if (mParent->typeID() == todoID ) { 341 if (mParent->typeID() == todoID ) {
342 Todo *t = static_cast<Todo*>(mParent); 342 Todo *t = static_cast<Todo*>(mParent);
343 return t->dtDue().secsTo( mAlarmTime ) ; 343 return t->dtDue().secsTo( mAlarmTime ) ;
344 } else 344 } else
345 return mParent->dtStart().secsTo( mAlarmTime ) ; 345 return mParent->dtStart().secsTo( mAlarmTime ) ;
346 } 346 }
347 else 347 else
348 { 348 {
349 return mOffset.asSeconds(); 349 return mOffset.asSeconds();
350 } 350 }
351 351
352} 352}
353QString Alarm::offsetText() 353QString Alarm::offsetText()
354{ 354{
355 int min = -offset()/60; 355 int min = -offset()/60;
356 int hours = min /60; 356 int hours = min /60;
357 min = min % 60; 357 min = min % 60;
358 int days = hours /24; 358 int days = hours /24;
359 hours = hours % 24; 359 hours = hours % 24;
360 QString message; 360 QString message;
361 //qDebug("%d %d %d ", days, hours, min ); 361 //qDebug("%d %d %d ", days, hours, min );
362 if ( days > 0 ) 362 if ( days > 0 )
363 message += i18n("%1d").arg( days ); 363 message += i18n("%1d").arg( days );
364 if ( hours > 0 ) { 364 if ( hours > 0 ) {
365 if ( !message.isEmpty() ) message += "/"; 365 if ( !message.isEmpty() ) message += "/";
366 message += i18n("%1h").arg( hours ); 366 message += i18n("%1h").arg( hours );
367 } 367 }
368 if ( min > 0 ) { 368 if ( min > 0 ) {
369 if ( !message.isEmpty() ) message += "/"; 369 if ( !message.isEmpty() ) message += "/";
370 message += i18n("%1min").arg( min ); 370 message += i18n("%1min").arg( min );
371 } 371 }
372 if ( message.isEmpty() ) 372 if ( message.isEmpty() )
373 message = i18n("%1min").arg( 0 ); 373 message = i18n("%1min").arg( 0 );
374 if ( !mParent->alarmEnabled() )
375 return "!"+message + i18n("(disabled)");
374 return message; 376 return message;
375} 377}
376 378
377 379
378QDateTime Alarm::time() const 380QDateTime Alarm::time() const
379{ 381{
380 if ( hasTime() ) 382 if ( hasTime() )
381 return mAlarmTime; 383 return mAlarmTime;
382 else 384 else
383 { 385 {
384 if (mParent->typeID() == todoID ) { 386 if (mParent->typeID() == todoID ) {
385 Todo *t = static_cast<Todo*>(mParent); 387 Todo *t = static_cast<Todo*>(mParent);
386 return mOffset.end( t->dtDue() ); 388 return mOffset.end( t->dtDue() );
387 } else if (mEndOffset) { 389 } else if (mEndOffset) {
388 return mOffset.end( mParent->dtEnd() ); 390 return mOffset.end( mParent->dtEnd() );
389 } else { 391 } else {
390 return mOffset.end( mParent->dtStart() ); 392 return mOffset.end( mParent->dtStart() );
391 } 393 }
392 } 394 }
393} 395}
394 396
395bool Alarm::hasTime() const 397bool Alarm::hasTime() const
396{ 398{
397 return mHasTime; 399 return mHasTime;
398} 400}
399 401
400void Alarm::setSnoozeTime(int alarmSnoozeTime) 402void Alarm::setSnoozeTime(int alarmSnoozeTime)
401{ 403{
402 mAlarmSnoozeTime = alarmSnoozeTime; 404 mAlarmSnoozeTime = alarmSnoozeTime;
403 mParent->updated(); 405 mParent->updated();
404} 406}
405 407
406int Alarm::snoozeTime() const 408int Alarm::snoozeTime() const
407{ 409{
408 return mAlarmSnoozeTime; 410 return mAlarmSnoozeTime;
409} 411}
410 412
411void Alarm::setRepeatCount(int alarmRepeatCount) 413void Alarm::setRepeatCount(int alarmRepeatCount)
412{ 414{
413 kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; 415 kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl;
414 416
415 mAlarmRepeatCount = alarmRepeatCount; 417 mAlarmRepeatCount = alarmRepeatCount;
416 mParent->updated(); 418 mParent->updated();
417} 419}
418 420
419int Alarm::repeatCount() const 421int Alarm::repeatCount() const
420{ 422{
421 kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; 423 kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl;
422 return mAlarmRepeatCount; 424 return mAlarmRepeatCount;
423} 425}
424 426
425void Alarm::toggleAlarm() 427void Alarm::toggleAlarm()
426{ 428{
427 mAlarmEnabled = !mAlarmEnabled; 429 mAlarmEnabled = !mAlarmEnabled;
428 mParent->updated(); 430 mParent->updated();
429} 431}
430 432
431void Alarm::setEnabled(bool enable) 433void Alarm::setEnabled(bool enable)
432{ 434{
433 mAlarmEnabled = enable; 435 mAlarmEnabled = enable;
434 mParent->updated(); 436 mParent->updated();
435} 437}
436 438
437bool Alarm::enabled() const 439bool Alarm::enabled() const
438{ 440{
439 return mAlarmEnabled; 441 return mAlarmEnabled;
440} 442}
441 443
442void Alarm::setStartOffset( const Duration &offset ) 444void Alarm::setStartOffset( const Duration &offset )
443{ 445{
444 mOffset = offset; 446 mOffset = offset;
445 mEndOffset = false; 447 mEndOffset = false;
446 mHasTime = false; 448 mHasTime = false;
447 mParent->updated(); 449 mParent->updated();
448} 450}
449 451
450Duration Alarm::startOffset() const 452Duration Alarm::startOffset() const
451{ 453{
452 return (mHasTime || mEndOffset) ? 0 : mOffset; 454 return (mHasTime || mEndOffset) ? 0 : mOffset;
453} 455}
454 456
455bool Alarm::hasStartOffset() const 457bool Alarm::hasStartOffset() const
456{ 458{
457 return !mHasTime && !mEndOffset; 459 return !mHasTime && !mEndOffset;
458} 460}
459 461
460bool Alarm::hasEndOffset() const 462bool Alarm::hasEndOffset() const
461{ 463{
462 return !mHasTime && mEndOffset; 464 return !mHasTime && mEndOffset;
463} 465}
464 466
465void Alarm::setEndOffset( const Duration &offset ) 467void Alarm::setEndOffset( const Duration &offset )
466{ 468{
467 mOffset = offset; 469 mOffset = offset;
468 mEndOffset = true; 470 mEndOffset = true;
469 mHasTime = false; 471 mHasTime = false;
470 mParent->updated(); 472 mParent->updated();
471} 473}
472 474
473Duration Alarm::endOffset() const 475Duration Alarm::endOffset() const
474{ 476{
475 return (mHasTime || !mEndOffset) ? 0 : mOffset; 477 return (mHasTime || !mEndOffset) ? 0 : mOffset;
476} 478}
477 479
478void Alarm::setParent( Incidence *parent ) 480void Alarm::setParent( Incidence *parent )
479{ 481{
480 mParent = parent; 482 mParent = parent;
481} 483}
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 5092d1a..a662eeb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -241,248 +241,248 @@ void Calendar::setEmail(const QString &e)
241 mOwnerEmail = e; 241 mOwnerEmail = e;
242 242
243 setModified( true ); 243 setModified( true );
244} 244}
245 245
246void Calendar::setFilter(CalFilter *filter) 246void Calendar::setFilter(CalFilter *filter)
247{ 247{
248 mFilter = filter; 248 mFilter = filter;
249} 249}
250 250
251CalFilter *Calendar::filter() 251CalFilter *Calendar::filter()
252{ 252{
253 return mFilter; 253 return mFilter;
254} 254}
255 255
256QPtrList<Incidence> Calendar::incidences() 256QPtrList<Incidence> Calendar::incidences()
257{ 257{
258 QPtrList<Incidence> incidences; 258 QPtrList<Incidence> incidences;
259 259
260 Incidence *i; 260 Incidence *i;
261 261
262 QPtrList<Event> e = events(); 262 QPtrList<Event> e = events();
263 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 263 for( i = e.first(); i; i = e.next() ) incidences.append( i );
264 264
265 QPtrList<Todo> t = todos(); 265 QPtrList<Todo> t = todos();
266 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 266 for( i = t.first(); i; i = t.next() ) incidences.append( i );
267 267
268 QPtrList<Journal> j = journals(); 268 QPtrList<Journal> j = journals();
269 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 269 for( i = j.first(); i; i = j.next() ) incidences.append( i );
270 270
271 return incidences; 271 return incidences;
272} 272}
273 273
274void Calendar::resetPilotStat(int id ) 274void Calendar::resetPilotStat(int id )
275{ 275{
276 QPtrList<Incidence> incidences; 276 QPtrList<Incidence> incidences;
277 277
278 Incidence *i; 278 Incidence *i;
279 279
280 QPtrList<Event> e = rawEvents(); 280 QPtrList<Event> e = rawEvents();
281 for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); 281 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
282 282
283 QPtrList<Todo> t = rawTodos(); 283 QPtrList<Todo> t = rawTodos();
284 for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); 284 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
285 285
286 QPtrList<Journal> j = journals(); 286 QPtrList<Journal> j = journals();
287 for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); 287 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
288} 288}
289void Calendar::resetTempSyncStat() 289void Calendar::resetTempSyncStat()
290{ 290{
291 QPtrList<Incidence> incidences; 291 QPtrList<Incidence> incidences;
292 292
293 Incidence *i; 293 Incidence *i;
294 294
295 QPtrList<Event> e = rawEvents(); 295 QPtrList<Event> e = rawEvents();
296 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 296 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
297 297
298 QPtrList<Todo> t = rawTodos(); 298 QPtrList<Todo> t = rawTodos();
299 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 299 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
300 300
301 QPtrList<Journal> j = journals(); 301 QPtrList<Journal> j = journals();
302 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 302 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
303} 303}
304QPtrList<Incidence> Calendar::rawIncidences() 304QPtrList<Incidence> Calendar::rawIncidences()
305{ 305{
306 QPtrList<Incidence> incidences; 306 QPtrList<Incidence> incidences;
307 307
308 Incidence *i; 308 Incidence *i;
309 309
310 QPtrList<Event> e = rawEvents(); 310 QPtrList<Event> e = rawEvents();
311 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 311 for( i = e.first(); i; i = e.next() ) incidences.append( i );
312 312
313 QPtrList<Todo> t = rawTodos(); 313 QPtrList<Todo> t = rawTodos();
314 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 314 for( i = t.first(); i; i = t.next() ) incidences.append( i );
315 315
316 QPtrList<Journal> j = journals(); 316 QPtrList<Journal> j = journals();
317 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 317 for( i = j.first(); i; i = j.next() ) incidences.append( i );
318 318
319 return incidences; 319 return incidences;
320} 320}
321 321
322QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 322QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
323{ 323{
324 QPtrList<Event> el = rawEventsForDate(date,sorted); 324 QPtrList<Event> el = rawEventsForDate(date,sorted);
325 mFilter->apply(&el); 325 mFilter->apply(&el);
326 return el; 326 return el;
327} 327}
328 328
329QPtrList<Event> Calendar::events( const QDateTime &qdt ) 329QPtrList<Event> Calendar::events( const QDateTime &qdt )
330{ 330{
331 QPtrList<Event> el = rawEventsForDate(qdt); 331 QPtrList<Event> el = rawEventsForDate(qdt);
332 mFilter->apply(&el); 332 mFilter->apply(&el);
333 return el; 333 return el;
334} 334}
335 335
336QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 336QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
337 bool inclusive) 337 bool inclusive)
338{ 338{
339 QPtrList<Event> el = rawEvents(start,end,inclusive); 339 QPtrList<Event> el = rawEvents(start,end,inclusive);
340 mFilter->apply(&el); 340 mFilter->apply(&el);
341 return el; 341 return el;
342} 342}
343 343
344QPtrList<Event> Calendar::events() 344QPtrList<Event> Calendar::events()
345{ 345{
346 QPtrList<Event> el = rawEvents(); 346 QPtrList<Event> el = rawEvents();
347 mFilter->apply(&el); 347 mFilter->apply(&el);
348 return el; 348 return el;
349} 349}
350void Calendar::addIncidenceBranch(Incidence *i) 350void Calendar::addIncidenceBranch(Incidence *i)
351{ 351{
352 addIncidence( i ); 352 addIncidence( i );
353 Incidence * inc; 353 Incidence * inc;
354 QPtrList<Incidence> Relations = i->relations(); 354 QPtrList<Incidence> Relations = i->relations();
355 for (inc=Relations.first();inc;inc=Relations.next()) { 355 for (inc=Relations.first();inc;inc=Relations.next()) {
356 addIncidenceBranch( inc ); 356 addIncidenceBranch( inc );
357 } 357 }
358} 358}
359 359
360bool Calendar::addIncidence(Incidence *i) 360bool Calendar::addIncidence(Incidence *i)
361{ 361{
362 Incidence::AddVisitor<Calendar> v(this); 362 Incidence::AddVisitor<Calendar> v(this);
363 i->setCalID( mDefaultCalendar ); 363 i->setCalID( mDefaultCalendar );
364 i->setCalEnabled( true ); 364 i->setCalEnabled( true );
365 return i->accept(v); 365 return i->accept(v);
366} 366}
367void Calendar::deleteIncidence(Incidence *in) 367void Calendar::deleteIncidence(Incidence *in)
368{ 368{
369 if ( in->typeID() == eventID ) 369 if ( in->typeID() == eventID )
370 deleteEvent( (Event*) in ); 370 deleteEvent( (Event*) in );
371 else if ( in->typeID() == todoID ) 371 else if ( in->typeID() == todoID )
372 deleteTodo( (Todo*) in); 372 deleteTodo( (Todo*) in);
373 else if ( in->typeID() == journalID ) 373 else if ( in->typeID() == journalID )
374 deleteJournal( (Journal*) in ); 374 deleteJournal( (Journal*) in );
375} 375}
376 376
377Incidence* Calendar::incidence( const QString& uid ) 377Incidence* Calendar::incidence( const QString& uid )
378{ 378{
379 Incidence* i; 379 Incidence* i;
380 380
381 if( (i = todo( uid )) != 0 ) 381 if( (i = todo( uid )) != 0 )
382 return i; 382 return i;
383 if( (i = event( uid )) != 0 ) 383 if( (i = event( uid )) != 0 )
384 return i; 384 return i;
385 if( (i = journal( uid )) != 0 ) 385 if( (i = journal( uid )) != 0 )
386 return i; 386 return i;
387 387
388 return 0; 388 return 0;
389} 389}
390 390
391QPtrList<Todo> Calendar::todos() 391QPtrList<Todo> Calendar::todos()
392{ 392{
393 QPtrList<Todo> tl = rawTodos(); 393 QPtrList<Todo> tl = rawTodos();
394 mFilter->apply( &tl ); 394 mFilter->apply( &tl );
395 return tl; 395 return tl;
396} 396}
397 397
398// When this is called, the todo have already been added to the calendar. 398// When this is called, the todo have already been added to the calendar.
399// This method is only about linking related todos 399// This method is only about linking related todos
400void Calendar::setupRelations( Incidence *incidence ) 400void Calendar::setupRelations( Incidence *incidence )
401{ 401{
402 QString uid = incidence->uid(); 402 QString uid = incidence->uid();
403 //qDebug("Calendar::setupRelations "); 403 //qDebug("Calendar::setupRelations ");
404 // First, go over the list of orphans and see if this is their parent 404 // First, go over the list of orphans and see if this is their parent
405 while( Incidence* i = mOrphans[ uid ] ) { 405 while( Incidence* i = mOrphans[ uid ] ) {
406 mOrphans.remove( uid ); 406 mOrphans.remove( uid );
407 i->setRelatedTo( incidence ); 407 i->setRelatedTo( incidence );
408 incidence->addRelation( i ); 408 incidence->addRelation( i );
409 mOrphanUids.remove( i->uid() ); 409 mOrphanUids.remove( i->uid() );
410 } 410 }
411 411
412 // Now see about this incidences parent 412 // Now see about this incidences parent
413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
414 // This incidence has a uid it is related to, but is not registered to it yet 414 // This incidence has a uid it is related to, but is not registered to it yet
415 // Try to find it 415 // Try to find it
416 Incidence* parent = this->incidence( incidence->relatedToUid() ); 416 Incidence* parent = this->incidence( incidence->relatedToUid() );
417 if( parent ) { 417 if( parent ) {
418 // Found it 418 // Found it
419 incidence->setRelatedTo( parent ); 419 incidence->setRelatedTo( parent );
420 parent->addRelation( incidence ); 420 parent->addRelation( incidence );
421 } else { 421 } else {
422 // Not found, put this in the mOrphans list 422 // Not found, put this in the mOrphans list
423 mOrphans.insert( incidence->relatedToUid(), incidence ); 423 mOrphans.insert( incidence->relatedToUid(), incidence );
424 mOrphanUids.insert( incidence->uid(), incidence ); 424 mOrphanUids.insert( incidence->uid(), incidence );
425 } 425 }
426 } 426 }
427} 427}
428 428
429// If a task with subtasks is deleted, move it's subtasks to the orphans list 429// If a task with subtasks is deleted, move it's subtasks to the orphans list
430void Calendar::removeRelations( Incidence *incidence ) 430void Calendar::removeRelations( Incidence *incidence )
431{ 431{
432 // qDebug("Calendar::removeRelations "); 432 // qDebug("Calendar::removeRelations ");
433 QString uid = incidence->uid(); 433 QString uid = incidence->uid();
434 434
435 QPtrList<Incidence> relations = incidence->relations(); 435 QPtrList<Incidence> relations = incidence->relations();
436 for( Incidence* i = relations.first(); i; i = relations.next() ) 436 for( Incidence* i = relations.first(); i; i = relations.next() )
437 if( !mOrphanUids.find( i->uid() ) ) { 437 if( !mOrphanUids.find( i->uid() ) ) {
438 mOrphans.insert( uid, i ); 438 mOrphans.insert( uid, i );
439 mOrphanUids.insert( i->uid(), i ); 439 mOrphanUids.insert( i->uid(), i );
440 i->setRelatedTo( 0 ); 440 i->setRelatedTo( 0 );
441 i->setRelatedToUid( uid ); 441 i->setRelatedToUid( uid );
442 } 442 }
443 443
444 // If this incidence is related to something else, tell that about it 444 // If this incidence is related to something else, tell that about it
445 if( incidence->relatedTo() ) 445 if( incidence->relatedTo() )
446 incidence->relatedTo()->removeRelation( incidence ); 446 incidence->relatedTo()->removeRelation( incidence );
447 447
448 // Remove this one from the orphans list 448 // Remove this one from the orphans list
449 if( mOrphanUids.remove( uid ) ) 449 if( mOrphanUids.remove( uid ) )
450 // This incidence is located in the orphans list - it should be removed 450 // This incidence is located in the orphans list - it should be removed
451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
452 // Removing wasn't that easy 452 // Removing wasn't that easy
453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
454 if( it.current()->uid() == uid ) { 454 if( it.current()->uid() == uid ) {
455 mOrphans.remove( it.currentKey() ); 455 mOrphans.remove( it.currentKey() );
456 break; 456 break;
457 } 457 }
458 } 458 }
459 } 459 }
460} 460}
461 461
462void Calendar::registerObserver( Observer *observer ) 462void Calendar::registerObserver( Observer *observer )
463{ 463{
464 mObserver = observer; 464 mObserver = observer;
465 mNewObserver = true; 465 mNewObserver = true;
466} 466}
467 467
468void Calendar::setModified( bool modified ) 468void Calendar::setModified( bool modified )
469{ 469{
470 if ( mObserver ) mObserver->calendarModified( modified, this ); 470 if ( mObserver ) mObserver->calendarModified( modified, this );
471 if ( modified != mModified || mNewObserver ) { 471 if ( modified != mModified || mNewObserver ) {
472 mNewObserver = false; 472 mNewObserver = false;
473 // if ( mObserver ) mObserver->calendarModified( modified, this ); 473 // if ( mObserver ) mObserver->calendarModified( modified, this );
474 mModified = modified; 474 mModified = modified;
475 } 475 }
476} 476}
477 477
478void Calendar::setLoadedProductId( const QString &id ) 478void Calendar::setLoadedProductId( const QString &id )
479{ 479{
480 mLoadedProductId = id; 480 mLoadedProductId = id;
481} 481}
482 482
483QString Calendar::loadedProductId() 483QString Calendar::loadedProductId()
484{ 484{
485 return mLoadedProductId; 485 return mLoadedProductId;
486} 486}
487 487
488//#include "calendar.moc" 488//#include "calendar.moc"
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 73f82bb..2243e28 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -123,251 +123,252 @@ public:
123 values). 123 values).
124 */ 124 */
125 void setTimeZoneId( const QString & ); 125 void setTimeZoneId( const QString & );
126 /** 126 /**
127 Return time zone id. 127 Return time zone id.
128 */ 128 */
129 QString timeZoneId() const; 129 QString timeZoneId() const;
130 /** 130 /**
131 Use local time, not UTC or a time zone. 131 Use local time, not UTC or a time zone.
132 */ 132 */
133 void setLocalTime(); 133 void setLocalTime();
134 /** 134 /**
135 Return whether local time is being used. 135 Return whether local time is being used.
136 */ 136 */
137 bool isLocalTime() const; 137 bool isLocalTime() const;
138 138
139 /** 139 /**
140 Add an incidence to calendar. 140 Add an incidence to calendar.
141 141
142 @return true on success, false on error. 142 @return true on success, false on error.
143 */ 143 */
144 virtual bool addIncidence( Incidence * ); 144 virtual bool addIncidence( Incidence * );
145 145
146 // Adds an incidence and all relatedto incidences to the cal 146 // Adds an incidence and all relatedto incidences to the cal
147 void addIncidenceBranch( Incidence * ); 147 void addIncidenceBranch( Incidence * );
148 /** 148 /**
149 Return filtered list of all incidences of this calendar. 149 Return filtered list of all incidences of this calendar.
150 */ 150 */
151 virtual QPtrList<Incidence> incidences(); 151 virtual QPtrList<Incidence> incidences();
152 152
153 /** 153 /**
154 Return unfiltered list of all incidences of this calendar. 154 Return unfiltered list of all incidences of this calendar.
155 */ 155 */
156 virtual QPtrList<Incidence> rawIncidences(); 156 virtual QPtrList<Incidence> rawIncidences();
157 157
158 /** 158 /**
159 Adds a Event to this calendar object. 159 Adds a Event to this calendar object.
160 @param anEvent a pointer to the event to add 160 @param anEvent a pointer to the event to add
161 161
162 @return true on success, false on error. 162 @return true on success, false on error.
163 */ 163 */
164 virtual bool addEventNoDup( Event *event ) = 0; 164 virtual bool addEventNoDup( Event *event ) = 0;
165 virtual bool addAnniversaryNoDup( Event *event ) = 0; 165 virtual bool addAnniversaryNoDup( Event *event ) = 0;
166 virtual bool addEvent( Event *anEvent ) = 0; 166 virtual bool addEvent( Event *anEvent ) = 0;
167 /** 167 /**
168 Delete event from calendar. 168 Delete event from calendar.
169 */ 169 */
170 virtual void deleteEvent( Event * ) = 0; 170 virtual void deleteEvent( Event * ) = 0;
171 /** 171 /**
172 Retrieves an event on the basis of the unique string ID. 172 Retrieves an event on the basis of the unique string ID.
173 */ 173 */
174 virtual Event *event( const QString &UniqueStr ) = 0; 174 virtual Event *event( const QString &UniqueStr ) = 0;
175 virtual Event *event( QString, QString ) = 0; 175 virtual Event *event( QString, QString ) = 0;
176 /** 176 /**
177 Builds and then returns a list of all events that match for the 177 Builds and then returns a list of all events that match for the
178 date specified. useful for dayView, etc. etc. 178 date specified. useful for dayView, etc. etc.
179 The calendar filter is applied. 179 The calendar filter is applied.
180 */ 180 */
181 QPtrList<Event> events( const QDate &date, bool sorted = false); 181 QPtrList<Event> events( const QDate &date, bool sorted = false);
182 /** 182 /**
183 Get events, which occur on the given date. 183 Get events, which occur on the given date.
184 The calendar filter is applied. 184 The calendar filter is applied.
185 */ 185 */
186 QPtrList<Event> events( const QDateTime &qdt ); 186 QPtrList<Event> events( const QDateTime &qdt );
187 /** 187 /**
188 Get events in a range of dates. If inclusive is set to true, only events 188 Get events in a range of dates. If inclusive is set to true, only events
189 are returned, which are completely included in the range. 189 are returned, which are completely included in the range.
190 The calendar filter is applied. 190 The calendar filter is applied.
191 */ 191 */
192 QPtrList<Event> events( const QDate &start, const QDate &end, 192 QPtrList<Event> events( const QDate &start, const QDate &end,
193 bool inclusive = false); 193 bool inclusive = false);
194 /** 194 /**
195 Return filtered list of all events in calendar. 195 Return filtered list of all events in calendar.
196 */ 196 */
197 virtual QPtrList<Event> events(); 197 virtual QPtrList<Event> events();
198 /** 198 /**
199 Return unfiltered list of all events in calendar. 199 Return unfiltered list of all events in calendar.
200 */ 200 */
201 virtual QPtrList<Event> rawEvents() = 0; 201 virtual QPtrList<Event> rawEvents() = 0;
202 202
203 /** 203 /**
204 Add a todo to the todolist. 204 Add a todo to the todolist.
205 205
206 @return true on success, false on error. 206 @return true on success, false on error.
207 */ 207 */
208 virtual bool addTodo( Todo *todo ) = 0; 208 virtual bool addTodo( Todo *todo ) = 0;
209 virtual bool addTodoNoDup( Todo *todo ) = 0; 209 virtual bool addTodoNoDup( Todo *todo ) = 0;
210 /** 210 /**
211 Remove a todo from the todolist. 211 Remove a todo from the todolist.
212 */ 212 */
213 virtual void deleteTodo( Todo * ) = 0; 213 virtual void deleteTodo( Todo * ) = 0;
214 virtual void deleteJournal( Journal * ) = 0; 214 virtual void deleteJournal( Journal * ) = 0;
215 /** 215 /**
216 Return filterd list of todos. 216 Return filterd list of todos.
217 */ 217 */
218 virtual QPtrList<Todo> todos(); 218 virtual QPtrList<Todo> todos();
219 /** 219 /**
220 Searches todolist for an event with this unique string identifier, 220 Searches todolist for an event with this unique string identifier,
221 returns a pointer or null. 221 returns a pointer or null.
222 */ 222 */
223 virtual Todo *todo( const QString &uid ) = 0; 223 virtual Todo *todo( const QString &uid ) = 0;
224 virtual Todo *todo( QString, QString ) = 0; 224 virtual Todo *todo( QString, QString ) = 0;
225 /** 225 /**
226 Returns list of todos due on the specified date. 226 Returns list of todos due on the specified date.
227 */ 227 */
228 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 228 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
229 /** 229 /**
230 Return unfiltered list of todos. 230 Return unfiltered list of todos.
231 */ 231 */
232 virtual QPtrList<Todo> rawTodos() = 0; 232 virtual QPtrList<Todo> rawTodos() = 0;
233 233
234 /** 234 /**
235 Add a Journal entry to calendar. 235 Add a Journal entry to calendar.
236 236
237 @return true on success, false on error. 237 @return true on success, false on error.
238 */ 238 */
239 virtual bool addJournal( Journal * ) = 0; 239 virtual bool addJournal( Journal * ) = 0;
240 /** 240 /**
241 Return Journal for given date. 241 Return Journal for given date.
242 */ 242 */
243 virtual Journal *journal( const QDate & ) = 0; 243 virtual Journal *journal( const QDate & ) = 0;
244 /** 244 /**
245 Return Journal with given UID. 245 Return Journal with given UID.
246 */ 246 */
247 virtual Journal *journal( const QString &UID ) = 0; 247 virtual Journal *journal( const QString &UID ) = 0;
248 /** 248 /**
249 Return list of all Journal entries. 249 Return list of all Journal entries.
250 */ 250 */
251 virtual QPtrList<Journal> journals() = 0; 251 virtual QPtrList<Journal> journals() = 0;
252 252
253 /** 253 /**
254 Searches all incidence types for an incidence with this unique 254 Searches all incidence types for an incidence with this unique
255 string identifier, returns a pointer or null. 255 string identifier, returns a pointer or null.
256 */ 256 */
257 Incidence* incidence( const QString&UID ); 257 Incidence* incidence( const QString&UID );
258 258
259 /** 259 /**
260 Setup relations for an incidence. 260 Setup relations for an incidence.
261 */ 261 */
262 virtual void setupRelations( Incidence * ); 262 virtual void setupRelations( Incidence * );
263 /** 263 /**
264 Remove all relations to an incidence 264 Remove all relations to an incidence
265 */ 265 */
266 virtual void removeRelations( Incidence * ); 266 virtual void removeRelations( Incidence * );
267 267
268 /** 268 /**
269 Set calendar filter, which filters events for the events() functions. 269 Set calendar filter, which filters events for the events() functions.
270 The Filter object is owned by the caller. 270 The Filter object is owned by the caller.
271 */ 271 */
272 void setFilter( CalFilter * ); 272 void setFilter( CalFilter * );
273 /** 273 /**
274 Return calendar filter. 274 Return calendar filter.
275 */ 275 */
276 CalFilter *filter(); 276 CalFilter *filter();
277 virtual QDateTime nextAlarm( int daysTo ) = 0; 277 virtual QDateTime nextAlarm( int daysTo ) = 0;
278 virtual QString nextSummary( ) const = 0; 278 virtual QString nextSummary( ) const = 0;
279 virtual void reInitAlarmSettings() = 0; 279 virtual void reInitAlarmSettings() = 0;
280 virtual QDateTime nextAlarmEventDateTime() const = 0; 280 virtual QDateTime nextAlarmEventDateTime() const = 0;
281 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 281 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
282 /** 282 /**
283 Return all alarms, which ocur in the given time interval. 283 Return all alarms, which ocur in the given time interval.
284 */ 284 */
285 virtual Alarm::List alarms( const QDateTime &from, 285 virtual Alarm::List alarms( const QDateTime &from,
286 const QDateTime &to ) = 0; 286 const QDateTime &to ) = 0;
287 287
288 class Observer { 288 class Observer {
289 public: 289 public:
290 virtual void calendarModified( bool, Calendar * ) = 0; 290 virtual void calendarModified( bool, Calendar * ) = 0;
291 }; 291 };
292 292
293 void registerObserver( Observer * ); 293 void registerObserver( Observer * );
294 294
295 void setModified( bool ); 295 void setModified( bool );
296 296
297 /** 297 /**
298 Set product id returned by loadedProductId(). This function is only 298 Set product id returned by loadedProductId(). This function is only
299 useful for the calendar loading code. 299 useful for the calendar loading code.
300 */ 300 */
301 void setLoadedProductId( const QString & ); 301 void setLoadedProductId( const QString & );
302 /** 302 /**
303 Return product id taken from file that has been loaded. Returns 303 Return product id taken from file that has been loaded. Returns
304 QString::null, if no calendar has been loaded. 304 QString::null, if no calendar has been loaded.
305 */ 305 */
306 QString loadedProductId(); 306 QString loadedProductId();
307 int defaultCalendar(); 307 int defaultCalendar();
308 void setDontDeleteIncidencesOnClose (); 308 void setDontDeleteIncidencesOnClose ();
309 public slots: 309 public slots:
310 void setDefaultCalendar( int ); 310 void setDefaultCalendar( int );
311 virtual void setCalendarEnabled( int id, bool enable ) = 0; 311 virtual void setCalendarEnabled( int id, bool enable ) = 0;
312 virtual void setAlarmEnabled( int id, bool enable ) = 0; 312 virtual void setAlarmEnabled( int id, bool enable ) = 0;
313 virtual void setReadOnly( int id, bool enable ) = 0; 313 virtual void setReadOnly( int id, bool enable ) = 0;
314 virtual void setDefaultCalendarEnabledOnly() = 0; 314 virtual void setDefaultCalendarEnabledOnly() = 0;
315 virtual void setCalendarRemove( int id ) = 0;
315 signals: 316 signals:
316 void calendarChanged(); 317 void calendarChanged();
317 void calendarSaved(); 318 void calendarSaved();
318 void calendarLoaded(); 319 void calendarLoaded();
319 void addAlarm(const QDateTime &qdt, const QString &noti ); 320 void addAlarm(const QDateTime &qdt, const QString &noti );
320 void removeAlarm(const QDateTime &qdt, const QString &noti ); 321 void removeAlarm(const QDateTime &qdt, const QString &noti );
321 322
322 protected: 323 protected:
323 /** 324 /**
324 Get unfiltered events, which occur on the given date. 325 Get unfiltered events, which occur on the given date.
325 */ 326 */
326 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 327 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
327 /** 328 /**
328 Get unfiltered events, which occur on the given date. 329 Get unfiltered events, which occur on the given date.
329 */ 330 */
330 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 331 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
331 bool sorted = false ) = 0; 332 bool sorted = false ) = 0;
332 /** 333 /**
333 Get events in a range of dates. If inclusive is set to true, only events 334 Get events in a range of dates. If inclusive is set to true, only events
334 are returned, which are completely included in the range. 335 are returned, which are completely included in the range.
335 */ 336 */
336 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 337 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
337 bool inclusive = false ) = 0; 338 bool inclusive = false ) = 0;
338 339
339 Incidence *mNextAlarmIncidence; 340 Incidence *mNextAlarmIncidence;
340 Incidence *mUndoIncidence; 341 Incidence *mUndoIncidence;
341 int mDefaultCalendar; 342 int mDefaultCalendar;
342 bool mDeleteIncidencesOnClose; 343 bool mDeleteIncidencesOnClose;
343 344
344private: 345private:
345 void init(); 346 void init();
346 347
347 QString mOwner; // who the calendar belongs to 348 QString mOwner; // who the calendar belongs to
348 QString mOwnerEmail; // email address of the owner 349 QString mOwnerEmail; // email address of the owner
349 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 350 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
350 bool mLocalTime; // use local time, not UTC or a time zone 351 bool mLocalTime; // use local time, not UTC or a time zone
351 352
352 353
353 CalFilter *mFilter; 354 CalFilter *mFilter;
354 CalFilter *mDefaultFilter; 355 CalFilter *mDefaultFilter;
355 356
356 357
357 QString mTimeZoneId; 358 QString mTimeZoneId;
358 359
359 Observer *mObserver; 360 Observer *mObserver;
360 bool mNewObserver; 361 bool mNewObserver;
361 362
362 bool mModified; 363 bool mModified;
363 364
364 QString mLoadedProductId; 365 QString mLoadedProductId;
365 366
366 // This list is used to put together related todos 367 // This list is used to put together related todos
367 QDict<Incidence> mOrphans; 368 QDict<Incidence> mOrphans;
368 QDict<Incidence> mOrphanUids; 369 QDict<Incidence> mOrphanUids;
369}; 370};
370 371
371} 372}
372 373
373#endif 374#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index e48122a..749d9f6 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -1,299 +1,318 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 if ( mDeleteIncidencesOnClose ) 68 if ( mDeleteIncidencesOnClose )
69 close(); 69 close();
70} 70}
71bool CalendarLocal::addCalendarFile( QString name, int id ) 71bool CalendarLocal::addCalendarFile( QString name, int id )
72{ 72{
73 CalendarLocal calendar( timeZoneId() ); 73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id ); 74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) { 75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar ); 76 addCalendar( &calendar );
77 return true; 77 return true;
78 } 78 }
79 return false; 79 return false;
80} 80}
81void CalendarLocal::addCalendar( Calendar* cal ) 81void CalendarLocal::addCalendar( Calendar* cal )
82{ 82{
83 cal->setDontDeleteIncidencesOnClose(); 83 cal->setDontDeleteIncidencesOnClose();
84 { 84 {
85 QPtrList<Event> EventList = cal->rawEvents(); 85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first(); 86 Event * ev = EventList.first();
87 while ( ev ) { 87 while ( ev ) {
88 ev->unRegisterObserver( cal );
89 ev->registerObserver( this );
88 mEventList.append( ev ); 90 mEventList.append( ev );
89 ev = EventList.next(); 91 ev = EventList.next();
90 } 92 }
91 } 93 }
92 { 94 {
95
93 QPtrList<Todo> TodoList = cal->rawTodos(); 96 QPtrList<Todo> TodoList = cal->rawTodos();
94 Todo * ev = TodoList.first(); 97 Todo * ev = TodoList.first();
95 while ( ev ) { 98 while ( ev ) {
99 QString rel = ev->relatedToUid();
100 if ( !rel.isEmpty() ){
101 ev->setRelatedTo ( 0 );
102 ev->setRelatedToUid( rel );
103 }
104 ev = TodoList.next();
105 }
106 //TodoList = cal->rawTodos();
107 ev = TodoList.first();
108 while ( ev ) {
109 ev->unRegisterObserver( cal );
110 ev->registerObserver( this );
96 mTodoList.append( ev ); 111 mTodoList.append( ev );
112 setupRelations( ev );
97 ev = TodoList.next(); 113 ev = TodoList.next();
98 } 114 }
99 } 115 }
100 { 116 {
101 QPtrList<Journal> JournalList = cal->journals(); 117 QPtrList<Journal> JournalList = cal->journals();
102 Journal * ev = JournalList.first(); 118 Journal * ev = JournalList.first();
103 while ( ev ) { 119 while ( ev ) {
120 ev->unRegisterObserver( cal );
121 ev->registerObserver( this );
104 mJournalList.append( ev ); 122 mJournalList.append( ev );
105 ev = JournalList.next(); 123 ev = JournalList.next();
106 } 124 }
107 } 125 }
126 setModified( true );
108} 127}
109bool CalendarLocal::load( const QString &fileName ) 128bool CalendarLocal::load( const QString &fileName )
110{ 129{
111 FileStorage storage( this, fileName ); 130 FileStorage storage( this, fileName );
112 return storage.load(); 131 return storage.load();
113} 132}
114 133
115bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 134bool CalendarLocal::save( const QString &fileName, CalFormat *format )
116{ 135{
117 FileStorage storage( this, fileName, format ); 136 FileStorage storage( this, fileName, format );
118 return storage.save(); 137 return storage.save();
119} 138}
120 139
121void CalendarLocal::close() 140void CalendarLocal::close()
122{ 141{
123 142
124 Todo * i; 143 Todo * i;
125 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 144 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
126 145
127 mEventList.setAutoDelete( true ); 146 mEventList.setAutoDelete( true );
128 mTodoList.setAutoDelete( true ); 147 mTodoList.setAutoDelete( true );
129 mJournalList.setAutoDelete( false ); 148 mJournalList.setAutoDelete( false );
130 149
131 mEventList.clear(); 150 mEventList.clear();
132 mTodoList.clear(); 151 mTodoList.clear();
133 mJournalList.clear(); 152 mJournalList.clear();
134 153
135 mEventList.setAutoDelete( false ); 154 mEventList.setAutoDelete( false );
136 mTodoList.setAutoDelete( false ); 155 mTodoList.setAutoDelete( false );
137 mJournalList.setAutoDelete( false ); 156 mJournalList.setAutoDelete( false );
138 157
139 setModified( false ); 158 setModified( false );
140} 159}
141 160
142bool CalendarLocal::addAnniversaryNoDup( Event *event ) 161bool CalendarLocal::addAnniversaryNoDup( Event *event )
143{ 162{
144 QString cat; 163 QString cat;
145 bool isBirthday = true; 164 bool isBirthday = true;
146 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 165 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
147 isBirthday = false; 166 isBirthday = false;
148 cat = i18n( "Anniversary" ); 167 cat = i18n( "Anniversary" );
149 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 168 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
150 isBirthday = true; 169 isBirthday = true;
151 cat = i18n( "Birthday" ); 170 cat = i18n( "Birthday" );
152 } else { 171 } else {
153 qDebug("addAnniversaryNoDup called without fitting category! "); 172 qDebug("addAnniversaryNoDup called without fitting category! ");
154 return false; 173 return false;
155 } 174 }
156 Event * eve; 175 Event * eve;
157 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 176 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
158 if ( !(eve->categories().contains( cat ) )) 177 if ( !(eve->categories().contains( cat ) ))
159 continue; 178 continue;
160 // now we have an event with fitting category 179 // now we have an event with fitting category
161 if ( eve->dtStart().date() != event->dtStart().date() ) 180 if ( eve->dtStart().date() != event->dtStart().date() )
162 continue; 181 continue;
163 // now we have an event with fitting category+date 182 // now we have an event with fitting category+date
164 if ( eve->summary() != event->summary() ) 183 if ( eve->summary() != event->summary() )
165 continue; 184 continue;
166 // now we have an event with fitting category+date+summary 185 // now we have an event with fitting category+date+summary
167 return false; 186 return false;
168 } 187 }
169 return addEvent( event ); 188 return addEvent( event );
170 189
171} 190}
172bool CalendarLocal::addEventNoDup( Event *event ) 191bool CalendarLocal::addEventNoDup( Event *event )
173{ 192{
174 Event * eve; 193 Event * eve;
175 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
176 if ( *eve == *event ) { 195 if ( *eve == *event ) {
177 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
178 return false; 197 return false;
179 } 198 }
180 } 199 }
181 return addEvent( event ); 200 return addEvent( event );
182} 201}
183 202
184bool CalendarLocal::addEvent( Event *event ) 203bool CalendarLocal::addEvent( Event *event )
185{ 204{
186 insertEvent( event ); 205 insertEvent( event );
187 206
188 event->registerObserver( this ); 207 event->registerObserver( this );
189 208
190 setModified( true ); 209 setModified( true );
191 event->setCalID( mDefaultCalendar ); 210 event->setCalID( mDefaultCalendar );
192 event->setCalEnabled( true ); 211 event->setCalEnabled( true );
193 212
194 return true; 213 return true;
195} 214}
196 215
197void CalendarLocal::deleteEvent( Event *event ) 216void CalendarLocal::deleteEvent( Event *event )
198{ 217{
199 if ( mUndoIncidence ) delete mUndoIncidence; 218 if ( mUndoIncidence ) delete mUndoIncidence;
200 mUndoIncidence = event->clone(); 219 mUndoIncidence = event->clone();
201 if ( mEventList.removeRef( event ) ) { 220 if ( mEventList.removeRef( event ) ) {
202 setModified( true ); 221 setModified( true );
203 } 222 }
204} 223}
205 224
206 225
207Event *CalendarLocal::event( const QString &uid ) 226Event *CalendarLocal::event( const QString &uid )
208{ 227{
209 228
210 Event *event; 229 Event *event;
211 230
212 for ( event = mEventList.first(); event; event = mEventList.next() ) { 231 for ( event = mEventList.first(); event; event = mEventList.next() ) {
213 if ( event->uid() == uid && event->calEnabled() ) { 232 if ( event->uid() == uid && event->calEnabled() ) {
214 return event; 233 return event;
215 } 234 }
216 } 235 }
217 236
218 return 0; 237 return 0;
219} 238}
220bool CalendarLocal::addTodoNoDup( Todo *todo ) 239bool CalendarLocal::addTodoNoDup( Todo *todo )
221{ 240{
222 Todo * eve; 241 Todo * eve;
223 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 242 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
224 if ( *eve == *todo ) { 243 if ( *eve == *todo ) {
225 //qDebug("duplicate todo found! not inserted! "); 244 //qDebug("duplicate todo found! not inserted! ");
226 return false; 245 return false;
227 } 246 }
228 } 247 }
229 return addTodo( todo ); 248 return addTodo( todo );
230} 249}
231bool CalendarLocal::addTodo( Todo *todo ) 250bool CalendarLocal::addTodo( Todo *todo )
232{ 251{
233 mTodoList.append( todo ); 252 mTodoList.append( todo );
234 253
235 todo->registerObserver( this ); 254 todo->registerObserver( this );
236 255
237 // Set up subtask relations 256 // Set up subtask relations
238 setupRelations( todo ); 257 setupRelations( todo );
239 258
240 setModified( true ); 259 setModified( true );
241 todo->setCalID( mDefaultCalendar ); 260 todo->setCalID( mDefaultCalendar );
242 todo->setCalEnabled( true ); 261 todo->setCalEnabled( true );
243 return true; 262 return true;
244} 263}
245 264
246void CalendarLocal::deleteTodo( Todo *todo ) 265void CalendarLocal::deleteTodo( Todo *todo )
247{ 266{
248 // Handle orphaned children 267 // Handle orphaned children
249 if ( mUndoIncidence ) delete mUndoIncidence; 268 if ( mUndoIncidence ) delete mUndoIncidence;
250 removeRelations( todo ); 269 removeRelations( todo );
251 mUndoIncidence = todo->clone(); 270 mUndoIncidence = todo->clone();
252 271
253 if ( mTodoList.removeRef( todo ) ) { 272 if ( mTodoList.removeRef( todo ) ) {
254 setModified( true ); 273 setModified( true );
255 } 274 }
256} 275}
257 276
258QPtrList<Todo> CalendarLocal::rawTodos() 277QPtrList<Todo> CalendarLocal::rawTodos()
259{ 278{
260 QPtrList<Todo> el; 279 QPtrList<Todo> el;
261 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 280 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
262 if ( it->calEnabled() ) el.append( it ); 281 if ( it->calEnabled() ) el.append( it );
263 return el; 282 return el;
264} 283}
265Todo *CalendarLocal::todo( QString syncProf, QString id ) 284Todo *CalendarLocal::todo( QString syncProf, QString id )
266{ 285{
267 Todo *todo; 286 Todo *todo;
268 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 287 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
269 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 288 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
270 } 289 }
271 290
272 return 0; 291 return 0;
273} 292}
274void CalendarLocal::removeSyncInfo( QString syncProfile) 293void CalendarLocal::removeSyncInfo( QString syncProfile)
275{ 294{
276 QPtrList<Incidence> all = rawIncidences() ; 295 QPtrList<Incidence> all = rawIncidences() ;
277 Incidence *inc; 296 Incidence *inc;
278 for ( inc = all.first(); inc; inc = all.next() ) { 297 for ( inc = all.first(); inc; inc = all.next() ) {
279 inc->removeID( syncProfile ); 298 inc->removeID( syncProfile );
280 } 299 }
281 if ( syncProfile.isEmpty() ) { 300 if ( syncProfile.isEmpty() ) {
282 QPtrList<Event> el; 301 QPtrList<Event> el;
283 Event *todo; 302 Event *todo;
284 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 303 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
285 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 304 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
286 el.append( todo ); 305 el.append( todo );
287 } 306 }
288 for ( todo = el.first(); todo; todo = el.next() ) { 307 for ( todo = el.first(); todo; todo = el.next() ) {
289 deleteIncidence ( todo ); 308 deleteIncidence ( todo );
290 } 309 }
291 } else { 310 } else {
292 Event *lse = event( "last-syncEvent-"+ syncProfile); 311 Event *lse = event( "last-syncEvent-"+ syncProfile);
293 if ( lse ) 312 if ( lse )
294 deleteIncidence ( lse ); 313 deleteIncidence ( lse );
295 } 314 }
296} 315}
297QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 316QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
298{ 317{
299 QPtrList<Event> el; 318 QPtrList<Event> el;
@@ -592,243 +611,280 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
592 611
593 Event *event; 612 Event *event;
594 for( event = mEventList.first(); event; event = mEventList.next() ) { 613 for( event = mEventList.first(); event; event = mEventList.next() ) {
595 if ( !event->calEnabled() ) continue; 614 if ( !event->calEnabled() ) continue;
596 if ( event->doesRecur() ) { 615 if ( event->doesRecur() ) {
597 if ( event->isMultiDay() ) { 616 if ( event->isMultiDay() ) {
598 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 617 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
599 int i; 618 int i;
600 for ( i = 0; i <= extraDays; i++ ) { 619 for ( i = 0; i <= extraDays; i++ ) {
601 if ( event->recursOn( qd.addDays( -i ) ) ) { 620 if ( event->recursOn( qd.addDays( -i ) ) ) {
602 eventList.append( event ); 621 eventList.append( event );
603 break; 622 break;
604 } 623 }
605 } 624 }
606 } else { 625 } else {
607 if ( event->recursOn( qd ) ) 626 if ( event->recursOn( qd ) )
608 eventList.append( event ); 627 eventList.append( event );
609 } 628 }
610 } else { 629 } else {
611 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 630 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
612 eventList.append( event ); 631 eventList.append( event );
613 } 632 }
614 } 633 }
615 } 634 }
616 635
617 if ( !sorted ) { 636 if ( !sorted ) {
618 return eventList; 637 return eventList;
619 } 638 }
620 639
621 // kdDebug(5800) << "Sorting events for date\n" << endl; 640 // kdDebug(5800) << "Sorting events for date\n" << endl;
622 // now, we have to sort it based on dtStart.time() 641 // now, we have to sort it based on dtStart.time()
623 QPtrList<Event> eventListSorted; 642 QPtrList<Event> eventListSorted;
624 Event *sortEvent; 643 Event *sortEvent;
625 for ( event = eventList.first(); event; event = eventList.next() ) { 644 for ( event = eventList.first(); event; event = eventList.next() ) {
626 sortEvent = eventListSorted.first(); 645 sortEvent = eventListSorted.first();
627 int i = 0; 646 int i = 0;
628 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 647 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
629 { 648 {
630 i++; 649 i++;
631 sortEvent = eventListSorted.next(); 650 sortEvent = eventListSorted.next();
632 } 651 }
633 eventListSorted.insert( i, event ); 652 eventListSorted.insert( i, event );
634 } 653 }
635 return eventListSorted; 654 return eventListSorted;
636} 655}
637 656
638 657
639QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 658QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
640 bool inclusive ) 659 bool inclusive )
641{ 660{
642 Event *event = 0; 661 Event *event = 0;
643 662
644 QPtrList<Event> eventList; 663 QPtrList<Event> eventList;
645 664
646 // Get non-recurring events 665 // Get non-recurring events
647 for( event = mEventList.first(); event; event = mEventList.next() ) { 666 for( event = mEventList.first(); event; event = mEventList.next() ) {
648 if ( !event->calEnabled() ) continue; 667 if ( !event->calEnabled() ) continue;
649 if ( event->doesRecur() ) { 668 if ( event->doesRecur() ) {
650 QDate rStart = event->dtStart().date(); 669 QDate rStart = event->dtStart().date();
651 bool found = false; 670 bool found = false;
652 if ( inclusive ) { 671 if ( inclusive ) {
653 if ( rStart >= start && rStart <= end ) { 672 if ( rStart >= start && rStart <= end ) {
654 // Start date of event is in range. Now check for end date. 673 // Start date of event is in range. Now check for end date.
655 // if duration is negative, event recurs forever, so do not include it. 674 // if duration is negative, event recurs forever, so do not include it.
656 if ( event->recurrence()->duration() == 0 ) { // End date set 675 if ( event->recurrence()->duration() == 0 ) { // End date set
657 QDate rEnd = event->recurrence()->endDate(); 676 QDate rEnd = event->recurrence()->endDate();
658 if ( rEnd >= start && rEnd <= end ) { // End date within range 677 if ( rEnd >= start && rEnd <= end ) { // End date within range
659 found = true; 678 found = true;
660 } 679 }
661 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 680 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
662 // TODO: Calculate end date from duration. Should be done in Event 681 // TODO: Calculate end date from duration. Should be done in Event
663 // For now exclude all events with a duration. 682 // For now exclude all events with a duration.
664 } 683 }
665 } 684 }
666 } else { 685 } else {
667 bool founOne; 686 bool founOne;
668 QDate next = event->getNextOccurence( start, &founOne ).date(); 687 QDate next = event->getNextOccurence( start, &founOne ).date();
669 if ( founOne ) { 688 if ( founOne ) {
670 if ( next <= end ) { 689 if ( next <= end ) {
671 found = true; 690 found = true;
672 } 691 }
673 } 692 }
674 693
675 /* 694 /*
676 // crap !!! 695 // crap !!!
677 if ( rStart <= end ) { // Start date not after range 696 if ( rStart <= end ) { // Start date not after range
678 if ( rStart >= start ) { // Start date within range 697 if ( rStart >= start ) { // Start date within range
679 found = true; 698 found = true;
680 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 699 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
681 found = true; 700 found = true;
682 } else if ( event->recurrence()->duration() == 0 ) { // End date set 701 } else if ( event->recurrence()->duration() == 0 ) { // End date set
683 QDate rEnd = event->recurrence()->endDate(); 702 QDate rEnd = event->recurrence()->endDate();
684 if ( rEnd >= start && rEnd <= end ) { // End date within range 703 if ( rEnd >= start && rEnd <= end ) { // End date within range
685 found = true; 704 found = true;
686 } 705 }
687 } else { // Duration set 706 } else { // Duration set
688 // TODO: Calculate end date from duration. Should be done in Event 707 // TODO: Calculate end date from duration. Should be done in Event
689 // For now include all events with a duration. 708 // For now include all events with a duration.
690 found = true; 709 found = true;
691 } 710 }
692 } 711 }
693 */ 712 */
694 713
695 } 714 }
696 715
697 if ( found ) eventList.append( event ); 716 if ( found ) eventList.append( event );
698 } else { 717 } else {
699 QDate s = event->dtStart().date(); 718 QDate s = event->dtStart().date();
700 QDate e = event->dtEnd().date(); 719 QDate e = event->dtEnd().date();
701 720
702 if ( inclusive ) { 721 if ( inclusive ) {
703 if ( s >= start && e <= end ) { 722 if ( s >= start && e <= end ) {
704 eventList.append( event ); 723 eventList.append( event );
705 } 724 }
706 } else { 725 } else {
707 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { 726 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) {
708 eventList.append( event ); 727 eventList.append( event );
709 } 728 }
710 } 729 }
711 } 730 }
712 } 731 }
713 732
714 return eventList; 733 return eventList;
715} 734}
716 735
717QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 736QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
718{ 737{
719 return rawEventsForDate( qdt.date() ); 738 return rawEventsForDate( qdt.date() );
720} 739}
721 740
722QPtrList<Event> CalendarLocal::rawEvents() 741QPtrList<Event> CalendarLocal::rawEvents()
723{ 742{
724 QPtrList<Event> el; 743 QPtrList<Event> el;
725 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 744 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
726 if ( it->calEnabled() ) el.append( it ); 745 if ( it->calEnabled() ) el.append( it );
727 return el; 746 return el;
728} 747}
729 748
730bool CalendarLocal::addJournal(Journal *journal) 749bool CalendarLocal::addJournal(Journal *journal)
731{ 750{
732 if ( journal->dtStart().isValid()) 751 if ( journal->dtStart().isValid())
733 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; 752 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
734 else 753 else
735 kdDebug(5800) << "Adding Journal without a DTSTART" << endl; 754 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
736 755
737 mJournalList.append(journal); 756 mJournalList.append(journal);
738 757
739 journal->registerObserver( this ); 758 journal->registerObserver( this );
740 759
741 setModified( true ); 760 setModified( true );
742 journal->setCalID( mDefaultCalendar ); 761 journal->setCalID( mDefaultCalendar );
743 journal->setCalEnabled( true ); 762 journal->setCalEnabled( true );
744 return true; 763 return true;
745} 764}
746 765
747void CalendarLocal::deleteJournal( Journal *journal ) 766void CalendarLocal::deleteJournal( Journal *journal )
748{ 767{
749 if ( mUndoIncidence ) delete mUndoIncidence; 768 if ( mUndoIncidence ) delete mUndoIncidence;
750 mUndoIncidence = journal->clone(); 769 mUndoIncidence = journal->clone();
751 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 770 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
752 if ( mJournalList.removeRef(journal) ) { 771 if ( mJournalList.removeRef(journal) ) {
753 setModified( true ); 772 setModified( true );
754 } 773 }
755} 774}
756 775
757Journal *CalendarLocal::journal( const QDate &date ) 776Journal *CalendarLocal::journal( const QDate &date )
758{ 777{
759// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 778// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
760 779
761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
762 if ( it->calEnabled() && it->dtStart().date() == date ) 781 if ( it->calEnabled() && it->dtStart().date() == date )
763 return it; 782 return it;
764 783
765 return 0; 784 return 0;
766} 785}
767 786
768Journal *CalendarLocal::journal( const QString &uid ) 787Journal *CalendarLocal::journal( const QString &uid )
769{ 788{
770 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 789 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
771 if ( it->calEnabled() && it->uid() == uid ) 790 if ( it->calEnabled() && it->uid() == uid )
772 return it; 791 return it;
773 792
774 return 0; 793 return 0;
775} 794}
776 795
777QPtrList<Journal> CalendarLocal::journals() 796QPtrList<Journal> CalendarLocal::journals()
778{ 797{
779 QPtrList<Journal> el; 798 QPtrList<Journal> el;
780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 799 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
781 if ( it->calEnabled() ) el.append( it ); 800 if ( it->calEnabled() ) el.append( it );
782 return el; 801 return el;
783} 802}
803void CalendarLocal::setCalendarRemove( int id )
804{
805
806 {
807 QPtrList<Event> EventList = mEventList;
808 Event * ev = EventList.first();
809 while ( ev ) {
810 if ( ev->calID() == id )
811 deleteEvent( ev );
812 ev = EventList.next();
813 }
814 }
815 {
816
817 QPtrList<Todo> TodoList = mTodoList;
818 Todo * ev = TodoList.first();
819 while ( ev ) {
820 if ( ev->calID() == id )
821 deleteTodo( ev );
822 ev = TodoList.next();
823 }
824 }
825 {
826 QPtrList<Journal> JournalList = mJournalList;
827 Journal * ev = JournalList.first();
828 while ( ev ) {
829 if ( ev->calID() == id )
830 deleteJournal( ev );
831 ev = JournalList.next();
832 }
833 }
834
835 if ( mUndoIncidence ) delete mUndoIncidence;
836 mUndoIncidence = 0;
837
838}
784 839
785void CalendarLocal::setCalendarEnabled( int id, bool enable ) 840void CalendarLocal::setCalendarEnabled( int id, bool enable )
786{ 841{
787 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 842 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
788 if ( it->calID() == id ) it->setCalEnabled( enable ); 843 if ( it->calID() == id ) it->setCalEnabled( enable );
789 844
790 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 845 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
791 if ( it->calID() == id ) it->setCalEnabled( enable ); 846 if ( it->calID() == id ) it->setCalEnabled( enable );
792 847
793 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 848 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
794 if ( it->calID() == id ) it->setCalEnabled( enable ); 849 if ( it->calID() == id ) it->setCalEnabled( enable );
795 850
796} 851}
797 852
798void CalendarLocal::setReadOnly( int id, bool enable ) 853void CalendarLocal::setReadOnly( int id, bool enable )
799{ 854{
800 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 855 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
801 if ( it->calID() == id ) it->setReadOnly( enable ); 856 if ( it->calID() == id ) it->setReadOnly( enable );
802 857
803 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 858 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
804 if ( it->calID() == id ) it->setReadOnly( enable ); 859 if ( it->calID() == id ) it->setReadOnly( enable );
805 860
806 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 861 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
807 if ( it->calID() == id ) it->setReadOnly( enable ); 862 if ( it->calID() == id ) it->setReadOnly( enable );
808 863
809} 864}
810 865
811void CalendarLocal::setAlarmEnabled( int id, bool enable ) 866void CalendarLocal::setAlarmEnabled( int id, bool enable )
812{ 867{
813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 868 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
814 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 869 if ( it->calID() == id ) it->setAlarmEnabled( enable );
815 870
816 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 871 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
817 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 872 if ( it->calID() == id ) it->setAlarmEnabled( enable );
818 873
819 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 874 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
820 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 875 if ( it->calID() == id ) it->setAlarmEnabled( enable );
876 reInitAlarmSettings();
821 877
822} 878}
823void CalendarLocal::setDefaultCalendarEnabledOnly() 879void CalendarLocal::setDefaultCalendarEnabledOnly()
824{ 880{
825 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 881 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
826 it->setCalEnabled( it->calID() == mDefaultCalendar ); 882 it->setCalEnabled( it->calID() == mDefaultCalendar );
827 883
828 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 884 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
829 it->setCalEnabled( it->calID() == mDefaultCalendar); 885 it->setCalEnabled( it->calID() == mDefaultCalendar);
830 886
831 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 887 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
832 it->setCalEnabled( it->calID() == mDefaultCalendar); 888 it->setCalEnabled( it->calID() == mDefaultCalendar);
833 889
834} 890}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 65f6aa7..5bbe55f 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,223 +1,224 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 /** 48 /**
49 Loads a calendar on disk in vCalendar or iCalendar format into the current 49 Loads a calendar on disk in vCalendar or iCalendar format into the current
50 calendar. Any information already present is lost. 50 calendar. Any information already present is lost.
51 @return true, if successfull, false on error. 51 @return true, if successfull, false on error.
52 @param fileName the name of the calendar on disk. 52 @param fileName the name of the calendar on disk.
53 */ 53 */
54 bool load( const QString &fileName ); 54 bool load( const QString &fileName );
55 /** 55 /**
56 Writes out the calendar to disk in the specified \a format. 56 Writes out the calendar to disk in the specified \a format.
57 CalendarLocal takes ownership of the CalFormat object. 57 CalendarLocal takes ownership of the CalFormat object.
58 @return true, if successfull, false on error. 58 @return true, if successfull, false on error.
59 @param fileName the name of the file 59 @param fileName the name of the file
60 */ 60 */
61 bool save( const QString &fileName, CalFormat *format = 0 ); 61 bool save( const QString &fileName, CalFormat *format = 0 );
62 62
63 /** 63 /**
64 Clears out the current calendar, freeing all used memory etc. etc. 64 Clears out the current calendar, freeing all used memory etc. etc.
65 */ 65 */
66 void close(); 66 void close();
67 67
68 void save() {} 68 void save() {}
69 69
70 /** 70 /**
71 Add Event to calendar. 71 Add Event to calendar.
72 */ 72 */
73 void removeSyncInfo( QString syncProfile); 73 void removeSyncInfo( QString syncProfile);
74 bool addAnniversaryNoDup( Event *event ); 74 bool addAnniversaryNoDup( Event *event );
75 bool addEventNoDup( Event *event ); 75 bool addEventNoDup( Event *event );
76 bool addEvent( Event *event ); 76 bool addEvent( Event *event );
77 /** 77 /**
78 Deletes an event from this calendar. 78 Deletes an event from this calendar.
79 */ 79 */
80 void deleteEvent( Event *event ); 80 void deleteEvent( Event *event );
81 81
82 /** 82 /**
83 Retrieves an event on the basis of the unique string ID. 83 Retrieves an event on the basis of the unique string ID.
84 */ 84 */
85 Event *event( const QString &uid ); 85 Event *event( const QString &uid );
86 /** 86 /**
87 Return unfiltered list of all events in calendar. 87 Return unfiltered list of all events in calendar.
88 */ 88 */
89 QPtrList<Event> rawEvents(); 89 QPtrList<Event> rawEvents();
90 QPtrList<Event> getExternLastSyncEvents(); 90 QPtrList<Event> getExternLastSyncEvents();
91 /** 91 /**
92 Add a todo to the todolist. 92 Add a todo to the todolist.
93 */ 93 */
94 bool addTodo( Todo *todo ); 94 bool addTodo( Todo *todo );
95 bool addTodoNoDup( Todo *todo ); 95 bool addTodoNoDup( Todo *todo );
96 /** 96 /**
97 Remove a todo from the todolist. 97 Remove a todo from the todolist.
98 */ 98 */
99 void deleteTodo( Todo * ); 99 void deleteTodo( Todo * );
100 /** 100 /**
101 Searches todolist for an event with this unique string identifier, 101 Searches todolist for an event with this unique string identifier,
102 returns a pointer or null. 102 returns a pointer or null.
103 */ 103 */
104 Todo *todo( const QString &uid ); 104 Todo *todo( const QString &uid );
105 /** 105 /**
106 Return list of all todos. 106 Return list of all todos.
107 */ 107 */
108 QPtrList<Todo> rawTodos(); 108 QPtrList<Todo> rawTodos();
109 /** 109 /**
110 Returns list of todos due on the specified date. 110 Returns list of todos due on the specified date.
111 */ 111 */
112 QPtrList<Todo> todos( const QDate &date ); 112 QPtrList<Todo> todos( const QDate &date );
113 /** 113 /**
114 Return list of all todos. 114 Return list of all todos.
115 115
116 Workaround because compiler does not recognize function of base class. 116 Workaround because compiler does not recognize function of base class.
117 */ 117 */
118 QPtrList<Todo> todos() { return Calendar::todos(); } 118 QPtrList<Todo> todos() { return Calendar::todos(); }
119 119
120 /** 120 /**
121 Add a Journal entry to calendar. 121 Add a Journal entry to calendar.
122 */ 122 */
123 bool addJournal( Journal * ); 123 bool addJournal( Journal * );
124 /** 124 /**
125 Remove a Journal from the calendar. 125 Remove a Journal from the calendar.
126 */ 126 */
127 void deleteJournal( Journal * ); 127 void deleteJournal( Journal * );
128 /** 128 /**
129 Return Journal for given date. 129 Return Journal for given date.
130 */ 130 */
131 Journal *journal( const QDate & ); 131 Journal *journal( const QDate & );
132 /** 132 /**
133 Return Journal with given UID. 133 Return Journal with given UID.
134 */ 134 */
135 Journal *journal( const QString &uid ); 135 Journal *journal( const QString &uid );
136 /** 136 /**
137 Return list of all Journals stored in calendar. 137 Return list of all Journals stored in calendar.
138 */ 138 */
139 QPtrList<Journal> journals(); 139 QPtrList<Journal> journals();
140 140
141 /** 141 /**
142 Return all alarms, which ocur in the given time interval. 142 Return all alarms, which ocur in the given time interval.
143 */ 143 */
144 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 144 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
145 145
146 /** 146 /**
147 Return all alarms, which ocur before given date. 147 Return all alarms, which ocur before given date.
148 */ 148 */
149 Alarm::List alarmsTo( const QDateTime &to ); 149 Alarm::List alarmsTo( const QDateTime &to );
150 150
151 QDateTime nextAlarm( int daysTo ) ; 151 QDateTime nextAlarm( int daysTo ) ;
152 QDateTime nextAlarmEventDateTime() const; 152 QDateTime nextAlarmEventDateTime() const;
153 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 153 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
154 void registerAlarm(); 154 void registerAlarm();
155 void deRegisterAlarm(); 155 void deRegisterAlarm();
156 QString getAlarmNotification(); 156 QString getAlarmNotification();
157 QString nextSummary() const ; 157 QString nextSummary() const ;
158 /** 158 /**
159 This method should be called whenever a Event is modified directly 159 This method should be called whenever a Event is modified directly
160 via it's pointer. It makes sure that the calendar is internally 160 via it's pointer. It makes sure that the calendar is internally
161 consistent. 161 consistent.
162 */ 162 */
163 void update( IncidenceBase *incidence ); 163 void update( IncidenceBase *incidence );
164 164
165 /** 165 /**
166 Builds and then returns a list of all events that match for the 166 Builds and then returns a list of all events that match for the
167 date specified. useful for dayView, etc. etc. 167 date specified. useful for dayView, etc. etc.
168 */ 168 */
169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
170 /** 170 /**
171 Get unfiltered events for date \a qdt. 171 Get unfiltered events for date \a qdt.
172 */ 172 */
173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
174 /** 174 /**
175 Get unfiltered events in a range of dates. If inclusive is set to true, 175 Get unfiltered events in a range of dates. If inclusive is set to true,
176 only events are returned, which are completely included in the range. 176 only events are returned, which are completely included in the range.
177 */ 177 */
178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
179 bool inclusive = false ); 179 bool inclusive = false );
180 Todo *todo( QString, QString ); 180 Todo *todo( QString, QString );
181 Event *event( QString, QString ); 181 Event *event( QString, QString );
182 182
183public slots: 183public slots:
184 void setCalendarEnabled( int id, bool enable ); 184 void setCalendarEnabled( int id, bool enable );
185 void setAlarmEnabled( int id, bool enable ); 185 void setAlarmEnabled( int id, bool enable );
186 void setReadOnly( int id, bool enable ); 186 void setReadOnly( int id, bool enable );
187 void setDefaultCalendarEnabledOnly(); 187 void setDefaultCalendarEnabledOnly();
188 void setCalendarRemove( int id );
188 189
189 protected: 190 protected:
190 191
191 // Event* mNextAlarmEvent; 192 // Event* mNextAlarmEvent;
192 QString mNextSummary; 193 QString mNextSummary;
193 QString mNextAlarmEventDateTimeString; 194 QString mNextAlarmEventDateTimeString;
194 QString mLastAlarmNotificationString; 195 QString mLastAlarmNotificationString;
195 QDateTime mNextAlarmEventDateTime; 196 QDateTime mNextAlarmEventDateTime;
196 QDateTime mNextAlarmDateTime; 197 QDateTime mNextAlarmDateTime;
197 void reInitAlarmSettings(); 198 void reInitAlarmSettings();
198 199
199 /** Notification function of IncidenceBase::Observer. */ 200 /** Notification function of IncidenceBase::Observer. */
200 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 201 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
201 202
202 /** inserts an event into its "proper place" in the calendar. */ 203 /** inserts an event into its "proper place" in the calendar. */
203 void insertEvent( Event *event ); 204 void insertEvent( Event *event );
204 205
205 /** Append alarms of incidence in interval to list of alarms. */ 206 /** Append alarms of incidence in interval to list of alarms. */
206 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 207 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
207 const QDateTime &from, const QDateTime &to ); 208 const QDateTime &from, const QDateTime &to );
208 209
209 /** Append alarms of recurring events in interval to list of alarms. */ 210 /** Append alarms of recurring events in interval to list of alarms. */
210 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 211 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
211 const QDateTime &from, const QDateTime &to ); 212 const QDateTime &from, const QDateTime &to );
212 213
213 private: 214 private:
214 void init(); 215 void init();
215 216
216 QPtrList<Event> mEventList; 217 QPtrList<Event> mEventList;
217 QPtrList<Todo> mTodoList; 218 QPtrList<Todo> mTodoList;
218 QPtrList<Journal> mJournalList; 219 QPtrList<Journal> mJournalList;
219}; 220};
220 221
221} 222}
222 223
223#endif 224#endif