summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/koeditorgeneral.cpp65
-rw-r--r--korganizer/koeditorgeneral.h4
-rw-r--r--korganizer/koeventpopupmenu.cpp1
-rw-r--r--libkcal/calendarlocal.cpp7
5 files changed, 69 insertions, 10 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 71d7208..27d37c4 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,197 +1,199 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.1.13 ************ 3********** VERSION 2.1.13 ************
4 4
5Fixed a problem in KA/Pi search. 5Fixed a problem in KA/Pi search.
6Fixed some minor problems in KO/Pi.
7Added calendar selection possibility to the todo view popup and to the event/todo editor.
6 8
7 9
8********** VERSION 2.1.12 ************ 10********** VERSION 2.1.12 ************
9 11
10KO/Pi: 12KO/Pi:
11Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. 13Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus.
12Fixed a problem with the month view when file was saved but KO/Pi was not the active window. 14Fixed a problem with the month view when file was saved but KO/Pi was not the active window.
13Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). 15Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only).
14Fixed some other small problems. 16Fixed some other small problems.
15 17
16********** VERSION 2.1.11 ************ 18********** VERSION 2.1.11 ************
17 19
18KO/Pi: 20KO/Pi:
19Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. 21Because we can have many calendars now in KO/Pi we can have more than one journal entry per day.
20Added features to handle (and add ) more than one journal entry per day. 22Added features to handle (and add ) more than one journal entry per day.
21Added option for a journal title. 23Added option for a journal title.
22 24
23Added info about the calendar, the item belongs to, to the event/todo/journal viewer. 25Added info about the calendar, the item belongs to, to the event/todo/journal viewer.
24Fixed a problem of the alarm of completed recurring todos. 26Fixed a problem of the alarm of completed recurring todos.
25Added to the event/todo editor to set quickly the category of an item. 27Added to the event/todo editor to set quickly the category of an item.
26 28
27 29
28Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. 30Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet.
29 31
30Added KA/Pi multi sync to the multi sync called from the alarm applet. 32Added KA/Pi multi sync to the multi sync called from the alarm applet.
31 33
32********** VERSION 2.1.10 ************ 34********** VERSION 2.1.10 ************
33 35
34KO/Pi: 36KO/Pi:
35Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. 37Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file.
36When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. 38When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted.
37Fixed a bug in searching for a small timerange, i.e. one day. 39Fixed a bug in searching for a small timerange, i.e. one day.
38 40
39KA/Pi: 41KA/Pi:
40Fixed two problems in csv export. 42Fixed two problems in csv export.
41Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. 43Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi.
42 44
43********** VERSION 2.1.9 ************ 45********** VERSION 2.1.9 ************
44 46
45KO/Pi: 47KO/Pi:
46Fixed some problems of the new search options in the search dialog. 48Fixed some problems of the new search options in the search dialog.
47Fixed some problems in the new resource config options. 49Fixed some problems in the new resource config options.
48Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. 50Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page.
49Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: 51Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown:
50Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. 52Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup.
51 53
52Fixed a problem in recurrence range in syncing with DTM. 54Fixed a problem in recurrence range in syncing with DTM.
53 55
54KA/Pi: 56KA/Pi:
55Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) 57Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...)
56 58
57PwM/Pi: 59PwM/Pi:
58Added "sec" to the timeout config settings to make it clear the timeout values are seconds. 60Added "sec" to the timeout config settings to make it clear the timeout values are seconds.
59 61
60********** VERSION 2.1.8 ************ 62********** VERSION 2.1.8 ************
61 63
62KO/Pi: 64KO/Pi:
63Added info about the completion state of a todo in the ListView/Searchdialog. 65Added info about the completion state of a todo in the ListView/Searchdialog.
64If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. 66If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well.
65Fixed some updating problems when changing the filter. 67Fixed some updating problems when changing the filter.
66 68
67KA/Pi: 69KA/Pi:
68In the addressee selection dialog now the formatted name is shown, if not empty. 70In the addressee selection dialog now the formatted name is shown, if not empty.
69Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. 71Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category.
70Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. 72Now in the addressee selection dialog a selected contact is remove with a single click from the selected list.
71 73
72Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. 74Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored.
73Fixed the sorting for size in the file selector on the Z. 75Fixed the sorting for size in the file selector on the Z.
74 76
75Changed the color selection dialog on the Zaurus to a more user friendly version. 77Changed the color selection dialog on the Zaurus to a more user friendly version.
76 78
77********** VERSION 2.1.7 ************ 79********** VERSION 2.1.7 ************
78 80
79KO/Pi: 81KO/Pi:
80Fixed several problems in the new Resource handling. 82Fixed several problems in the new Resource handling.
81Added more options to the search dialog. 83Added more options to the search dialog.
82Fixed a problem in the Month view. 84Fixed a problem in the Month view.
83Added more options to the dialog when setting a todo to stopped. 85Added more options to the dialog when setting a todo to stopped.
84 86
85Fixed two small problems in KO/Pi Alarm applet. 87Fixed two small problems in KO/Pi Alarm applet.
86 88
87********** VERSION 2.1.6 ************ 89********** VERSION 2.1.6 ************
88 90
89This release is for testing only. 91This release is for testing only.
90 92
91KO/Pi: 93KO/Pi:
92Added to the list view (the list view is used in search dialog as well) the possibility to print it. 94Added to the list view (the list view is used in search dialog as well) the possibility to print it.
93Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. 95Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view.
94Added to the list view the possibility to add all subtodos of selected todos to an export/beam. 96Added to the list view the possibility to add all subtodos of selected todos to an export/beam.
95Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. 97Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout.
96Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. 98Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus.
97Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. 99Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly.
98 100
99Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. 101Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars.
100In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. 102In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later.
101Now on every sync the set of calendars is synced which are enabled in the resource view. 103Now on every sync the set of calendars is synced which are enabled in the resource view.
102 104
103A calendar is enabled in the resource view if the "eye" column is checked. 105A calendar is enabled in the resource view if the "eye" column is checked.
104You can set a calendar to be the default for new items( "+" column ). 106You can set a calendar to be the default for new items( "+" column ).
105You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. 107You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly.
106To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... 108To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ...
107 109
108 110
109********** VERSION 2.1.5 ************ 111********** VERSION 2.1.5 ************
110 112
111This is the new stable version. 113This is the new stable version.
112Bugfix: 114Bugfix:
113Fixed a problem with agenda popup on the desktop in KO/Pi. 115Fixed a problem with agenda popup on the desktop in KO/Pi.
114Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. 116Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization.
115Added config option to not display completed todos in agenda view. 117Added config option to not display completed todos in agenda view.
116Addressee view is now using the formatted name, if defined. 118Addressee view is now using the formatted name, if defined.
117That makes it possible to display "lastname, firstname" in that view now. 119That makes it possible to display "lastname, firstname" in that view now.
118To set the formatted name for all contacts, please use menu: 120To set the formatted name for all contacts, please use menu:
119Edit->Change->Set formatted name. 121Edit->Change->Set formatted name.
120Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. 122Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows.
121 123
122********** VERSION 2.1.4 ************ 124********** VERSION 2.1.4 ************
123 125
124Fixed two more bugs in the KA/Pi CSV import dialog: 126Fixed two more bugs in the KA/Pi CSV import dialog:
125Made it possible to read multi-line fields and import it to the "Note" field. 127Made it possible to read multi-line fields and import it to the "Note" field.
126Fixed a problem in mapping custom fields, whatever a custem field is... 128Fixed a problem in mapping custom fields, whatever a custem field is...
127 129
128********** VERSION 2.1.3 ************ 130********** VERSION 2.1.3 ************
129 131
130Changed the menu structure of the alarm applet: 132Changed the menu structure of the alarm applet:
131Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". 133Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List".
132 134
133Fixed several problems in the KA/Pi CSV import dialog: 135Fixed several problems in the KA/Pi CSV import dialog:
134Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. 136Added "Category", made codec configureable and made it possible to map many fields to the "Note" field.
135 137
136 138
137********** VERSION 2.1.2 ************ 139********** VERSION 2.1.2 ************
138 140
139Fixed a problem closing the alarm dialog on Zaurus with "OK" button. 141Fixed a problem closing the alarm dialog on Zaurus with "OK" button.
140 142
141Fixed a problem when importing data from Outlook with mutiple categories set. 143Fixed a problem when importing data from Outlook with mutiple categories set.
142 144
143Changed display of days in datenavigator: 145Changed display of days in datenavigator:
144Birthdays are now blue, not dark green. 146Birthdays are now blue, not dark green.
145When todo view is shown, no birtdays are shown and days with due todos are shown blue. 147When todo view is shown, no birtdays are shown and days with due todos are shown blue.
146When journal view is shown, only holidays are shown and days with journals are blue. 148When journal view is shown, only holidays are shown and days with journals are blue.
147 149
148Added Backup options to global config: 150Added Backup options to global config:
149You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). 151You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ).
150It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. 152It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again.
151The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. 153The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups.
152 154
153********** VERSION 2.1.1 ************ 155********** VERSION 2.1.1 ************
154 156
155Stable release 2.1.1! 157Stable release 2.1.1!
156 158
157KO/Pi: 159KO/Pi:
158Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. 160Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display.
159 161
160********** VERSION 2.1.0 ************ 162********** VERSION 2.1.0 ************
161 163
162Stable release 2.1.0! 164Stable release 2.1.0!
163 165
164Summary of changes/fixes compared to version 2.0.6: 166Summary of changes/fixes compared to version 2.0.6:
165 167
166Many bugs of version 2.0.6 fixed. 168Many bugs of version 2.0.6 fixed.
167Most of them were small bugs, but some of them were important. 169Most of them were small bugs, but some of them were important.
168It is recommended to use version 2.1.0 and not version 2.0.6. 170It is recommended to use version 2.1.0 and not version 2.0.6.
169 171
170Important changes: 172Important changes:
171 173
172Added recurring todos to KO/Pi. 174Added recurring todos to KO/Pi.
173 175
174Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. 176Added global application font settings (for all KDE-Pim/Pi apps) to the general settings.
175 177
176Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 178Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
177 179
178Datenavigator can now display many months. Very useful on the desktop. 180Datenavigator can now display many months. Very useful on the desktop.
179 181
180KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. 182KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements.
181 183
182Made alarm sound working on Linux desktop. 184Made alarm sound working on Linux desktop.
183 185
184Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. 186Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details.
185 187
186Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. 188Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details.
187 189
188Many other usebility enhancements. 190Many other usebility enhancements.
189Special thanks to Ben for his suggestions! 191Special thanks to Ben for his suggestions!
190 192
191You can find the complete changelog 193You can find the complete changelog
192from version 1.7.7 to 2.1.0 194from version 1.7.7 to 2.1.0
193in the source package or on 195in the source package or on
194 196
195http://www.pi-sync.net/html/changelog.html 197http://www.pi-sync.net/html/changelog.html
196 198
197 199
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 29e68b3..753630b 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,572 +1,623 @@
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 <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36 36
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <kfiledialog.h> 43#include <kfiledialog.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45 45
46#include <libkcal/todo.h> 46#include <libkcal/todo.h>
47#include <libkcal/event.h> 47#include <libkcal/event.h>
48#include <libkdepim/categoryselectdialog.h> 48#include <libkdepim/categoryselectdialog.h>
49#include <libkdepim/kdateedit.h> 49#include <libkdepim/kdateedit.h>
50 50
51#include "koprefs.h" 51#include "koprefs.h"
52#include "koglobals.h" 52#include "koglobals.h"
53 53
54#include "koeditorgeneral.h" 54#include "koeditorgeneral.h"
55#include "kolocationbox.h" 55#include "kolocationbox.h"
56#ifndef DESKTOP_VERSION 56#ifndef DESKTOP_VERSION
57#include <qpe/qpeapplication.h> 57#include <qpe/qpeapplication.h>
58#else 58#else
59#include <qapplication.h> 59#include <qapplication.h>
60#endif 60#endif
61 61
62KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 62KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
63 QObject( parent, name) 63 QObject( parent, name)
64{ 64{
65 mNextFocus = 0; 65 mNextFocus = 0;
66} 66}
67 67
68KOEditorGeneral::~KOEditorGeneral() 68KOEditorGeneral::~KOEditorGeneral()
69{ 69{
70} 70}
71 71
72void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 72void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
73{ 73{
74 QGridLayout *headerLayout = new QGridLayout(topLayout); 74 QGridLayout *headerLayout = new QGridLayout(topLayout);
75 75
76#if 0 76#if 0
77 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 77 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
78 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 78 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
79#endif 79#endif
80 // 1 on pda 80 // 1 on pda
81 // 11 on desktop 81 // 11 on desktop
82 headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); 82 headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 );
83 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 83 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
84 headerLayout->addWidget(summaryLabel,1,0); 84 headerLayout->addWidget(summaryLabel,0,0);
85 85
86 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 86 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
87 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 87 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
88 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 88 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
89 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 89 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
90 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 90 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
91 if ( QApplication::desktop()->width() > 320 ) 91 if ( QApplication::desktop()->width() > 320 )
92 mSummaryEdit->setMaximumHeight( hei +6 ); 92 mSummaryEdit->setMaximumHeight( hei +6 );
93 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 93 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
94 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 94 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
95 // mSummaryEdit = new QLineEdit(parent); 95 // mSummaryEdit = new QLineEdit(parent);
96 headerLayout->addWidget(mSummaryEdit,1,1); 96 if ( QApplication::desktop()->height() < 320 )
97 headerLayout->addWidget(mSummaryEdit,0,1);
98 else
99 headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2);
97 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 100 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
98 101
99 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 102 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
100 if ( QApplication::desktop()->height() < 320 ) 103 if ( QApplication::desktop()->height() < 320 )
101 headerLayout->addWidget(locationLabel,1,2); 104 headerLayout->addWidget(locationLabel,0,2);
102 else 105 else
103 headerLayout->addWidget(locationLabel,2,0); 106 headerLayout->addWidget(locationLabel,1,0);
104 107
105 mLocationEdit = new KOLocationBox(TRUE,parent,10); 108 mLocationEdit = new KOLocationBox(TRUE,parent,10);
106 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 109 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
107 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 110 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
108 mLocationEdit->setMaximumHeight( hei + 6); 111 mLocationEdit->setMaximumHeight( hei + 6);
109 112
110 // mLocationEdit = new QLineEdit(parent); 113 // mLocationEdit = new QLineEdit(parent);
111 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 114 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
115
116 mCalendarBox = new QComboBox ( parent );
117 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
112 if ( QApplication::desktop()->height() < 320 ) { 118 if ( QApplication::desktop()->height() < 320 ) {
113 headerLayout->addWidget(mLocationEdit,1,3); 119 headerLayout->addWidget(mLocationEdit,0,3);
120 headerLayout->addWidget(mCalendarBox,0,4);
114 headerLayout->setColStretch( 1, 10); 121 headerLayout->setColStretch( 1, 10);
115 headerLayout->setColStretch( 3, 10); 122 headerLayout->setColStretch( 3, 10);
123 mCalendarBox->setMaximumWidth( 64 );
116 } 124 }
117 else { 125 else {
118 headerLayout->addWidget(mLocationEdit,2,1); 126 headerLayout->addWidget(mLocationEdit,1,1);
127 headerLayout->addWidget(mCalendarBox,1,2);
119 headerLayout->setColStretch( 1, 10); 128 headerLayout->setColStretch( 1, 10);
120 } 129 }
130
121} 131}
122void KOEditorGeneral::setFocusOn( int i ) 132void KOEditorGeneral::setFocusOn( int i )
123{ 133{
124 mNextFocus = i; 134 mNextFocus = i;
125 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 135 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
126} 136}
127void KOEditorGeneral::slotSetFocusOn() 137void KOEditorGeneral::slotSetFocusOn()
128{ 138{
129 mNextFocus; 139 mNextFocus;
130 if ( mNextFocus == 1 ) { 140 if ( mNextFocus == 1 ) {
131 mDescriptionEdit->setFocus(); 141 mDescriptionEdit->setFocus();
132 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 142 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
133 } 143 }
134 if ( mNextFocus == 2 ) { 144 if ( mNextFocus == 2 ) {
135 mSummaryEdit->setFocus(); 145 mSummaryEdit->setFocus();
136 } 146 }
137} 147}
138void KOEditorGeneral::editCategories() 148void KOEditorGeneral::editCategories()
139{ 149{
140 // qDebug("KOEditorGeneral::editCategories() "); 150 // qDebug("KOEditorGeneral::editCategories() ");
141 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 151 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
142 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 152 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
143 //KOGlobals::fitDialogToScreen( csd ); 153 //KOGlobals::fitDialogToScreen( csd );
144 csd->setColorEnabled(); 154 csd->setColorEnabled();
145 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 155 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
146 csd->exec(); 156 csd->exec();
147 delete csd; 157 delete csd;
148} 158}
149 159
150void KOEditorGeneral::showCatPopup() 160void KOEditorGeneral::showCatPopup()
151{ 161{
152 mCatPopup->clear(); 162 mCatPopup->clear();
153 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 163 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
154 int index = 0; 164 int index = 0;
155 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 165 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
156 it != KOPrefs::instance()->mCustomCategories.end (); 166 it != KOPrefs::instance()->mCustomCategories.end ();
157 ++it) { 167 ++it) {
158 mCatPopup->insertItem (*it, index ); 168 mCatPopup->insertItem (*it, index );
159 //mCategory[index] = *it; 169 //mCategory[index] = *it;
160 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 170 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
161 ++index; 171 ++index;
162 } 172 }
163} 173}
164void KOEditorGeneral::selectedCatPopup( int index ) 174void KOEditorGeneral::selectedCatPopup( int index )
165{ 175{
166 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 176 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
167 QString colcat = categories.first(); 177 QString colcat = categories.first();
168 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 178 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
169 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 179 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
170 else 180 else
171 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 181 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
172 categories.sort (); 182 categories.sort ();
173 if ( !colcat.isEmpty() ) { 183 if ( !colcat.isEmpty() ) {
174 if ( categories.find ( colcat ) != categories.end () ) { 184 if ( categories.find ( colcat ) != categories.end () ) {
175 categories.remove( colcat ); 185 categories.remove( colcat );
176 categories.prepend( colcat ); 186 categories.prepend( colcat );
177 } 187 }
178 } 188 }
179 setCategories( categories.join(",") ); 189 setCategories( categories.join(",") );
180} 190}
181 191
182void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 192void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
183{ 193{
184 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 194 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
185 mCatPopup = new QPopupMenu ( parent ); 195 mCatPopup = new QPopupMenu ( parent );
186 mCatPopup->setCheckable (true); 196 mCatPopup->setCheckable (true);
187 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 197 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
188 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 198 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
189 mCategoriesButton = new QPushButton(parent); 199 mCategoriesButton = new QPushButton(parent);
190 mCategoriesButton->setText(i18n("Categories...")); 200 mCategoriesButton->setText(i18n("Categories..."));
191 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 201 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
192 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 202 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
193 categoriesLayout->addWidget(mCategoriesButton); 203 categoriesLayout->addWidget(mCategoriesButton);
194 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); 204 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
195 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); 205 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) );
196 mCategoriesLabel->setPopup( mCatPopup ); 206 mCategoriesLabel->setPopup( mCatPopup );
197 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 207 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
198 categoriesLayout->addWidget(mCategoriesLabel,1); 208 categoriesLayout->addWidget(mCategoriesLabel,1);
199} 209}
200 210
201void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 211void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
202{ 212{
203 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 213 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
204 214
205 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 215 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
206 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 216 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
207 secrecyLayout->addWidget(mCancelBox); 217 secrecyLayout->addWidget(mCancelBox);
208 secrecyLayout->addWidget(secrecyLabel); 218 secrecyLayout->addWidget(secrecyLabel);
209 219
210 mSecrecyCombo = new QComboBox(parent); 220 mSecrecyCombo = new QComboBox(parent);
211 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 221 mSecrecyCombo->insertStringList(Incidence::secrecyList());
212 secrecyLayout->addWidget(mSecrecyCombo); 222 secrecyLayout->addWidget(mSecrecyCombo);
213} 223}
214 224
215void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 225void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
216{ 226{
217 mDescriptionEdit = new KTextEdit(parent); 227 mDescriptionEdit = new KTextEdit(parent);
218 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 228 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
219 mDescriptionEdit->append(""); 229 mDescriptionEdit->append("");
220 mDescriptionEdit->setReadOnly(false); 230 mDescriptionEdit->setReadOnly(false);
221 mDescriptionEdit->setOverwriteMode(false); 231 mDescriptionEdit->setOverwriteMode(false);
222 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 232 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
223 topLayout->addWidget(mDescriptionEdit); 233 topLayout->addWidget(mDescriptionEdit);
224#ifndef DESKTOP_VERSION 234#ifndef DESKTOP_VERSION
225 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 235 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
226#endif 236#endif
227 237
228} 238}
229 239
230void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 240void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
231{ 241{
232 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 242 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
233 243
234 //mAlarmBell = new QLabel(parent); 244 //mAlarmBell = new QLabel(parent);
235 //mAlarmBell->setPixmap(SmallIcon("bell")); 245 //mAlarmBell->setPixmap(SmallIcon("bell"));
236 //alarmLayout->addWidget(mAlarmBell); 246 //alarmLayout->addWidget(mAlarmBell);
237 if ( QApplication::desktop()->width() < 320 ) 247 if ( QApplication::desktop()->width() < 320 )
238 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 248 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
239 else 249 else
240 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 250 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
241 251
242 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 252 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
243 alarmLayout->addWidget(mAlarmButton); 253 alarmLayout->addWidget(mAlarmButton);
244 254
245 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 255 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
246 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 256 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
247 alarmLayout->addWidget(mAlarmTimeEdit); 257 alarmLayout->addWidget(mAlarmTimeEdit);
248 mAlarmIncrCombo = new QComboBox(false, parent); 258 mAlarmIncrCombo = new QComboBox(false, parent);
249 if ( QApplication::desktop()->width() < 320 ) { 259 if ( QApplication::desktop()->width() < 320 ) {
250 mAlarmIncrCombo->insertItem(i18n("min")); 260 mAlarmIncrCombo->insertItem(i18n("min"));
251 mAlarmIncrCombo->insertItem(i18n("hou")); 261 mAlarmIncrCombo->insertItem(i18n("hou"));
252 mAlarmIncrCombo->insertItem(i18n("day")); 262 mAlarmIncrCombo->insertItem(i18n("day"));
253 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 263 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
254 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 264 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
255 } else { 265 } else {
256 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 266 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
257 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 267 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
258 mAlarmIncrCombo->insertItem(i18n("day(s)")); 268 mAlarmIncrCombo->insertItem(i18n("day(s)"));
259 } 269 }
260 270
261 // mAlarmIncrCombo->setMinimumHeight(20); 271 // mAlarmIncrCombo->setMinimumHeight(20);
262 alarmLayout->addWidget(mAlarmIncrCombo); 272 alarmLayout->addWidget(mAlarmIncrCombo);
263 mAlarmSoundButton = new QPushButton(parent); 273 mAlarmSoundButton = new QPushButton(parent);
264 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 274 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
265 mAlarmSoundButton->setToggleButton(true); 275 mAlarmSoundButton->setToggleButton(true);
266 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 276 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
267 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 277 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
268 alarmLayout->addWidget(mAlarmSoundButton); 278 alarmLayout->addWidget(mAlarmSoundButton);
269 279
270 mAlarmProgramButton = new QPushButton(parent); 280 mAlarmProgramButton = new QPushButton(parent);
271 mAlarmProgramButton->setPixmap(SmallIcon("run")); 281 mAlarmProgramButton->setPixmap(SmallIcon("run"));
272 mAlarmProgramButton->setToggleButton(true); 282 mAlarmProgramButton->setToggleButton(true);
273 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 283 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
274 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 284 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
275 alarmLayout->addWidget(mAlarmProgramButton); 285 alarmLayout->addWidget(mAlarmProgramButton);
276 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 286 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
277 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 287 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
278 // if ( KOPrefs::instance()->mCompactDialogs ) { 288 // if ( KOPrefs::instance()->mCompactDialogs ) {
279 // mAlarmSoundButton->hide(); 289 // mAlarmSoundButton->hide();
280 // mAlarmProgramButton->hide(); 290 // mAlarmProgramButton->hide();
281 // } 291 // }
282} 292}
283 293
284void KOEditorGeneral::pickAlarmSound() 294void KOEditorGeneral::pickAlarmSound()
285{ 295{
286 296
287 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 297 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
288 298
289 bool oldState = mAlarmSoundButton->isOn(); 299 bool oldState = mAlarmSoundButton->isOn();
290 300
291 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 301 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
292 i18n("*.wav|Wav Files"), 0)); 302 i18n("*.wav|Wav Files"), 0));
293 if (!fileName.isEmpty()) { 303 if (!fileName.isEmpty()) {
294 mAlarmSound = fileName; 304 mAlarmSound = fileName;
295 QToolTip::remove(mAlarmSoundButton); 305 QToolTip::remove(mAlarmSoundButton);
296 QString dispStr = i18n("Playing '%1'").arg(fileName); 306 QString dispStr = i18n("Playing '%1'").arg(fileName);
297 QToolTip::add(mAlarmSoundButton, dispStr); 307 QToolTip::add(mAlarmSoundButton, dispStr);
298 mAlarmProgramButton->setOn(false); 308 mAlarmProgramButton->setOn(false);
299 mAlarmSoundButton->setOn(true); 309 mAlarmSoundButton->setOn(true);
300 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 310 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
301 } else { 311 } else {
302 mAlarmProgramButton->setOn(oldState); 312 mAlarmProgramButton->setOn(oldState);
303 mAlarmSoundButton->setOn(!oldState); 313 mAlarmSoundButton->setOn(!oldState);
304 314
305 315
306 } 316 }
307 317
308 if (mAlarmProgramButton->isOn()) 318 if (mAlarmProgramButton->isOn())
309 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 319 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
310 if ( mAlarmSoundButton->isOn()) 320 if ( mAlarmSoundButton->isOn())
311 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 321 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
312 322
313} 323}
314 324
315void KOEditorGeneral::pickAlarmProgram() 325void KOEditorGeneral::pickAlarmProgram()
316{ 326{
317 bool oldState = mAlarmProgramButton->isOn(); 327 bool oldState = mAlarmProgramButton->isOn();
318 328
319 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 329 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
320 if (!fileName.isEmpty()) { 330 if (!fileName.isEmpty()) {
321 mAlarmProgram = fileName; 331 mAlarmProgram = fileName;
322 QToolTip::remove(mAlarmProgramButton); 332 QToolTip::remove(mAlarmProgramButton);
323 QString dispStr = i18n("Running '%1'").arg(fileName); 333 QString dispStr = i18n("Running '%1'").arg(fileName);
324 QToolTip::add(mAlarmProgramButton, dispStr); 334 QToolTip::add(mAlarmProgramButton, dispStr);
325 mAlarmSoundButton->setOn(false); 335 mAlarmSoundButton->setOn(false);
326 mAlarmProgramButton->setOn(true); 336 mAlarmProgramButton->setOn(true);
327 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 337 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
328 } else { 338 } else {
329 mAlarmProgramButton->setOn(!oldState); 339 mAlarmProgramButton->setOn(!oldState);
330 mAlarmSoundButton->setOn(oldState); 340 mAlarmSoundButton->setOn(oldState);
331 } 341 }
332 342
333 if (mAlarmProgramButton->isOn()) 343 if (mAlarmProgramButton->isOn())
334 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 344 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
335 if ( mAlarmSoundButton->isOn()) 345 if ( mAlarmSoundButton->isOn())
336 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 346 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
337 347
338} 348}
339 349
340 350
341QString KOEditorGeneral::getFittingPath( const QString s ) 351QString KOEditorGeneral::getFittingPath( const QString s )
342{ 352{
343 int maxlen = 50; 353 int maxlen = 50;
344 if ( QApplication::desktop()->width() < 640 ) { 354 if ( QApplication::desktop()->width() < 640 ) {
345 if ( QApplication::desktop()->width() < 320 ) 355 if ( QApplication::desktop()->width() < 320 )
346 maxlen = 22; 356 maxlen = 22;
347 else 357 else
348 maxlen = 35; 358 maxlen = 35;
349 } 359 }
350 if ( s.length() > maxlen ) { 360 if ( s.length() > maxlen ) {
351 return "..."+s.right(maxlen -3); 361 return "..."+s.right(maxlen -3);
352 } 362 }
353 return s; 363 return s;
354} 364}
355 365
356void KOEditorGeneral::enableAlarmEdit(bool enable) 366void KOEditorGeneral::enableAlarmEdit(bool enable)
357{ 367{
358 if ( enable ) { 368 if ( enable ) {
359 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 369 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
360 mAlarmSoundButton->setOn( true ); 370 mAlarmSoundButton->setOn( true );
361 if ( mAlarmSound.isEmpty() ) 371 if ( mAlarmSound.isEmpty() )
362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 372 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
363 else { 373 else {
364 if ( ! QFile::exists( mAlarmSound ) ) 374 if ( ! QFile::exists( mAlarmSound ) )
365 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 375 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
366 } 376 }
367 } 377 }
368 } 378 }
369 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 379 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
370 mAlarmTimeEdit->setEnabled(enable); 380 mAlarmTimeEdit->setEnabled(enable);
371 mAlarmSoundButton->setEnabled(enable); 381 mAlarmSoundButton->setEnabled(enable);
372 mAlarmProgramButton->setEnabled(enable); 382 mAlarmProgramButton->setEnabled(enable);
373 mAlarmIncrCombo->setEnabled(enable); 383 mAlarmIncrCombo->setEnabled(enable);
374} 384}
375 385
376void KOEditorGeneral::disableAlarmEdit(bool disable) 386void KOEditorGeneral::disableAlarmEdit(bool disable)
377{ 387{
378 enableAlarmEdit( !disable ); 388 enableAlarmEdit( !disable );
379} 389}
380 390
381void KOEditorGeneral::enableAlarm( bool enable ) 391void KOEditorGeneral::enableAlarm( bool enable )
382{ 392{
383 enableAlarmEdit( enable ); 393 enableAlarmEdit( enable );
384} 394}
385 395
386void KOEditorGeneral::alarmDisable(bool disable) 396void KOEditorGeneral::alarmDisable(bool disable)
387{ 397{
388 if (!disable) { 398 if (!disable) {
389 //mAlarmBell->setEnabled(true); 399 //mAlarmBell->setEnabled(true);
390 mAlarmButton->setEnabled(true); 400 mAlarmButton->setEnabled(true);
391 } else { 401 } else {
392 //mAlarmBell->setEnabled(false); 402 //mAlarmBell->setEnabled(false);
393 mAlarmButton->setEnabled(false); 403 mAlarmButton->setEnabled(false);
394 mAlarmButton->setChecked(false); 404 mAlarmButton->setChecked(false);
395 mAlarmTimeEdit->setEnabled(false); 405 mAlarmTimeEdit->setEnabled(false);
396 mAlarmSoundButton->setEnabled(false); 406 mAlarmSoundButton->setEnabled(false);
397 mAlarmProgramButton->setEnabled(false); 407 mAlarmProgramButton->setEnabled(false);
398 mAlarmIncrCombo->setEnabled(false); 408 mAlarmIncrCombo->setEnabled(false);
399 } 409 }
400} 410}
401 411
402void KOEditorGeneral::setCategories(const QString &str) 412void KOEditorGeneral::setCategories(const QString &str)
403{ 413{
404 QString tt = str; 414 QString tt = str;
405 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); 415 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>");
406 mCategoriesLabel->setText(str); 416 mCategoriesLabel->setText(str);
407} 417}
408 418
409void KOEditorGeneral::setDefaults(bool allDay) 419void KOEditorGeneral::setDefaults(bool allDay)
410{ 420{
411#if 0 421#if 0
412 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 422 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
413#endif 423#endif
414 424
415 mAlarmMessage = i18n("Edit new item"); 425 mAlarmMessage = i18n("Edit new item");
416 enableAlarmEdit( !allDay ); 426 enableAlarmEdit( !allDay );
417 427
418 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 428 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
419 int alarmTime; 429 int alarmTime;
420 int a[] = { 1,5,10,15,30,60,180, 1440 }; 430 int a[] = { 1,5,10,15,30,60,180, 1440 };
421 int index = KOPrefs::instance()->mAlarmTime; 431 int index = KOPrefs::instance()->mAlarmTime;
422 if (index < 0 || index > 7) { 432 if (index < 0 || index > 7) {
423 alarmTime = 15; 433 alarmTime = 15;
424 } else { 434 } else {
425 alarmTime = a[index]; 435 alarmTime = a[index];
426 } 436 }
427 mAlarmButton ->setChecked( false ); 437 mAlarmButton ->setChecked( false );
428 mAlarmTimeEdit->setValue(alarmTime); 438 mAlarmTimeEdit->setValue(alarmTime);
429 mAlarmIncrCombo->setCurrentItem(0); 439 mAlarmIncrCombo->setCurrentItem(0);
430 enableAlarmEdit( false ); 440 enableAlarmEdit( false );
431 //alarmDisable (false); 441 //alarmDisable (false);
432 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 442 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
433 mCancelBox->setChecked( false ); 443 mCancelBox->setChecked( false );
434 mSummaryEdit->setEditText(""); 444 mSummaryEdit->setEditText("");
435 mLocationEdit->setEditText(""); 445 mLocationEdit->setEditText("");
436 mDescriptionEdit->setText(""); 446 mDescriptionEdit->setText("");
437 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 447 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
438 setCategories(""); 448 setCategories("");
449 fillCalCombo();
439} 450}
440void KOEditorGeneral::setSecrecy( int num ) 451void KOEditorGeneral::setSecrecy( int num )
441{ 452{
442 mSecrecyCombo->setCurrentItem(num); 453 mSecrecyCombo->setCurrentItem(num);
443} 454}
444void KOEditorGeneral::readIncidence(Incidence *event) 455void KOEditorGeneral::fillCalCombo( int setToID )
445{ 456{
457 mCalendarBox->clear();
458 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
459 int std = 0;
460 int count = 0;
461 while ( kkf ) {
462 if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) {
463 if ( setToID ) {
464 if ( kkf->mCalNumber == setToID )
465 std = count;
466 } else {
467 if ( kkf->isStandard ) {
468 std = count;
469 }
470 }
471 ++count;
472 mCalendarBox->insertItem( kkf->mName );
473 }
474 kkf = KOPrefs::instance()->mCalendars.next();
475 }
476 mCalendarBox->setCurrentItem( std );
477 if ( KOPrefs::instance()->mCalendars.count() == 1 )
478 mCalendarBox->hide();
479 else
480 mCalendarBox->show();
481
482}
483int KOEditorGeneral::getCalendarID()
484{
485 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
486 while ( kkf ) {
487 if ( mCalendarBox->currentText() == kkf->mName)
488 return kkf->mCalNumber;
489 kkf = KOPrefs::instance()->mCalendars.next();
490 }
491 return 1;
492}
446 493
494void KOEditorGeneral::readIncidence(Incidence *event)
495{
496 fillCalCombo( event->calID() );
447 mAlarmMessage = event->summary(); 497 mAlarmMessage = event->summary();
448 if ( ! event->location().isEmpty() ) 498 if ( ! event->location().isEmpty() )
449 mAlarmMessage += " ("+event->location()+")"; 499 mAlarmMessage += " ("+event->location()+")";
450 mAlarmIncrCombo->setCurrentItem(0); 500 mAlarmIncrCombo->setCurrentItem(0);
451 mSummaryEdit->setEditText(event->summary()); 501 mSummaryEdit->setEditText(event->summary());
452 mLocationEdit->setEditText(event->location()); 502 mLocationEdit->setEditText(event->location());
453 mDescriptionEdit->setText(event->description()); 503 mDescriptionEdit->setText(event->description());
454 504
455#if 0 505#if 0
456 // organizer information 506 // organizer information
457 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 507 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
458#endif 508#endif
459 509
460 enableAlarmEdit( event->isAlarmEnabled() ); 510 enableAlarmEdit( event->isAlarmEnabled() );
461 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 511 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
462 if(!event->isAlarmEnabled()) { 512 if(!event->isAlarmEnabled()) {
463 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 513 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
464 int alarmTime; 514 int alarmTime;
465 int a[] = { 1,5,10,15,30,60,180, 1440 }; 515 int a[] = { 1,5,10,15,30,60,180, 1440 };
466 int index = KOPrefs::instance()->mAlarmTime; 516 int index = KOPrefs::instance()->mAlarmTime;
467 if (index < 0 || index > 7) { 517 if (index < 0 || index > 7) {
468 alarmTime = 15; 518 alarmTime = 15;
469 } else { 519 } else {
470 alarmTime = a[index]; 520 alarmTime = a[index];
471 } 521 }
472 mAlarmTimeEdit->setValue(alarmTime); 522 mAlarmTimeEdit->setValue(alarmTime);
473 } 523 }
474 mAlarmButton->setChecked( event->isAlarmEnabled() ); 524 mAlarmButton->setChecked( event->isAlarmEnabled() );
475 mSecrecyCombo->setCurrentItem(event->secrecy()); 525 mSecrecyCombo->setCurrentItem(event->secrecy());
476 mCancelBox->setChecked( event->cancelled() ); 526 mCancelBox->setChecked( event->cancelled() );
477 mAlarmProgramButton->setOn(false); 527 mAlarmProgramButton->setOn(false);
478 mAlarmSoundButton->setOn(false); 528 mAlarmSoundButton->setOn(false);
479 529
480 // set up alarm stuff 530 // set up alarm stuff
481 QPtrList<Alarm> alarms = event->alarms(); 531 QPtrList<Alarm> alarms = event->alarms();
482 Alarm* alarm; 532 Alarm* alarm;
483 mAlarmIncrCombo->setCurrentItem(0); 533 mAlarmIncrCombo->setCurrentItem(0);
484 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 534 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
485 int offset; 535 int offset;
486 if ( alarm->hasTime() ) { 536 if ( alarm->hasTime() ) {
487 QDateTime t = alarm->time(); 537 QDateTime t = alarm->time();
488 offset = event->dtStart().secsTo( t ); 538 offset = event->dtStart().secsTo( t );
489 } else { 539 } else {
490 offset = alarm->startOffset().asSeconds(); 540 offset = alarm->startOffset().asSeconds();
491 } 541 }
492 if ( offset != 0 ) { 542 if ( offset != 0 ) {
493 offset = offset / -60; // make minutes 543 offset = offset / -60; // make minutes
494 if (offset % 60 == 0) { // divides evenly into hours? 544 if (offset % 60 == 0) { // divides evenly into hours?
495 offset = offset / 60; 545 offset = offset / 60;
496 mAlarmIncrCombo->setCurrentItem(1); 546 mAlarmIncrCombo->setCurrentItem(1);
497 if (offset % 24 == 0) { // divides evenly into days? 547 if (offset % 24 == 0) { // divides evenly into days?
498 offset = offset / 24; 548 offset = offset / 24;
499 mAlarmIncrCombo->setCurrentItem(2); 549 mAlarmIncrCombo->setCurrentItem(2);
500 } 550 }
501 } 551 }
502 } 552 }
503 mAlarmTimeEdit->setValue( offset ); 553 mAlarmTimeEdit->setValue( offset );
504 if (alarm->type() == Alarm::Procedure) { 554 if (alarm->type() == Alarm::Procedure) {
505 555
506 mAlarmProgram = alarm->programFile(); 556 mAlarmProgram = alarm->programFile();
507 mAlarmProgramButton->setOn(true); 557 mAlarmProgramButton->setOn(true);
508 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 558 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
509 QToolTip::add(mAlarmProgramButton, dispStr); 559 QToolTip::add(mAlarmProgramButton, dispStr);
510 } 560 }
511 else if (alarm->type() == Alarm::Audio) { 561 else if (alarm->type() == Alarm::Audio) {
512 mAlarmSound = alarm->audioFile(); 562 mAlarmSound = alarm->audioFile();
513 if ( ! QFile::exists( mAlarmSound ) ) 563 if ( ! QFile::exists( mAlarmSound ) )
514 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 564 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
515 mAlarmSoundButton->setOn(true); 565 mAlarmSoundButton->setOn(true);
516 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 566 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
517 QToolTip::add(mAlarmSoundButton, dispStr); 567 QToolTip::add(mAlarmSoundButton, dispStr);
518 } 568 }
519 mAlarmButton->setChecked(alarm->enabled()); 569 mAlarmButton->setChecked(alarm->enabled());
520 enableAlarmEdit( alarm->enabled() ); 570 enableAlarmEdit( alarm->enabled() );
521 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 571 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
522 // TODO: Deal with multiple alarms 572 // TODO: Deal with multiple alarms
523 break; // For now, stop after the first alarm 573 break; // For now, stop after the first alarm
524 } 574 }
525 575
526 setCategories(event->categoriesStr()); 576 setCategories(event->categoriesStr());
527} 577}
528 578
529void KOEditorGeneral::writeIncidence(Incidence *event) 579void KOEditorGeneral::writeIncidence(Incidence *event)
530{ 580{
531 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 581 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
532 mLocationEdit->save(KOLocationBox::LOCATION); 582 mLocationEdit->save(KOLocationBox::LOCATION);
533 event->setSummary(mSummaryEdit->currentText()); 583 event->setSummary(mSummaryEdit->currentText());
534 event->setLocation(mLocationEdit->currentText()); 584 event->setLocation(mLocationEdit->currentText());
535 event->setDescription(mDescriptionEdit->text()); 585 event->setDescription(mDescriptionEdit->text());
536 event->setCategories(mCategoriesLabel->text()); 586 event->setCategories(mCategoriesLabel->text());
537 event->setSecrecy(mSecrecyCombo->currentItem()); 587 event->setSecrecy(mSecrecyCombo->currentItem());
538 event->setCancelled(mCancelBox->isChecked() );; 588 event->setCancelled(mCancelBox->isChecked() );;
539 // alarm stuff 589 // alarm stuff
540 if (mAlarmButton->isChecked()) { 590 if (mAlarmButton->isChecked()) {
541 if (event->alarms().count() == 0) 591 if (event->alarms().count() == 0)
542 event->newAlarm(); 592 event->newAlarm();
543 QPtrList<Alarm> alarms = event->alarms(); 593 QPtrList<Alarm> alarms = event->alarms();
544 Alarm *alarm; 594 Alarm *alarm;
545 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 595 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
546 alarm->setEnabled(true); 596 alarm->setEnabled(true);
547 int j = mAlarmTimeEdit->value()* -60; 597 int j = mAlarmTimeEdit->value()* -60;
548 if (mAlarmIncrCombo->currentItem() == 1) 598 if (mAlarmIncrCombo->currentItem() == 1)
549 j = j * 60; 599 j = j * 60;
550 else if (mAlarmIncrCombo->currentItem() == 2) 600 else if (mAlarmIncrCombo->currentItem() == 2)
551 j = j * (60 * 24); 601 j = j * (60 * 24);
552 alarm->setStartOffset( j ); 602 alarm->setStartOffset( j );
553 603
554 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 604 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
555 alarm->setProcedureAlarm(mAlarmProgram); 605 alarm->setProcedureAlarm(mAlarmProgram);
556 } 606 }
557 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 607 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
558 alarm->setAudioAlarm(mAlarmSound); 608 alarm->setAudioAlarm(mAlarmSound);
559 else 609 else
560 alarm->setType(Alarm::Invalid); 610 alarm->setType(Alarm::Invalid);
561 //alarm->setAudioAlarm("default"); 611 //alarm->setAudioAlarm("default");
562 // TODO: Deal with multiple alarms 612 // TODO: Deal with multiple alarms
563 break; // For now, stop after the first alarm 613 break; // For now, stop after the first alarm
564 } 614 }
565 } else { 615 } else {
566 Alarm* alarm = event->alarms().first(); 616 Alarm* alarm = event->alarms().first();
567 if ( alarm ) { 617 if ( alarm ) {
568 alarm->setEnabled(false); 618 alarm->setEnabled(false);
569 alarm->setType(Alarm::Invalid); 619 alarm->setType(Alarm::Invalid);
570 } 620 }
571 } 621 }
622 event->setCalID( getCalendarID() );
572} 623}
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
index c463403..d8b15af 100644
--- a/korganizer/koeditorgeneral.h
+++ b/korganizer/koeditorgeneral.h
@@ -1,121 +1,125 @@
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 KOEDITORGENERAL_H 23#ifndef KOEDITORGENERAL_H
24#define KOEDITORGENERAL_H 24#define KOEDITORGENERAL_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qgroupbox.h> 31#include <qgroupbox.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qradiobutton.h> 35#include <qradiobutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qcombobox.h>
38 39
39#include <ktextedit.h> 40#include <ktextedit.h>
40#include <krestrictedline.h> 41#include <krestrictedline.h>
41 42
42#include <libkcal/incidence.h> 43#include <libkcal/incidence.h>
43 44
44#include "ktimeedit.h" 45#include "ktimeedit.h"
45 46
46class KDateEdit; 47class KDateEdit;
47class KOLocationBox; 48class KOLocationBox;
48using namespace KCal; 49using namespace KCal;
49 50
50class KOEditorGeneral : public QObject 51class KOEditorGeneral : public QObject
51{ 52{
52 Q_OBJECT 53 Q_OBJECT
53 public: 54 public:
54 KOEditorGeneral (QObject* parent=0,const char* name=0); 55 KOEditorGeneral (QObject* parent=0,const char* name=0);
55 virtual ~KOEditorGeneral(); 56 virtual ~KOEditorGeneral();
56 void setFocusOn( int i ); 57 void setFocusOn( int i );
57 void initHeader(QWidget *,QBoxLayout *); 58 void initHeader(QWidget *,QBoxLayout *);
58 void initDescription(QWidget *,QBoxLayout *); 59 void initDescription(QWidget *,QBoxLayout *);
59 void initSecrecy(QWidget *,QBoxLayout *); 60 void initSecrecy(QWidget *,QBoxLayout *);
60 void initCategories(QWidget *,QBoxLayout *); 61 void initCategories(QWidget *,QBoxLayout *);
61 void initAlarm(QWidget *,QBoxLayout *); 62 void initAlarm(QWidget *,QBoxLayout *);
62 63
63 /** Set widgets to default values */ 64 /** Set widgets to default values */
64 void setDefaults(bool allDay); 65 void setDefaults(bool allDay);
65 /** Read event object and setup widgets accordingly */ 66 /** Read event object and setup widgets accordingly */
66 void readIncidence(Incidence *); 67 void readIncidence(Incidence *);
67 /** Write event settings to event object */ 68 /** Write event settings to event object */
68 void writeIncidence(Incidence *); 69 void writeIncidence(Incidence *);
69 70
70 /** Check if the input is valid. */ 71 /** Check if the input is valid. */
71 bool validateInput() { return true; } 72 bool validateInput() { return true; }
72 73
73 void enableAlarm( bool enable ); 74 void enableAlarm( bool enable );
74 void setSecrecy( int num ); 75 void setSecrecy( int num );
76 int getCalendarID();
75 public slots: 77 public slots:
76 void setCategories(const QString &); 78 void setCategories(const QString &);
77 void editCategories(); 79 void editCategories();
78 80
79 protected slots: 81 protected slots:
80 void enableAlarmEdit( bool enable ); 82 void enableAlarmEdit( bool enable );
81 void disableAlarmEdit( bool disable ); 83 void disableAlarmEdit( bool disable );
82 void alarmDisable( bool disable ); 84 void alarmDisable( bool disable );
83 void pickAlarmSound(); 85 void pickAlarmSound();
84 void pickAlarmProgram(); 86 void pickAlarmProgram();
85 void slotSetFocusOn(); 87 void slotSetFocusOn();
86 void showCatPopup(); 88 void showCatPopup();
87 void selectedCatPopup( int ); 89 void selectedCatPopup( int );
88 90
89 signals: 91 signals:
90 void openCategoryDialog(); 92 void openCategoryDialog();
91 void allAccepted(); 93 void allAccepted();
92 void dateTimesChanged(QDateTime,QDateTime); 94 void dateTimesChanged(QDateTime,QDateTime);
93 95
94 protected: 96 protected:
97 void fillCalCombo( int setToID = 0 );
95 int mNextFocus; 98 int mNextFocus;
96 //QLineEdit *mSummaryEdit; 99 //QLineEdit *mSummaryEdit;
97 //QLineEdit *mLocationEdit; 100 //QLineEdit *mLocationEdit;
98 KOLocationBox *mSummaryEdit; 101 KOLocationBox *mSummaryEdit;
99 KOLocationBox *mLocationEdit; 102 KOLocationBox *mLocationEdit;
103 QComboBox *mCalendarBox;
100 QLabel *mAlarmBell; 104 QLabel *mAlarmBell;
101 QCheckBox *mAlarmButton; 105 QCheckBox *mAlarmButton;
102 QSpinBox *mAlarmTimeEdit; 106 QSpinBox *mAlarmTimeEdit;
103 QPushButton *mAlarmSoundButton; 107 QPushButton *mAlarmSoundButton;
104 QPushButton *mAlarmProgramButton; 108 QPushButton *mAlarmProgramButton;
105 QComboBox *mAlarmIncrCombo; 109 QComboBox *mAlarmIncrCombo;
106 KTextEdit *mDescriptionEdit; 110 KTextEdit *mDescriptionEdit;
107 QLabel *mOwnerLabel; 111 QLabel *mOwnerLabel;
108 QComboBox *mSecrecyCombo; 112 QComboBox *mSecrecyCombo;
109 QCheckBox *mCancelBox; 113 QCheckBox *mCancelBox;
110 QPushButton *mCategoriesButton; 114 QPushButton *mCategoriesButton;
111 QPushButton *mCategoriesLabel; 115 QPushButton *mCategoriesLabel;
112 116
113 private: 117 private:
114 QPopupMenu * mCatPopup; 118 QPopupMenu * mCatPopup;
115 QString getFittingPath( const QString ) ; 119 QString getFittingPath( const QString ) ;
116 QString mAlarmSound; 120 QString mAlarmSound;
117 QString mAlarmProgram; 121 QString mAlarmProgram;
118 QString mAlarmMessage; 122 QString mAlarmMessage;
119}; 123};
120 124
121#endif 125#endif
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 77322e7..fc4d9a4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,201 +1,200 @@
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 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 <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koprefs.h" 33#include "koprefs.h"
34 34
35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
36{ 36{
37 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
38 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
39 39
40 40
41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
43 mEditOnlyItems.append(insertItem (i18n("&Delete..."), 43 mEditOnlyItems.append(insertItem (i18n("&Delete..."),
44 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
45 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
46 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
47 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
48 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
49#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
50 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
51 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
52#endif 52#endif
53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
54 this,SLOT(popupCancel()))); 54 this,SLOT(popupCancel())));
55 isDisabled = false; 55 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this ); 56 mCatPopup = new QPopupMenu ( this );
57 mCatPopup->setCheckable (true); 57 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); 58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); 59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mCalPopup = new QPopupMenu ( this ); 60 mCalPopup = new QPopupMenu ( this );
61 mCalPopup->setCheckable (true); 61 mCalPopup->setCheckable (true);
62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup())); 62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int ))); 63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
64 //mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); 64 //mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
65 //mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup )); 65 //mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
66 insertItem (i18n("Categories"),mCatPopup ); 66 insertItem (i18n("Categories"),mCatPopup );
67 insertItem (i18n("Calendar"),mCalPopup ); 67 insertItem (i18n("Calendar"),mCalPopup );
68 QValueList<int>::Iterator it; 68 QValueList<int>::Iterator it;
69 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 69 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
70 mSingleOnlyItems.append(*it); 70 mSingleOnlyItems.append(*it);
71 } 71 }
72 72
73} 73}
74void KOEventPopupMenu::enableDefault( bool enable ) 74void KOEventPopupMenu::enableDefault( bool enable )
75{ 75{
76 isDisabled = !enable; 76 isDisabled = !enable;
77 QValueList<int>::Iterator it; 77 QValueList<int>::Iterator it;
78 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 78 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
79 setItemEnabled(*it,enable); 79 setItemEnabled(*it,enable);
80 } 80 }
81
82} 81}
83 82
84void KOEventPopupMenu::fillCalPopup() // CAL 83void KOEventPopupMenu::fillCalPopup() // CAL
85{ 84{
86 mCalPopup->clear(); 85 mCalPopup->clear();
87 if (!mCurrentIncidence) return; 86 if (!mCurrentIncidence) return;
88 bool readO = mCurrentIncidence->isReadOnly()|| isDisabled; 87 bool readO = mCurrentIncidence->isReadOnly()|| isDisabled;
89 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 88 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
90 while ( kkf ) { 89 while ( kkf ) {
91 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); 90 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
92 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 91 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
93 mCalPopup->setItemEnabled( index, false ); 92 mCalPopup->setItemEnabled( index, false );
94 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID()); 93 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
95 kkf = KOPrefs::instance()->mCalendars.next(); 94 kkf = KOPrefs::instance()->mCalendars.next();
96 } 95 }
97} 96}
98void KOEventPopupMenu::computeCalPopup( int index ) // CAL 97void KOEventPopupMenu::computeCalPopup( int index ) // CAL
99{ 98{
100 if (!mCurrentIncidence) return; 99 if (!mCurrentIncidence) return;
101 mCurrentIncidence->setCalID( index ); 100 mCurrentIncidence->setCalID( index );
102 emit categoryChanged( mCurrentIncidence ); 101 emit categoryChanged( mCurrentIncidence );
103} 102}
104void KOEventPopupMenu::fillCatPopup() 103void KOEventPopupMenu::fillCatPopup()
105{ 104{
106 mCatPopup->clear(); 105 mCatPopup->clear();
107 if (!mCurrentIncidence) return; 106 if (!mCurrentIncidence) return;
108 bool readO = mCurrentIncidence->isReadOnly() || isDisabled; 107 bool readO = mCurrentIncidence->isReadOnly() || isDisabled;
109 QStringList checkedCategories = mCurrentIncidence->categories(); 108 QStringList checkedCategories = mCurrentIncidence->categories();
110 int index = 0; 109 int index = 0;
111 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 110 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
112 it != KOPrefs::instance()->mCustomCategories.end (); 111 it != KOPrefs::instance()->mCustomCategories.end ();
113 ++it) { 112 ++it) {
114 mCatPopup->insertItem (*it, index ); 113 mCatPopup->insertItem (*it, index );
115 if (checkedCategories.find (*it) != checkedCategories.end ()) { 114 if (checkedCategories.find (*it) != checkedCategories.end ()) {
116 mCatPopup->setItemChecked (index, true); 115 mCatPopup->setItemChecked (index, true);
117 } 116 }
118 if ( readO ) 117 if ( readO )
119 mCatPopup->setItemEnabled( index, false ); 118 mCatPopup->setItemEnabled( index, false );
120 ++index; 119 ++index;
121 } 120 }
122} 121}
123void KOEventPopupMenu::computeCatPopup( int index ) 122void KOEventPopupMenu::computeCatPopup( int index )
124{ 123{
125 if (!mCurrentIncidence) return; 124 if (!mCurrentIncidence) return;
126 QStringList categories = mCurrentIncidence->categories(); 125 QStringList categories = mCurrentIncidence->categories();
127 QString colcat = categories.first(); 126 QString colcat = categories.first();
128 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 127 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
129 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 128 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
130 else 129 else
131 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 130 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
132 categories.sort (); 131 categories.sort ();
133 if ( !colcat.isEmpty() ) { 132 if ( !colcat.isEmpty() ) {
134 if ( categories.find ( colcat ) != categories.end () ) { 133 if ( categories.find ( colcat ) != categories.end () ) {
135 categories.remove( colcat ); 134 categories.remove( colcat );
136 categories.prepend( colcat ); 135 categories.prepend( colcat );
137 } 136 }
138 } 137 }
139 mCurrentIncidence->setCategories( categories ); 138 mCurrentIncidence->setCategories( categories );
140 emit categoryChanged( mCurrentIncidence ); 139 emit categoryChanged( mCurrentIncidence );
141} 140}
142void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 141void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
143{ 142{
144 if ( !incidence) return; 143 if ( !incidence) return;
145 mCurrentIncidence = incidence; 144 mCurrentIncidence = incidence;
146 145
147 if (mCurrentIncidence) { 146 if (mCurrentIncidence) {
148 // Enable/Disabled menu items only valid for editable events. 147 // Enable/Disabled menu items only valid for editable events.
149 if ( !isDisabled ) { 148 if ( !isDisabled ) {
150 QValueList<int>::Iterator it; 149 QValueList<int>::Iterator it;
151 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 150 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
152 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 151 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
153 } 152 }
154 } 153 }
155 popup(QCursor::pos()); 154 popup(QCursor::pos());
156 } 155 }
157} 156}
158 157
159void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 158void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
160 const QObject *receiver, const char *member, 159 const QObject *receiver, const char *member,
161 bool editOnly) 160 bool editOnly)
162{ 161{
163 if (!mHasAdditionalItems) { 162 if (!mHasAdditionalItems) {
164 mHasAdditionalItems = true; 163 mHasAdditionalItems = true;
165 insertSeparator(); 164 insertSeparator();
166 } 165 }
167 int id = insertItem(icon,text,receiver,member); 166 int id = insertItem(icon,text,receiver,member);
168 if (editOnly) mEditOnlyItems.append(id); 167 if (editOnly) mEditOnlyItems.append(id);
169} 168}
170 169
171void KOEventPopupMenu::popupShow() 170void KOEventPopupMenu::popupShow()
172{ 171{
173 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 172 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
174} 173}
175 174
176void KOEventPopupMenu::popupEdit() 175void KOEventPopupMenu::popupEdit()
177{ 176{
178 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 177 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
179} 178}
180 179
181void KOEventPopupMenu::popupDelete() 180void KOEventPopupMenu::popupDelete()
182{ 181{
183 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 182 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
184} 183}
185void KOEventPopupMenu::popupClone() 184void KOEventPopupMenu::popupClone()
186{ 185{
187 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 186 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
188} 187}
189void KOEventPopupMenu::popupCancel() 188void KOEventPopupMenu::popupCancel()
190{ 189{
191 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 190 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
192} 191}
193void KOEventPopupMenu::popupMove() 192void KOEventPopupMenu::popupMove()
194{ 193{
195 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 194 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
196} 195}
197 196
198void KOEventPopupMenu::popupBeam() 197void KOEventPopupMenu::popupBeam()
199{ 198{
200 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 199 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
201} 200}
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index ca64e66..cce798f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -34,438 +34,440 @@
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::setSyncEventsReadOnly() 81void CalendarLocal::setSyncEventsReadOnly()
82{ 82{
83 Event * ev; 83 Event * ev;
84 ev = mEventList.first(); 84 ev = mEventList.first();
85 while ( ev ) { 85 while ( ev ) {
86 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 86 if ( ev->uid().left(15) == QString("last-syncEvent-") )
87 ev->setReadOnly( true ); 87 ev->setReadOnly( true );
88 ev = mEventList.next(); 88 ev = mEventList.next();
89 } 89 }
90} 90}
91void CalendarLocal::addCalendar( Calendar* cal ) 91void CalendarLocal::addCalendar( Calendar* cal )
92{ 92{
93 cal->setDontDeleteIncidencesOnClose(); 93 cal->setDontDeleteIncidencesOnClose();
94 { 94 {
95 QPtrList<Event> EventList = cal->rawEvents(); 95 QPtrList<Event> EventList = cal->rawEvents();
96 Event * ev = EventList.first(); 96 Event * ev = EventList.first();
97 while ( ev ) { 97 while ( ev ) {
98 ev->unRegisterObserver( cal ); 98 ev->unRegisterObserver( cal );
99 ev->registerObserver( this ); 99 ev->registerObserver( this );
100 mEventList.append( ev ); 100 mEventList.append( ev );
101 ev = EventList.next(); 101 ev = EventList.next();
102 } 102 }
103 } 103 }
104 { 104 {
105 105
106 QPtrList<Todo> TodoList = cal->rawTodos(); 106 QPtrList<Todo> TodoList = cal->rawTodos();
107 Todo * ev = TodoList.first(); 107 Todo * ev = TodoList.first();
108 while ( ev ) { 108 while ( ev ) {
109 QString rel = ev->relatedToUid(); 109 QString rel = ev->relatedToUid();
110 if ( !rel.isEmpty() ){ 110 if ( !rel.isEmpty() ){
111 ev->setRelatedTo ( 0 ); 111 ev->setRelatedTo ( 0 );
112 ev->setRelatedToUid( rel ); 112 ev->setRelatedToUid( rel );
113 } 113 }
114 ev = TodoList.next(); 114 ev = TodoList.next();
115 } 115 }
116 //TodoList = cal->rawTodos(); 116 //TodoList = cal->rawTodos();
117 ev = TodoList.first(); 117 ev = TodoList.first();
118 while ( ev ) { 118 while ( ev ) {
119 ev->unRegisterObserver( cal ); 119 ev->unRegisterObserver( cal );
120 ev->registerObserver( this ); 120 ev->registerObserver( this );
121 mTodoList.append( ev ); 121 mTodoList.append( ev );
122 setupRelations( ev ); 122 setupRelations( ev );
123 ev = TodoList.next(); 123 ev = TodoList.next();
124 } 124 }
125 } 125 }
126 { 126 {
127 QPtrList<Journal> JournalList = cal->journals(); 127 QPtrList<Journal> JournalList = cal->journals();
128 Journal * ev = JournalList.first(); 128 Journal * ev = JournalList.first();
129 while ( ev ) { 129 while ( ev ) {
130 ev->unRegisterObserver( cal ); 130 ev->unRegisterObserver( cal );
131 ev->registerObserver( this ); 131 ev->registerObserver( this );
132 mJournalList.append( ev ); 132 mJournalList.append( ev );
133 ev = JournalList.next(); 133 ev = JournalList.next();
134 } 134 }
135 } 135 }
136 setModified( true ); 136 setModified( true );
137} 137}
138bool CalendarLocal::load( const QString &fileName ) 138bool CalendarLocal::load( const QString &fileName )
139{ 139{
140 FileStorage storage( this, fileName ); 140 FileStorage storage( this, fileName );
141 return storage.load(); 141 return storage.load();
142} 142}
143 143
144bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 144bool CalendarLocal::save( const QString &fileName, CalFormat *format )
145{ 145{
146 FileStorage storage( this, fileName, format ); 146 FileStorage storage( this, fileName, format );
147 return storage.save(); 147 return storage.save();
148} 148}
149 149
150void CalendarLocal::stopAllTodos() 150void CalendarLocal::stopAllTodos()
151{ 151{
152 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 152 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
153 it->setRunning( false ); 153 it->setRunning( false );
154 154
155} 155}
156void CalendarLocal::close() 156void CalendarLocal::close()
157{ 157{
158 158
159 Todo * i; 159 Todo * i;
160 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 160 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
161 161
162 mEventList.setAutoDelete( true ); 162 mEventList.setAutoDelete( true );
163 mTodoList.setAutoDelete( true ); 163 mTodoList.setAutoDelete( true );
164 mJournalList.setAutoDelete( false ); 164 mJournalList.setAutoDelete( false );
165 165
166 mEventList.clear(); 166 mEventList.clear();
167 mTodoList.clear(); 167 mTodoList.clear();
168 mJournalList.clear(); 168 mJournalList.clear();
169 169
170 mEventList.setAutoDelete( false ); 170 mEventList.setAutoDelete( false );
171 mTodoList.setAutoDelete( false ); 171 mTodoList.setAutoDelete( false );
172 mJournalList.setAutoDelete( false ); 172 mJournalList.setAutoDelete( false );
173 173
174 setModified( false ); 174 setModified( false );
175} 175}
176 176
177bool CalendarLocal::addAnniversaryNoDup( Event *event ) 177bool CalendarLocal::addAnniversaryNoDup( Event *event )
178{ 178{
179 QString cat; 179 QString cat;
180 bool isBirthday = true; 180 bool isBirthday = true;
181 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 181 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
182 isBirthday = false; 182 isBirthday = false;
183 cat = i18n( "Anniversary" ); 183 cat = i18n( "Anniversary" );
184 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 184 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
185 isBirthday = true; 185 isBirthday = true;
186 cat = i18n( "Birthday" ); 186 cat = i18n( "Birthday" );
187 } else { 187 } else {
188 qDebug("addAnniversaryNoDup called without fitting category! "); 188 qDebug("addAnniversaryNoDup called without fitting category! ");
189 return false; 189 return false;
190 } 190 }
191 Event * eve; 191 Event * eve;
192 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 192 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
193 if ( !(eve->categories().contains( cat ) )) 193 if ( !(eve->categories().contains( cat ) ))
194 continue; 194 continue;
195 // now we have an event with fitting category 195 // now we have an event with fitting category
196 if ( eve->dtStart().date() != event->dtStart().date() ) 196 if ( eve->dtStart().date() != event->dtStart().date() )
197 continue; 197 continue;
198 // now we have an event with fitting category+date 198 // now we have an event with fitting category+date
199 if ( eve->summary() != event->summary() ) 199 if ( eve->summary() != event->summary() )
200 continue; 200 continue;
201 // now we have an event with fitting category+date+summary 201 // now we have an event with fitting category+date+summary
202 return false; 202 return false;
203 } 203 }
204 return addEvent( event ); 204 return addEvent( event );
205 205
206} 206}
207bool CalendarLocal::addEventNoDup( Event *event ) 207bool CalendarLocal::addEventNoDup( Event *event )
208{ 208{
209 Event * eve; 209 Event * eve;
210 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 210 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
211 if ( *eve == *event ) { 211 if ( *eve == *event ) {
212 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 212 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
213 return false; 213 return false;
214 } 214 }
215 } 215 }
216 return addEvent( event ); 216 return addEvent( event );
217} 217}
218 218
219bool CalendarLocal::addEvent( Event *event ) 219bool CalendarLocal::addEvent( Event *event )
220{ 220{
221 insertEvent( event ); 221 insertEvent( event );
222 222
223 event->registerObserver( this ); 223 event->registerObserver( this );
224 224
225 setModified( true ); 225 setModified( true );
226 event->setCalID( mDefaultCalendar ); 226 if ( event->calID() == 0 )
227 event->setCalID( mDefaultCalendar );
227 event->setCalEnabled( true ); 228 event->setCalEnabled( true );
228 229
229 return true; 230 return true;
230} 231}
231 232
232void CalendarLocal::deleteEvent( Event *event ) 233void CalendarLocal::deleteEvent( Event *event )
233{ 234{
234 if ( mUndoIncidence ) delete mUndoIncidence; 235 if ( mUndoIncidence ) delete mUndoIncidence;
235 mUndoIncidence = event->clone(); 236 mUndoIncidence = event->clone();
236 if ( mEventList.removeRef( event ) ) { 237 if ( mEventList.removeRef( event ) ) {
237 setModified( true ); 238 setModified( true );
238 } 239 }
239} 240}
240 241
241 242
242Event *CalendarLocal::event( const QString &uid ) 243Event *CalendarLocal::event( const QString &uid )
243{ 244{
244 Event *event; 245 Event *event;
245 Event *retVal = 0; 246 Event *retVal = 0;
246 for ( event = mEventList.first(); event; event = mEventList.next() ) { 247 for ( event = mEventList.first(); event; event = mEventList.next() ) {
247 if ( event->calEnabled() && event->uid() == uid ) { 248 if ( event->calEnabled() && event->uid() == uid ) {
248 if ( retVal ) { 249 if ( retVal ) {
249 if ( retVal->calID() > event->calID() ) { 250 if ( retVal->calID() > event->calID() ) {
250 retVal = event; 251 retVal = event;
251 } 252 }
252 } else { 253 } else {
253 retVal = event; 254 retVal = event;
254 } 255 }
255 } 256 }
256 } 257 }
257 return retVal; 258 return retVal;
258} 259}
259bool CalendarLocal::addTodoNoDup( Todo *todo ) 260bool CalendarLocal::addTodoNoDup( Todo *todo )
260{ 261{
261 Todo * eve; 262 Todo * eve;
262 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 263 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
263 if ( *eve == *todo ) { 264 if ( *eve == *todo ) {
264 //qDebug("duplicate todo found! not inserted! "); 265 //qDebug("duplicate todo found! not inserted! ");
265 return false; 266 return false;
266 } 267 }
267 } 268 }
268 return addTodo( todo ); 269 return addTodo( todo );
269} 270}
270bool CalendarLocal::addTodo( Todo *todo ) 271bool CalendarLocal::addTodo( Todo *todo )
271{ 272{
272 mTodoList.append( todo ); 273 mTodoList.append( todo );
273 274
274 todo->registerObserver( this ); 275 todo->registerObserver( this );
275 276
276 // Set up subtask relations 277 // Set up subtask relations
277 setupRelations( todo ); 278 setupRelations( todo );
278 279
279 setModified( true ); 280 setModified( true );
281 if ( todo->calID() == 0 )
280 todo->setCalID( mDefaultCalendar ); 282 todo->setCalID( mDefaultCalendar );
281 todo->setCalEnabled( true ); 283 todo->setCalEnabled( true );
282 return true; 284 return true;
283} 285}
284 286
285void CalendarLocal::deleteTodo( Todo *todo ) 287void CalendarLocal::deleteTodo( Todo *todo )
286{ 288{
287 // Handle orphaned children 289 // Handle orphaned children
288 if ( mUndoIncidence ) delete mUndoIncidence; 290 if ( mUndoIncidence ) delete mUndoIncidence;
289 removeRelations( todo ); 291 removeRelations( todo );
290 mUndoIncidence = todo->clone(); 292 mUndoIncidence = todo->clone();
291 293
292 if ( mTodoList.removeRef( todo ) ) { 294 if ( mTodoList.removeRef( todo ) ) {
293 setModified( true ); 295 setModified( true );
294 } 296 }
295} 297}
296 298
297QPtrList<Todo> CalendarLocal::rawTodos() 299QPtrList<Todo> CalendarLocal::rawTodos()
298{ 300{
299 QPtrList<Todo> el; 301 QPtrList<Todo> el;
300 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 302 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
301 if ( it->calEnabled() ) el.append( it ); 303 if ( it->calEnabled() ) el.append( it );
302 return el; 304 return el;
303} 305}
304Todo *CalendarLocal::todo( QString syncProf, QString id ) 306Todo *CalendarLocal::todo( QString syncProf, QString id )
305{ 307{
306 Todo *todo; 308 Todo *todo;
307 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 309 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
308 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 310 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
309 } 311 }
310 312
311 return 0; 313 return 0;
312} 314}
313void CalendarLocal::removeSyncInfo( QString syncProfile) 315void CalendarLocal::removeSyncInfo( QString syncProfile)
314{ 316{
315 QPtrList<Incidence> all = rawIncidences() ; 317 QPtrList<Incidence> all = rawIncidences() ;
316 Incidence *inc; 318 Incidence *inc;
317 for ( inc = all.first(); inc; inc = all.next() ) { 319 for ( inc = all.first(); inc; inc = all.next() ) {
318 inc->removeID( syncProfile ); 320 inc->removeID( syncProfile );
319 } 321 }
320 if ( syncProfile.isEmpty() ) { 322 if ( syncProfile.isEmpty() ) {
321 QPtrList<Event> el; 323 QPtrList<Event> el;
322 Event *todo; 324 Event *todo;
323 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 325 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
324 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 326 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
325 el.append( todo ); 327 el.append( todo );
326 } 328 }
327 for ( todo = el.first(); todo; todo = el.next() ) { 329 for ( todo = el.first(); todo; todo = el.next() ) {
328 deleteIncidence ( todo ); 330 deleteIncidence ( todo );
329 } 331 }
330 } else { 332 } else {
331 Event *lse = event( "last-syncEvent-"+ syncProfile); 333 Event *lse = event( "last-syncEvent-"+ syncProfile);
332 if ( lse ) 334 if ( lse )
333 deleteIncidence ( lse ); 335 deleteIncidence ( lse );
334 } 336 }
335} 337}
336QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 338QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
337{ 339{
338 QPtrList<Event> el; 340 QPtrList<Event> el;
339 Event *todo; 341 Event *todo;
340 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 342 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
341 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 343 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
342 if ( todo->summary().left(3) == "E: " ) 344 if ( todo->summary().left(3) == "E: " )
343 el.append( todo ); 345 el.append( todo );
344 } 346 }
345 347
346 return el; 348 return el;
347 349
348} 350}
349Event *CalendarLocal::event( QString syncProf, QString id ) 351Event *CalendarLocal::event( QString syncProf, QString id )
350{ 352{
351 Event *todo; 353 Event *todo;
352 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 354 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
353 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 355 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
354 } 356 }
355 357
356 return 0; 358 return 0;
357} 359}
358Todo *CalendarLocal::todo( const QString &uid ) 360Todo *CalendarLocal::todo( const QString &uid )
359{ 361{
360 Todo *todo;; 362 Todo *todo;;
361 Todo *retVal = 0; 363 Todo *retVal = 0;
362 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 364 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
363 if ( todo->calEnabled() && todo->uid() == uid ) { 365 if ( todo->calEnabled() && todo->uid() == uid ) {
364 if ( retVal ) { 366 if ( retVal ) {
365 if ( retVal->calID() > todo->calID() ) { 367 if ( retVal->calID() > todo->calID() ) {
366 retVal = todo; 368 retVal = todo;
367 } 369 }
368 } else { 370 } else {
369 retVal = todo; 371 retVal = todo;
370 } 372 }
371 } 373 }
372 } 374 }
373 return retVal; 375 return retVal;
374} 376}
375QString CalendarLocal::nextSummary() const 377QString CalendarLocal::nextSummary() const
376{ 378{
377 return mNextSummary; 379 return mNextSummary;
378} 380}
379QDateTime CalendarLocal::nextAlarmEventDateTime() const 381QDateTime CalendarLocal::nextAlarmEventDateTime() const
380{ 382{
381 return mNextAlarmEventDateTime; 383 return mNextAlarmEventDateTime;
382} 384}
383void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 385void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
384{ 386{
385 //mNextAlarmIncidence 387 //mNextAlarmIncidence
386 //mNextAlarmDateTime 388 //mNextAlarmDateTime
387 //return mNextSummary; 389 //return mNextSummary;
388 //return mNextAlarmEventDateTime; 390 //return mNextAlarmEventDateTime;
389 bool newNextAlarm = false; 391 bool newNextAlarm = false;
390 bool computeNextAlarm = false; 392 bool computeNextAlarm = false;
391 bool ok; 393 bool ok;
392 int offset; 394 int offset;
393 QDateTime nextA; 395 QDateTime nextA;
394 // QString nextSum; 396 // QString nextSum;
395 //QDateTime nextEvent; 397 //QDateTime nextEvent;
396 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 398 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
397 computeNextAlarm = true; 399 computeNextAlarm = true;
398 } else { 400 } else {
399 if ( ! deleted ) { 401 if ( ! deleted ) {
400 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 402 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
401 if ( ok ) { 403 if ( ok ) {
402 if ( nextA < mNextAlarmDateTime ) { 404 if ( nextA < mNextAlarmDateTime ) {
403 deRegisterAlarm(); 405 deRegisterAlarm();
404 mNextAlarmDateTime = nextA; 406 mNextAlarmDateTime = nextA;
405 mNextSummary = incidence->summary(); 407 mNextSummary = incidence->summary();
406 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 408 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
407 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 409 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
408 newNextAlarm = true; 410 newNextAlarm = true;
409 mNextAlarmIncidence = incidence; 411 mNextAlarmIncidence = incidence;
410 } else { 412 } else {
411 if ( incidence == mNextAlarmIncidence ) { 413 if ( incidence == mNextAlarmIncidence ) {
412 computeNextAlarm = true; 414 computeNextAlarm = true;
413 } 415 }
414 } 416 }
415 } else { 417 } else {
416 if ( mNextAlarmIncidence == incidence ) { 418 if ( mNextAlarmIncidence == incidence ) {
417 computeNextAlarm = true; 419 computeNextAlarm = true;
418 } 420 }
419 } 421 }
420 } else { // deleted 422 } else { // deleted
421 if ( incidence == mNextAlarmIncidence ) { 423 if ( incidence == mNextAlarmIncidence ) {
422 computeNextAlarm = true; 424 computeNextAlarm = true;
423 } 425 }
424 } 426 }
425 } 427 }
426 if ( computeNextAlarm ) { 428 if ( computeNextAlarm ) {
427 deRegisterAlarm(); 429 deRegisterAlarm();
428 nextA = nextAlarm( 1000 ); 430 nextA = nextAlarm( 1000 );
429 if (! mNextAlarmIncidence ) { 431 if (! mNextAlarmIncidence ) {
430 return; 432 return;
431 } 433 }
432 newNextAlarm = true; 434 newNextAlarm = true;
433 } 435 }
434 if ( newNextAlarm ) 436 if ( newNextAlarm )
435 registerAlarm(); 437 registerAlarm();
436} 438}
437QString CalendarLocal:: getAlarmNotification() 439QString CalendarLocal:: getAlarmNotification()
438{ 440{
439 QString ret; 441 QString ret;
440 // this should not happen 442 // this should not happen
441 if (! mNextAlarmIncidence ) 443 if (! mNextAlarmIncidence )
442 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 444 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
443 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 445 Alarm* alarm = mNextAlarmIncidence->alarms().first();
444 if ( alarm->type() == Alarm::Procedure ) { 446 if ( alarm->type() == Alarm::Procedure ) {
445 ret = "proc_alarm" + alarm->programFile()+"+++"; 447 ret = "proc_alarm" + alarm->programFile()+"+++";
446 } else { 448 } else {
447 ret = "audio_alarm" +alarm->audioFile() +"+++"; 449 ret = "audio_alarm" +alarm->audioFile() +"+++";
448 } 450 }
449 ret += "cal_alarm"+ mNextSummary.left( 25 ); 451 ret += "cal_alarm"+ mNextSummary.left( 25 );
450 if ( mNextSummary.length() > 25 ) 452 if ( mNextSummary.length() > 25 )
451 ret += "\n" + mNextSummary.mid(25, 25 ); 453 ret += "\n" + mNextSummary.mid(25, 25 );
452 ret+= "\n"+mNextAlarmEventDateTimeString; 454 ret+= "\n"+mNextAlarmEventDateTimeString;
453 return ret; 455 return ret;
454} 456}
455void CalendarLocal::registerAlarm() 457void CalendarLocal::registerAlarm()
456{ 458{
457 mLastAlarmNotificationString = getAlarmNotification(); 459 mLastAlarmNotificationString = getAlarmNotification();
458 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 460 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
459 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 461 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
460// #ifndef DESKTOP_VERSION 462// #ifndef DESKTOP_VERSION
461// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 463// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
462// #endif 464// #endif
463} 465}
464void CalendarLocal::deRegisterAlarm() 466void CalendarLocal::deRegisterAlarm()
465{ 467{
466 if ( mLastAlarmNotificationString.isNull() ) 468 if ( mLastAlarmNotificationString.isNull() )
467 return; 469 return;
468 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 470 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
469 471
470 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 472 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
471 mNextAlarmEventDateTime = QDateTime(); 473 mNextAlarmEventDateTime = QDateTime();
@@ -592,336 +594,337 @@ void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
592 Incidence *incidence, 594 Incidence *incidence,
593 const QDateTime &from, 595 const QDateTime &from,
594 const QDateTime &to ) 596 const QDateTime &to )
595{ 597{
596 598
597 QPtrList<Alarm> alarmList = incidence->alarms(); 599 QPtrList<Alarm> alarmList = incidence->alarms();
598 Alarm *alarm; 600 Alarm *alarm;
599 QDateTime qdt; 601 QDateTime qdt;
600 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 602 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
601 if (incidence->recursOn(from.date())) { 603 if (incidence->recursOn(from.date())) {
602 qdt.setTime(alarm->time().time()); 604 qdt.setTime(alarm->time().time());
603 qdt.setDate(from.date()); 605 qdt.setDate(from.date());
604 } 606 }
605 else qdt = alarm->time(); 607 else qdt = alarm->time();
606 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 608 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
607 if ( alarm->enabled() ) { 609 if ( alarm->enabled() ) {
608 if ( qdt >= from && qdt <= to ) { 610 if ( qdt >= from && qdt <= to ) {
609 alarms.append( alarm ); 611 alarms.append( alarm );
610 } 612 }
611 } 613 }
612 } 614 }
613} 615}
614 616
615 617
616/****************************** PROTECTED METHODS ****************************/ 618/****************************** PROTECTED METHODS ****************************/
617 619
618// after changes are made to an event, this should be called. 620// after changes are made to an event, this should be called.
619void CalendarLocal::update( IncidenceBase *incidence ) 621void CalendarLocal::update( IncidenceBase *incidence )
620{ 622{
621 incidence->setSyncStatus( Event::SYNCMOD ); 623 incidence->setSyncStatus( Event::SYNCMOD );
622 incidence->setLastModified( QDateTime::currentDateTime() ); 624 incidence->setLastModified( QDateTime::currentDateTime() );
623 // we should probably update the revision number here, 625 // we should probably update the revision number here,
624 // or internally in the Event itself when certain things change. 626 // or internally in the Event itself when certain things change.
625 // need to verify with ical documentation. 627 // need to verify with ical documentation.
626 628
627 setModified( true ); 629 setModified( true );
628} 630}
629 631
630void CalendarLocal::insertEvent( Event *event ) 632void CalendarLocal::insertEvent( Event *event )
631{ 633{
632 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 634 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
633} 635}
634 636
635 637
636QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 638QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
637{ 639{
638 QPtrList<Event> eventList; 640 QPtrList<Event> eventList;
639 641
640 Event *event; 642 Event *event;
641 for( event = mEventList.first(); event; event = mEventList.next() ) { 643 for( event = mEventList.first(); event; event = mEventList.next() ) {
642 if ( !event->calEnabled() ) continue; 644 if ( !event->calEnabled() ) continue;
643 if ( event->doesRecur() ) { 645 if ( event->doesRecur() ) {
644 if ( event->isMultiDay() ) { 646 if ( event->isMultiDay() ) {
645 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 647 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
646 int i; 648 int i;
647 for ( i = 0; i <= extraDays; i++ ) { 649 for ( i = 0; i <= extraDays; i++ ) {
648 if ( event->recursOn( qd.addDays( -i ) ) ) { 650 if ( event->recursOn( qd.addDays( -i ) ) ) {
649 eventList.append( event ); 651 eventList.append( event );
650 break; 652 break;
651 } 653 }
652 } 654 }
653 } else { 655 } else {
654 if ( event->recursOn( qd ) ) 656 if ( event->recursOn( qd ) )
655 eventList.append( event ); 657 eventList.append( event );
656 } 658 }
657 } else { 659 } else {
658 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 660 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
659 eventList.append( event ); 661 eventList.append( event );
660 } 662 }
661 } 663 }
662 } 664 }
663 665
664 if ( !sorted ) { 666 if ( !sorted ) {
665 return eventList; 667 return eventList;
666 } 668 }
667 669
668 // kdDebug(5800) << "Sorting events for date\n" << endl; 670 // kdDebug(5800) << "Sorting events for date\n" << endl;
669 // now, we have to sort it based on dtStart.time() 671 // now, we have to sort it based on dtStart.time()
670 QPtrList<Event> eventListSorted; 672 QPtrList<Event> eventListSorted;
671 Event *sortEvent; 673 Event *sortEvent;
672 for ( event = eventList.first(); event; event = eventList.next() ) { 674 for ( event = eventList.first(); event; event = eventList.next() ) {
673 sortEvent = eventListSorted.first(); 675 sortEvent = eventListSorted.first();
674 int i = 0; 676 int i = 0;
675 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 677 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
676 { 678 {
677 i++; 679 i++;
678 sortEvent = eventListSorted.next(); 680 sortEvent = eventListSorted.next();
679 } 681 }
680 eventListSorted.insert( i, event ); 682 eventListSorted.insert( i, event );
681 } 683 }
682 return eventListSorted; 684 return eventListSorted;
683} 685}
684 686
685 687
686QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 688QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
687 bool inclusive ) 689 bool inclusive )
688{ 690{
689 Event *event = 0; 691 Event *event = 0;
690 692
691 QPtrList<Event> eventList; 693 QPtrList<Event> eventList;
692 694
693 // Get non-recurring events 695 // Get non-recurring events
694 for( event = mEventList.first(); event; event = mEventList.next() ) { 696 for( event = mEventList.first(); event; event = mEventList.next() ) {
695 if ( !event->calEnabled() ) continue; 697 if ( !event->calEnabled() ) continue;
696 if ( event->doesRecur() ) { 698 if ( event->doesRecur() ) {
697 QDate rStart = event->dtStart().date(); 699 QDate rStart = event->dtStart().date();
698 bool found = false; 700 bool found = false;
699 if ( inclusive ) { 701 if ( inclusive ) {
700 if ( rStart >= start && rStart <= end ) { 702 if ( rStart >= start && rStart <= end ) {
701 // Start date of event is in range. Now check for end date. 703 // Start date of event is in range. Now check for end date.
702 // if duration is negative, event recurs forever, so do not include it. 704 // if duration is negative, event recurs forever, so do not include it.
703 if ( event->recurrence()->duration() == 0 ) { // End date set 705 if ( event->recurrence()->duration() == 0 ) { // End date set
704 QDate rEnd = event->recurrence()->endDate(); 706 QDate rEnd = event->recurrence()->endDate();
705 if ( rEnd >= start && rEnd <= end ) { // End date within range 707 if ( rEnd >= start && rEnd <= end ) { // End date within range
706 found = true; 708 found = true;
707 } 709 }
708 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 710 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
709 // TODO: Calculate end date from duration. Should be done in Event 711 // TODO: Calculate end date from duration. Should be done in Event
710 // For now exclude all events with a duration. 712 // For now exclude all events with a duration.
711 } 713 }
712 } 714 }
713 } else { 715 } else {
714 bool founOne; 716 bool founOne;
715 QDate next = event->getNextOccurence( start, &founOne ).date(); 717 QDate next = event->getNextOccurence( start, &founOne ).date();
716 if ( founOne ) { 718 if ( founOne ) {
717 if ( next <= end ) { 719 if ( next <= end ) {
718 found = true; 720 found = true;
719 } 721 }
720 } 722 }
721 723
722 /* 724 /*
723 // crap !!! 725 // crap !!!
724 if ( rStart <= end ) { // Start date not after range 726 if ( rStart <= end ) { // Start date not after range
725 if ( rStart >= start ) { // Start date within range 727 if ( rStart >= start ) { // Start date within range
726 found = true; 728 found = true;
727 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 729 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
728 found = true; 730 found = true;
729 } else if ( event->recurrence()->duration() == 0 ) { // End date set 731 } else if ( event->recurrence()->duration() == 0 ) { // End date set
730 QDate rEnd = event->recurrence()->endDate(); 732 QDate rEnd = event->recurrence()->endDate();
731 if ( rEnd >= start && rEnd <= end ) { // End date within range 733 if ( rEnd >= start && rEnd <= end ) { // End date within range
732 found = true; 734 found = true;
733 } 735 }
734 } else { // Duration set 736 } else { // Duration set
735 // TODO: Calculate end date from duration. Should be done in Event 737 // TODO: Calculate end date from duration. Should be done in Event
736 // For now include all events with a duration. 738 // For now include all events with a duration.
737 found = true; 739 found = true;
738 } 740 }
739 } 741 }
740 */ 742 */
741 743
742 } 744 }
743 745
744 if ( found ) eventList.append( event ); 746 if ( found ) eventList.append( event );
745 } else { 747 } else {
746 QDate s = event->dtStart().date(); 748 QDate s = event->dtStart().date();
747 QDate e = event->dtEnd().date(); 749 QDate e = event->dtEnd().date();
748 750
749 if ( inclusive ) { 751 if ( inclusive ) {
750 if ( s >= start && e <= end ) { 752 if ( s >= start && e <= end ) {
751 eventList.append( event ); 753 eventList.append( event );
752 } 754 }
753 } else { 755 } else {
754 if ( ( e >= start && s <= end ) ) { 756 if ( ( e >= start && s <= end ) ) {
755 eventList.append( event ); 757 eventList.append( event );
756 } 758 }
757 } 759 }
758 } 760 }
759 } 761 }
760 762
761 return eventList; 763 return eventList;
762} 764}
763 765
764QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 766QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
765{ 767{
766 return rawEventsForDate( qdt.date() ); 768 return rawEventsForDate( qdt.date() );
767} 769}
768 770
769QPtrList<Event> CalendarLocal::rawEvents() 771QPtrList<Event> CalendarLocal::rawEvents()
770{ 772{
771 QPtrList<Event> el; 773 QPtrList<Event> el;
772 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 774 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
773 if ( it->calEnabled() ) el.append( it ); 775 if ( it->calEnabled() ) el.append( it );
774 return el; 776 return el;
775} 777}
776 778
777bool CalendarLocal::addJournal(Journal *journal) 779bool CalendarLocal::addJournal(Journal *journal)
778{ 780{
779 mJournalList.append(journal); 781 mJournalList.append(journal);
780 782
781 journal->registerObserver( this ); 783 journal->registerObserver( this );
782 784
783 setModified( true ); 785 setModified( true );
784 journal->setCalID( mDefaultCalendar ); 786 if ( journal->calID() == 0 )
787 journal->setCalID( mDefaultCalendar );
785 journal->setCalEnabled( true ); 788 journal->setCalEnabled( true );
786 return true; 789 return true;
787} 790}
788 791
789void CalendarLocal::deleteJournal( Journal *journal ) 792void CalendarLocal::deleteJournal( Journal *journal )
790{ 793{
791 if ( mUndoIncidence ) delete mUndoIncidence; 794 if ( mUndoIncidence ) delete mUndoIncidence;
792 mUndoIncidence = journal->clone(); 795 mUndoIncidence = journal->clone();
793 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 796 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
794 if ( mJournalList.removeRef(journal) ) { 797 if ( mJournalList.removeRef(journal) ) {
795 setModified( true ); 798 setModified( true );
796 } 799 }
797} 800}
798 801
799QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) 802QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
800{ 803{
801 QPtrList<Journal> el; 804 QPtrList<Journal> el;
802 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 805 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
803 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); 806 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
804 return el; 807 return el;
805} 808}
806Journal *CalendarLocal::journal( const QDate &date ) 809Journal *CalendarLocal::journal( const QDate &date )
807{ 810{
808// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 811// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
809 812
810 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
811 if ( it->calEnabled() && it->dtStart().date() == date ) 814 if ( it->calEnabled() && it->dtStart().date() == date )
812 return it; 815 return it;
813 816
814 return 0; 817 return 0;
815} 818}
816 819
817Journal *CalendarLocal::journal( const QString &uid ) 820Journal *CalendarLocal::journal( const QString &uid )
818{ 821{
819 Journal * retVal = 0; 822 Journal * retVal = 0;
820 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 823 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
821 if ( it->calEnabled() && it->uid() == uid ) { 824 if ( it->calEnabled() && it->uid() == uid ) {
822 if ( retVal ) { 825 if ( retVal ) {
823 if ( retVal->calID() > it->calID() ) { 826 if ( retVal->calID() > it->calID() ) {
824 retVal = it; 827 retVal = it;
825 } 828 }
826 } else { 829 } else {
827 retVal = it; 830 retVal = it;
828 } 831 }
829 } 832 }
830 return retVal; 833 return retVal;
831} 834}
832 835
833QPtrList<Journal> CalendarLocal::journals() 836QPtrList<Journal> CalendarLocal::journals()
834{ 837{
835 QPtrList<Journal> el; 838 QPtrList<Journal> el;
836 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 839 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
837 if ( it->calEnabled() ) el.append( it ); 840 if ( it->calEnabled() ) el.append( it );
838 return el; 841 return el;
839} 842}
840void CalendarLocal::setCalendarRemove( int id ) 843void CalendarLocal::setCalendarRemove( int id )
841{ 844{
842 845
843 { 846 {
844 QPtrList<Event> EventList = mEventList; 847 QPtrList<Event> EventList = mEventList;
845 Event * ev = EventList.first(); 848 Event * ev = EventList.first();
846 while ( ev ) { 849 while ( ev ) {
847 if ( ev->calID() == id ) 850 if ( ev->calID() == id )
848 deleteEvent( ev ); 851 deleteEvent( ev );
849 ev = EventList.next(); 852 ev = EventList.next();
850 } 853 }
851 } 854 }
852 { 855 {
853 856
854 QPtrList<Todo> TodoList = mTodoList; 857 QPtrList<Todo> TodoList = mTodoList;
855 Todo * ev = TodoList.first(); 858 Todo * ev = TodoList.first();
856 while ( ev ) { 859 while ( ev ) {
857 if ( ev->calID() == id ) 860 if ( ev->calID() == id )
858 deleteTodo( ev ); 861 deleteTodo( ev );
859 ev = TodoList.next(); 862 ev = TodoList.next();
860 } 863 }
861 } 864 }
862 { 865 {
863 QPtrList<Journal> JournalList = mJournalList; 866 QPtrList<Journal> JournalList = mJournalList;
864 Journal * ev = JournalList.first(); 867 Journal * ev = JournalList.first();
865 while ( ev ) { 868 while ( ev ) {
866 if ( ev->calID() == id ) 869 if ( ev->calID() == id )
867 deleteJournal( ev ); 870 deleteJournal( ev );
868 ev = JournalList.next(); 871 ev = JournalList.next();
869 } 872 }
870 } 873 }
871 874
872 if ( mUndoIncidence ) delete mUndoIncidence; 875 if ( mUndoIncidence ) delete mUndoIncidence;
873 mUndoIncidence = 0; 876 mUndoIncidence = 0;
874 877
875} 878}
876 879
877void CalendarLocal::setCalendarEnabled( int id, bool enable ) 880void CalendarLocal::setCalendarEnabled( int id, bool enable )
878{ 881{
879 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 882 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
880 if ( it->calID() == id ) it->setCalEnabled( enable ); 883 if ( it->calID() == id ) it->setCalEnabled( enable );
881 884
882 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 885 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
883 if ( it->calID() == id ) it->setCalEnabled( enable ); 886 if ( it->calID() == id ) it->setCalEnabled( enable );
884 887
885 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 888 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
886 if ( it->calID() == id ) it->setCalEnabled( enable ); 889 if ( it->calID() == id ) it->setCalEnabled( enable );
887 890
888} 891}
889 892
890void CalendarLocal::setReadOnly( int id, bool enable ) 893void CalendarLocal::setReadOnly( int id, bool enable )
891{ 894{
892 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 895 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
893 if ( it->calID() == id ) it->setReadOnly( enable ); 896 if ( it->calID() == id ) it->setReadOnly( enable );
894 897
895 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 898 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
896 if ( it->calID() == id ) it->setReadOnly( enable ); 899 if ( it->calID() == id ) it->setReadOnly( enable );
897 900
898 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 901 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
899 if ( it->calID() == id ) it->setReadOnly( enable ); 902 if ( it->calID() == id ) it->setReadOnly( enable );
900 903
901} 904}
902 905
903void CalendarLocal::setAlarmEnabled( int id, bool enable ) 906void CalendarLocal::setAlarmEnabled( int id, bool enable )
904{ 907{
905 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 908 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
906 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 909 if ( it->calID() == id ) it->setAlarmEnabled( enable );
907 910
908 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 911 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
909 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 912 if ( it->calID() == id ) it->setAlarmEnabled( enable );
910 913
911 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 914 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
912 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 915 if ( it->calID() == id ) it->setAlarmEnabled( enable );
913 reInitAlarmSettings(); 916 reInitAlarmSettings();
914 917
915} 918}
916void CalendarLocal::setDefaultCalendarEnabledOnly() 919void CalendarLocal::setDefaultCalendarEnabledOnly()
917{ 920{
918 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 921 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
919 it->setCalEnabled( it->calID() == mDefaultCalendar ); 922 it->setCalEnabled( it->calID() == mDefaultCalendar );
920 923
921 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 924 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
922 it->setCalEnabled( it->calID() == mDefaultCalendar); 925 it->setCalEnabled( it->calID() == mDefaultCalendar);
923 926
924 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 927 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
925 it->setCalEnabled( it->calID() == mDefaultCalendar); 928 it->setCalEnabled( it->calID() == mDefaultCalendar);
926 929
927} 930}