author | zautrix <zautrix> | 2005-06-11 15:15:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-11 15:15:54 (UTC) |
commit | 0cfaf22fc5d8f511320813171be84ce3436990c6 (patch) (unidiff) | |
tree | 00f858c12e9c810c53acdd816a9fcfe7e880996a | |
parent | d4501288ba7414ba89a791dd2c306e9f74eeb3fa (diff) | |
download | kdepimpi-0cfaf22fc5d8f511320813171be84ce3436990c6.zip kdepimpi-0cfaf22fc5d8f511320813171be84ce3436990c6.tar.gz kdepimpi-0cfaf22fc5d8f511320813171be84ce3436990c6.tar.bz2 |
fixx
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index ec6a4ec..a11fab3 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,100 +1,102 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.6 ************ | 3 | ********** VERSION 2.1.6 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 6 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
7 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 7 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
8 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 8 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
9 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 9 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
10 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | ||
11 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | ||
10 | 12 | ||
11 | ********** VERSION 2.1.5 ************ | 13 | ********** VERSION 2.1.5 ************ |
12 | 14 | ||
13 | This is the new stable version. | 15 | This is the new stable version. |
14 | Bugfix: | 16 | Bugfix: |
15 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 17 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
16 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 18 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
17 | Added config option to not display completed todos in agenda view. | 19 | Added config option to not display completed todos in agenda view. |
18 | Addressee view is now using the formatted name, if defined. | 20 | Addressee view is now using the formatted name, if defined. |
19 | That makes it possible to display "lastname, firstname" in that view now. | 21 | That makes it possible to display "lastname, firstname" in that view now. |
20 | To set the formatted name for all contacts, please use menu: | 22 | To set the formatted name for all contacts, please use menu: |
21 | Edit->Change->Set formatted name. | 23 | Edit->Change->Set formatted name. |
22 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 24 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
23 | 25 | ||
24 | ********** VERSION 2.1.4 ************ | 26 | ********** VERSION 2.1.4 ************ |
25 | 27 | ||
26 | Fixed two more bugs in the KA/Pi CSV import dialog: | 28 | Fixed two more bugs in the KA/Pi CSV import dialog: |
27 | Made it possible to read multi-line fields and import it to the "Note" field. | 29 | Made it possible to read multi-line fields and import it to the "Note" field. |
28 | Fixed a problem in mapping custom fields, whatever a custem field is... | 30 | Fixed a problem in mapping custom fields, whatever a custem field is... |
29 | 31 | ||
30 | ********** VERSION 2.1.3 ************ | 32 | ********** VERSION 2.1.3 ************ |
31 | 33 | ||
32 | Changed the menu structure of the alarm applet: | 34 | Changed the menu structure of the alarm applet: |
33 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 35 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
34 | 36 | ||
35 | Fixed several problems in the KA/Pi CSV import dialog: | 37 | Fixed several problems in the KA/Pi CSV import dialog: |
36 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 38 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
37 | 39 | ||
38 | 40 | ||
39 | ********** VERSION 2.1.2 ************ | 41 | ********** VERSION 2.1.2 ************ |
40 | 42 | ||
41 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 43 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
42 | 44 | ||
43 | Fixed a problem when importing data from Outlook with mutiple categories set. | 45 | Fixed a problem when importing data from Outlook with mutiple categories set. |
44 | 46 | ||
45 | Changed display of days in datenavigator: | 47 | Changed display of days in datenavigator: |
46 | Birthdays are now blue, not dark green. | 48 | Birthdays are now blue, not dark green. |
47 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 49 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
48 | When journal view is shown, only holidays are shown and days with journals are blue. | 50 | When journal view is shown, only holidays are shown and days with journals are blue. |
49 | 51 | ||
50 | Added Backup options to global config: | 52 | Added Backup options to global config: |
51 | You 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 ). | 53 | You 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 ). |
52 | It 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. | 54 | It 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. |
53 | The 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. | 55 | The 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. |
54 | 56 | ||
55 | ********** VERSION 2.1.1 ************ | 57 | ********** VERSION 2.1.1 ************ |
56 | 58 | ||
57 | Stable release 2.1.1! | 59 | Stable release 2.1.1! |
58 | 60 | ||
59 | KO/Pi: | 61 | KO/Pi: |
60 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 62 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
61 | 63 | ||
62 | ********** VERSION 2.1.0 ************ | 64 | ********** VERSION 2.1.0 ************ |
63 | 65 | ||
64 | Stable release 2.1.0! | 66 | Stable release 2.1.0! |
65 | 67 | ||
66 | Summary of changes/fixes compared to version 2.0.6: | 68 | Summary of changes/fixes compared to version 2.0.6: |
67 | 69 | ||
68 | Many bugs of version 2.0.6 fixed. | 70 | Many bugs of version 2.0.6 fixed. |
69 | Most of them were small bugs, but some of them were important. | 71 | Most of them were small bugs, but some of them were important. |
70 | It is recommended to use version 2.1.0 and not version 2.0.6. | 72 | It is recommended to use version 2.1.0 and not version 2.0.6. |
71 | 73 | ||
72 | Important changes: | 74 | Important changes: |
73 | 75 | ||
74 | Added recurring todos to KO/Pi. | 76 | Added recurring todos to KO/Pi. |
75 | 77 | ||
76 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 78 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
77 | 79 | ||
78 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 80 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
79 | 81 | ||
80 | Datenavigator can now display many months. Very useful on the desktop. | 82 | Datenavigator can now display many months. Very useful on the desktop. |
81 | 83 | ||
82 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 84 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
83 | 85 | ||
84 | Made alarm sound working on Linux desktop. | 86 | Made alarm sound working on Linux desktop. |
85 | 87 | ||
86 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 88 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
87 | 89 | ||
88 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 90 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
89 | 91 | ||
90 | Many other usebility enhancements. | 92 | Many other usebility enhancements. |
91 | Special thanks to Ben for his suggestions! | 93 | Special thanks to Ben for his suggestions! |
92 | 94 | ||
93 | You can find the complete changelog | 95 | You can find the complete changelog |
94 | from version 1.7.7 to 2.1.0 | 96 | from version 1.7.7 to 2.1.0 |
95 | in the source package or on | 97 | in the source package or on |
96 | 98 | ||
97 | http://www.pi-sync.net/html/changelog.html | 99 | http://www.pi-sync.net/html/changelog.html |
98 | 100 | ||
99 | 101 | ||
100 | 102 | ||
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index 37e7d0d..d6e06c8 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -1,696 +1,696 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KOrganizer alarm daemon. | 2 | This file is part of the KOrganizer alarm daemon. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 "simplealarmdaemonimpl.h" | 24 | #include "simplealarmdaemonimpl.h" |
25 | 25 | ||
26 | #include "alarmdialog.h" | 26 | #include "alarmdialog.h" |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qhbox.h> | 31 | #include <qhbox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #define protected public | 39 | #define protected public |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #undef protected | 41 | #undef protected |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qtopia/qcopenvelope_qws.h> | 43 | #include <qtopia/qcopenvelope_qws.h> |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) |
52 | : QLabel( parent ) | 52 | : QLabel( parent ) |
53 | { | 53 | { |
54 | mAlarmDialog = new AlarmDialog( 0 ); | 54 | mAlarmDialog = new AlarmDialog( 0 ); |
55 | mPopUp = new QPopupMenu( this ); | 55 | mPopUp = new QPopupMenu( this ); |
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | 56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); |
57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | 57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); |
58 | mPopUp->insertSeparator(); | 58 | mPopUp->insertSeparator(); |
59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); | 59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); |
60 | mPopUp->insertSeparator(); | 60 | mPopUp->insertSeparator(); |
61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | 61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); |
62 | mPopUp->insertSeparator(); | 62 | mPopUp->insertSeparator(); |
63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | 63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); |
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | 64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); |
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | 65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); |
66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); | 66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); |
67 | mPopUp->insertSeparator(); | 67 | mPopUp->insertSeparator(); |
68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | 68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); |
69 | mTimerPopUp = new QPopupMenu( this ); | 69 | mTimerPopUp = new QPopupMenu( this ); |
70 | QFont fon = mTimerPopUp->font(); | 70 | QFont fon = mTimerPopUp->font(); |
71 | fon.setPointSize( fon.pointSize() *3/2 ); | 71 | fon.setPointSize( fon.pointSize() *3/2 ); |
72 | mTimerPopUp->setFont( fon ); | 72 | mTimerPopUp->setFont( fon ); |
73 | mPopUp->setFont( fon ); | 73 | mPopUp->setFont( fon ); |
74 | mBeepPopUp = new QPopupMenu( this ); | 74 | mBeepPopUp = new QPopupMenu( this ); |
75 | mSoundPopUp = new QPopupMenu( this ); | 75 | mSoundPopUp = new QPopupMenu( this ); |
76 | mPausePopUp = new QPopupMenu( this ); | 76 | mPausePopUp = new QPopupMenu( this ); |
77 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 77 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
78 | savePopUp->insertItem( "Save", 0 ); | 78 | savePopUp->insertItem( "Save", 0 ); |
79 | savePopUp->insertItem( "Load", 1 ); | 79 | savePopUp->insertItem( "Load", 1 ); |
80 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 80 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
81 | mSoundPopUp->insertItem( "Wav file", 1 ); | 81 | mSoundPopUp->insertItem( "Wav file", 1 ); |
82 | mPausePopUp->insertItem( " 1 sec", 1 ); | 82 | mPausePopUp->insertItem( " 1 sec", 1 ); |
83 | mPausePopUp->insertItem( " 2 sec", 2 ); | 83 | mPausePopUp->insertItem( " 2 sec", 2 ); |
84 | mPausePopUp->insertItem( " 3 sec", 3 ); | 84 | mPausePopUp->insertItem( " 3 sec", 3 ); |
85 | mPausePopUp->insertItem( " 5 sec", 5 ); | 85 | mPausePopUp->insertItem( " 5 sec", 5 ); |
86 | mPausePopUp->insertItem( "10 sec", 10 ); | 86 | mPausePopUp->insertItem( "10 sec", 10 ); |
87 | mPausePopUp->insertItem( "30 sec", 30 ); | 87 | mPausePopUp->insertItem( "30 sec", 30 ); |
88 | mPausePopUp->insertItem( " 1 min", 60 ); | 88 | mPausePopUp->insertItem( " 1 min", 60 ); |
89 | mPausePopUp->insertItem( " 5 min", 300 ); | 89 | mPausePopUp->insertItem( " 5 min", 300 ); |
90 | mPausePopUp->insertItem( "10 min", 600 ); | 90 | mPausePopUp->insertItem( "10 min", 600 ); |
91 | mSuspendPopUp = new QPopupMenu( this ); | 91 | mSuspendPopUp = new QPopupMenu( this ); |
92 | mSuspendPopUp->insertItem( "Off", 0 ); | 92 | mSuspendPopUp->insertItem( "Off", 0 ); |
93 | mSuspendPopUp->insertItem( " 1x", 1 ); | 93 | mSuspendPopUp->insertItem( " 1x", 1 ); |
94 | mSuspendPopUp->insertItem( " 2x", 2 ); | 94 | mSuspendPopUp->insertItem( " 2x", 2 ); |
95 | mSuspendPopUp->insertItem( " 3x", 3 ); | 95 | mSuspendPopUp->insertItem( " 3x", 3 ); |
96 | mSuspendPopUp->insertItem( " 5x", 5 ); | 96 | mSuspendPopUp->insertItem( " 5x", 5 ); |
97 | mSuspendPopUp->insertItem( "10x", 10 ); | 97 | mSuspendPopUp->insertItem( "10x", 10 ); |
98 | mSuspendPopUp->insertItem( "20x", 20 ); | 98 | mSuspendPopUp->insertItem( "20x", 20 ); |
99 | mSuspendPopUp->insertItem( "30x", 30 ); | 99 | mSuspendPopUp->insertItem( "30x", 30 ); |
100 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 100 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
101 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 101 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
102 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 102 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
103 | mBeepPopUp->insertItem( "Config",savePopUp ); | 103 | mBeepPopUp->insertItem( "Config",savePopUp ); |
104 | mBeepPopUp->insertItem( "300", 300 ); | 104 | mBeepPopUp->insertItem( "300", 300 ); |
105 | mBeepPopUp->insertItem( "180", 180 ); | 105 | mBeepPopUp->insertItem( "180", 180 ); |
106 | mBeepPopUp->insertItem( "60", 60 ); | 106 | mBeepPopUp->insertItem( "60", 60 ); |
107 | mBeepPopUp->insertItem( "30", 30 ); | 107 | mBeepPopUp->insertItem( "30", 30 ); |
108 | mBeepPopUp->insertItem( "10", 10 ); | 108 | mBeepPopUp->insertItem( "10", 10 ); |
109 | mBeepPopUp->insertItem( "3", 3 ); | 109 | mBeepPopUp->insertItem( "3", 3 ); |
110 | mBeepPopUp->insertItem( "1", 1 ); | 110 | mBeepPopUp->insertItem( "1", 1 ); |
111 | mBeepPopUp->insertItem( "Off", 0 ); | 111 | mBeepPopUp->insertItem( "Off", 0 ); |
112 | mBeepPopUp->insertSeparator(); | 112 | mBeepPopUp->insertSeparator(); |
113 | mBeepPopUp->insertItem( "Simulate", 1000 ); | 113 | mBeepPopUp->insertItem( "Simulate", 1000 ); |
114 | mBeepPopUp->setCheckable( true ); | 114 | mBeepPopUp->setCheckable( true ); |
115 | mPopUp->insertSeparator(); | 115 | mPopUp->insertSeparator(); |
116 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | 116 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); |
117 | mPopUp->insertSeparator(); | 117 | mPopUp->insertSeparator(); |
118 | mPopUp->insertItem( "Timer", mTimerPopUp ); | 118 | mPopUp->insertItem( "Timer", mTimerPopUp ); |
119 | //mPopUp->insertSeparator(); | 119 | //mPopUp->insertSeparator(); |
120 | //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 120 | //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
121 | 121 | ||
122 | mPopUp->resize( mPopUp->sizeHint() ); | 122 | mPopUp->resize( mPopUp->sizeHint() ); |
123 | mPlayBeeps = 60; | 123 | mPlayBeeps = 60; |
124 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 124 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
125 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 125 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
126 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 126 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
127 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 127 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
128 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 128 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
129 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 129 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
130 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 130 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
131 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 131 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
132 | mTimerTime = 0; | 132 | mTimerTime = 0; |
133 | mCustomText = "Custom Text"; | 133 | mCustomText = "Custom Text"; |
134 | mCustomMinutes = 7; | 134 | mCustomMinutes = 7; |
135 | mTimerPopupConf = 1; | 135 | mTimerPopupConf = 1; |
136 | fillTimerPopUp(); | 136 | fillTimerPopUp(); |
137 | mPausePlay = 0; | 137 | mPausePlay = 0; |
138 | confPause( 1 ); | 138 | confPause( 1 ); |
139 | mSuspend = 0; | 139 | mSuspend = 0; |
140 | confSuspend( 0 ); | 140 | confSuspend( 0 ); |
141 | if ( QApplication::desktop()->width() < 480 ) { | 141 | if ( QApplication::desktop()->width() < 480 ) { |
142 | wavAlarm = false; | 142 | wavAlarm = false; |
143 | mSoundPopUp->setItemChecked ( 0, true ); | 143 | mSoundPopUp->setItemChecked ( 0, true ); |
144 | } | 144 | } |
145 | else { | 145 | else { |
146 | wavAlarm = true; | 146 | wavAlarm = true; |
147 | mSoundPopUp->setItemChecked ( 1, true ); | 147 | mSoundPopUp->setItemChecked ( 1, true ); |
148 | } | 148 | } |
149 | saveSlot( 1 ); | 149 | saveSlot( 1 ); |
150 | } | 150 | } |
151 | 151 | ||
152 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 152 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
153 | { | 153 | { |
154 | //delete mPopUp; | 154 | //delete mPopUp; |
155 | delete mAlarmDialog; | 155 | delete mAlarmDialog; |
156 | } | 156 | } |
157 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 157 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
158 | { | 158 | { |
159 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 159 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
160 | //qDebug("save %d ", load ); | 160 | //qDebug("save %d ", load ); |
161 | QFile file( fileName ); | 161 | QFile file( fileName ); |
162 | if ( load ) { | 162 | if ( load ) { |
163 | if( !QFile::exists( fileName) ) | 163 | if( !QFile::exists( fileName) ) |
164 | return; | 164 | return; |
165 | if (!file.open( IO_ReadOnly ) ) { | 165 | if (!file.open( IO_ReadOnly ) ) { |
166 | return ; | 166 | return ; |
167 | } | 167 | } |
168 | QString line; | 168 | QString line; |
169 | bool ok; | 169 | bool ok; |
170 | int val; | 170 | int val; |
171 | int len; | 171 | int len; |
172 | while ( file.readLine( line, 1024 ) > 0 ) { | 172 | while ( file.readLine( line, 1024 ) > 0 ) { |
173 | //qDebug("read %s ", line.latin1()); | 173 | //qDebug("read %s ", line.latin1()); |
174 | len = line.length(); | 174 | len = line.length(); |
175 | if ( line.left(4 ) == "PPAU" ) { | 175 | if ( line.left(4 ) == "PPAU" ) { |
176 | val = line.mid( 4,len-5).toInt( &ok ); | 176 | val = line.mid( 4,len-5).toInt( &ok ); |
177 | if ( ok ) { | 177 | if ( ok ) { |
178 | confPause( val ); | 178 | confPause( val ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( line.left(4 ) == "SUCO" ) { | 181 | if ( line.left(4 ) == "SUCO" ) { |
182 | val = line.mid( 4,len-5).toInt( &ok ); | 182 | val = line.mid( 4,len-5).toInt( &ok ); |
183 | if ( ok ) | 183 | if ( ok ) |
184 | confSuspend ( val ); | 184 | confSuspend ( val ); |
185 | } | 185 | } |
186 | if ( line.left(4 ) == "WAAL" ) { | 186 | if ( line.left(4 ) == "WAAL" ) { |
187 | val = line.mid( 4,len-5).toInt( &ok ); | 187 | val = line.mid( 4,len-5).toInt( &ok ); |
188 | if ( ok ) | 188 | if ( ok ) |
189 | confSound( val ); | 189 | confSound( val ); |
190 | 190 | ||
191 | } | 191 | } |
192 | if ( line.left(4 ) == "PLBE" ) { | 192 | if ( line.left(4 ) == "PLBE" ) { |
193 | val = line.mid( 4,len-5).toInt( &ok ); | 193 | val = line.mid( 4,len-5).toInt( &ok ); |
194 | if ( ok ) | 194 | if ( ok ) |
195 | slotPlayBeep( val ); | 195 | slotPlayBeep( val ); |
196 | 196 | ||
197 | } | 197 | } |
198 | if ( line.left(4 ) == "CUTE" ) { | 198 | if ( line.left(4 ) == "CUTE" ) { |
199 | mCustomText = line.mid( 5,len-6); | 199 | mCustomText = line.mid( 5,len-6); |
200 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 200 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( line.left(4 ) == "CUMI" ) { | 203 | if ( line.left(4 ) == "CUMI" ) { |
204 | val = line.mid( 4,len-5).toInt( &ok ); | 204 | val = line.mid( 4,len-5).toInt( &ok ); |
205 | if ( ok ) | 205 | if ( ok ) |
206 | mCustomMinutes = val; | 206 | mCustomMinutes = val; |
207 | 207 | ||
208 | } | 208 | } |
209 | if ( line.left(4 ) == "SUTI" ) { | 209 | if ( line.left(4 ) == "SUTI" ) { |
210 | val = line.mid( 4,len-5).toInt( &ok ); | 210 | val = line.mid( 4,len-5).toInt( &ok ); |
211 | if ( ok ) | 211 | if ( ok ) |
212 | mAlarmDialog->setSuspendTime( val );; | 212 | mAlarmDialog->setSuspendTime( val );; |
213 | 213 | ||
214 | } | 214 | } |
215 | } | 215 | } |
216 | file.close(); | 216 | file.close(); |
217 | } else { | 217 | } else { |
218 | if (!file.open( IO_WriteOnly ) ) { | 218 | if (!file.open( IO_WriteOnly ) ) { |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | QString configString ; | 221 | QString configString ; |
222 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 222 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
223 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 223 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
224 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 224 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
225 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 225 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
226 | configString += "CUTE " + mCustomText + "\n"; | 226 | configString += "CUTE " + mCustomText + "\n"; |
227 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 227 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
228 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 228 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
229 | QTextStream ts( &file ); | 229 | QTextStream ts( &file ); |
230 | ts << configString ; | 230 | ts << configString ; |
231 | file.close(); | 231 | file.close(); |
232 | } | 232 | } |
233 | 233 | ||
234 | } | 234 | } |
235 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 235 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
236 | { | 236 | { |
237 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 237 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
238 | mSuspend = num; | 238 | mSuspend = num; |
239 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 239 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
240 | } | 240 | } |
241 | void SimpleAlarmDaemonImpl::confPause( int num ) | 241 | void SimpleAlarmDaemonImpl::confPause( int num ) |
242 | { | 242 | { |
243 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 243 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
244 | mPausePlay = num; | 244 | mPausePlay = num; |
245 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 245 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
246 | } | 246 | } |
247 | void SimpleAlarmDaemonImpl::confSound( int num ) | 247 | void SimpleAlarmDaemonImpl::confSound( int num ) |
248 | { | 248 | { |
249 | if ( num == 0 ) { | 249 | if ( num == 0 ) { |
250 | wavAlarm = false; | 250 | wavAlarm = false; |
251 | mSoundPopUp->setItemChecked ( 0, true ); | 251 | mSoundPopUp->setItemChecked ( 0, true ); |
252 | mSoundPopUp->setItemChecked ( 1, false ); | 252 | mSoundPopUp->setItemChecked ( 1, false ); |
253 | } else { | 253 | } else { |
254 | wavAlarm = true; | 254 | wavAlarm = true; |
255 | mSoundPopUp->setItemChecked ( 0, false ); | 255 | mSoundPopUp->setItemChecked ( 0, false ); |
256 | mSoundPopUp->setItemChecked ( 1, true ); | 256 | mSoundPopUp->setItemChecked ( 1, true ); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 259 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
260 | { | 260 | { |
261 | if ( num == 1000 ) { | 261 | if ( num == 1000 ) { |
262 | simulate(); | 262 | simulate(); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 265 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
266 | mPlayBeeps = num; | 266 | mPlayBeeps = num; |
267 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 267 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
268 | } | 268 | } |
269 | 269 | ||
270 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 270 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
271 | { | 271 | { |
272 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 272 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
273 | QString mess = msg; | 273 | QString mess = QString::fromUtf8(msg.data()); |
274 | mAlarmMessage = mess.mid( 9 ); | 274 | mAlarmMessage = mess.mid( 9 ); |
275 | QString filename = getenv("QPEDIR") ; | 275 | QString filename = getenv("QPEDIR") ; |
276 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 276 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
277 | QString tempfilename; | 277 | QString tempfilename; |
278 | if ( mess.left( 13 ) == "suspend_alarm") { | 278 | if ( mess.left( 13 ) == "suspend_alarm") { |
279 | bool error = false; | 279 | bool error = false; |
280 | int len = mess.mid( 13 ).find("+++"); | 280 | int len = mess.mid( 13 ).find("+++"); |
281 | if ( len < 2 ) | 281 | if ( len < 2 ) |
282 | error = true; | 282 | error = true; |
283 | else { | 283 | else { |
284 | tempfilename = mess.mid( 13, len ); | 284 | tempfilename = mess.mid( 13, len ); |
285 | if ( !QFile::exists( tempfilename ) ) | 285 | if ( !QFile::exists( tempfilename ) ) |
286 | error = true; | 286 | error = true; |
287 | } | 287 | } |
288 | if ( ! error ) { | 288 | if ( ! error ) { |
289 | filename = tempfilename; | 289 | filename = tempfilename; |
290 | } | 290 | } |
291 | mAlarmMessage = mess.mid( 13+len+3 ); | 291 | mAlarmMessage = mess.mid( 13+len+3 ); |
292 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 292 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
293 | startAlarm( mAlarmMessage, filename); | 293 | startAlarm( mAlarmMessage, filename); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | if ( mess.left( 11 ) == "timer_alarm") { | 296 | if ( mess.left( 11 ) == "timer_alarm") { |
297 | mTimerTime = 0; | 297 | mTimerTime = 0; |
298 | startAlarm( mess.mid( 11 ), filename ); | 298 | startAlarm( mess.mid( 11 ), filename ); |
299 | return; | 299 | return; |
300 | } | 300 | } |
301 | if ( mess.left( 10 ) == "proc_alarm") { | 301 | if ( mess.left( 10 ) == "proc_alarm") { |
302 | bool error = false; | 302 | bool error = false; |
303 | int len = mess.mid( 10 ).find("+++"); | 303 | int len = mess.mid( 10 ).find("+++"); |
304 | if ( len < 2 ) | 304 | if ( len < 2 ) |
305 | error = true; | 305 | error = true; |
306 | else { | 306 | else { |
307 | tempfilename = mess.mid( 10, len ); | 307 | tempfilename = mess.mid( 10, len ); |
308 | if ( !QFile::exists( tempfilename ) ) | 308 | if ( !QFile::exists( tempfilename ) ) |
309 | error = true; | 309 | error = true; |
310 | } | 310 | } |
311 | if ( error ) { | 311 | if ( error ) { |
312 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 312 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
313 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 313 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
314 | } else { | 314 | } else { |
315 | { | 315 | { |
316 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 316 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
317 | } | 317 | } |
318 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 318 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
319 | if ( vfork () == 0 ) { | 319 | if ( vfork () == 0 ) { |
320 | execl ( tempfilename.latin1(), 0 ); | 320 | execl ( tempfilename.latin1(), 0 ); |
321 | return; | 321 | return; |
322 | } | 322 | } |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | 325 | ||
326 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 326 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
327 | } | 327 | } |
328 | if ( mess.left( 11 ) == "audio_alarm") { | 328 | if ( mess.left( 11 ) == "audio_alarm") { |
329 | bool error = false; | 329 | bool error = false; |
330 | int len = mess.mid( 11 ).find("+++"); | 330 | int len = mess.mid( 11 ).find("+++"); |
331 | if ( len < 2 ) | 331 | if ( len < 2 ) |
332 | error = true; | 332 | error = true; |
333 | else { | 333 | else { |
334 | tempfilename = mess.mid( 11, len ); | 334 | tempfilename = mess.mid( 11, len ); |
335 | if ( !QFile::exists( tempfilename ) ) | 335 | if ( !QFile::exists( tempfilename ) ) |
336 | error = true; | 336 | error = true; |
337 | } | 337 | } |
338 | if ( ! error ) { | 338 | if ( ! error ) { |
339 | filename = tempfilename; | 339 | filename = tempfilename; |
340 | } | 340 | } |
341 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 341 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
342 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 342 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
343 | } | 343 | } |
344 | if ( mess.left( 9 ) == "cal_alarm") { | 344 | if ( mess.left( 9 ) == "cal_alarm") { |
345 | mAlarmMessage = mess.mid( 9 ) ; | 345 | mAlarmMessage = mess.mid( 9 ) ; |
346 | } | 346 | } |
347 | 347 | ||
348 | writeFile(); | 348 | writeFile(); |
349 | startAlarm( mAlarmMessage, filename ); | 349 | startAlarm( mAlarmMessage, filename ); |
350 | 350 | ||
351 | } | 351 | } |
352 | 352 | ||
353 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 353 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
354 | { | 354 | { |
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 357 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
358 | { | 358 | { |
359 | //mAlarmDialog->show(); | 359 | //mAlarmDialog->show(); |
360 | //mAlarmDialog->raise(); | 360 | //mAlarmDialog->raise(); |
361 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 361 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 365 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
366 | { | 366 | { |
367 | 367 | ||
368 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 368 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
369 | if ( mTimerPopupConf == mTimerTime ) { | 369 | if ( mTimerPopupConf == mTimerTime ) { |
370 | if ( mTimerTime ) { | 370 | if ( mTimerTime ) { |
371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
373 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 373 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
374 | } | 374 | } |
375 | else { | 375 | else { |
376 | QString text = mCustomText.stripWhiteSpace (); | 376 | QString text = mCustomText.stripWhiteSpace (); |
377 | int in = text.find( " " ); | 377 | int in = text.find( " " ); |
378 | text = text.left ( in ); | 378 | text = text.left ( in ); |
379 | mTimerPopUp->changeItem ( 3, text ); | 379 | mTimerPopUp->changeItem ( 3, text ); |
380 | } | 380 | } |
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | mTimerPopupConf = mTimerTime; | 383 | mTimerPopupConf = mTimerTime; |
384 | mTimerPopUp->clear(); | 384 | mTimerPopUp->clear(); |
385 | if ( mTimerTime ) { | 385 | if ( mTimerTime ) { |
386 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 386 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
387 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 387 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
388 | 388 | ||
389 | 389 | ||
390 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 390 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
391 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 391 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
392 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 392 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
393 | } else { | 393 | } else { |
394 | 394 | ||
395 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 395 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
396 | QFile file( fileName ); | 396 | QFile file( fileName ); |
397 | if( !QFile::exists( fileName) ) { | 397 | if( !QFile::exists( fileName) ) { |
398 | // write defaults | 398 | // write defaults |
399 | if (!file.open( IO_WriteOnly ) ) { | 399 | if (!file.open( IO_WriteOnly ) ) { |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | QString configString ; | 402 | QString configString ; |
403 | configString += "#config file for kopi alarm timer\n"; | 403 | configString += "#config file for kopi alarm timer\n"; |
404 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 404 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
405 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | 405 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; |
406 | configString += "24 h; 1440\n"; | 406 | configString += "24 h; 1440\n"; |
407 | configString += " 8 h; 480\n"; | 407 | configString += " 8 h; 480\n"; |
408 | configString += " 5 h; 300\n"; | 408 | configString += " 5 h; 300\n"; |
409 | configString += " 1 h; 60\n"; | 409 | configString += " 1 h; 60\n"; |
410 | configString += "30 min; 30\n"; | 410 | configString += "30 min; 30\n"; |
411 | configString += "15 min; 15\n"; | 411 | configString += "15 min; 15\n"; |
412 | configString += "SEPARATOR\n"; | 412 | configString += "SEPARATOR\n"; |
413 | configString += "Pizza; 22\n"; | 413 | configString += "Pizza; 22\n"; |
414 | configString += "Nap; 45\n"; | 414 | configString += "Nap; 45\n"; |
415 | configString += "Tea; 5\n"; | 415 | configString += "Tea; 5\n"; |
416 | QTextStream ts( &file ); | 416 | QTextStream ts( &file ); |
417 | ts << configString ; | 417 | ts << configString ; |
418 | file.close(); | 418 | file.close(); |
419 | } | 419 | } |
420 | 420 | ||
421 | if (!file.open( IO_ReadOnly ) ) { | 421 | if (!file.open( IO_ReadOnly ) ) { |
422 | return ; | 422 | return ; |
423 | } | 423 | } |
424 | QString line; | 424 | QString line; |
425 | bool ok; | 425 | bool ok; |
426 | while ( file.readLine( line, 1024 ) > 0 ) { | 426 | while ( file.readLine( line, 1024 ) > 0 ) { |
427 | //qDebug("read %s ", line.latin1()); | 427 | //qDebug("read %s ", line.latin1()); |
428 | if ( line.left(1 ) != "#" ) { | 428 | if ( line.left(1 ) != "#" ) { |
429 | // no comment | 429 | // no comment |
430 | if ( line.left(9 ) == "SEPARATOR" ) { | 430 | if ( line.left(9 ) == "SEPARATOR" ) { |
431 | mTimerPopUp->insertSeparator(); | 431 | mTimerPopUp->insertSeparator(); |
432 | } else { | 432 | } else { |
433 | QStringList li = QStringList::split(";",line); | 433 | QStringList li = QStringList::split(";",line); |
434 | ok = false; | 434 | ok = false; |
435 | if ( li.count() == 2 ) { | 435 | if ( li.count() == 2 ) { |
436 | int val = li[1].toInt( &ok ); | 436 | int val = li[1].toInt( &ok ); |
437 | if ( ok && val > 2 ) { | 437 | if ( ok && val > 2 ) { |
438 | mTimerPopUp->insertItem( li[0], val); | 438 | mTimerPopUp->insertItem( li[0], val); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |
442 | } | 442 | } |
443 | } | 443 | } |
444 | file.close(); | 444 | file.close(); |
445 | #if 0 | 445 | #if 0 |
446 | mTimerPopUp->insertItem( "24 h", 1440 ); | 446 | mTimerPopUp->insertItem( "24 h", 1440 ); |
447 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 447 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
448 | mTimerPopUp->insertItem( " 8 h", 480 ); | 448 | mTimerPopUp->insertItem( " 8 h", 480 ); |
449 | mTimerPopUp->insertItem( " 5 h", 300 ); | 449 | mTimerPopUp->insertItem( " 5 h", 300 ); |
450 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 450 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
451 | mTimerPopUp->insertItem( " 1 h", 60 ); | 451 | mTimerPopUp->insertItem( " 1 h", 60 ); |
452 | mTimerPopUp->insertItem( "30 min", 30 ); | 452 | mTimerPopUp->insertItem( "30 min", 30 ); |
453 | mTimerPopUp->insertItem( "15 min", 15 ); | 453 | mTimerPopUp->insertItem( "15 min", 15 ); |
454 | mTimerPopUp->insertItem( "10 min", 10 ); | 454 | mTimerPopUp->insertItem( "10 min", 10 ); |
455 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 455 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
456 | mTimerPopUp->insertSeparator(); | 456 | mTimerPopUp->insertSeparator(); |
457 | mTimerPopUp->insertItem( "Pizza", 22 ); | 457 | mTimerPopUp->insertItem( "Pizza", 22 ); |
458 | mTimerPopUp->insertItem( "Nap", 45 ); | 458 | mTimerPopUp->insertItem( "Nap", 45 ); |
459 | mTimerPopUp->insertItem( "Tea", 5 ); | 459 | mTimerPopUp->insertItem( "Tea", 5 ); |
460 | #endif | 460 | #endif |
461 | QString text = mCustomText.stripWhiteSpace (); | 461 | QString text = mCustomText.stripWhiteSpace (); |
462 | int in = text.find( " " ); | 462 | int in = text.find( " " ); |
463 | text = text.left ( in ); | 463 | text = text.left ( in ); |
464 | mTimerPopUp->insertItem( text, 3 ); | 464 | mTimerPopUp->insertItem( text, 3 ); |
465 | mTimerPopUp->insertSeparator(); | 465 | mTimerPopUp->insertSeparator(); |
466 | mTimerPopUp->insertItem( "Customize", 2 ); | 466 | mTimerPopUp->insertItem( "Customize", 2 ); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | void SimpleAlarmDaemonImpl::showTimer() | 471 | void SimpleAlarmDaemonImpl::showTimer() |
472 | { | 472 | { |
473 | fillTimerPopUp(); | 473 | fillTimerPopUp(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 476 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
477 | { | 477 | { |
478 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 478 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
479 | int minutes = time; | 479 | int minutes = time; |
480 | if ( minutes == 0 ) { | 480 | if ( minutes == 0 ) { |
481 | if ( ! mTimerTime ) | 481 | if ( ! mTimerTime ) |
482 | return; | 482 | return; |
483 | 483 | ||
484 | QDialog dia ( 0, ("Stop Timer" ), true ); | 484 | QDialog dia ( 0, ("Stop Timer" ), true ); |
485 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 485 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
486 | lab.setAlignment( AlignCenter ); | 486 | lab.setAlignment( AlignCenter ); |
487 | dia.setCaption(("KO/Pi Timer Stop" )); | 487 | dia.setCaption(("KO/Pi Timer Stop" )); |
488 | QVBoxLayout lay( &dia ); | 488 | QVBoxLayout lay( &dia ); |
489 | lay.addWidget( &lab); | 489 | lay.addWidget( &lab); |
490 | QPushButton ok ( "Stop timer!", &dia); | 490 | QPushButton ok ( "Stop timer!", &dia); |
491 | QFont fo = dia.font(); | 491 | QFont fo = dia.font(); |
492 | fo.setPointSize( 36 ); | 492 | fo.setPointSize( 36 ); |
493 | ok.setFont( fo ); | 493 | ok.setFont( fo ); |
494 | lay.addWidget( &ok); | 494 | lay.addWidget( &ok); |
495 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 495 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
496 | QPushButton con ( "Continue timer!", &dia); | 496 | QPushButton con ( "Continue timer!", &dia); |
497 | fo.setPointSize( 36 ); | 497 | fo.setPointSize( 36 ); |
498 | con.setFont( fo ); | 498 | con.setFont( fo ); |
499 | lay.addWidget( &con); | 499 | lay.addWidget( &con); |
500 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 500 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
501 | lay.setMargin(5); | 501 | lay.setMargin(5); |
502 | lay.setSpacing(5); | 502 | lay.setSpacing(5); |
503 | dia.resize(dia.sizeHint() ); | 503 | dia.resize(dia.sizeHint() ); |
504 | 504 | ||
505 | if ( !dia.exec() ) | 505 | if ( !dia.exec() ) |
506 | return; | 506 | return; |
507 | 507 | ||
508 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 508 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
509 | mTimerTime = 0; | 509 | mTimerTime = 0; |
510 | return; | 510 | return; |
511 | } | 511 | } |
512 | if ( mTimerTime ) | 512 | if ( mTimerTime ) |
513 | return; | 513 | return; |
514 | if ( minutes == 1 ) { | 514 | if ( minutes == 1 ) { |
515 | return; | 515 | return; |
516 | } | 516 | } |
517 | QString mess = "timer_alarm"; | 517 | QString mess = "timer_alarm"; |
518 | mess += ("Timer Alarm!\n"); | 518 | mess += ("Timer Alarm!\n"); |
519 | if ( minutes == 22 ) { | 519 | if ( minutes == 22 ) { |
520 | mess += ( "Pizza is ready"); | 520 | mess += ( "Pizza is ready"); |
521 | mRunningTimerText = "Pizza"; | 521 | mRunningTimerText = "Pizza"; |
522 | } | 522 | } |
523 | else if ( minutes == 45 ) { | 523 | else if ( minutes == 45 ) { |
524 | mess += ( "Please wake up!"); | 524 | mess += ( "Please wake up!"); |
525 | mRunningTimerText = "Nap"; | 525 | mRunningTimerText = "Nap"; |
526 | } | 526 | } |
527 | else if ( minutes == 5 ) { | 527 | else if ( minutes == 5 ) { |
528 | mess += ( "Tea is ready"); | 528 | mess += ( "Tea is ready"); |
529 | mRunningTimerText = "Tea"; | 529 | mRunningTimerText = "Tea"; |
530 | } | 530 | } |
531 | else if ( minutes == 3 ) { | 531 | else if ( minutes == 3 ) { |
532 | mess += mCustomText; | 532 | mess += mCustomText; |
533 | minutes = mCustomMinutes ; | 533 | minutes = mCustomMinutes ; |
534 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 534 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
535 | int in = mRunningTimerText.find( " " ); | 535 | int in = mRunningTimerText.find( " " ); |
536 | mRunningTimerText = mRunningTimerText.left ( in ); | 536 | mRunningTimerText = mRunningTimerText.left ( in ); |
537 | } | 537 | } |
538 | else { | 538 | else { |
539 | if ( minutes == 2 ) { | 539 | if ( minutes == 2 ) { |
540 | // ask time | 540 | // ask time |
541 | QDialog dia ( 0, ("Customize Timer" ), true ); | 541 | QDialog dia ( 0, ("Customize Timer" ), true ); |
542 | QLabel lab (("Message Text:"), &dia ); | 542 | QLabel lab (("Message Text:"), &dia ); |
543 | dia.setCaption(("KO/Pi Timer" )); | 543 | dia.setCaption(("KO/Pi Timer" )); |
544 | QVBoxLayout lay( &dia ); | 544 | QVBoxLayout lay( &dia ); |
545 | lay.setMargin(5); | 545 | lay.setMargin(5); |
546 | lay.setSpacing(5); | 546 | lay.setSpacing(5); |
547 | lay.addWidget( &lab); | 547 | lay.addWidget( &lab); |
548 | QLineEdit lEdit( mCustomText, &dia ); | 548 | QLineEdit lEdit( mCustomText, &dia ); |
549 | lay.addWidget( &lEdit); | 549 | lay.addWidget( &lEdit); |
550 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 550 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
551 | lay.addWidget( &lab2); | 551 | lay.addWidget( &lab2); |
552 | QHBox hbox1 ( &dia ); | 552 | QHBox hbox1 ( &dia ); |
553 | lay.addWidget( &hbox1); | 553 | lay.addWidget( &hbox1); |
554 | QLabel lab3 (("Hours"), &hbox1 ); | 554 | QLabel lab3 (("Hours"), &hbox1 ); |
555 | QLabel lab4 (("Minutes"), &hbox1 ); | 555 | QLabel lab4 (("Minutes"), &hbox1 ); |
556 | QHBox hbox ( &dia ); | 556 | QHBox hbox ( &dia ); |
557 | QSpinBox spinh( 0, 24, 1,& hbox ); | 557 | QSpinBox spinh( 0, 24, 1,& hbox ); |
558 | QFont fo = dia.font(); | 558 | QFont fo = dia.font(); |
559 | fo.setPointSize( 36 ); | 559 | fo.setPointSize( 36 ); |
560 | QSpinBox spinm( 0, 59, 1,&hbox ); | 560 | QSpinBox spinm( 0, 59, 1,&hbox ); |
561 | spinm.setFont( fo ); | 561 | spinm.setFont( fo ); |
562 | spinh.setFont( fo ); | 562 | spinh.setFont( fo ); |
563 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 563 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
564 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 564 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
565 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 565 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
566 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 566 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
567 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 567 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
568 | spinh.setFixedSize( 100,62 ); | 568 | spinh.setFixedSize( 100,62 ); |
569 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 569 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
570 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 570 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
571 | spinm.downButton ()->setGeometry( 50,50,50,50); | 571 | spinm.downButton ()->setGeometry( 50,50,50,50); |
572 | // spinm.setSuffix( " m" ); | 572 | // spinm.setSuffix( " m" ); |
573 | //spinh.setSuffix( " h" ); | 573 | //spinh.setSuffix( " h" ); |
574 | spinm.setWrapping ( true ); | 574 | spinm.setWrapping ( true ); |
575 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 575 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
576 | spinm.setLineStep( 1 ); | 576 | spinm.setLineStep( 1 ); |
577 | spinm.setFixedSize( 110,62 ); | 577 | spinm.setFixedSize( 110,62 ); |
578 | lay.addWidget( &hbox); | 578 | lay.addWidget( &hbox); |
579 | QLabel lab5 ("Timer fires at:", &dia ); | 579 | QLabel lab5 ("Timer fires at:", &dia ); |
580 | lab5.setAlignment( AlignCenter ); | 580 | lab5.setAlignment( AlignCenter ); |
581 | lay.addWidget( &lab5); | 581 | lay.addWidget( &lab5); |
582 | KODateLabel dl ( &dia ); | 582 | KODateLabel dl ( &dia ); |
583 | dl.setAlignment( AlignCenter ); | 583 | dl.setAlignment( AlignCenter ); |
584 | dl.setFont( fo ); | 584 | dl.setFont( fo ); |
585 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 585 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
586 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 586 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
587 | lay.addWidget( &dl); | 587 | lay.addWidget( &dl); |
588 | spinh.setValue( mCustomMinutes/60 ); | 588 | spinh.setValue( mCustomMinutes/60 ); |
589 | spinm.setValue( mCustomMinutes%60 ); | 589 | spinm.setValue( mCustomMinutes%60 ); |
590 | QPushButton ok ( "Start timer", &dia); | 590 | QPushButton ok ( "Start timer", &dia); |
591 | ok.setDefault( true ); | 591 | ok.setDefault( true ); |
592 | ok.setFont( fo ); | 592 | ok.setFont( fo ); |
593 | spinh.setFocus(); | 593 | spinh.setFocus(); |
594 | lay.addWidget( &ok); | 594 | lay.addWidget( &ok); |
595 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 595 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
596 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 596 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
597 | 597 | ||
598 | if ( !dia.exec() ) | 598 | if ( !dia.exec() ) |
599 | return; | 599 | return; |
600 | mCustomText = lEdit.text(); | 600 | mCustomText = lEdit.text(); |
601 | mCustomMinutes = spinh.value()*60+spinm.value(); | 601 | mCustomMinutes = spinh.value()*60+spinm.value(); |
602 | if ( mCustomMinutes == 0 ) | 602 | if ( mCustomMinutes == 0 ) |
603 | mCustomMinutes = 1; | 603 | mCustomMinutes = 1; |
604 | if ( mCustomMinutes > 1440 ) | 604 | if ( mCustomMinutes > 1440 ) |
605 | mCustomMinutes = 1440; | 605 | mCustomMinutes = 1440; |
606 | mess += mCustomText; | 606 | mess += mCustomText; |
607 | minutes = mCustomMinutes; | 607 | minutes = mCustomMinutes; |
608 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 608 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
609 | int in = mRunningTimerText.find( " " ); | 609 | int in = mRunningTimerText.find( " " ); |
610 | mRunningTimerText = mRunningTimerText.left ( in ); | 610 | mRunningTimerText = mRunningTimerText.left ( in ); |
611 | } | 611 | } |
612 | else { | 612 | else { |
613 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 613 | mess+= QString::number ( minutes ) + ( " minutes are past!"); |
614 | int min = minutes; | 614 | int min = minutes; |
615 | if ( min % 60 == 0 ) | 615 | if ( min % 60 == 0 ) |
616 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); | 616 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); |
617 | else | 617 | else |
618 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); | 618 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); |
619 | } | 619 | } |
620 | } | 620 | } |
621 | //minutes = 1; | 621 | //minutes = 1; |
622 | 622 | ||
623 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 623 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
624 | timerMesssage = mess; | 624 | timerMesssage = mess; |
625 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | 625 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); |
626 | mTimerTime = 1; | 626 | mTimerTime = 1; |
627 | } | 627 | } |
628 | 628 | ||
629 | void SimpleAlarmDaemonImpl::writeFile() | 629 | void SimpleAlarmDaemonImpl::writeFile() |
630 | { | 630 | { |
631 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 631 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
632 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 632 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
633 | } | 633 | } |
634 | void SimpleAlarmDaemonImpl::showWN() | 634 | void SimpleAlarmDaemonImpl::showWN() |
635 | { | 635 | { |
636 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 636 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
637 | } | 637 | } |
638 | void SimpleAlarmDaemonImpl::newTodo() | 638 | void SimpleAlarmDaemonImpl::newTodo() |
639 | { | 639 | { |
640 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 640 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
641 | } | 641 | } |
642 | 642 | ||
643 | void SimpleAlarmDaemonImpl::newEvent() | 643 | void SimpleAlarmDaemonImpl::newEvent() |
644 | { | 644 | { |
645 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 645 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
646 | 646 | ||
647 | } | 647 | } |
648 | void SimpleAlarmDaemonImpl::newMail() | 648 | void SimpleAlarmDaemonImpl::newMail() |
649 | { | 649 | { |
650 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 650 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
651 | } | 651 | } |
652 | void SimpleAlarmDaemonImpl::showAdd() | 652 | void SimpleAlarmDaemonImpl::showAdd() |
653 | { | 653 | { |
654 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 654 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
655 | } | 655 | } |
656 | void SimpleAlarmDaemonImpl::ringSync() | 656 | void SimpleAlarmDaemonImpl::ringSync() |
657 | { | 657 | { |
658 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 658 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
659 | 659 | ||
660 | } | 660 | } |
661 | void SimpleAlarmDaemonImpl::newCountdown() | 661 | void SimpleAlarmDaemonImpl::newCountdown() |
662 | { | 662 | { |
663 | //recieve("cal_alarm", 10 ); | 663 | //recieve("cal_alarm", 10 ); |
664 | } | 664 | } |
665 | void SimpleAlarmDaemonImpl::simulate() | 665 | void SimpleAlarmDaemonImpl::simulate() |
666 | { | 666 | { |
667 | writeFile(); | 667 | writeFile(); |
668 | QString filename = getenv("QPEDIR") ; | 668 | QString filename = getenv("QPEDIR") ; |
669 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 669 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
670 | startAlarm("Alarm simulation", filename ); | 670 | startAlarm("Alarm simulation", filename ); |
671 | } | 671 | } |
672 | void SimpleAlarmDaemonImpl::showKO() | 672 | void SimpleAlarmDaemonImpl::showKO() |
673 | { | 673 | { |
674 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 674 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
675 | // testing only | 675 | // testing only |
676 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 676 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
677 | 677 | ||
678 | } | 678 | } |
679 | void SimpleAlarmDaemonImpl::showTodo() | 679 | void SimpleAlarmDaemonImpl::showTodo() |
680 | { | 680 | { |
681 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 681 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
682 | 682 | ||
683 | } | 683 | } |
684 | void SimpleAlarmDaemonImpl::writeJournal() | 684 | void SimpleAlarmDaemonImpl::writeJournal() |
685 | { | 685 | { |
686 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 686 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
687 | 687 | ||
688 | } | 688 | } |
689 | 689 | ||
690 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 690 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
691 | { | 691 | { |
692 | 692 | ||
693 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 693 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
694 | 694 | ||
695 | } | 695 | } |
696 | 696 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d992b9..4b82aa8 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3907 +1,3909 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | mTodoList->setNavigator( mNavigator ); | 462 | mTodoList->setNavigator( mNavigator ); |
463 | #if 0 | 463 | #if 0 |
464 | if ( QApplication::desktop()->width() < 480 ) { | 464 | if ( QApplication::desktop()->width() < 480 ) { |
465 | leftFrameLayout->addWidget(mFilterView); | 465 | leftFrameLayout->addWidget(mFilterView); |
466 | leftFrameLayout->addWidget(mTodoList, 2 ); | 466 | leftFrameLayout->addWidget(mTodoList, 2 ); |
467 | 467 | ||
468 | } else { | 468 | } else { |
469 | leftFrameLayout->addWidget(mTodoList,2 ); | 469 | leftFrameLayout->addWidget(mTodoList,2 ); |
470 | leftFrameLayout->addWidget(mFilterView ); | 470 | leftFrameLayout->addWidget(mFilterView ); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | mFilterView->hide(); | 473 | mFilterView->hide(); |
474 | mCalEditView->hide(); | 474 | mCalEditView->hide(); |
475 | QWidget *rightBox = new QWidget( mMainFrame ); | 475 | QWidget *rightBox = new QWidget( mMainFrame ); |
476 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 476 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
478 | mRightFrame = new QWidgetStack( rightBox ); | 478 | mRightFrame = new QWidgetStack( rightBox ); |
479 | rightLayout->addWidget( mRightFrame, 10 ); | 479 | rightLayout->addWidget( mRightFrame, 10 ); |
480 | 480 | ||
481 | //mLeftFrame = (QWidget *)leftFrame; | 481 | //mLeftFrame = (QWidget *)leftFrame; |
482 | if ( KOPrefs::instance()->mVerticalScreen ) { | 482 | if ( KOPrefs::instance()->mVerticalScreen ) { |
483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
487 | } else { | 487 | } else { |
488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
491 | } | 491 | } |
492 | if ( !KOPrefs::instance()->mShowDateNavigator) | 492 | if ( !KOPrefs::instance()->mShowDateNavigator) |
493 | mDateNavigator->hide(); | 493 | mDateNavigator->hide(); |
494 | //qDebug("Calendarview Size %d %d ", width(), height()); | 494 | //qDebug("Calendarview Size %d %d ", width(), height()); |
495 | #endif | 495 | #endif |
496 | 496 | ||
497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
498 | SLOT( showDates( const KCal::DateList & ) ) ); | 498 | SLOT( showDates( const KCal::DateList & ) ) ); |
499 | 499 | ||
500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
502 | 502 | ||
503 | 503 | ||
504 | 504 | ||
505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
507 | 507 | ||
508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
510 | 510 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
512 | mNavigator, SLOT( selectPreviousYear() ) ); | 512 | mNavigator, SLOT( selectPreviousYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 513 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
514 | mNavigator, SLOT( selectNextYear() ) ); | 514 | mNavigator, SLOT( selectNextYear() ) ); |
515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
516 | mNavigator, SLOT( selectPreviousMonth() ) ); | 516 | mNavigator, SLOT( selectPreviousMonth() ) ); |
517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
518 | mNavigator, SLOT( selectNextMonth() ) ); | 518 | mNavigator, SLOT( selectNextMonth() ) ); |
519 | 519 | ||
520 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 520 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
521 | mNavigator, SLOT( selectPrevious() ) ); | 521 | mNavigator, SLOT( selectPrevious() ) ); |
522 | connect( mDateNavigator, SIGNAL( goNext() ), | 522 | connect( mDateNavigator, SIGNAL( goNext() ), |
523 | mNavigator, SLOT( selectNext() ) ); | 523 | mNavigator, SLOT( selectNext() ) ); |
524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | #if 0 | 529 | #if 0 |
530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
531 | SLOT( incidenceAdded( Incidence *) ) ); | 531 | SLOT( incidenceAdded( Incidence *) ) ); |
532 | #endif | 532 | #endif |
533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
534 | 534 | ||
535 | connect( this, SIGNAL( configChanged() ), | 535 | connect( this, SIGNAL( configChanged() ), |
536 | mDateNavigator, SLOT( updateConfig() ) ); | 536 | mDateNavigator, SLOT( updateConfig() ) ); |
537 | 537 | ||
538 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 538 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
539 | SLOT( newTodo() ) ); | 539 | SLOT( newTodo() ) ); |
540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
541 | SLOT( newSubTodo( Todo * ) ) ); | 541 | SLOT( newSubTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
543 | SLOT( editTodo( Todo * ) ) ); | 543 | SLOT( editTodo( Todo * ) ) ); |
544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
545 | SLOT( showTodo( Todo *) ) ); | 545 | SLOT( showTodo( Todo *) ) ); |
546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
547 | SLOT( deleteTodo( Todo *) ) ); | 547 | SLOT( deleteTodo( Todo *) ) ); |
548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
550 | SLOT( purgeCompleted() ) ); | 550 | SLOT( purgeCompleted() ) ); |
551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
552 | SIGNAL( todoModified( Todo *, int ) ) ); | 552 | SIGNAL( todoModified( Todo *, int ) ) ); |
553 | 553 | ||
554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
557 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 557 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
558 | 558 | ||
559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
560 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 560 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
562 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 562 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
563 | 563 | ||
564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
565 | this, SLOT ( todo_unsub( Todo * ) ) ); | 565 | this, SLOT ( todo_unsub( Todo * ) ) ); |
566 | 566 | ||
567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
570 | SLOT( updateTodo( Todo *, int ) ) ); | 570 | SLOT( updateTodo( Todo *, int ) ) ); |
571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
573 | 573 | ||
574 | 574 | ||
575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | 582 | ||
583 | 583 | ||
584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
585 | SLOT(checkClipboard())); | 585 | SLOT(checkClipboard())); |
586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
587 | SLOT( processTodoListSelection( Incidence * ) ) ); | 587 | SLOT( processTodoListSelection( Incidence * ) ) ); |
588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
589 | 589 | ||
590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
591 | 591 | ||
592 | mDateFrame = new QVBox(0,0,WType_Popup); | 592 | mDateFrame = new QVBox(0,0,WType_Popup); |
593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
595 | mDateFrame->setLineWidth(3); | 595 | mDateFrame->setLineWidth(3); |
596 | mDateFrame->hide(); | 596 | mDateFrame->hide(); |
597 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 597 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
599 | 599 | ||
600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
601 | 601 | ||
602 | mEventEditor = mDialogManager->getEventEditor(); | 602 | mEventEditor = mDialogManager->getEventEditor(); |
603 | mTodoEditor = mDialogManager->getTodoEditor(); | 603 | mTodoEditor = mDialogManager->getTodoEditor(); |
604 | 604 | ||
605 | mFlagEditDescription = false; | 605 | mFlagEditDescription = false; |
606 | 606 | ||
607 | mSuspendTimer = new QTimer( this ); | 607 | mSuspendTimer = new QTimer( this ); |
608 | mAlarmTimer = new QTimer( this ); | 608 | mAlarmTimer = new QTimer( this ); |
609 | mRecheckAlarmTimer = new QTimer( this ); | 609 | mRecheckAlarmTimer = new QTimer( this ); |
610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
613 | mAlarmDialog = new AlarmDialog( this ); | 613 | mAlarmDialog = new AlarmDialog( this ); |
614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
615 | mAlarmDialog->setServerNotification( false ); | 615 | mAlarmDialog->setServerNotification( false ); |
616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
617 | 617 | ||
618 | 618 | ||
619 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
620 | //US listen for arriving address resultsets | 620 | //US listen for arriving address resultsets |
621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
623 | #endif | 623 | #endif |
624 | mDateNavigator->setCalendar( mCalendar ); | 624 | mDateNavigator->setCalendar( mCalendar ); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | CalendarView::~CalendarView() | 628 | CalendarView::~CalendarView() |
629 | { | 629 | { |
630 | // kdDebug() << "~CalendarView()" << endl; | 630 | // kdDebug() << "~CalendarView()" << endl; |
631 | //qDebug("CalendarView::~CalendarView() "); | 631 | //qDebug("CalendarView::~CalendarView() "); |
632 | delete mDialogManager; | 632 | delete mDialogManager; |
633 | delete mViewManager; | 633 | delete mViewManager; |
634 | delete mStorage; | 634 | delete mStorage; |
635 | delete mDateFrame ; | 635 | delete mDateFrame ; |
636 | delete beamDialog; | 636 | delete beamDialog; |
637 | delete mEventViewerDialog; | 637 | delete mEventViewerDialog; |
638 | //kdDebug() << "~CalendarView() done" << endl; | 638 | //kdDebug() << "~CalendarView() done" << endl; |
639 | } | 639 | } |
640 | void CalendarView::checkAlarms() | 640 | void CalendarView::checkAlarms() |
641 | { | 641 | { |
642 | KConfig *config = KOGlobals::config(); | 642 | KConfig *config = KOGlobals::config(); |
643 | config->setGroup( "AppRun" ); | 643 | config->setGroup( "AppRun" ); |
644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | 646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; |
647 | //secs -= ( 3600 * 24*3 ); // debug only | 647 | //secs -= ( 3600 * 24*3 ); // debug only |
648 | QDateTime latest = dt.addSecs ( secs ); | 648 | QDateTime latest = dt.addSecs ( secs ); |
649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
651 | QPtrList<Incidence> al; | 651 | QPtrList<Incidence> al; |
652 | Incidence* inL = el.first(); | 652 | Incidence* inL = el.first(); |
653 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | ||
654 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | ||
653 | while ( inL ) { | 655 | while ( inL ) { |
654 | bool ok = false; | 656 | bool ok = false; |
655 | int offset = 0; | 657 | int offset = 0; |
656 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 658 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
657 | if ( ok ) { | 659 | if ( ok ) { |
658 | //qDebug("OK %s",next.toString().latin1()); | 660 | //qDebug("OK %s",next.toString().latin1()); |
659 | if ( next < QDateTime::currentDateTime() ) { | 661 | if ( next < cur ) { |
660 | al.append( inL ); | 662 | al.append( inL ); |
661 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 663 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
662 | } | 664 | } |
663 | } | 665 | } |
664 | inL = el.next(); | 666 | inL = el.next(); |
665 | } | 667 | } |
666 | if ( al.count() ) { | 668 | if ( al.count() ) { |
667 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 669 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
668 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 670 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
669 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 671 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
670 | lay->setSpacing( 0 ); | 672 | lay->setSpacing( 0 ); |
671 | lay->setMargin( 0 ); | 673 | lay->setMargin( 0 ); |
672 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 674 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
673 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 675 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
674 | lay->addWidget( matb ); | 676 | lay->addWidget( matb ); |
675 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 677 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
676 | int wid = 210; | 678 | int wid = 210; |
677 | int x = QApplication::desktop()->width() - wid - 7; | 679 | int x = QApplication::desktop()->width() - wid - 7; |
678 | int y = QApplication::desktop()->height() - wid - 70; | 680 | int y = QApplication::desktop()->height() - wid - 70; |
679 | dia->setGeometry ( x,y,wid,wid); | 681 | dia->setGeometry ( x,y,wid,wid); |
680 | } else { | 682 | } else { |
681 | int si = 220; | 683 | int si = 220; |
682 | if ( QApplication::desktop()->width() > 470 ) | 684 | if ( QApplication::desktop()->width() > 470 ) |
683 | si = 400; | 685 | si = 400; |
684 | dia->resize(si,si/2); | 686 | dia->resize(si,si/2); |
685 | } | 687 | } |
686 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 688 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
687 | dia->show(); | 689 | dia->show(); |
688 | 690 | ||
689 | } | 691 | } |
690 | } | 692 | } |
691 | void CalendarView::showDay( QDate d ) | 693 | void CalendarView::showDay( QDate d ) |
692 | { | 694 | { |
693 | dateNavigator()->blockSignals( true ); | 695 | dateNavigator()->blockSignals( true ); |
694 | dateNavigator()->selectDate( d ); | 696 | dateNavigator()->selectDate( d ); |
695 | dateNavigator()->blockSignals( false ); | 697 | dateNavigator()->blockSignals( false ); |
696 | mViewManager->showDayView(); | 698 | mViewManager->showDayView(); |
697 | //dateNavigator()->selectDate( d ); | 699 | //dateNavigator()->selectDate( d ); |
698 | } | 700 | } |
699 | void CalendarView::timerAlarm() | 701 | void CalendarView::timerAlarm() |
700 | { | 702 | { |
701 | //qDebug("CalendarView::timerAlarm() "); | 703 | //qDebug("CalendarView::timerAlarm() "); |
702 | computeAlarm(mAlarmNotification ); | 704 | computeAlarm(mAlarmNotification ); |
703 | } | 705 | } |
704 | 706 | ||
705 | void CalendarView::suspendAlarm() | 707 | void CalendarView::suspendAlarm() |
706 | { | 708 | { |
707 | //qDebug(" CalendarView::suspendAlarm() "); | 709 | //qDebug(" CalendarView::suspendAlarm() "); |
708 | computeAlarm(mSuspendAlarmNotification ); | 710 | computeAlarm(mSuspendAlarmNotification ); |
709 | 711 | ||
710 | } | 712 | } |
711 | 713 | ||
712 | void CalendarView::startAlarm( QString mess , QString filename) | 714 | void CalendarView::startAlarm( QString mess , QString filename) |
713 | { | 715 | { |
714 | 716 | ||
715 | topLevelWidget()->showNormal(); | 717 | topLevelWidget()->showNormal(); |
716 | topLevelWidget()->setActiveWindow(); | 718 | topLevelWidget()->setActiveWindow(); |
717 | topLevelWidget()->raise(); | 719 | topLevelWidget()->raise(); |
718 | 720 | ||
719 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 721 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
720 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 722 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
721 | 723 | ||
722 | } | 724 | } |
723 | 725 | ||
724 | void CalendarView::checkNextTimerAlarm() | 726 | void CalendarView::checkNextTimerAlarm() |
725 | { | 727 | { |
726 | mCalendar->checkAlarmForIncidence( 0, true ); | 728 | mCalendar->checkAlarmForIncidence( 0, true ); |
727 | } | 729 | } |
728 | 730 | ||
729 | void CalendarView::computeAlarm( QString msg ) | 731 | void CalendarView::computeAlarm( QString msg ) |
730 | { | 732 | { |
731 | 733 | ||
732 | QString mess = msg; | 734 | QString mess = msg; |
733 | QString mAlarmMessage = mess.mid( 9 ); | 735 | QString mAlarmMessage = mess.mid( 9 ); |
734 | QString filename = MainWindow::resourcePath(); | 736 | QString filename = MainWindow::resourcePath(); |
735 | filename += "koalarm.wav"; | 737 | filename += "koalarm.wav"; |
736 | QString tempfilename; | 738 | QString tempfilename; |
737 | if ( mess.left( 13 ) == "suspend_alarm") { | 739 | if ( mess.left( 13 ) == "suspend_alarm") { |
738 | bool error = false; | 740 | bool error = false; |
739 | int len = mess.mid( 13 ).find("+++"); | 741 | int len = mess.mid( 13 ).find("+++"); |
740 | if ( len < 2 ) | 742 | if ( len < 2 ) |
741 | error = true; | 743 | error = true; |
742 | else { | 744 | else { |
743 | tempfilename = mess.mid( 13, len ); | 745 | tempfilename = mess.mid( 13, len ); |
744 | if ( !QFile::exists( tempfilename ) ) | 746 | if ( !QFile::exists( tempfilename ) ) |
745 | error = true; | 747 | error = true; |
746 | } | 748 | } |
747 | if ( ! error ) { | 749 | if ( ! error ) { |
748 | filename = tempfilename; | 750 | filename = tempfilename; |
749 | } | 751 | } |
750 | mAlarmMessage = mess.mid( 13+len+3 ); | 752 | mAlarmMessage = mess.mid( 13+len+3 ); |
751 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 753 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
752 | startAlarm( mAlarmMessage, filename); | 754 | startAlarm( mAlarmMessage, filename); |
753 | return; | 755 | return; |
754 | } | 756 | } |
755 | if ( mess.left( 11 ) == "timer_alarm") { | 757 | if ( mess.left( 11 ) == "timer_alarm") { |
756 | //mTimerTime = 0; | 758 | //mTimerTime = 0; |
757 | startAlarm( mess.mid( 11 ), filename ); | 759 | startAlarm( mess.mid( 11 ), filename ); |
758 | return; | 760 | return; |
759 | } | 761 | } |
760 | if ( mess.left( 10 ) == "proc_alarm") { | 762 | if ( mess.left( 10 ) == "proc_alarm") { |
761 | bool error = false; | 763 | bool error = false; |
762 | int len = mess.mid( 10 ).find("+++"); | 764 | int len = mess.mid( 10 ).find("+++"); |
763 | if ( len < 2 ) | 765 | if ( len < 2 ) |
764 | error = true; | 766 | error = true; |
765 | else { | 767 | else { |
766 | tempfilename = mess.mid( 10, len ); | 768 | tempfilename = mess.mid( 10, len ); |
767 | if ( !QFile::exists( tempfilename ) ) | 769 | if ( !QFile::exists( tempfilename ) ) |
768 | error = true; | 770 | error = true; |
769 | } | 771 | } |
770 | if ( error ) { | 772 | if ( error ) { |
771 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 773 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
772 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 774 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
773 | } else { | 775 | } else { |
774 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 776 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
775 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 777 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
776 | #ifndef _WIN32_ | 778 | #ifndef _WIN32_ |
777 | if ( vfork () == 0 ) { | 779 | if ( vfork () == 0 ) { |
778 | execl ( tempfilename.latin1(), 0 ); | 780 | execl ( tempfilename.latin1(), 0 ); |
779 | return; | 781 | return; |
780 | } | 782 | } |
781 | #else | 783 | #else |
782 | QProcess* p = new QProcess(); | 784 | QProcess* p = new QProcess(); |
783 | p->addArgument( tempfilename.latin1() ); | 785 | p->addArgument( tempfilename.latin1() ); |
784 | p->start(); | 786 | p->start(); |
785 | return; | 787 | return; |
786 | #endif | 788 | #endif |
787 | 789 | ||
788 | return; | 790 | return; |
789 | } | 791 | } |
790 | 792 | ||
791 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 793 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
792 | } | 794 | } |
793 | if ( mess.left( 11 ) == "audio_alarm") { | 795 | if ( mess.left( 11 ) == "audio_alarm") { |
794 | bool error = false; | 796 | bool error = false; |
795 | int len = mess.mid( 11 ).find("+++"); | 797 | int len = mess.mid( 11 ).find("+++"); |
796 | if ( len < 2 ) | 798 | if ( len < 2 ) |
797 | error = true; | 799 | error = true; |
798 | else { | 800 | else { |
799 | tempfilename = mess.mid( 11, len ); | 801 | tempfilename = mess.mid( 11, len ); |
800 | if ( !QFile::exists( tempfilename ) ) | 802 | if ( !QFile::exists( tempfilename ) ) |
801 | error = true; | 803 | error = true; |
802 | } | 804 | } |
803 | if ( ! error ) { | 805 | if ( ! error ) { |
804 | filename = tempfilename; | 806 | filename = tempfilename; |
805 | } | 807 | } |
806 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 808 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
807 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 809 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
808 | } | 810 | } |
809 | if ( mess.left( 9 ) == "cal_alarm") { | 811 | if ( mess.left( 9 ) == "cal_alarm") { |
810 | mAlarmMessage = mess.mid( 9 ) ; | 812 | mAlarmMessage = mess.mid( 9 ) ; |
811 | } | 813 | } |
812 | 814 | ||
813 | startAlarm( mAlarmMessage, filename ); | 815 | startAlarm( mAlarmMessage, filename ); |
814 | 816 | ||
815 | 817 | ||
816 | } | 818 | } |
817 | 819 | ||
818 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 820 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
819 | { | 821 | { |
820 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 822 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
821 | 823 | ||
822 | mSuspendAlarmNotification = noti; | 824 | mSuspendAlarmNotification = noti; |
823 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 825 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
824 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 826 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
825 | mSuspendTimer->start( ms , true ); | 827 | mSuspendTimer->start( ms , true ); |
826 | 828 | ||
827 | } | 829 | } |
828 | 830 | ||
829 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 831 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
830 | { | 832 | { |
831 | mNextAlarmDateTime = qdt; | 833 | mNextAlarmDateTime = qdt; |
832 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 834 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
833 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 835 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
834 | #ifndef DESKTOP_VERSION | 836 | #ifndef DESKTOP_VERSION |
835 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 837 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
836 | #endif | 838 | #endif |
837 | return; | 839 | return; |
838 | } | 840 | } |
839 | int maxSec; | 841 | int maxSec; |
840 | //maxSec = 5; //testing only | 842 | //maxSec = 5; //testing only |
841 | maxSec = 86400+3600; // one day+1hour | 843 | maxSec = 86400+3600; // one day+1hour |
842 | mAlarmNotification = noti; | 844 | mAlarmNotification = noti; |
843 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 845 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
844 | if ( sec > maxSec ) { | 846 | if ( sec > maxSec ) { |
845 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 847 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
846 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 848 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
847 | return; | 849 | return; |
848 | } else { | 850 | } else { |
849 | mRecheckAlarmTimer->stop(); | 851 | mRecheckAlarmTimer->stop(); |
850 | } | 852 | } |
851 | //qDebug("Alarm timer started with secs: %d ", sec); | 853 | //qDebug("Alarm timer started with secs: %d ", sec); |
852 | mAlarmTimer->start( sec *1000 , true ); | 854 | mAlarmTimer->start( sec *1000 , true ); |
853 | 855 | ||
854 | } | 856 | } |
855 | // called by mRecheckAlarmTimer to get next alarm | 857 | // called by mRecheckAlarmTimer to get next alarm |
856 | // we need this, because a QTimer has only a max range of 25 days | 858 | // we need this, because a QTimer has only a max range of 25 days |
857 | void CalendarView::recheckTimerAlarm() | 859 | void CalendarView::recheckTimerAlarm() |
858 | { | 860 | { |
859 | mAlarmTimer->stop(); | 861 | mAlarmTimer->stop(); |
860 | mRecheckAlarmTimer->stop(); | 862 | mRecheckAlarmTimer->stop(); |
861 | mCalendar->checkAlarmForIncidence( 0, true ); | 863 | mCalendar->checkAlarmForIncidence( 0, true ); |
862 | } | 864 | } |
863 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 865 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
864 | { | 866 | { |
865 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 867 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
866 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 868 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 870 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
869 | #endif | 871 | #endif |
870 | return; | 872 | return; |
871 | } | 873 | } |
872 | mAlarmTimer->stop(); | 874 | mAlarmTimer->stop(); |
873 | } | 875 | } |
874 | void CalendarView::selectWeekNum ( int num ) | 876 | void CalendarView::selectWeekNum ( int num ) |
875 | { | 877 | { |
876 | dateNavigator()->blockSignals( true ); | 878 | dateNavigator()->blockSignals( true ); |
877 | dateNavigator()->selectWeek( num ); | 879 | dateNavigator()->selectWeek( num ); |
878 | dateNavigator()->blockSignals( false ); | 880 | dateNavigator()->blockSignals( false ); |
879 | mViewManager->showWeekView(); | 881 | mViewManager->showWeekView(); |
880 | } | 882 | } |
881 | KOViewManager *CalendarView::viewManager() | 883 | KOViewManager *CalendarView::viewManager() |
882 | { | 884 | { |
883 | return mViewManager; | 885 | return mViewManager; |
884 | } | 886 | } |
885 | 887 | ||
886 | KODialogManager *CalendarView::dialogManager() | 888 | KODialogManager *CalendarView::dialogManager() |
887 | { | 889 | { |
888 | return mDialogManager; | 890 | return mDialogManager; |
889 | } | 891 | } |
890 | 892 | ||
891 | QDate CalendarView::startDate() | 893 | QDate CalendarView::startDate() |
892 | { | 894 | { |
893 | DateList dates = mNavigator->selectedDates(); | 895 | DateList dates = mNavigator->selectedDates(); |
894 | 896 | ||
895 | return dates.first(); | 897 | return dates.first(); |
896 | } | 898 | } |
897 | 899 | ||
898 | QDate CalendarView::endDate() | 900 | QDate CalendarView::endDate() |
899 | { | 901 | { |
900 | DateList dates = mNavigator->selectedDates(); | 902 | DateList dates = mNavigator->selectedDates(); |
901 | 903 | ||
902 | return dates.last(); | 904 | return dates.last(); |
903 | } | 905 | } |
904 | 906 | ||
905 | 907 | ||
906 | void CalendarView::createPrinter() | 908 | void CalendarView::createPrinter() |
907 | { | 909 | { |
908 | #ifndef KORG_NOPRINTER | 910 | #ifndef KORG_NOPRINTER |
909 | if (!mCalPrinter) { | 911 | if (!mCalPrinter) { |
910 | mCalPrinter = new CalPrinter(this, mCalendar); | 912 | mCalPrinter = new CalPrinter(this, mCalendar); |
911 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 913 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
912 | } | 914 | } |
913 | #endif | 915 | #endif |
914 | } | 916 | } |
915 | 917 | ||
916 | 918 | ||
917 | //KOPrefs::instance()->mWriteBackFile | 919 | //KOPrefs::instance()->mWriteBackFile |
918 | //KOPrefs::instance()->mWriteBackExistingOnly | 920 | //KOPrefs::instance()->mWriteBackExistingOnly |
919 | 921 | ||
920 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 922 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
921 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 923 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
922 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 924 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
923 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 925 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
924 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 926 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
925 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 927 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
926 | 928 | ||
927 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 929 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
928 | { | 930 | { |
929 | 931 | ||
930 | // 0 equal | 932 | // 0 equal |
931 | // 1 take local | 933 | // 1 take local |
932 | // 2 take remote | 934 | // 2 take remote |
933 | // 3 cancel | 935 | // 3 cancel |
934 | QDateTime lastSync = mLastCalendarSync; | 936 | QDateTime lastSync = mLastCalendarSync; |
935 | QDateTime localMod = local->lastModified(); | 937 | QDateTime localMod = local->lastModified(); |
936 | QDateTime remoteMod = remote->lastModified(); | 938 | QDateTime remoteMod = remote->lastModified(); |
937 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 939 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
938 | bool remCh, locCh; | 940 | bool remCh, locCh; |
939 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 941 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
940 | //if ( remCh ) | 942 | //if ( remCh ) |
941 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 943 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
942 | locCh = ( localMod > mLastCalendarSync ); | 944 | locCh = ( localMod > mLastCalendarSync ); |
943 | if ( !remCh && ! locCh ) { | 945 | if ( !remCh && ! locCh ) { |
944 | //qDebug("both not changed "); | 946 | //qDebug("both not changed "); |
945 | lastSync = localMod.addDays(1); | 947 | lastSync = localMod.addDays(1); |
946 | if ( mode <= SYNC_PREF_ASK ) | 948 | if ( mode <= SYNC_PREF_ASK ) |
947 | return 0; | 949 | return 0; |
948 | } else { | 950 | } else { |
949 | if ( locCh ) { | 951 | if ( locCh ) { |
950 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 952 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
951 | lastSync = localMod.addDays( -1 ); | 953 | lastSync = localMod.addDays( -1 ); |
952 | if ( !remCh ) | 954 | if ( !remCh ) |
953 | remoteMod = ( lastSync.addDays( -1 ) ); | 955 | remoteMod = ( lastSync.addDays( -1 ) ); |
954 | } else { | 956 | } else { |
955 | //qDebug(" not loc changed "); | 957 | //qDebug(" not loc changed "); |
956 | lastSync = localMod.addDays( 1 ); | 958 | lastSync = localMod.addDays( 1 ); |
957 | if ( remCh ) | 959 | if ( remCh ) |
958 | remoteMod =( lastSync.addDays( 1 ) ); | 960 | remoteMod =( lastSync.addDays( 1 ) ); |
959 | 961 | ||
960 | } | 962 | } |
961 | } | 963 | } |
962 | full = true; | 964 | full = true; |
963 | if ( mode < SYNC_PREF_ASK ) | 965 | if ( mode < SYNC_PREF_ASK ) |
964 | mode = SYNC_PREF_ASK; | 966 | mode = SYNC_PREF_ASK; |
965 | } else { | 967 | } else { |
966 | if ( localMod == remoteMod ) | 968 | if ( localMod == remoteMod ) |
967 | // if ( local->revision() == remote->revision() ) | 969 | // if ( local->revision() == remote->revision() ) |
968 | return 0; | 970 | return 0; |
969 | 971 | ||
970 | } | 972 | } |
971 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 973 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
972 | 974 | ||
973 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 975 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
974 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 976 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
975 | //full = true; //debug only | 977 | //full = true; //debug only |
976 | if ( full ) { | 978 | if ( full ) { |
977 | bool equ = false; | 979 | bool equ = false; |
978 | if ( local->typeID() == eventID ) { | 980 | if ( local->typeID() == eventID ) { |
979 | equ = (*((Event*) local) == *((Event*) remote)); | 981 | equ = (*((Event*) local) == *((Event*) remote)); |
980 | } | 982 | } |
981 | else if ( local->typeID() == todoID ) | 983 | else if ( local->typeID() == todoID ) |
982 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 984 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
983 | else if ( local->typeID() == journalID ) | 985 | else if ( local->typeID() == journalID ) |
984 | equ = (*((Journal*) local) == *((Journal*) remote)); | 986 | equ = (*((Journal*) local) == *((Journal*) remote)); |
985 | if ( equ ) { | 987 | if ( equ ) { |
986 | //qDebug("equal "); | 988 | //qDebug("equal "); |
987 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 989 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
988 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 990 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
989 | } | 991 | } |
990 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 992 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
991 | return 0; | 993 | return 0; |
992 | 994 | ||
993 | }//else //debug only | 995 | }//else //debug only |
994 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 996 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
995 | } | 997 | } |
996 | int result; | 998 | int result; |
997 | bool localIsNew; | 999 | bool localIsNew; |
998 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1000 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
999 | 1001 | ||
1000 | 1002 | ||
1001 | // ************************************************ | 1003 | // ************************************************ |
1002 | // ************************************************ | 1004 | // ************************************************ |
1003 | // ************************************************ | 1005 | // ************************************************ |
1004 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1006 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1005 | // BUT remoteMod != localMod | 1007 | // BUT remoteMod != localMod |
1006 | 1008 | ||
1007 | 1009 | ||
1008 | if ( full && mode < SYNC_PREF_NEWEST ) | 1010 | if ( full && mode < SYNC_PREF_NEWEST ) |
1009 | mode = SYNC_PREF_ASK; | 1011 | mode = SYNC_PREF_ASK; |
1010 | 1012 | ||
1011 | switch( mode ) { | 1013 | switch( mode ) { |
1012 | case SYNC_PREF_LOCAL: | 1014 | case SYNC_PREF_LOCAL: |
1013 | if ( lastSync > remoteMod ) | 1015 | if ( lastSync > remoteMod ) |
1014 | return 1; | 1016 | return 1; |
1015 | if ( lastSync > localMod ) | 1017 | if ( lastSync > localMod ) |
1016 | return 2; | 1018 | return 2; |
1017 | return 1; | 1019 | return 1; |
1018 | break; | 1020 | break; |
1019 | case SYNC_PREF_REMOTE: | 1021 | case SYNC_PREF_REMOTE: |
1020 | if ( lastSync > localMod ) | 1022 | if ( lastSync > localMod ) |
1021 | return 2; | 1023 | return 2; |
1022 | if ( lastSync > remoteMod ) | 1024 | if ( lastSync > remoteMod ) |
1023 | return 1; | 1025 | return 1; |
1024 | return 2; | 1026 | return 2; |
1025 | break; | 1027 | break; |
1026 | case SYNC_PREF_NEWEST: | 1028 | case SYNC_PREF_NEWEST: |
1027 | if ( localMod >= remoteMod ) | 1029 | if ( localMod >= remoteMod ) |
1028 | return 1; | 1030 | return 1; |
1029 | else | 1031 | else |
1030 | return 2; | 1032 | return 2; |
1031 | break; | 1033 | break; |
1032 | case SYNC_PREF_ASK: | 1034 | case SYNC_PREF_ASK: |
1033 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1035 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1034 | if ( lastSync > remoteMod && lastSync > localMod) | 1036 | if ( lastSync > remoteMod && lastSync > localMod) |
1035 | return 0; | 1037 | return 0; |
1036 | if ( lastSync > remoteMod ) | 1038 | if ( lastSync > remoteMod ) |
1037 | return 1; | 1039 | return 1; |
1038 | if ( lastSync > localMod ) | 1040 | if ( lastSync > localMod ) |
1039 | return 2; | 1041 | return 2; |
1040 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1042 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1041 | localIsNew = localMod >= remoteMod; | 1043 | localIsNew = localMod >= remoteMod; |
1042 | if ( localIsNew ) | 1044 | if ( localIsNew ) |
1043 | getEventViewerDialog()->setColorMode( 1 ); | 1045 | getEventViewerDialog()->setColorMode( 1 ); |
1044 | else | 1046 | else |
1045 | getEventViewerDialog()->setColorMode( 2 ); | 1047 | getEventViewerDialog()->setColorMode( 2 ); |
1046 | getEventViewerDialog()->setIncidence(local); | 1048 | getEventViewerDialog()->setIncidence(local); |
1047 | if ( localIsNew ) | 1049 | if ( localIsNew ) |
1048 | getEventViewerDialog()->setColorMode( 2 ); | 1050 | getEventViewerDialog()->setColorMode( 2 ); |
1049 | else | 1051 | else |
1050 | getEventViewerDialog()->setColorMode( 1 ); | 1052 | getEventViewerDialog()->setColorMode( 1 ); |
1051 | getEventViewerDialog()->addIncidence(remote); | 1053 | getEventViewerDialog()->addIncidence(remote); |
1052 | getEventViewerDialog()->setColorMode( 0 ); | 1054 | getEventViewerDialog()->setColorMode( 0 ); |
1053 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1055 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1054 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1056 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1055 | getEventViewerDialog()->showMe(); | 1057 | getEventViewerDialog()->showMe(); |
1056 | result = getEventViewerDialog()->executeS( localIsNew ); | 1058 | result = getEventViewerDialog()->executeS( localIsNew ); |
1057 | return result; | 1059 | return result; |
1058 | 1060 | ||
1059 | break; | 1061 | break; |
1060 | case SYNC_PREF_FORCE_LOCAL: | 1062 | case SYNC_PREF_FORCE_LOCAL: |
1061 | return 1; | 1063 | return 1; |
1062 | break; | 1064 | break; |
1063 | case SYNC_PREF_FORCE_REMOTE: | 1065 | case SYNC_PREF_FORCE_REMOTE: |
1064 | return 2; | 1066 | return 2; |
1065 | break; | 1067 | break; |
1066 | 1068 | ||
1067 | default: | 1069 | default: |
1068 | // SYNC_PREF_TAKE_BOTH not implemented | 1070 | // SYNC_PREF_TAKE_BOTH not implemented |
1069 | break; | 1071 | break; |
1070 | } | 1072 | } |
1071 | return 0; | 1073 | return 0; |
1072 | } | 1074 | } |
1073 | Event* CalendarView::getLastSyncEvent() | 1075 | Event* CalendarView::getLastSyncEvent() |
1074 | { | 1076 | { |
1075 | Event* lse; | 1077 | Event* lse; |
1076 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1078 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1077 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1079 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1078 | if (!lse) { | 1080 | if (!lse) { |
1079 | lse = new Event(); | 1081 | lse = new Event(); |
1080 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1082 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1081 | QString sum = ""; | 1083 | QString sum = ""; |
1082 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1084 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1083 | sum = "E: "; | 1085 | sum = "E: "; |
1084 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1086 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1085 | lse->setDtStart( mLastCalendarSync ); | 1087 | lse->setDtStart( mLastCalendarSync ); |
1086 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1088 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1087 | lse->setCategories( i18n("SyncEvent") ); | 1089 | lse->setCategories( i18n("SyncEvent") ); |
1088 | lse->setReadOnly( true ); | 1090 | lse->setReadOnly( true ); |
1089 | mCalendar->addEvent( lse ); | 1091 | mCalendar->addEvent( lse ); |
1090 | } | 1092 | } |
1091 | 1093 | ||
1092 | return lse; | 1094 | return lse; |
1093 | 1095 | ||
1094 | } | 1096 | } |
1095 | 1097 | ||
1096 | // we check, if the to delete event has a id for a profile | 1098 | // we check, if the to delete event has a id for a profile |
1097 | // if yes, we set this id in the profile to delete | 1099 | // if yes, we set this id in the profile to delete |
1098 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1100 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1099 | { | 1101 | { |
1100 | if ( lastSync.count() == 0 ) { | 1102 | if ( lastSync.count() == 0 ) { |
1101 | //qDebug(" lastSync.count() == 0"); | 1103 | //qDebug(" lastSync.count() == 0"); |
1102 | return; | 1104 | return; |
1103 | } | 1105 | } |
1104 | if ( toDelete->typeID() == journalID ) | 1106 | if ( toDelete->typeID() == journalID ) |
1105 | return; | 1107 | return; |
1106 | 1108 | ||
1107 | Event* eve = lastSync.first(); | 1109 | Event* eve = lastSync.first(); |
1108 | 1110 | ||
1109 | while ( eve ) { | 1111 | while ( eve ) { |
1110 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1112 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1111 | if ( !id.isEmpty() ) { | 1113 | if ( !id.isEmpty() ) { |
1112 | QString des = eve->description(); | 1114 | QString des = eve->description(); |
1113 | QString pref = "e"; | 1115 | QString pref = "e"; |
1114 | if ( toDelete->typeID() == todoID ) | 1116 | if ( toDelete->typeID() == todoID ) |
1115 | pref = "t"; | 1117 | pref = "t"; |
1116 | des += pref+ id + ","; | 1118 | des += pref+ id + ","; |
1117 | eve->setReadOnly( false ); | 1119 | eve->setReadOnly( false ); |
1118 | eve->setDescription( des ); | 1120 | eve->setDescription( des ); |
1119 | //qDebug("setdes %s ", des.latin1()); | 1121 | //qDebug("setdes %s ", des.latin1()); |
1120 | eve->setReadOnly( true ); | 1122 | eve->setReadOnly( true ); |
1121 | } | 1123 | } |
1122 | eve = lastSync.next(); | 1124 | eve = lastSync.next(); |
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | } | 1127 | } |
1126 | void CalendarView::checkExternalId( Incidence * inc ) | 1128 | void CalendarView::checkExternalId( Incidence * inc ) |
1127 | { | 1129 | { |
1128 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1130 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1129 | checkExternSyncEvent( lastSync, inc ); | 1131 | checkExternSyncEvent( lastSync, inc ); |
1130 | 1132 | ||
1131 | } | 1133 | } |
1132 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1134 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1133 | { | 1135 | { |
1134 | bool syncOK = true; | 1136 | bool syncOK = true; |
1135 | int addedEvent = 0; | 1137 | int addedEvent = 0; |
1136 | int addedEventR = 0; | 1138 | int addedEventR = 0; |
1137 | int deletedEventR = 0; | 1139 | int deletedEventR = 0; |
1138 | int deletedEventL = 0; | 1140 | int deletedEventL = 0; |
1139 | int changedLocal = 0; | 1141 | int changedLocal = 0; |
1140 | int changedRemote = 0; | 1142 | int changedRemote = 0; |
1141 | int filteredIN = 0; | 1143 | int filteredIN = 0; |
1142 | int filteredOUT = 0; | 1144 | int filteredOUT = 0; |
1143 | //QPtrList<Event> el = local->rawEvents(); | 1145 | //QPtrList<Event> el = local->rawEvents(); |
1144 | Event* eventR; | 1146 | Event* eventR; |
1145 | QString uid; | 1147 | QString uid; |
1146 | int take; | 1148 | int take; |
1147 | Event* eventL; | 1149 | Event* eventL; |
1148 | Event* eventRSync; | 1150 | Event* eventRSync; |
1149 | Event* eventLSync; | 1151 | Event* eventLSync; |
1150 | clearAllViews(); | 1152 | clearAllViews(); |
1151 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1153 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1152 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1154 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1153 | bool fullDateRange = false; | 1155 | bool fullDateRange = false; |
1154 | local->resetTempSyncStat(); | 1156 | local->resetTempSyncStat(); |
1155 | mLastCalendarSync = QDateTime::currentDateTime(); | 1157 | mLastCalendarSync = QDateTime::currentDateTime(); |
1156 | if ( mSyncManager->syncWithDesktop() ) { | 1158 | if ( mSyncManager->syncWithDesktop() ) { |
1157 | remote->resetPilotStat(1); | 1159 | remote->resetPilotStat(1); |
1158 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1160 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1159 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1161 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1160 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1162 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1161 | } else { | 1163 | } else { |
1162 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1164 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1163 | } | 1165 | } |
1164 | } | 1166 | } |
1165 | QDateTime modifiedCalendar = mLastCalendarSync; | 1167 | QDateTime modifiedCalendar = mLastCalendarSync; |
1166 | eventLSync = getLastSyncEvent(); | 1168 | eventLSync = getLastSyncEvent(); |
1167 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1169 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1168 | if ( eventR ) { | 1170 | if ( eventR ) { |
1169 | eventRSync = (Event*) eventR->clone(); | 1171 | eventRSync = (Event*) eventR->clone(); |
1170 | remote->deleteEvent(eventR ); | 1172 | remote->deleteEvent(eventR ); |
1171 | 1173 | ||
1172 | } else { | 1174 | } else { |
1173 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1175 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1174 | eventRSync = (Event*)eventLSync->clone(); | 1176 | eventRSync = (Event*)eventLSync->clone(); |
1175 | } else { | 1177 | } else { |
1176 | fullDateRange = true; | 1178 | fullDateRange = true; |
1177 | eventRSync = new Event(); | 1179 | eventRSync = new Event(); |
1178 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1180 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1179 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1181 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1183 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1182 | eventRSync->setCategories( i18n("SyncEvent") ); | 1184 | eventRSync->setCategories( i18n("SyncEvent") ); |
1183 | } | 1185 | } |
1184 | } | 1186 | } |
1185 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1187 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1186 | fullDateRange = true; | 1188 | fullDateRange = true; |
1187 | 1189 | ||
1188 | if ( ! fullDateRange ) { | 1190 | if ( ! fullDateRange ) { |
1189 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1191 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1190 | 1192 | ||
1191 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1193 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1192 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1194 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1193 | fullDateRange = true; | 1195 | fullDateRange = true; |
1194 | } | 1196 | } |
1195 | } | 1197 | } |
1196 | if ( mSyncManager->syncWithDesktop() ) { | 1198 | if ( mSyncManager->syncWithDesktop() ) { |
1197 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1199 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1198 | } | 1200 | } |
1199 | if ( fullDateRange ) | 1201 | if ( fullDateRange ) |
1200 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1202 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1201 | else | 1203 | else |
1202 | mLastCalendarSync = eventLSync->dtStart(); | 1204 | mLastCalendarSync = eventLSync->dtStart(); |
1203 | // for resyncing if own file has changed | 1205 | // for resyncing if own file has changed |
1204 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1206 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1205 | mLastCalendarSync = loadedFileVersion; | 1207 | mLastCalendarSync = loadedFileVersion; |
1206 | //qDebug("setting mLastCalendarSync "); | 1208 | //qDebug("setting mLastCalendarSync "); |
1207 | } | 1209 | } |
1208 | //qDebug("*************************** "); | 1210 | //qDebug("*************************** "); |
1209 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1211 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1210 | QPtrList<Incidence> er = remote->rawIncidences(); | 1212 | QPtrList<Incidence> er = remote->rawIncidences(); |
1211 | Incidence* inR = er.first(); | 1213 | Incidence* inR = er.first(); |
1212 | Incidence* inL; | 1214 | Incidence* inL; |
1213 | QProgressBar bar( er.count(),0 ); | 1215 | QProgressBar bar( er.count(),0 ); |
1214 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1216 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1215 | 1217 | ||
1216 | // ************** setting up filter ************* | 1218 | // ************** setting up filter ************* |
1217 | CalFilter *filterIN = 0; | 1219 | CalFilter *filterIN = 0; |
1218 | CalFilter *filterOUT = 0; | 1220 | CalFilter *filterOUT = 0; |
1219 | CalFilter *filter = mFilters.first(); | 1221 | CalFilter *filter = mFilters.first(); |
1220 | while(filter) { | 1222 | while(filter) { |
1221 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1223 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1222 | filterIN = filter; | 1224 | filterIN = filter; |
1223 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1225 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1224 | filterOUT = filter; | 1226 | filterOUT = filter; |
1225 | filter = mFilters.next(); | 1227 | filter = mFilters.next(); |
1226 | } | 1228 | } |
1227 | int w = 300; | 1229 | int w = 300; |
1228 | if ( QApplication::desktop()->width() < 320 ) | 1230 | if ( QApplication::desktop()->width() < 320 ) |
1229 | w = 220; | 1231 | w = 220; |
1230 | int h = bar.sizeHint().height() ; | 1232 | int h = bar.sizeHint().height() ; |
1231 | int dw = QApplication::desktop()->width(); | 1233 | int dw = QApplication::desktop()->width(); |
1232 | int dh = QApplication::desktop()->height(); | 1234 | int dh = QApplication::desktop()->height(); |
1233 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1235 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1234 | bar.show(); | 1236 | bar.show(); |
1235 | int modulo = (er.count()/10)+1; | 1237 | int modulo = (er.count()/10)+1; |
1236 | int incCounter = 0; | 1238 | int incCounter = 0; |
1237 | while ( inR ) { | 1239 | while ( inR ) { |
1238 | if ( ! bar.isVisible() ) | 1240 | if ( ! bar.isVisible() ) |
1239 | return false; | 1241 | return false; |
1240 | if ( incCounter % modulo == 0 ) | 1242 | if ( incCounter % modulo == 0 ) |
1241 | bar.setProgress( incCounter ); | 1243 | bar.setProgress( incCounter ); |
1242 | ++incCounter; | 1244 | ++incCounter; |
1243 | uid = inR->uid(); | 1245 | uid = inR->uid(); |
1244 | bool skipIncidence = false; | 1246 | bool skipIncidence = false; |
1245 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1247 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1246 | skipIncidence = true; | 1248 | skipIncidence = true; |
1247 | QString idS; | 1249 | QString idS; |
1248 | qApp->processEvents(); | 1250 | qApp->processEvents(); |
1249 | if ( !skipIncidence ) { | 1251 | if ( !skipIncidence ) { |
1250 | inL = local->incidence( uid ); | 1252 | inL = local->incidence( uid ); |
1251 | if ( inL ) { // maybe conflict - same uid in both calendars | 1253 | if ( inL ) { // maybe conflict - same uid in both calendars |
1252 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1254 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1253 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1255 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1254 | if ( take == 3 ) | 1256 | if ( take == 3 ) |
1255 | return false; | 1257 | return false; |
1256 | if ( take == 1 ) {// take local ********************** | 1258 | if ( take == 1 ) {// take local ********************** |
1257 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1259 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1258 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1260 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1259 | else | 1261 | else |
1260 | idS = inR->IDStr(); | 1262 | idS = inR->IDStr(); |
1261 | remote->deleteIncidence( inR ); | 1263 | remote->deleteIncidence( inR ); |
1262 | inR = inL->clone(); | 1264 | inR = inL->clone(); |
1263 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1265 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1264 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1266 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1265 | inR->setIDStr( idS ); | 1267 | inR->setIDStr( idS ); |
1266 | remote->addIncidence( inR ); | 1268 | remote->addIncidence( inR ); |
1267 | if ( mSyncManager->syncWithDesktop() ) | 1269 | if ( mSyncManager->syncWithDesktop() ) |
1268 | inR->setPilotId( 2 ); | 1270 | inR->setPilotId( 2 ); |
1269 | ++changedRemote; | 1271 | ++changedRemote; |
1270 | } else {// take remote ********************** | 1272 | } else {// take remote ********************** |
1271 | idS = inL->IDStr(); | 1273 | idS = inL->IDStr(); |
1272 | int pid = inL->pilotId(); | 1274 | int pid = inL->pilotId(); |
1273 | local->deleteIncidence( inL ); | 1275 | local->deleteIncidence( inL ); |
1274 | inL = inR->clone(); | 1276 | inL = inR->clone(); |
1275 | if ( mSyncManager->syncWithDesktop() ) | 1277 | if ( mSyncManager->syncWithDesktop() ) |
1276 | inL->setPilotId( pid ); | 1278 | inL->setPilotId( pid ); |
1277 | inL->setIDStr( idS ); | 1279 | inL->setIDStr( idS ); |
1278 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1280 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1279 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1281 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1280 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1282 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1281 | } | 1283 | } |
1282 | local->addIncidence( inL ); | 1284 | local->addIncidence( inL ); |
1283 | ++changedLocal; | 1285 | ++changedLocal; |
1284 | } | 1286 | } |
1285 | } | 1287 | } |
1286 | } else { // no conflict ********** add or delete remote | 1288 | } else { // no conflict ********** add or delete remote |
1287 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1289 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1288 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1290 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1289 | QString des = eventLSync->description(); | 1291 | QString des = eventLSync->description(); |
1290 | QString pref = "e"; | 1292 | QString pref = "e"; |
1291 | if ( inR->typeID() == todoID ) | 1293 | if ( inR->typeID() == todoID ) |
1292 | pref = "t"; | 1294 | pref = "t"; |
1293 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1295 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1294 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1296 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1295 | //remote->deleteIncidence( inR ); | 1297 | //remote->deleteIncidence( inR ); |
1296 | ++deletedEventR; | 1298 | ++deletedEventR; |
1297 | } else { | 1299 | } else { |
1298 | inR->setLastModified( modifiedCalendar ); | 1300 | inR->setLastModified( modifiedCalendar ); |
1299 | inL = inR->clone(); | 1301 | inL = inR->clone(); |
1300 | inL->setIDStr( ":" ); | 1302 | inL->setIDStr( ":" ); |
1301 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1303 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1302 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1304 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1303 | local->addIncidence( inL ); | 1305 | local->addIncidence( inL ); |
1304 | ++addedEvent; | 1306 | ++addedEvent; |
1305 | 1307 | ||
1306 | } | 1308 | } |
1307 | } else { | 1309 | } else { |
1308 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1310 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1309 | inR->setLastModified( modifiedCalendar ); | 1311 | inR->setLastModified( modifiedCalendar ); |
1310 | inL = inR->clone(); | 1312 | inL = inR->clone(); |
1311 | inL->setIDStr( ":" ); | 1313 | inL->setIDStr( ":" ); |
1312 | local->addIncidence( inL ); | 1314 | local->addIncidence( inL ); |
1313 | ++addedEvent; | 1315 | ++addedEvent; |
1314 | 1316 | ||
1315 | } else { | 1317 | } else { |
1316 | checkExternSyncEvent(eventRSyncSharp, inR); | 1318 | checkExternSyncEvent(eventRSyncSharp, inR); |
1317 | remote->deleteIncidence( inR ); | 1319 | remote->deleteIncidence( inR ); |
1318 | ++deletedEventR; | 1320 | ++deletedEventR; |
1319 | } | 1321 | } |
1320 | } | 1322 | } |
1321 | } else { | 1323 | } else { |
1322 | ++filteredIN; | 1324 | ++filteredIN; |
1323 | } | 1325 | } |
1324 | } | 1326 | } |
1325 | } | 1327 | } |
1326 | inR = er.next(); | 1328 | inR = er.next(); |
1327 | } | 1329 | } |
1328 | QPtrList<Incidence> el = local->rawIncidences(); | 1330 | QPtrList<Incidence> el = local->rawIncidences(); |
1329 | inL = el.first(); | 1331 | inL = el.first(); |
1330 | modulo = (el.count()/10)+1; | 1332 | modulo = (el.count()/10)+1; |
1331 | bar.setCaption (i18n("Add / remove events") ); | 1333 | bar.setCaption (i18n("Add / remove events") ); |
1332 | bar.setTotalSteps ( el.count() ) ; | 1334 | bar.setTotalSteps ( el.count() ) ; |
1333 | bar.show(); | 1335 | bar.show(); |
1334 | incCounter = 0; | 1336 | incCounter = 0; |
1335 | 1337 | ||
1336 | while ( inL ) { | 1338 | while ( inL ) { |
1337 | 1339 | ||
1338 | qApp->processEvents(); | 1340 | qApp->processEvents(); |
1339 | if ( ! bar.isVisible() ) | 1341 | if ( ! bar.isVisible() ) |
1340 | return false; | 1342 | return false; |
1341 | if ( incCounter % modulo == 0 ) | 1343 | if ( incCounter % modulo == 0 ) |
1342 | bar.setProgress( incCounter ); | 1344 | bar.setProgress( incCounter ); |
1343 | ++incCounter; | 1345 | ++incCounter; |
1344 | uid = inL->uid(); | 1346 | uid = inL->uid(); |
1345 | bool skipIncidence = false; | 1347 | bool skipIncidence = false; |
1346 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1348 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1347 | skipIncidence = true; | 1349 | skipIncidence = true; |
1348 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1350 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1349 | skipIncidence = true; | 1351 | skipIncidence = true; |
1350 | if ( !skipIncidence ) { | 1352 | if ( !skipIncidence ) { |
1351 | inR = remote->incidence( uid ); | 1353 | inR = remote->incidence( uid ); |
1352 | if ( ! inR ) { | 1354 | if ( ! inR ) { |
1353 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1355 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1354 | // no conflict ********** add or delete local | 1356 | // no conflict ********** add or delete local |
1355 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1357 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1356 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1358 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1357 | checkExternSyncEvent(eventLSyncSharp, inL); | 1359 | checkExternSyncEvent(eventLSyncSharp, inL); |
1358 | local->deleteIncidence( inL ); | 1360 | local->deleteIncidence( inL ); |
1359 | ++deletedEventL; | 1361 | ++deletedEventL; |
1360 | } else { | 1362 | } else { |
1361 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1363 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1362 | inL->removeID(mCurrentSyncDevice ); | 1364 | inL->removeID(mCurrentSyncDevice ); |
1363 | ++addedEventR; | 1365 | ++addedEventR; |
1364 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1366 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1365 | inL->setLastModified( modifiedCalendar ); | 1367 | inL->setLastModified( modifiedCalendar ); |
1366 | inR = inL->clone(); | 1368 | inR = inL->clone(); |
1367 | inR->setIDStr( ":" ); | 1369 | inR->setIDStr( ":" ); |
1368 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1370 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1369 | remote->addIncidence( inR ); | 1371 | remote->addIncidence( inR ); |
1370 | } | 1372 | } |
1371 | } | 1373 | } |
1372 | } else { | 1374 | } else { |
1373 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1375 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1374 | checkExternSyncEvent(eventLSyncSharp, inL); | 1376 | checkExternSyncEvent(eventLSyncSharp, inL); |
1375 | local->deleteIncidence( inL ); | 1377 | local->deleteIncidence( inL ); |
1376 | ++deletedEventL; | 1378 | ++deletedEventL; |
1377 | } else { | 1379 | } else { |
1378 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1380 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1379 | ++addedEventR; | 1381 | ++addedEventR; |
1380 | inL->setLastModified( modifiedCalendar ); | 1382 | inL->setLastModified( modifiedCalendar ); |
1381 | inR = inL->clone(); | 1383 | inR = inL->clone(); |
1382 | inR->setIDStr( ":" ); | 1384 | inR->setIDStr( ":" ); |
1383 | remote->addIncidence( inR ); | 1385 | remote->addIncidence( inR ); |
1384 | } | 1386 | } |
1385 | } | 1387 | } |
1386 | } | 1388 | } |
1387 | } else { | 1389 | } else { |
1388 | ++filteredOUT; | 1390 | ++filteredOUT; |
1389 | } | 1391 | } |
1390 | } | 1392 | } |
1391 | } | 1393 | } |
1392 | inL = el.next(); | 1394 | inL = el.next(); |
1393 | } | 1395 | } |
1394 | int delFut = 0; | 1396 | int delFut = 0; |
1395 | int remRem = 0; | 1397 | int remRem = 0; |
1396 | if ( mSyncManager->mWriteBackInFuture ) { | 1398 | if ( mSyncManager->mWriteBackInFuture ) { |
1397 | er = remote->rawIncidences(); | 1399 | er = remote->rawIncidences(); |
1398 | remRem = er.count(); | 1400 | remRem = er.count(); |
1399 | inR = er.first(); | 1401 | inR = er.first(); |
1400 | QDateTime dt; | 1402 | QDateTime dt; |
1401 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1403 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1402 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1404 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1403 | while ( inR ) { | 1405 | while ( inR ) { |
1404 | if ( inR->typeID() == todoID ) { | 1406 | if ( inR->typeID() == todoID ) { |
1405 | Todo * t = (Todo*)inR; | 1407 | Todo * t = (Todo*)inR; |
1406 | if ( t->hasDueDate() ) | 1408 | if ( t->hasDueDate() ) |
1407 | dt = t->dtDue(); | 1409 | dt = t->dtDue(); |
1408 | else | 1410 | else |
1409 | dt = cur.addSecs( 62 ); | 1411 | dt = cur.addSecs( 62 ); |
1410 | } | 1412 | } |
1411 | else if (inR->typeID() == eventID ) { | 1413 | else if (inR->typeID() == eventID ) { |
1412 | bool ok; | 1414 | bool ok; |
1413 | dt = inR->getNextOccurence( cur, &ok ); | 1415 | dt = inR->getNextOccurence( cur, &ok ); |
1414 | if ( !ok ) | 1416 | if ( !ok ) |
1415 | dt = cur.addSecs( -62 ); | 1417 | dt = cur.addSecs( -62 ); |
1416 | } | 1418 | } |
1417 | else | 1419 | else |
1418 | dt = inR->dtStart(); | 1420 | dt = inR->dtStart(); |
1419 | if ( dt < cur || dt > end ) { | 1421 | if ( dt < cur || dt > end ) { |
1420 | remote->deleteIncidence( inR ); | 1422 | remote->deleteIncidence( inR ); |
1421 | ++delFut; | 1423 | ++delFut; |
1422 | } | 1424 | } |
1423 | inR = er.next(); | 1425 | inR = er.next(); |
1424 | } | 1426 | } |
1425 | } | 1427 | } |
1426 | bar.hide(); | 1428 | bar.hide(); |
1427 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1429 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1428 | eventLSync->setReadOnly( false ); | 1430 | eventLSync->setReadOnly( false ); |
1429 | eventLSync->setDtStart( mLastCalendarSync ); | 1431 | eventLSync->setDtStart( mLastCalendarSync ); |
1430 | eventRSync->setDtStart( mLastCalendarSync ); | 1432 | eventRSync->setDtStart( mLastCalendarSync ); |
1431 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1433 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1432 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1434 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1433 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1435 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1434 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1436 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1435 | eventLSync->setReadOnly( true ); | 1437 | eventLSync->setReadOnly( true ); |
1436 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1438 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1437 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1439 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1438 | remote->addEvent( eventRSync ); | 1440 | remote->addEvent( eventRSync ); |
1439 | else | 1441 | else |
1440 | delete eventRSync; | 1442 | delete eventRSync; |
1441 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1443 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1442 | QString mes; | 1444 | QString mes; |
1443 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1445 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1444 | QString delmess; | 1446 | QString delmess; |
1445 | if ( delFut ) { | 1447 | if ( delFut ) { |
1446 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1448 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1447 | mes += delmess; | 1449 | mes += delmess; |
1448 | } | 1450 | } |
1449 | mes = i18n("Local calendar changed!\n") +mes; | 1451 | mes = i18n("Local calendar changed!\n") +mes; |
1450 | mCalendar->checkAlarmForIncidence( 0, true ); | 1452 | mCalendar->checkAlarmForIncidence( 0, true ); |
1451 | qDebug( mes ); | 1453 | qDebug( mes ); |
1452 | if ( mSyncManager->mShowSyncSummary ) { | 1454 | if ( mSyncManager->mShowSyncSummary ) { |
1453 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1455 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1454 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1456 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1455 | qDebug("KO: WB cancelled "); | 1457 | qDebug("KO: WB cancelled "); |
1456 | mSyncManager->mWriteBackFile = false; | 1458 | mSyncManager->mWriteBackFile = false; |
1457 | return syncOK; | 1459 | return syncOK; |
1458 | } | 1460 | } |
1459 | } | 1461 | } |
1460 | return syncOK; | 1462 | return syncOK; |
1461 | } | 1463 | } |
1462 | 1464 | ||
1463 | void CalendarView::setSyncDevice( QString s ) | 1465 | void CalendarView::setSyncDevice( QString s ) |
1464 | { | 1466 | { |
1465 | mCurrentSyncDevice= s; | 1467 | mCurrentSyncDevice= s; |
1466 | } | 1468 | } |
1467 | void CalendarView::setSyncName( QString s ) | 1469 | void CalendarView::setSyncName( QString s ) |
1468 | { | 1470 | { |
1469 | mCurrentSyncName= s; | 1471 | mCurrentSyncName= s; |
1470 | } | 1472 | } |
1471 | bool CalendarView::syncCalendar(QString filename, int mode) | 1473 | bool CalendarView::syncCalendar(QString filename, int mode) |
1472 | { | 1474 | { |
1473 | //qDebug("syncCalendar %s ", filename.latin1()); | 1475 | //qDebug("syncCalendar %s ", filename.latin1()); |
1474 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1476 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1475 | CalendarLocal* calendar = new CalendarLocal(); | 1477 | CalendarLocal* calendar = new CalendarLocal(); |
1476 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1478 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1477 | FileStorage* storage = new FileStorage( calendar ); | 1479 | FileStorage* storage = new FileStorage( calendar ); |
1478 | bool syncOK = false; | 1480 | bool syncOK = false; |
1479 | storage->setFileName( filename ); | 1481 | storage->setFileName( filename ); |
1480 | // qDebug("loading ... "); | 1482 | // qDebug("loading ... "); |
1481 | if ( storage->load() ) { | 1483 | if ( storage->load() ) { |
1482 | getEventViewerDialog()->setSyncMode( true ); | 1484 | getEventViewerDialog()->setSyncMode( true ); |
1483 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1485 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1484 | getEventViewerDialog()->setSyncMode( false ); | 1486 | getEventViewerDialog()->setSyncMode( false ); |
1485 | if ( syncOK ) { | 1487 | if ( syncOK ) { |
1486 | if ( mSyncManager->mWriteBackFile ) | 1488 | if ( mSyncManager->mWriteBackFile ) |
1487 | { | 1489 | { |
1488 | storage->setSaveFormat( new ICalFormat() ); | 1490 | storage->setSaveFormat( new ICalFormat() ); |
1489 | storage->save(); | 1491 | storage->save(); |
1490 | } | 1492 | } |
1491 | } | 1493 | } |
1492 | setModified( true ); | 1494 | setModified( true ); |
1493 | } | 1495 | } |
1494 | delete storage; | 1496 | delete storage; |
1495 | delete calendar; | 1497 | delete calendar; |
1496 | if ( syncOK ) | 1498 | if ( syncOK ) |
1497 | updateView(); | 1499 | updateView(); |
1498 | return syncOK; | 1500 | return syncOK; |
1499 | } | 1501 | } |
1500 | 1502 | ||
1501 | void CalendarView::syncExternal( int mode ) | 1503 | void CalendarView::syncExternal( int mode ) |
1502 | { | 1504 | { |
1503 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1505 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1504 | 1506 | ||
1505 | qApp->processEvents(); | 1507 | qApp->processEvents(); |
1506 | CalendarLocal* calendar = new CalendarLocal(); | 1508 | CalendarLocal* calendar = new CalendarLocal(); |
1507 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1509 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1508 | bool syncOK = false; | 1510 | bool syncOK = false; |
1509 | bool loadSuccess = false; | 1511 | bool loadSuccess = false; |
1510 | PhoneFormat* phoneFormat = 0; | 1512 | PhoneFormat* phoneFormat = 0; |
1511 | emit tempDisableBR(true); | 1513 | emit tempDisableBR(true); |
1512 | #ifndef DESKTOP_VERSION | 1514 | #ifndef DESKTOP_VERSION |
1513 | SharpFormat* sharpFormat = 0; | 1515 | SharpFormat* sharpFormat = 0; |
1514 | if ( mode == 0 ) { // sharp | 1516 | if ( mode == 0 ) { // sharp |
1515 | sharpFormat = new SharpFormat () ; | 1517 | sharpFormat = new SharpFormat () ; |
1516 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1518 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1517 | 1519 | ||
1518 | } else | 1520 | } else |
1519 | #endif | 1521 | #endif |
1520 | if ( mode == 1 ) { // phone | 1522 | if ( mode == 1 ) { // phone |
1521 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1523 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1522 | mSyncManager->mPhoneDevice, | 1524 | mSyncManager->mPhoneDevice, |
1523 | mSyncManager->mPhoneConnection, | 1525 | mSyncManager->mPhoneConnection, |
1524 | mSyncManager->mPhoneModel); | 1526 | mSyncManager->mPhoneModel); |
1525 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1527 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1526 | 1528 | ||
1527 | } else { | 1529 | } else { |
1528 | emit tempDisableBR(false); | 1530 | emit tempDisableBR(false); |
1529 | return; | 1531 | return; |
1530 | } | 1532 | } |
1531 | if ( loadSuccess ) { | 1533 | if ( loadSuccess ) { |
1532 | getEventViewerDialog()->setSyncMode( true ); | 1534 | getEventViewerDialog()->setSyncMode( true ); |
1533 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1535 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1534 | getEventViewerDialog()->setSyncMode( false ); | 1536 | getEventViewerDialog()->setSyncMode( false ); |
1535 | qApp->processEvents(); | 1537 | qApp->processEvents(); |
1536 | if ( syncOK ) { | 1538 | if ( syncOK ) { |
1537 | if ( mSyncManager->mWriteBackFile ) | 1539 | if ( mSyncManager->mWriteBackFile ) |
1538 | { | 1540 | { |
1539 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1541 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1540 | Incidence* inc = iL.first(); | 1542 | Incidence* inc = iL.first(); |
1541 | if ( phoneFormat ) { | 1543 | if ( phoneFormat ) { |
1542 | while ( inc ) { | 1544 | while ( inc ) { |
1543 | inc->removeID(mCurrentSyncDevice); | 1545 | inc->removeID(mCurrentSyncDevice); |
1544 | inc = iL.next(); | 1546 | inc = iL.next(); |
1545 | } | 1547 | } |
1546 | } | 1548 | } |
1547 | #ifndef DESKTOP_VERSION | 1549 | #ifndef DESKTOP_VERSION |
1548 | if ( sharpFormat ) | 1550 | if ( sharpFormat ) |
1549 | sharpFormat->save(calendar); | 1551 | sharpFormat->save(calendar); |
1550 | #endif | 1552 | #endif |
1551 | if ( phoneFormat ) | 1553 | if ( phoneFormat ) |
1552 | phoneFormat->save(calendar); | 1554 | phoneFormat->save(calendar); |
1553 | iL = calendar->rawIncidences(); | 1555 | iL = calendar->rawIncidences(); |
1554 | inc = iL.first(); | 1556 | inc = iL.first(); |
1555 | Incidence* loc; | 1557 | Incidence* loc; |
1556 | while ( inc ) { | 1558 | while ( inc ) { |
1557 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1559 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1558 | loc = mCalendar->incidence(inc->uid() ); | 1560 | loc = mCalendar->incidence(inc->uid() ); |
1559 | if ( loc ) { | 1561 | if ( loc ) { |
1560 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1562 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1561 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1563 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1562 | } | 1564 | } |
1563 | } | 1565 | } |
1564 | inc = iL.next(); | 1566 | inc = iL.next(); |
1565 | } | 1567 | } |
1566 | Incidence* lse = getLastSyncEvent(); | 1568 | Incidence* lse = getLastSyncEvent(); |
1567 | if ( lse ) { | 1569 | if ( lse ) { |
1568 | lse->setReadOnly( false ); | 1570 | lse->setReadOnly( false ); |
1569 | lse->setDescription( "" ); | 1571 | lse->setDescription( "" ); |
1570 | lse->setReadOnly( true ); | 1572 | lse->setReadOnly( true ); |
1571 | } | 1573 | } |
1572 | } | 1574 | } |
1573 | } else { | 1575 | } else { |
1574 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1576 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1575 | } | 1577 | } |
1576 | setModified( true ); | 1578 | setModified( true ); |
1577 | } else { | 1579 | } else { |
1578 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1579 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1580 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1581 | 1583 | ||
1582 | } | 1584 | } |
1583 | delete calendar; | 1585 | delete calendar; |
1584 | updateView(); | 1586 | updateView(); |
1585 | emit tempDisableBR(false); | 1587 | emit tempDisableBR(false); |
1586 | return ;//syncOK; | 1588 | return ;//syncOK; |
1587 | 1589 | ||
1588 | } | 1590 | } |
1589 | 1591 | ||
1590 | bool CalendarView::importBday() | 1592 | bool CalendarView::importBday() |
1591 | { | 1593 | { |
1592 | #ifndef KORG_NOKABC | 1594 | #ifndef KORG_NOKABC |
1593 | 1595 | ||
1594 | #ifdef DESKTOP_VERSION | 1596 | #ifdef DESKTOP_VERSION |
1595 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1597 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1596 | KABC::AddressBook::Iterator it; | 1598 | KABC::AddressBook::Iterator it; |
1597 | int count = 0; | 1599 | int count = 0; |
1598 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1600 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1599 | ++count; | 1601 | ++count; |
1600 | } | 1602 | } |
1601 | QProgressBar bar(count,0 ); | 1603 | QProgressBar bar(count,0 ); |
1602 | int w = 300; | 1604 | int w = 300; |
1603 | if ( QApplication::desktop()->width() < 320 ) | 1605 | if ( QApplication::desktop()->width() < 320 ) |
1604 | w = 220; | 1606 | w = 220; |
1605 | int h = bar.sizeHint().height() ; | 1607 | int h = bar.sizeHint().height() ; |
1606 | int dw = QApplication::desktop()->width(); | 1608 | int dw = QApplication::desktop()->width(); |
1607 | int dh = QApplication::desktop()->height(); | 1609 | int dh = QApplication::desktop()->height(); |
1608 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1610 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1609 | bar.show(); | 1611 | bar.show(); |
1610 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1612 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1611 | qApp->processEvents(); | 1613 | qApp->processEvents(); |
1612 | count = 0; | 1614 | count = 0; |
1613 | int addCount = 0; | 1615 | int addCount = 0; |
1614 | KCal::Attendee* a = 0; | 1616 | KCal::Attendee* a = 0; |
1615 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1617 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1616 | if ( ! bar.isVisible() ) | 1618 | if ( ! bar.isVisible() ) |
1617 | return false; | 1619 | return false; |
1618 | bar.setProgress( count++ ); | 1620 | bar.setProgress( count++ ); |
1619 | qApp->processEvents(); | 1621 | qApp->processEvents(); |
1620 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1622 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1621 | if ( (*it).birthday().date().isValid() ){ | 1623 | if ( (*it).birthday().date().isValid() ){ |
1622 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1624 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1623 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1625 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1624 | ++addCount; | 1626 | ++addCount; |
1625 | } | 1627 | } |
1626 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1628 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1627 | if ( anni.isValid() ){ | 1629 | if ( anni.isValid() ){ |
1628 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1630 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1629 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1631 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1630 | ++addCount; | 1632 | ++addCount; |
1631 | } | 1633 | } |
1632 | } | 1634 | } |
1633 | updateView(); | 1635 | updateView(); |
1634 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1636 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1635 | #else //DESKTOP_VERSION | 1637 | #else //DESKTOP_VERSION |
1636 | 1638 | ||
1637 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1639 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1638 | // the result should now arrive through method insertBirthdays | 1640 | // the result should now arrive through method insertBirthdays |
1639 | 1641 | ||
1640 | #endif //DESKTOP_VERSION | 1642 | #endif //DESKTOP_VERSION |
1641 | 1643 | ||
1642 | #endif //KORG_NOKABC | 1644 | #endif //KORG_NOKABC |
1643 | 1645 | ||
1644 | 1646 | ||
1645 | return true; | 1647 | return true; |
1646 | } | 1648 | } |
1647 | 1649 | ||
1648 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1650 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1649 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1651 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1650 | const QStringList& anniversaryList, const QStringList& realNameList, | 1652 | const QStringList& anniversaryList, const QStringList& realNameList, |
1651 | const QStringList& emailList, const QStringList& assembledNameList, | 1653 | const QStringList& emailList, const QStringList& assembledNameList, |
1652 | const QStringList& uidList) | 1654 | const QStringList& uidList) |
1653 | { | 1655 | { |
1654 | //qDebug("KO::CalendarView::insertBirthdays"); | 1656 | //qDebug("KO::CalendarView::insertBirthdays"); |
1655 | if (uid == this->name()) | 1657 | if (uid == this->name()) |
1656 | { | 1658 | { |
1657 | int count = birthdayList.count(); | 1659 | int count = birthdayList.count(); |
1658 | int addCount = 0; | 1660 | int addCount = 0; |
1659 | KCal::Attendee* a = 0; | 1661 | KCal::Attendee* a = 0; |
1660 | 1662 | ||
1661 | //qDebug("CalView 1 %i", count); | 1663 | //qDebug("CalView 1 %i", count); |
1662 | 1664 | ||
1663 | QProgressBar bar(count,0 ); | 1665 | QProgressBar bar(count,0 ); |
1664 | int w = 300; | 1666 | int w = 300; |
1665 | if ( QApplication::desktop()->width() < 320 ) | 1667 | if ( QApplication::desktop()->width() < 320 ) |
1666 | w = 220; | 1668 | w = 220; |
1667 | int h = bar.sizeHint().height() ; | 1669 | int h = bar.sizeHint().height() ; |
1668 | int dw = QApplication::desktop()->width(); | 1670 | int dw = QApplication::desktop()->width(); |
1669 | int dh = QApplication::desktop()->height(); | 1671 | int dh = QApplication::desktop()->height(); |
1670 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1672 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1671 | bar.show(); | 1673 | bar.show(); |
1672 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1674 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1673 | qApp->processEvents(); | 1675 | qApp->processEvents(); |
1674 | 1676 | ||
1675 | QDate birthday; | 1677 | QDate birthday; |
1676 | QDate anniversary; | 1678 | QDate anniversary; |
1677 | QString realName; | 1679 | QString realName; |
1678 | QString email; | 1680 | QString email; |
1679 | QString assembledName; | 1681 | QString assembledName; |
1680 | QString uid; | 1682 | QString uid; |
1681 | bool ok = true; | 1683 | bool ok = true; |
1682 | for ( int i = 0; i < count; i++) | 1684 | for ( int i = 0; i < count; i++) |
1683 | { | 1685 | { |
1684 | if ( ! bar.isVisible() ) | 1686 | if ( ! bar.isVisible() ) |
1685 | return; | 1687 | return; |
1686 | bar.setProgress( i ); | 1688 | bar.setProgress( i ); |
1687 | qApp->processEvents(); | 1689 | qApp->processEvents(); |
1688 | 1690 | ||
1689 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1691 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1690 | if (!ok) { | 1692 | if (!ok) { |
1691 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1693 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1692 | } | 1694 | } |
1693 | 1695 | ||
1694 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1696 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1695 | if (!ok) { | 1697 | if (!ok) { |
1696 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1698 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1697 | } | 1699 | } |
1698 | realName = realNameList[i]; | 1700 | realName = realNameList[i]; |
1699 | email = emailList[i]; | 1701 | email = emailList[i]; |
1700 | assembledName = assembledNameList[i]; | 1702 | assembledName = assembledNameList[i]; |
1701 | uid = uidList[i]; | 1703 | uid = uidList[i]; |
1702 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1704 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1703 | 1705 | ||
1704 | if ( birthday.isValid() ){ | 1706 | if ( birthday.isValid() ){ |
1705 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1707 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1706 | KCal::Attendee::ReqParticipant,uid) ; | 1708 | KCal::Attendee::ReqParticipant,uid) ; |
1707 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1709 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1708 | ++addCount; | 1710 | ++addCount; |
1709 | } | 1711 | } |
1710 | 1712 | ||
1711 | if ( anniversary.isValid() ){ | 1713 | if ( anniversary.isValid() ){ |
1712 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1714 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1713 | KCal::Attendee::ReqParticipant,uid) ; | 1715 | KCal::Attendee::ReqParticipant,uid) ; |
1714 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1716 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1715 | ++addCount; | 1717 | ++addCount; |
1716 | } | 1718 | } |
1717 | } | 1719 | } |
1718 | 1720 | ||
1719 | updateView(); | 1721 | updateView(); |
1720 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1722 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1721 | 1723 | ||
1722 | } | 1724 | } |
1723 | 1725 | ||
1724 | } | 1726 | } |
1725 | 1727 | ||
1726 | 1728 | ||
1727 | 1729 | ||
1728 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1730 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1729 | { | 1731 | { |
1730 | //qDebug("addAnni "); | 1732 | //qDebug("addAnni "); |
1731 | Event * ev = new Event(); | 1733 | Event * ev = new Event(); |
1732 | ev->setOrganizer(KOPrefs::instance()->email()); | 1734 | ev->setOrganizer(KOPrefs::instance()->email()); |
1733 | if ( a ) { | 1735 | if ( a ) { |
1734 | ev->addAttendee( a ); | 1736 | ev->addAttendee( a ); |
1735 | } | 1737 | } |
1736 | QString kind; | 1738 | QString kind; |
1737 | if ( birthday ) { | 1739 | if ( birthday ) { |
1738 | kind = i18n( "Birthday" ); | 1740 | kind = i18n( "Birthday" ); |
1739 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1741 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1740 | } | 1742 | } |
1741 | else { | 1743 | else { |
1742 | kind = i18n( "Anniversary" ); | 1744 | kind = i18n( "Anniversary" ); |
1743 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1745 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1744 | } | 1746 | } |
1745 | ev->setCategories( kind ); | 1747 | ev->setCategories( kind ); |
1746 | ev->setDtStart( QDateTime(date) ); | 1748 | ev->setDtStart( QDateTime(date) ); |
1747 | ev->setDtEnd( QDateTime(date) ); | 1749 | ev->setDtEnd( QDateTime(date) ); |
1748 | ev->setFloats( true ); | 1750 | ev->setFloats( true ); |
1749 | Recurrence * rec = ev->recurrence(); | 1751 | Recurrence * rec = ev->recurrence(); |
1750 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1752 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1751 | rec->addYearlyNum( date.month() ); | 1753 | rec->addYearlyNum( date.month() ); |
1752 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1754 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1753 | delete ev; | 1755 | delete ev; |
1754 | return false; | 1756 | return false; |
1755 | } | 1757 | } |
1756 | return true; | 1758 | return true; |
1757 | 1759 | ||
1758 | } | 1760 | } |
1759 | bool CalendarView::importQtopia( const QString &categories, | 1761 | bool CalendarView::importQtopia( const QString &categories, |
1760 | const QString &datebook, | 1762 | const QString &datebook, |
1761 | const QString &todolist ) | 1763 | const QString &todolist ) |
1762 | { | 1764 | { |
1763 | 1765 | ||
1764 | QtopiaFormat qtopiaFormat; | 1766 | QtopiaFormat qtopiaFormat; |
1765 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1767 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1766 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1768 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1767 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1769 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1768 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1770 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1769 | 1771 | ||
1770 | updateView(); | 1772 | updateView(); |
1771 | return true; | 1773 | return true; |
1772 | 1774 | ||
1773 | #if 0 | 1775 | #if 0 |
1774 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1776 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1775 | mCurrentSyncDevice = "qtopia-XML"; | 1777 | mCurrentSyncDevice = "qtopia-XML"; |
1776 | if ( mSyncManager->mAskForPreferences ) | 1778 | if ( mSyncManager->mAskForPreferences ) |
1777 | edit_sync_options(); | 1779 | edit_sync_options(); |
1778 | qApp->processEvents(); | 1780 | qApp->processEvents(); |
1779 | CalendarLocal* calendar = new CalendarLocal(); | 1781 | CalendarLocal* calendar = new CalendarLocal(); |
1780 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1782 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1781 | bool syncOK = false; | 1783 | bool syncOK = false; |
1782 | QtopiaFormat qtopiaFormat; | 1784 | QtopiaFormat qtopiaFormat; |
1783 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1785 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1784 | bool loadOk = true; | 1786 | bool loadOk = true; |
1785 | if ( !categories.isEmpty() ) | 1787 | if ( !categories.isEmpty() ) |
1786 | loadOk = qtopiaFormat.load( calendar, categories ); | 1788 | loadOk = qtopiaFormat.load( calendar, categories ); |
1787 | if ( loadOk && !datebook.isEmpty() ) | 1789 | if ( loadOk && !datebook.isEmpty() ) |
1788 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1790 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1789 | if ( loadOk && !todolist.isEmpty() ) | 1791 | if ( loadOk && !todolist.isEmpty() ) |
1790 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1792 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1791 | 1793 | ||
1792 | if ( loadOk ) { | 1794 | if ( loadOk ) { |
1793 | getEventViewerDialog()->setSyncMode( true ); | 1795 | getEventViewerDialog()->setSyncMode( true ); |
1794 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1796 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1795 | getEventViewerDialog()->setSyncMode( false ); | 1797 | getEventViewerDialog()->setSyncMode( false ); |
1796 | qApp->processEvents(); | 1798 | qApp->processEvents(); |
1797 | if ( syncOK ) { | 1799 | if ( syncOK ) { |
1798 | if ( mSyncManager->mWriteBackFile ) | 1800 | if ( mSyncManager->mWriteBackFile ) |
1799 | { | 1801 | { |
1800 | // write back XML file | 1802 | // write back XML file |
1801 | 1803 | ||
1802 | } | 1804 | } |
1803 | setModified( true ); | 1805 | setModified( true ); |
1804 | } | 1806 | } |
1805 | } else { | 1807 | } else { |
1806 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1808 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1807 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1809 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1808 | question, i18n("Ok")) ; | 1810 | question, i18n("Ok")) ; |
1809 | } | 1811 | } |
1810 | delete calendar; | 1812 | delete calendar; |
1811 | updateView(); | 1813 | updateView(); |
1812 | return syncOK; | 1814 | return syncOK; |
1813 | 1815 | ||
1814 | 1816 | ||
1815 | #endif | 1817 | #endif |
1816 | 1818 | ||
1817 | } | 1819 | } |
1818 | 1820 | ||
1819 | void CalendarView::setSyncEventsReadOnly() | 1821 | void CalendarView::setSyncEventsReadOnly() |
1820 | { | 1822 | { |
1821 | Event * ev; | 1823 | Event * ev; |
1822 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1824 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1823 | ev = eL.first(); | 1825 | ev = eL.first(); |
1824 | while ( ev ) { | 1826 | while ( ev ) { |
1825 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1827 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1826 | ev->setReadOnly( true ); | 1828 | ev->setReadOnly( true ); |
1827 | ev = eL.next(); | 1829 | ev = eL.next(); |
1828 | } | 1830 | } |
1829 | } | 1831 | } |
1830 | bool CalendarView::openCalendar(QString filename, bool merge) | 1832 | bool CalendarView::openCalendar(QString filename, bool merge) |
1831 | { | 1833 | { |
1832 | 1834 | ||
1833 | if (filename.isEmpty()) { | 1835 | if (filename.isEmpty()) { |
1834 | return false; | 1836 | return false; |
1835 | } | 1837 | } |
1836 | 1838 | ||
1837 | if (!QFile::exists(filename)) { | 1839 | if (!QFile::exists(filename)) { |
1838 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1840 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1839 | return false; | 1841 | return false; |
1840 | } | 1842 | } |
1841 | 1843 | ||
1842 | globalFlagBlockAgenda = 1; | 1844 | globalFlagBlockAgenda = 1; |
1843 | clearAllViews(); | 1845 | clearAllViews(); |
1844 | if (!merge) { | 1846 | if (!merge) { |
1845 | mViewManager->setDocumentId( filename ); | 1847 | mViewManager->setDocumentId( filename ); |
1846 | mCalendar->close(); | 1848 | mCalendar->close(); |
1847 | } | 1849 | } |
1848 | mStorage->setFileName( filename ); | 1850 | mStorage->setFileName( filename ); |
1849 | 1851 | ||
1850 | if ( mStorage->load() ) { | 1852 | if ( mStorage->load() ) { |
1851 | if ( merge ) ;//setModified( true ); | 1853 | if ( merge ) ;//setModified( true ); |
1852 | else { | 1854 | else { |
1853 | //setModified( true ); | 1855 | //setModified( true ); |
1854 | mViewManager->setDocumentId( filename ); | 1856 | mViewManager->setDocumentId( filename ); |
1855 | mDialogManager->setDocumentId( filename ); | 1857 | mDialogManager->setDocumentId( filename ); |
1856 | mTodoList->setDocumentId( filename ); | 1858 | mTodoList->setDocumentId( filename ); |
1857 | } | 1859 | } |
1858 | globalFlagBlockAgenda = 2; | 1860 | globalFlagBlockAgenda = 2; |
1859 | // if ( getLastSyncEvent() ) | 1861 | // if ( getLastSyncEvent() ) |
1860 | // getLastSyncEvent()->setReadOnly( true ); | 1862 | // getLastSyncEvent()->setReadOnly( true ); |
1861 | mCalendar->reInitAlarmSettings(); | 1863 | mCalendar->reInitAlarmSettings(); |
1862 | setSyncEventsReadOnly(); | 1864 | setSyncEventsReadOnly(); |
1863 | updateUnmanagedViews(); | 1865 | updateUnmanagedViews(); |
1864 | updateView(); | 1866 | updateView(); |
1865 | if ( filename != MainWindow::defaultFileName() ) { | 1867 | if ( filename != MainWindow::defaultFileName() ) { |
1866 | saveCalendar( MainWindow::defaultFileName() ); | 1868 | saveCalendar( MainWindow::defaultFileName() ); |
1867 | } else { | 1869 | } else { |
1868 | QFileInfo finf ( MainWindow::defaultFileName()); | 1870 | QFileInfo finf ( MainWindow::defaultFileName()); |
1869 | if ( finf.exists() ) { | 1871 | if ( finf.exists() ) { |
1870 | setLoadedFileVersion( finf.lastModified () ); | 1872 | setLoadedFileVersion( finf.lastModified () ); |
1871 | } | 1873 | } |
1872 | } | 1874 | } |
1873 | return true; | 1875 | return true; |
1874 | } else { | 1876 | } else { |
1875 | // while failing to load, the calendar object could | 1877 | // while failing to load, the calendar object could |
1876 | // have become partially populated. Clear it out. | 1878 | // have become partially populated. Clear it out. |
1877 | if ( !merge ) { | 1879 | if ( !merge ) { |
1878 | mCalendar->close(); | 1880 | mCalendar->close(); |
1879 | mViewManager->setDocumentId( filename ); | 1881 | mViewManager->setDocumentId( filename ); |
1880 | mDialogManager->setDocumentId( filename ); | 1882 | mDialogManager->setDocumentId( filename ); |
1881 | mTodoList->setDocumentId( filename ); | 1883 | mTodoList->setDocumentId( filename ); |
1882 | } | 1884 | } |
1883 | 1885 | ||
1884 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1886 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1885 | 1887 | ||
1886 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1888 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1887 | globalFlagBlockAgenda = 2; | 1889 | globalFlagBlockAgenda = 2; |
1888 | mCalendar->reInitAlarmSettings(); | 1890 | mCalendar->reInitAlarmSettings(); |
1889 | setSyncEventsReadOnly(); | 1891 | setSyncEventsReadOnly(); |
1890 | updateUnmanagedViews(); | 1892 | updateUnmanagedViews(); |
1891 | updateView(); | 1893 | updateView(); |
1892 | } | 1894 | } |
1893 | return false; | 1895 | return false; |
1894 | } | 1896 | } |
1895 | void CalendarView::showOpenError() | 1897 | void CalendarView::showOpenError() |
1896 | { | 1898 | { |
1897 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1899 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1898 | } | 1900 | } |
1899 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1901 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1900 | { | 1902 | { |
1901 | loadedFileVersion = dt; | 1903 | loadedFileVersion = dt; |
1902 | } | 1904 | } |
1903 | bool CalendarView::checkFileChanged(QString fn) | 1905 | bool CalendarView::checkFileChanged(QString fn) |
1904 | { | 1906 | { |
1905 | QFileInfo finf ( fn ); | 1907 | QFileInfo finf ( fn ); |
1906 | if ( !finf.exists() ) | 1908 | if ( !finf.exists() ) |
1907 | return true; | 1909 | return true; |
1908 | QDateTime dt = finf.lastModified (); | 1910 | QDateTime dt = finf.lastModified (); |
1909 | if ( dt <= loadedFileVersion ) | 1911 | if ( dt <= loadedFileVersion ) |
1910 | return false; | 1912 | return false; |
1911 | return true; | 1913 | return true; |
1912 | 1914 | ||
1913 | } | 1915 | } |
1914 | void CalendarView::watchSavedFile() | 1916 | void CalendarView::watchSavedFile() |
1915 | { | 1917 | { |
1916 | QFileInfo finf ( MainWindow::defaultFileName()); | 1918 | QFileInfo finf ( MainWindow::defaultFileName()); |
1917 | if ( !finf.exists() ) | 1919 | if ( !finf.exists() ) |
1918 | return; | 1920 | return; |
1919 | QDateTime dt = finf.lastModified (); | 1921 | QDateTime dt = finf.lastModified (); |
1920 | if ( dt < loadedFileVersion ) { | 1922 | if ( dt < loadedFileVersion ) { |
1921 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1923 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1922 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1924 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1923 | return; | 1925 | return; |
1924 | } | 1926 | } |
1925 | loadedFileVersion = dt; | 1927 | loadedFileVersion = dt; |
1926 | } | 1928 | } |
1927 | 1929 | ||
1928 | bool CalendarView::checkFileVersion(QString fn) | 1930 | bool CalendarView::checkFileVersion(QString fn) |
1929 | { | 1931 | { |
1930 | QFileInfo finf ( fn ); | 1932 | QFileInfo finf ( fn ); |
1931 | if ( !finf.exists() ) | 1933 | if ( !finf.exists() ) |
1932 | return true; | 1934 | return true; |
1933 | QDateTime dt = finf.lastModified (); | 1935 | QDateTime dt = finf.lastModified (); |
1934 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1936 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1935 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1937 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1936 | if ( dt <= loadedFileVersion ) | 1938 | if ( dt <= loadedFileVersion ) |
1937 | return true; | 1939 | return true; |
1938 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1940 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1939 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1941 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1940 | i18n("Sync+save")); | 1942 | i18n("Sync+save")); |
1941 | 1943 | ||
1942 | if ( km == KMessageBox::Cancel ) | 1944 | if ( km == KMessageBox::Cancel ) |
1943 | return false; | 1945 | return false; |
1944 | if ( km == KMessageBox::Yes ) | 1946 | if ( km == KMessageBox::Yes ) |
1945 | return true; | 1947 | return true; |
1946 | 1948 | ||
1947 | setSyncDevice("deleteaftersync" ); | 1949 | setSyncDevice("deleteaftersync" ); |
1948 | mSyncManager->mAskForPreferences = true; | 1950 | mSyncManager->mAskForPreferences = true; |
1949 | mSyncManager->mSyncAlgoPrefs = 3; | 1951 | mSyncManager->mSyncAlgoPrefs = 3; |
1950 | mSyncManager->mWriteBackFile = false; | 1952 | mSyncManager->mWriteBackFile = false; |
1951 | mSyncManager->mWriteBackExistingOnly = false; | 1953 | mSyncManager->mWriteBackExistingOnly = false; |
1952 | mSyncManager->mShowSyncSummary = false; | 1954 | mSyncManager->mShowSyncSummary = false; |
1953 | syncCalendar( fn, 3 ); | 1955 | syncCalendar( fn, 3 ); |
1954 | Event * e = getLastSyncEvent(); | 1956 | Event * e = getLastSyncEvent(); |
1955 | if ( e ) | 1957 | if ( e ) |
1956 | deleteEvent ( e ); | 1958 | deleteEvent ( e ); |
1957 | updateView(); | 1959 | updateView(); |
1958 | return true; | 1960 | return true; |
1959 | } | 1961 | } |
1960 | 1962 | ||
1961 | bool CalendarView::saveCalendar( QString filename ) | 1963 | bool CalendarView::saveCalendar( QString filename ) |
1962 | { | 1964 | { |
1963 | 1965 | ||
1964 | // Store back all unsaved data into calendar object | 1966 | // Store back all unsaved data into calendar object |
1965 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1967 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1966 | if ( mViewManager->currentView() ) | 1968 | if ( mViewManager->currentView() ) |
1967 | mViewManager->currentView()->flushView(); | 1969 | mViewManager->currentView()->flushView(); |
1968 | 1970 | ||
1969 | 1971 | ||
1970 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1972 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1971 | mStorage->setSaveFormat( new ICalFormat() ); | 1973 | mStorage->setSaveFormat( new ICalFormat() ); |
1972 | mStorage->setFileName( filename ); | 1974 | mStorage->setFileName( filename ); |
1973 | bool success; | 1975 | bool success; |
1974 | success = mStorage->save(); | 1976 | success = mStorage->save(); |
1975 | if ( !success ) { | 1977 | if ( !success ) { |
1976 | return false; | 1978 | return false; |
1977 | } | 1979 | } |
1978 | if ( filename == MainWindow::defaultFileName() ) { | 1980 | if ( filename == MainWindow::defaultFileName() ) { |
1979 | setLoadedFileVersion( lfv ); | 1981 | setLoadedFileVersion( lfv ); |
1980 | watchSavedFile(); | 1982 | watchSavedFile(); |
1981 | } | 1983 | } |
1982 | return true; | 1984 | return true; |
1983 | } | 1985 | } |
1984 | 1986 | ||
1985 | void CalendarView::closeCalendar() | 1987 | void CalendarView::closeCalendar() |
1986 | { | 1988 | { |
1987 | 1989 | ||
1988 | // child windows no longer valid | 1990 | // child windows no longer valid |
1989 | clearAllViews(); | 1991 | clearAllViews(); |
1990 | emit closingDown(); | 1992 | emit closingDown(); |
1991 | 1993 | ||
1992 | mCalendar->close(); | 1994 | mCalendar->close(); |
1993 | setModified(false); | 1995 | setModified(false); |
1994 | updateView(); | 1996 | updateView(); |
1995 | } | 1997 | } |
1996 | 1998 | ||
1997 | void CalendarView::archiveCalendar() | 1999 | void CalendarView::archiveCalendar() |
1998 | { | 2000 | { |
1999 | mDialogManager->showArchiveDialog(); | 2001 | mDialogManager->showArchiveDialog(); |
2000 | } | 2002 | } |
2001 | 2003 | ||
2002 | 2004 | ||
2003 | void CalendarView::readSettings() | 2005 | void CalendarView::readSettings() |
2004 | { | 2006 | { |
2005 | 2007 | ||
2006 | 2008 | ||
2007 | // mViewManager->showAgendaView(); | 2009 | // mViewManager->showAgendaView(); |
2008 | QString str; | 2010 | QString str; |
2009 | //qDebug("CalendarView::readSettings() "); | 2011 | //qDebug("CalendarView::readSettings() "); |
2010 | // read settings from the KConfig, supplying reasonable | 2012 | // read settings from the KConfig, supplying reasonable |
2011 | // defaults where none are to be found | 2013 | // defaults where none are to be found |
2012 | KConfig *config = KOGlobals::config(); | 2014 | KConfig *config = KOGlobals::config(); |
2013 | #ifndef KORG_NOSPLITTER | 2015 | #ifndef KORG_NOSPLITTER |
2014 | config->setGroup("KOrganizer Geometry"); | 2016 | config->setGroup("KOrganizer Geometry"); |
2015 | 2017 | ||
2016 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2018 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2017 | if (sizes.count() != 2) { | 2019 | if (sizes.count() != 2) { |
2018 | sizes << mDateNavigator->minimumSizeHint().width(); | 2020 | sizes << mDateNavigator->minimumSizeHint().width(); |
2019 | sizes << 300; | 2021 | sizes << 300; |
2020 | } | 2022 | } |
2021 | mPanner->setSizes(sizes); | 2023 | mPanner->setSizes(sizes); |
2022 | 2024 | ||
2023 | sizes = config->readIntListEntry("Separator2"); | 2025 | sizes = config->readIntListEntry("Separator2"); |
2024 | if ( ( mResourceView && sizes.count() == 4 ) || | 2026 | if ( ( mResourceView && sizes.count() == 4 ) || |
2025 | ( !mResourceView && sizes.count() == 3 ) ) { | 2027 | ( !mResourceView && sizes.count() == 3 ) ) { |
2026 | mLeftSplitter->setSizes(sizes); | 2028 | mLeftSplitter->setSizes(sizes); |
2027 | } | 2029 | } |
2028 | #endif | 2030 | #endif |
2029 | globalFlagBlockAgenda = 1; | 2031 | globalFlagBlockAgenda = 1; |
2030 | mViewManager->showAgendaView(); | 2032 | mViewManager->showAgendaView(); |
2031 | //mViewManager->readSettings( config ); | 2033 | //mViewManager->readSettings( config ); |
2032 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2034 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2033 | readFilterSettings(config); | 2035 | readFilterSettings(config); |
2034 | 2036 | ||
2035 | #ifdef DESKTOP_VERSION | 2037 | #ifdef DESKTOP_VERSION |
2036 | config->setGroup("WidgetLayout"); | 2038 | config->setGroup("WidgetLayout"); |
2037 | QStringList list; | 2039 | QStringList list; |
2038 | list = config->readListEntry("MainLayout"); | 2040 | list = config->readListEntry("MainLayout"); |
2039 | int x,y,w,h; | 2041 | int x,y,w,h; |
2040 | if ( ! list.isEmpty() ) { | 2042 | if ( ! list.isEmpty() ) { |
2041 | x = list[0].toInt(); | 2043 | x = list[0].toInt(); |
2042 | y = list[1].toInt(); | 2044 | y = list[1].toInt(); |
2043 | w = list[2].toInt(); | 2045 | w = list[2].toInt(); |
2044 | h = list[3].toInt(); | 2046 | h = list[3].toInt(); |
2045 | KApplication::testCoords( &x,&y,&w,&h ); | 2047 | KApplication::testCoords( &x,&y,&w,&h ); |
2046 | topLevelWidget()->setGeometry(x,y,w,h); | 2048 | topLevelWidget()->setGeometry(x,y,w,h); |
2047 | 2049 | ||
2048 | } else { | 2050 | } else { |
2049 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2051 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2050 | } | 2052 | } |
2051 | list = config->readListEntry("EditEventLayout"); | 2053 | list = config->readListEntry("EditEventLayout"); |
2052 | if ( ! list.isEmpty() ) { | 2054 | if ( ! list.isEmpty() ) { |
2053 | x = list[0].toInt(); | 2055 | x = list[0].toInt(); |
2054 | y = list[1].toInt(); | 2056 | y = list[1].toInt(); |
2055 | w = list[2].toInt(); | 2057 | w = list[2].toInt(); |
2056 | h = list[3].toInt(); | 2058 | h = list[3].toInt(); |
2057 | KApplication::testCoords( &x,&y,&w,&h ); | 2059 | KApplication::testCoords( &x,&y,&w,&h ); |
2058 | mEventEditor->setGeometry(x,y,w,h); | 2060 | mEventEditor->setGeometry(x,y,w,h); |
2059 | 2061 | ||
2060 | } | 2062 | } |
2061 | list = config->readListEntry("EditTodoLayout"); | 2063 | list = config->readListEntry("EditTodoLayout"); |
2062 | if ( ! list.isEmpty() ) { | 2064 | if ( ! list.isEmpty() ) { |
2063 | x = list[0].toInt(); | 2065 | x = list[0].toInt(); |
2064 | y = list[1].toInt(); | 2066 | y = list[1].toInt(); |
2065 | w = list[2].toInt(); | 2067 | w = list[2].toInt(); |
2066 | h = list[3].toInt(); | 2068 | h = list[3].toInt(); |
2067 | KApplication::testCoords( &x,&y,&w,&h ); | 2069 | KApplication::testCoords( &x,&y,&w,&h ); |
2068 | mTodoEditor->setGeometry(x,y,w,h); | 2070 | mTodoEditor->setGeometry(x,y,w,h); |
2069 | 2071 | ||
2070 | } | 2072 | } |
2071 | list = config->readListEntry("ViewerLayout"); | 2073 | list = config->readListEntry("ViewerLayout"); |
2072 | if ( ! list.isEmpty() ) { | 2074 | if ( ! list.isEmpty() ) { |
2073 | x = list[0].toInt(); | 2075 | x = list[0].toInt(); |
2074 | y = list[1].toInt(); | 2076 | y = list[1].toInt(); |
2075 | w = list[2].toInt(); | 2077 | w = list[2].toInt(); |
2076 | h = list[3].toInt(); | 2078 | h = list[3].toInt(); |
2077 | KApplication::testCoords( &x,&y,&w,&h ); | 2079 | KApplication::testCoords( &x,&y,&w,&h ); |
2078 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2080 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2079 | } | 2081 | } |
2080 | #endif | 2082 | #endif |
2081 | config->setGroup( "Views" ); | 2083 | config->setGroup( "Views" ); |
2082 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2084 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2083 | 2085 | ||
2084 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2086 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2085 | 2087 | ||
2086 | int resetval = 0; | 2088 | int resetval = 0; |
2087 | int maxVal = 0; | 2089 | int maxVal = 0; |
2088 | if (sizes.count() != 3) { | 2090 | if (sizes.count() != 3) { |
2089 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2091 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2090 | resetval = mDateNavigator->sizeHint().width()+2; | 2092 | resetval = mDateNavigator->sizeHint().width()+2; |
2091 | } else { | 2093 | } else { |
2092 | resetval = mDateNavigator->sizeHint().height()+2; | 2094 | resetval = mDateNavigator->sizeHint().height()+2; |
2093 | } | 2095 | } |
2094 | } | 2096 | } |
2095 | if ( resetval ) { | 2097 | if ( resetval ) { |
2096 | sizes.clear(); | 2098 | sizes.clear(); |
2097 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2099 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2098 | maxVal = QApplication::desktop()->width() -10; | 2100 | maxVal = QApplication::desktop()->width() -10; |
2099 | } else { | 2101 | } else { |
2100 | maxVal = QApplication::desktop()->height()-10; | 2102 | maxVal = QApplication::desktop()->height()-10; |
2101 | } | 2103 | } |
2102 | sizes << resetval; | 2104 | sizes << resetval; |
2103 | if ( maxVal < resetval + resetval) | 2105 | if ( maxVal < resetval + resetval) |
2104 | resetval = maxVal - resetval; | 2106 | resetval = maxVal - resetval; |
2105 | sizes << resetval; | 2107 | sizes << resetval; |
2106 | sizes << 100; | 2108 | sizes << 100; |
2107 | } | 2109 | } |
2108 | mLeftFrame->setSizes(sizes); | 2110 | mLeftFrame->setSizes(sizes); |
2109 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2111 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2110 | resetval = 0; | 2112 | resetval = 0; |
2111 | maxVal = 0; | 2113 | maxVal = 0; |
2112 | if (sizes.count() != 2) { | 2114 | if (sizes.count() != 2) { |
2113 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2115 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2114 | resetval = mDateNavigator->sizeHint().width()+2; | 2116 | resetval = mDateNavigator->sizeHint().width()+2; |
2115 | } else { | 2117 | } else { |
2116 | resetval = mDateNavigator->sizeHint().height()+2; | 2118 | resetval = mDateNavigator->sizeHint().height()+2; |
2117 | } | 2119 | } |
2118 | } | 2120 | } |
2119 | if ( resetval ) { | 2121 | if ( resetval ) { |
2120 | sizes.clear(); | 2122 | sizes.clear(); |
2121 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2123 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2122 | maxVal = QApplication::desktop()->width() -10; | 2124 | maxVal = QApplication::desktop()->width() -10; |
2123 | } else { | 2125 | } else { |
2124 | maxVal = QApplication::desktop()->height()-10; | 2126 | maxVal = QApplication::desktop()->height()-10; |
2125 | } | 2127 | } |
2126 | sizes << resetval; | 2128 | sizes << resetval; |
2127 | if ( maxVal < resetval + resetval) | 2129 | if ( maxVal < resetval + resetval) |
2128 | resetval = maxVal - resetval; | 2130 | resetval = maxVal - resetval; |
2129 | sizes << resetval; | 2131 | sizes << resetval; |
2130 | } | 2132 | } |
2131 | mMainFrame->setSizes(sizes); | 2133 | mMainFrame->setSizes(sizes); |
2132 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2134 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2133 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2135 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2134 | else mNavigator->selectDates( dateCount ); | 2136 | else mNavigator->selectDates( dateCount ); |
2135 | // mViewManager->readSettings( config ); | 2137 | // mViewManager->readSettings( config ); |
2136 | updateConfig(); | 2138 | updateConfig(); |
2137 | globalFlagBlockAgenda = 2; | 2139 | globalFlagBlockAgenda = 2; |
2138 | mViewManager->readSettings( config ); | 2140 | mViewManager->readSettings( config ); |
2139 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2141 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2140 | } | 2142 | } |
2141 | 2143 | ||
2142 | 2144 | ||
2143 | void CalendarView::writeSettings() | 2145 | void CalendarView::writeSettings() |
2144 | { | 2146 | { |
2145 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2147 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2146 | 2148 | ||
2147 | KConfig *config = KOGlobals::config(); | 2149 | KConfig *config = KOGlobals::config(); |
2148 | 2150 | ||
2149 | mViewManager->writeSettings( config ); | 2151 | mViewManager->writeSettings( config ); |
2150 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2152 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2151 | mDialogManager->writeSettings( config ); | 2153 | mDialogManager->writeSettings( config ); |
2152 | //KOPrefs::instance()->usrWriteConfig(); | 2154 | //KOPrefs::instance()->usrWriteConfig(); |
2153 | KOPrefs::instance()->writeConfig(); | 2155 | KOPrefs::instance()->writeConfig(); |
2154 | 2156 | ||
2155 | writeFilterSettings(config); | 2157 | writeFilterSettings(config); |
2156 | config->setGroup( "AppRun" ); | 2158 | config->setGroup( "AppRun" ); |
2157 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2159 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2158 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); | 2160 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); |
2159 | config->setGroup( "Views" ); | 2161 | config->setGroup( "Views" ); |
2160 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2162 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2161 | 2163 | ||
2162 | QValueList<int> listINT = mLeftFrame->sizes(); | 2164 | QValueList<int> listINT = mLeftFrame->sizes(); |
2163 | config->writeEntry("Left Splitter Frame",listINT); | 2165 | config->writeEntry("Left Splitter Frame",listINT); |
2164 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2166 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2165 | config->writeEntry("Main Splitter Frame",listINT2); | 2167 | config->writeEntry("Main Splitter Frame",listINT2); |
2166 | #ifdef DESKTOP_VERSION | 2168 | #ifdef DESKTOP_VERSION |
2167 | config->setGroup("WidgetLayout"); | 2169 | config->setGroup("WidgetLayout"); |
2168 | QStringList list ;//= config->readListEntry("MainLayout"); | 2170 | QStringList list ;//= config->readListEntry("MainLayout"); |
2169 | int x,y,w,h; | 2171 | int x,y,w,h; |
2170 | QWidget* wid; | 2172 | QWidget* wid; |
2171 | wid = topLevelWidget(); | 2173 | wid = topLevelWidget(); |
2172 | x = wid->geometry().x(); | 2174 | x = wid->geometry().x(); |
2173 | y = wid->geometry().y(); | 2175 | y = wid->geometry().y(); |
2174 | w = wid->width(); | 2176 | w = wid->width(); |
2175 | h = wid->height(); | 2177 | h = wid->height(); |
2176 | list.clear(); | 2178 | list.clear(); |
2177 | list << QString::number( x ); | 2179 | list << QString::number( x ); |
2178 | list << QString::number( y ); | 2180 | list << QString::number( y ); |
2179 | list << QString::number( w ); | 2181 | list << QString::number( w ); |
2180 | list << QString::number( h ); | 2182 | list << QString::number( h ); |
2181 | config->writeEntry("MainLayout",list ); | 2183 | config->writeEntry("MainLayout",list ); |
2182 | 2184 | ||
2183 | wid = mEventEditor; | 2185 | wid = mEventEditor; |
2184 | x = wid->geometry().x(); | 2186 | x = wid->geometry().x(); |
2185 | y = wid->geometry().y(); | 2187 | y = wid->geometry().y(); |
2186 | w = wid->width(); | 2188 | w = wid->width(); |
2187 | h = wid->height(); | 2189 | h = wid->height(); |
2188 | list.clear(); | 2190 | list.clear(); |
2189 | list << QString::number( x ); | 2191 | list << QString::number( x ); |
2190 | list << QString::number( y ); | 2192 | list << QString::number( y ); |
2191 | list << QString::number( w ); | 2193 | list << QString::number( w ); |
2192 | list << QString::number( h ); | 2194 | list << QString::number( h ); |
2193 | config->writeEntry("EditEventLayout",list ); | 2195 | config->writeEntry("EditEventLayout",list ); |
2194 | 2196 | ||
2195 | wid = mTodoEditor; | 2197 | wid = mTodoEditor; |
2196 | x = wid->geometry().x(); | 2198 | x = wid->geometry().x(); |
2197 | y = wid->geometry().y(); | 2199 | y = wid->geometry().y(); |
2198 | w = wid->width(); | 2200 | w = wid->width(); |
2199 | h = wid->height(); | 2201 | h = wid->height(); |
2200 | list.clear(); | 2202 | list.clear(); |
2201 | list << QString::number( x ); | 2203 | list << QString::number( x ); |
2202 | list << QString::number( y ); | 2204 | list << QString::number( y ); |
2203 | list << QString::number( w ); | 2205 | list << QString::number( w ); |
2204 | list << QString::number( h ); | 2206 | list << QString::number( h ); |
2205 | config->writeEntry("EditTodoLayout",list ); | 2207 | config->writeEntry("EditTodoLayout",list ); |
2206 | wid = getEventViewerDialog(); | 2208 | wid = getEventViewerDialog(); |
2207 | x = wid->geometry().x(); | 2209 | x = wid->geometry().x(); |
2208 | y = wid->geometry().y(); | 2210 | y = wid->geometry().y(); |
2209 | w = wid->width(); | 2211 | w = wid->width(); |
2210 | h = wid->height(); | 2212 | h = wid->height(); |
2211 | list.clear(); | 2213 | list.clear(); |
2212 | list << QString::number( x ); | 2214 | list << QString::number( x ); |
2213 | list << QString::number( y ); | 2215 | list << QString::number( y ); |
2214 | list << QString::number( w ); | 2216 | list << QString::number( w ); |
2215 | list << QString::number( h ); | 2217 | list << QString::number( h ); |
2216 | config->writeEntry("ViewerLayout",list ); | 2218 | config->writeEntry("ViewerLayout",list ); |
2217 | wid = mDialogManager->getSearchDialog(); | 2219 | wid = mDialogManager->getSearchDialog(); |
2218 | if ( wid ) { | 2220 | if ( wid ) { |
2219 | x = wid->geometry().x(); | 2221 | x = wid->geometry().x(); |
2220 | y = wid->geometry().y(); | 2222 | y = wid->geometry().y(); |
2221 | w = wid->width(); | 2223 | w = wid->width(); |
2222 | h = wid->height(); | 2224 | h = wid->height(); |
2223 | list.clear(); | 2225 | list.clear(); |
2224 | list << QString::number( x ); | 2226 | list << QString::number( x ); |
2225 | list << QString::number( y ); | 2227 | list << QString::number( y ); |
2226 | list << QString::number( w ); | 2228 | list << QString::number( w ); |
2227 | list << QString::number( h ); | 2229 | list << QString::number( h ); |
2228 | config->writeEntry("SearchLayout",list ); | 2230 | config->writeEntry("SearchLayout",list ); |
2229 | } | 2231 | } |
2230 | #endif | 2232 | #endif |
2231 | 2233 | ||
2232 | 2234 | ||
2233 | config->sync(); | 2235 | config->sync(); |
2234 | } | 2236 | } |
2235 | 2237 | ||
2236 | void CalendarView::readFilterSettings(KConfig *config) | 2238 | void CalendarView::readFilterSettings(KConfig *config) |
2237 | { | 2239 | { |
2238 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2240 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2239 | 2241 | ||
2240 | mFilters.clear(); | 2242 | mFilters.clear(); |
2241 | 2243 | ||
2242 | config->setGroup("General"); | 2244 | config->setGroup("General"); |
2243 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2245 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2244 | 2246 | ||
2245 | QStringList::ConstIterator it = filterList.begin(); | 2247 | QStringList::ConstIterator it = filterList.begin(); |
2246 | QStringList::ConstIterator end = filterList.end(); | 2248 | QStringList::ConstIterator end = filterList.end(); |
2247 | while(it != end) { | 2249 | while(it != end) { |
2248 | // kdDebug() << " filter: " << (*it) << endl; | 2250 | // kdDebug() << " filter: " << (*it) << endl; |
2249 | 2251 | ||
2250 | CalFilter *filter; | 2252 | CalFilter *filter; |
2251 | filter = new CalFilter(*it); | 2253 | filter = new CalFilter(*it); |
2252 | config->setGroup("Filter_" + (*it).utf8()); | 2254 | config->setGroup("Filter_" + (*it).utf8()); |
2253 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2255 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2254 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2256 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2255 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2257 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2256 | mFilters.append(filter); | 2258 | mFilters.append(filter); |
2257 | 2259 | ||
2258 | ++it; | 2260 | ++it; |
2259 | } | 2261 | } |
2260 | 2262 | ||
2261 | if (mFilters.count() == 0) { | 2263 | if (mFilters.count() == 0) { |
2262 | CalFilter *filter = new CalFilter(i18n("Default")); | 2264 | CalFilter *filter = new CalFilter(i18n("Default")); |
2263 | mFilters.append(filter); | 2265 | mFilters.append(filter); |
2264 | } | 2266 | } |
2265 | mFilterView->updateFilters(); | 2267 | mFilterView->updateFilters(); |
2266 | config->setGroup("FilterView"); | 2268 | config->setGroup("FilterView"); |
2267 | 2269 | ||
2268 | mFilterView->blockSignals(true); | 2270 | mFilterView->blockSignals(true); |
2269 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2271 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2270 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2272 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2271 | mFilterView->blockSignals(false); | 2273 | mFilterView->blockSignals(false); |
2272 | // We do it manually to avoid it being done twice by the above calls | 2274 | // We do it manually to avoid it being done twice by the above calls |
2273 | updateFilter(); | 2275 | updateFilter(); |
2274 | } | 2276 | } |
2275 | 2277 | ||
2276 | void CalendarView::writeFilterSettings(KConfig *config) | 2278 | void CalendarView::writeFilterSettings(KConfig *config) |
2277 | { | 2279 | { |
2278 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2280 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2279 | 2281 | ||
2280 | QStringList filterList; | 2282 | QStringList filterList; |
2281 | 2283 | ||
2282 | CalFilter *filter = mFilters.first(); | 2284 | CalFilter *filter = mFilters.first(); |
2283 | while(filter) { | 2285 | while(filter) { |
2284 | // kdDebug() << " fn: " << filter->name() << endl; | 2286 | // kdDebug() << " fn: " << filter->name() << endl; |
2285 | filterList << filter->name(); | 2287 | filterList << filter->name(); |
2286 | config->setGroup("Filter_" + filter->name().utf8()); | 2288 | config->setGroup("Filter_" + filter->name().utf8()); |
2287 | config->writeEntry("Criteria",filter->criteria()); | 2289 | config->writeEntry("Criteria",filter->criteria()); |
2288 | config->writeEntry("CategoryList",filter->categoryList()); | 2290 | config->writeEntry("CategoryList",filter->categoryList()); |
2289 | filter = mFilters.next(); | 2291 | filter = mFilters.next(); |
2290 | } | 2292 | } |
2291 | config->setGroup("General"); | 2293 | config->setGroup("General"); |
2292 | config->writeEntry("CalendarFilters",filterList); | 2294 | config->writeEntry("CalendarFilters",filterList); |
2293 | 2295 | ||
2294 | config->setGroup("FilterView"); | 2296 | config->setGroup("FilterView"); |
2295 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2297 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2296 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2298 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2297 | } | 2299 | } |
2298 | 2300 | ||
2299 | 2301 | ||
2300 | void CalendarView::goToday() | 2302 | void CalendarView::goToday() |
2301 | { | 2303 | { |
2302 | if ( mViewManager->currentView()->isMonthView() ) | 2304 | if ( mViewManager->currentView()->isMonthView() ) |
2303 | mNavigator->selectTodayMonth(); | 2305 | mNavigator->selectTodayMonth(); |
2304 | else | 2306 | else |
2305 | mNavigator->selectToday(); | 2307 | mNavigator->selectToday(); |
2306 | } | 2308 | } |
2307 | 2309 | ||
2308 | void CalendarView::goNext() | 2310 | void CalendarView::goNext() |
2309 | { | 2311 | { |
2310 | mNavigator->selectNext(); | 2312 | mNavigator->selectNext(); |
2311 | } | 2313 | } |
2312 | 2314 | ||
2313 | void CalendarView::goPrevious() | 2315 | void CalendarView::goPrevious() |
2314 | { | 2316 | { |
2315 | mNavigator->selectPrevious(); | 2317 | mNavigator->selectPrevious(); |
2316 | } | 2318 | } |
2317 | void CalendarView::goNextMonth() | 2319 | void CalendarView::goNextMonth() |
2318 | { | 2320 | { |
2319 | mNavigator->selectNextMonth(); | 2321 | mNavigator->selectNextMonth(); |
2320 | } | 2322 | } |
2321 | 2323 | ||
2322 | void CalendarView::goPreviousMonth() | 2324 | void CalendarView::goPreviousMonth() |
2323 | { | 2325 | { |
2324 | mNavigator->selectPreviousMonth(); | 2326 | mNavigator->selectPreviousMonth(); |
2325 | } | 2327 | } |
2326 | void CalendarView::writeLocale() | 2328 | void CalendarView::writeLocale() |
2327 | { | 2329 | { |
2328 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2330 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2329 | #if 0 | 2331 | #if 0 |
2330 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2332 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2331 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2333 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2332 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2334 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2333 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2335 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2334 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2336 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2335 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2337 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2336 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2338 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2337 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2339 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2338 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2340 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2339 | KOPrefs::instance()->mDaylightsavingStart, | 2341 | KOPrefs::instance()->mDaylightsavingStart, |
2340 | KOPrefs::instance()->mDaylightsavingEnd ); | 2342 | KOPrefs::instance()->mDaylightsavingEnd ); |
2341 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2343 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2342 | #endif | 2344 | #endif |
2343 | } | 2345 | } |
2344 | void CalendarView::updateConfig() | 2346 | void CalendarView::updateConfig() |
2345 | { | 2347 | { |
2346 | writeLocale(); | 2348 | writeLocale(); |
2347 | if ( KOPrefs::instance()->mUseAppColors ) | 2349 | if ( KOPrefs::instance()->mUseAppColors ) |
2348 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2350 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2349 | emit configChanged(); | 2351 | emit configChanged(); |
2350 | mTodoList->updateConfig(); | 2352 | mTodoList->updateConfig(); |
2351 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2353 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2352 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2354 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2353 | // To make the "fill window" configurations work | 2355 | // To make the "fill window" configurations work |
2354 | //mViewManager->raiseCurrentView(); | 2356 | //mViewManager->raiseCurrentView(); |
2355 | } | 2357 | } |
2356 | 2358 | ||
2357 | 2359 | ||
2358 | void CalendarView::eventChanged(Event *event) | 2360 | void CalendarView::eventChanged(Event *event) |
2359 | { | 2361 | { |
2360 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2362 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2361 | //updateUnmanagedViews(); | 2363 | //updateUnmanagedViews(); |
2362 | } | 2364 | } |
2363 | 2365 | ||
2364 | void CalendarView::eventAdded(Event *event) | 2366 | void CalendarView::eventAdded(Event *event) |
2365 | { | 2367 | { |
2366 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2368 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2367 | } | 2369 | } |
2368 | 2370 | ||
2369 | void CalendarView::eventToBeDeleted(Event *) | 2371 | void CalendarView::eventToBeDeleted(Event *) |
2370 | { | 2372 | { |
2371 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2373 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2372 | } | 2374 | } |
2373 | 2375 | ||
2374 | void CalendarView::eventDeleted() | 2376 | void CalendarView::eventDeleted() |
2375 | { | 2377 | { |
2376 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2378 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2377 | } | 2379 | } |
2378 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2380 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2379 | { | 2381 | { |
2380 | changeIncidenceDisplay((Incidence *)which, action); | 2382 | changeIncidenceDisplay((Incidence *)which, action); |
2381 | mDateNavigator->updateView(); //LR | 2383 | mDateNavigator->updateView(); //LR |
2382 | //mDialogManager->updateSearchDialog(); | 2384 | //mDialogManager->updateSearchDialog(); |
2383 | 2385 | ||
2384 | if (which) { | 2386 | if (which) { |
2385 | mViewManager->updateWNview(); | 2387 | mViewManager->updateWNview(); |
2386 | //mTodoList->updateView(); | 2388 | //mTodoList->updateView(); |
2387 | } | 2389 | } |
2388 | 2390 | ||
2389 | } | 2391 | } |
2390 | 2392 | ||
2391 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2393 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2392 | { | 2394 | { |
2393 | updateUnmanagedViews(); | 2395 | updateUnmanagedViews(); |
2394 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2396 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2395 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2397 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2396 | mCalendar->checkAlarmForIncidence( 0, true ); | 2398 | mCalendar->checkAlarmForIncidence( 0, true ); |
2397 | if ( mEventViewerDialog ) | 2399 | if ( mEventViewerDialog ) |
2398 | mEventViewerDialog->hide(); | 2400 | mEventViewerDialog->hide(); |
2399 | } | 2401 | } |
2400 | else | 2402 | else |
2401 | mCalendar->checkAlarmForIncidence( which , false ); | 2403 | mCalendar->checkAlarmForIncidence( which , false ); |
2402 | } | 2404 | } |
2403 | 2405 | ||
2404 | // most of the changeEventDisplays() right now just call the view's | 2406 | // most of the changeEventDisplays() right now just call the view's |
2405 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2407 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2406 | void CalendarView::changeEventDisplay(Event *which, int action) | 2408 | void CalendarView::changeEventDisplay(Event *which, int action) |
2407 | { | 2409 | { |
2408 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2410 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2409 | changeIncidenceDisplay((Incidence *)which, action); | 2411 | changeIncidenceDisplay((Incidence *)which, action); |
2410 | mDateNavigator->updateView(); | 2412 | mDateNavigator->updateView(); |
2411 | //mDialogManager->updateSearchDialog(); | 2413 | //mDialogManager->updateSearchDialog(); |
2412 | 2414 | ||
2413 | if (which) { | 2415 | if (which) { |
2414 | // If there is an event view visible update the display | 2416 | // If there is an event view visible update the display |
2415 | mViewManager->currentView()->changeEventDisplay(which,action); | 2417 | mViewManager->currentView()->changeEventDisplay(which,action); |
2416 | // TODO: check, if update needed | 2418 | // TODO: check, if update needed |
2417 | // if (which->getTodoStatus()) { | 2419 | // if (which->getTodoStatus()) { |
2418 | mTodoList->updateView(); | 2420 | mTodoList->updateView(); |
2419 | // } | 2421 | // } |
2420 | } else { | 2422 | } else { |
2421 | mViewManager->currentView()->updateView(); | 2423 | mViewManager->currentView()->updateView(); |
2422 | } | 2424 | } |
2423 | } | 2425 | } |
2424 | 2426 | ||
2425 | 2427 | ||
2426 | void CalendarView::updateTodoViews() | 2428 | void CalendarView::updateTodoViews() |
2427 | { | 2429 | { |
2428 | mTodoList->updateView(); | 2430 | mTodoList->updateView(); |
2429 | mViewManager->currentView()->updateView(); | 2431 | mViewManager->currentView()->updateView(); |
2430 | 2432 | ||
2431 | } | 2433 | } |
2432 | 2434 | ||
2433 | 2435 | ||
2434 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2436 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2435 | { | 2437 | { |
2436 | mTodoList->updateView(); | 2438 | mTodoList->updateView(); |
2437 | mViewManager->updateView(start, end); | 2439 | mViewManager->updateView(start, end); |
2438 | //mDateNavigator->updateView(); | 2440 | //mDateNavigator->updateView(); |
2439 | } | 2441 | } |
2440 | 2442 | ||
2441 | void CalendarView::clearAllViews() | 2443 | void CalendarView::clearAllViews() |
2442 | { | 2444 | { |
2443 | mTodoList->clearList(); | 2445 | mTodoList->clearList(); |
2444 | mViewManager->clearAllViews(); | 2446 | mViewManager->clearAllViews(); |
2445 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2447 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2446 | if ( sd ) { | 2448 | if ( sd ) { |
2447 | KOListView* kol = sd->listview(); | 2449 | KOListView* kol = sd->listview(); |
2448 | if ( kol ) | 2450 | if ( kol ) |
2449 | kol->clearList(); | 2451 | kol->clearList(); |
2450 | } | 2452 | } |
2451 | } | 2453 | } |
2452 | void CalendarView::updateView() | 2454 | void CalendarView::updateView() |
2453 | { | 2455 | { |
2454 | DateList tmpList = mNavigator->selectedDates(); | 2456 | DateList tmpList = mNavigator->selectedDates(); |
2455 | 2457 | ||
2456 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2458 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2457 | mTodoList->updateView(); | 2459 | mTodoList->updateView(); |
2458 | // We assume that the navigator only selects consecutive days. | 2460 | // We assume that the navigator only selects consecutive days. |
2459 | updateView( tmpList.first(), tmpList.last() ); | 2461 | updateView( tmpList.first(), tmpList.last() ); |
2460 | } | 2462 | } |
2461 | 2463 | ||
2462 | void CalendarView::updateUnmanagedViews() | 2464 | void CalendarView::updateUnmanagedViews() |
2463 | { | 2465 | { |
2464 | mDateNavigator->updateDayMatrix(); | 2466 | mDateNavigator->updateDayMatrix(); |
2465 | } | 2467 | } |
2466 | 2468 | ||
2467 | int CalendarView::msgItemDelete(const QString name) | 2469 | int CalendarView::msgItemDelete(const QString name) |
2468 | { | 2470 | { |
2469 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2471 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2470 | i18n("This item will be\npermanently deleted."), | 2472 | i18n("This item will be\npermanently deleted."), |
2471 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2473 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2472 | } | 2474 | } |
2473 | 2475 | ||
2474 | 2476 | ||
2475 | void CalendarView::edit_cut() | 2477 | void CalendarView::edit_cut() |
2476 | { | 2478 | { |
2477 | Event *anEvent=0; | 2479 | Event *anEvent=0; |
2478 | 2480 | ||
2479 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2481 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2480 | 2482 | ||
2481 | if (mViewManager->currentView()->isEventView()) { | 2483 | if (mViewManager->currentView()->isEventView()) { |
2482 | if ( incidence && incidence->typeID() == eventID ) { | 2484 | if ( incidence && incidence->typeID() == eventID ) { |
2483 | anEvent = static_cast<Event *>(incidence); | 2485 | anEvent = static_cast<Event *>(incidence); |
2484 | } | 2486 | } |
2485 | } | 2487 | } |
2486 | 2488 | ||
2487 | if (!anEvent) { | 2489 | if (!anEvent) { |
2488 | KNotifyClient::beep(); | 2490 | KNotifyClient::beep(); |
2489 | return; | 2491 | return; |
2490 | } | 2492 | } |
2491 | DndFactory factory( mCalendar ); | 2493 | DndFactory factory( mCalendar ); |
2492 | factory.cutIncidence(anEvent); | 2494 | factory.cutIncidence(anEvent); |
2493 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2495 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2494 | } | 2496 | } |
2495 | 2497 | ||
2496 | void CalendarView::edit_copy() | 2498 | void CalendarView::edit_copy() |
2497 | { | 2499 | { |
2498 | Event *anEvent=0; | 2500 | Event *anEvent=0; |
2499 | 2501 | ||
2500 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2502 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2501 | 2503 | ||
2502 | if (mViewManager->currentView()->isEventView()) { | 2504 | if (mViewManager->currentView()->isEventView()) { |
2503 | if ( incidence && incidence->typeID() == eventID ) { | 2505 | if ( incidence && incidence->typeID() == eventID ) { |
2504 | anEvent = static_cast<Event *>(incidence); | 2506 | anEvent = static_cast<Event *>(incidence); |
2505 | } | 2507 | } |
2506 | } | 2508 | } |
2507 | 2509 | ||
2508 | if (!anEvent) { | 2510 | if (!anEvent) { |
2509 | KNotifyClient::beep(); | 2511 | KNotifyClient::beep(); |
2510 | return; | 2512 | return; |
2511 | } | 2513 | } |
2512 | DndFactory factory( mCalendar ); | 2514 | DndFactory factory( mCalendar ); |
2513 | factory.copyIncidence(anEvent); | 2515 | factory.copyIncidence(anEvent); |
2514 | } | 2516 | } |
2515 | 2517 | ||
2516 | void CalendarView::edit_paste() | 2518 | void CalendarView::edit_paste() |
2517 | { | 2519 | { |
2518 | QDate date = mNavigator->selectedDates().first(); | 2520 | QDate date = mNavigator->selectedDates().first(); |
2519 | 2521 | ||
2520 | DndFactory factory( mCalendar ); | 2522 | DndFactory factory( mCalendar ); |
2521 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2523 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2522 | 2524 | ||
2523 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2525 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2524 | } | 2526 | } |
2525 | void CalendarView::edit_global_options() | 2527 | void CalendarView::edit_global_options() |
2526 | { | 2528 | { |
2527 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2529 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2528 | emit save(); | 2530 | emit save(); |
2529 | emit saveStopTimer(); | 2531 | emit saveStopTimer(); |
2530 | mDialogManager->showGlobalOptionsDialog(); | 2532 | mDialogManager->showGlobalOptionsDialog(); |
2531 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2533 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2532 | emit saveStopTimer(); | 2534 | emit saveStopTimer(); |
2533 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2535 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2534 | i18n("Timezone settings"),i18n("Reload"))) { | 2536 | i18n("Timezone settings"),i18n("Reload"))) { |
2535 | qDebug("KO: TZ reload cancelled "); | 2537 | qDebug("KO: TZ reload cancelled "); |
2536 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2538 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2537 | return; | 2539 | return; |
2538 | } | 2540 | } |
2539 | qDebug("KO: Timezone change "); | 2541 | qDebug("KO: Timezone change "); |
2540 | openCalendar( MainWindow::defaultFileName() ); | 2542 | openCalendar( MainWindow::defaultFileName() ); |
2541 | setModified(true); | 2543 | setModified(true); |
2542 | } | 2544 | } |
2543 | else | 2545 | else |
2544 | qDebug("KO: No tz change "); | 2546 | qDebug("KO: No tz change "); |
2545 | } | 2547 | } |
2546 | void CalendarView::edit_options() | 2548 | void CalendarView::edit_options() |
2547 | { | 2549 | { |
2548 | mDialogManager->showOptionsDialog(); | 2550 | mDialogManager->showOptionsDialog(); |
2549 | } | 2551 | } |
2550 | 2552 | ||
2551 | 2553 | ||
2552 | void CalendarView::slotSelectPickerDate( QDate d) | 2554 | void CalendarView::slotSelectPickerDate( QDate d) |
2553 | { | 2555 | { |
2554 | mDateFrame->hide(); | 2556 | mDateFrame->hide(); |
2555 | if ( mDatePickerMode == 1 ) { | 2557 | if ( mDatePickerMode == 1 ) { |
2556 | mNavigator->slotDaySelect( d ); | 2558 | mNavigator->slotDaySelect( d ); |
2557 | } else if ( mDatePickerMode == 2 ) { | 2559 | } else if ( mDatePickerMode == 2 ) { |
2558 | if ( mMoveIncidence->typeID() == todoID ) { | 2560 | if ( mMoveIncidence->typeID() == todoID ) { |
2559 | Todo * to = (Todo *) mMoveIncidence; | 2561 | Todo * to = (Todo *) mMoveIncidence; |
2560 | QTime tim; | 2562 | QTime tim; |
2561 | int len = 0; | 2563 | int len = 0; |
2562 | if ( to->hasStartDate() && to->hasDueDate() ) | 2564 | if ( to->hasStartDate() && to->hasDueDate() ) |
2563 | len = to->dtStart().secsTo( to->dtDue()); | 2565 | len = to->dtStart().secsTo( to->dtDue()); |
2564 | if ( to->hasDueDate() ) | 2566 | if ( to->hasDueDate() ) |
2565 | tim = to->dtDue().time(); | 2567 | tim = to->dtDue().time(); |
2566 | else { | 2568 | else { |
2567 | tim = QTime ( 0,0,0 ); | 2569 | tim = QTime ( 0,0,0 ); |
2568 | to->setFloats( true ); | 2570 | to->setFloats( true ); |
2569 | to->setHasDueDate( true ); | 2571 | to->setHasDueDate( true ); |
2570 | } | 2572 | } |
2571 | QDateTime dt ( d,tim ); | 2573 | QDateTime dt ( d,tim ); |
2572 | to->setDtDue( dt ); | 2574 | to->setDtDue( dt ); |
2573 | 2575 | ||
2574 | if ( to->hasStartDate() ) { | 2576 | if ( to->hasStartDate() ) { |
2575 | if ( len>0 ) | 2577 | if ( len>0 ) |
2576 | to->setDtStart(to->dtDue().addSecs( -len )); | 2578 | to->setDtStart(to->dtDue().addSecs( -len )); |
2577 | else | 2579 | else |
2578 | if (to->dtStart() > to->dtDue() ) | 2580 | if (to->dtStart() > to->dtDue() ) |
2579 | to->setDtStart(to->dtDue().addDays( -3 )); | 2581 | to->setDtStart(to->dtDue().addDays( -3 )); |
2580 | } | 2582 | } |
2581 | 2583 | ||
2582 | todoChanged( to ); | 2584 | todoChanged( to ); |
2583 | } else { | 2585 | } else { |
2584 | if ( mMoveIncidence->doesRecur() ) { | 2586 | if ( mMoveIncidence->doesRecur() ) { |
2585 | #if 0 | 2587 | #if 0 |
2586 | // PENDING implement this | 2588 | // PENDING implement this |
2587 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2589 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2588 | mCalendar()->addIncidence( newInc ); | 2590 | mCalendar()->addIncidence( newInc ); |
2589 | if ( mMoveIncidence->typeID() == todoID ) | 2591 | if ( mMoveIncidence->typeID() == todoID ) |
2590 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2592 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2591 | else | 2593 | else |
2592 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2594 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2593 | mMoveIncidence = newInc; | 2595 | mMoveIncidence = newInc; |
2594 | 2596 | ||
2595 | #endif | 2597 | #endif |
2596 | } | 2598 | } |
2597 | QTime tim = mMoveIncidence->dtStart().time(); | 2599 | QTime tim = mMoveIncidence->dtStart().time(); |
2598 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2600 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2599 | QDateTime dt ( d,tim ); | 2601 | QDateTime dt ( d,tim ); |
2600 | mMoveIncidence->setDtStart( dt ); | 2602 | mMoveIncidence->setDtStart( dt ); |
2601 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2603 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2602 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2604 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2603 | } | 2605 | } |
2604 | 2606 | ||
2605 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2607 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2606 | } | 2608 | } |
2607 | } | 2609 | } |
2608 | 2610 | ||
2609 | void CalendarView::removeCategories() | 2611 | void CalendarView::removeCategories() |
2610 | { | 2612 | { |
2611 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2613 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2612 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2614 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2613 | QStringList catIncList; | 2615 | QStringList catIncList; |
2614 | QStringList newCatList; | 2616 | QStringList newCatList; |
2615 | Incidence* inc = incList.first(); | 2617 | Incidence* inc = incList.first(); |
2616 | int i; | 2618 | int i; |
2617 | int count = 0; | 2619 | int count = 0; |
2618 | while ( inc ) { | 2620 | while ( inc ) { |
2619 | newCatList.clear(); | 2621 | newCatList.clear(); |
2620 | catIncList = inc->categories() ; | 2622 | catIncList = inc->categories() ; |
2621 | for( i = 0; i< catIncList.count(); ++i ) { | 2623 | for( i = 0; i< catIncList.count(); ++i ) { |
2622 | if ( catList.contains (catIncList[i])) | 2624 | if ( catList.contains (catIncList[i])) |
2623 | newCatList.append( catIncList[i] ); | 2625 | newCatList.append( catIncList[i] ); |
2624 | } | 2626 | } |
2625 | newCatList.sort(); | 2627 | newCatList.sort(); |
2626 | inc->setCategories( newCatList.join(",") ); | 2628 | inc->setCategories( newCatList.join(",") ); |
2627 | inc = incList.next(); | 2629 | inc = incList.next(); |
2628 | } | 2630 | } |
2629 | } | 2631 | } |
2630 | 2632 | ||
2631 | int CalendarView::addCategories() | 2633 | int CalendarView::addCategories() |
2632 | { | 2634 | { |
2633 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2635 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2634 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2636 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2635 | QStringList catIncList; | 2637 | QStringList catIncList; |
2636 | Incidence* inc = incList.first(); | 2638 | Incidence* inc = incList.first(); |
2637 | int i; | 2639 | int i; |
2638 | int count = 0; | 2640 | int count = 0; |
2639 | while ( inc ) { | 2641 | while ( inc ) { |
2640 | catIncList = inc->categories() ; | 2642 | catIncList = inc->categories() ; |
2641 | for( i = 0; i< catIncList.count(); ++i ) { | 2643 | for( i = 0; i< catIncList.count(); ++i ) { |
2642 | if ( !catList.contains (catIncList[i])) { | 2644 | if ( !catList.contains (catIncList[i])) { |
2643 | catList.append( catIncList[i] ); | 2645 | catList.append( catIncList[i] ); |
2644 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2646 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2645 | ++count; | 2647 | ++count; |
2646 | } | 2648 | } |
2647 | } | 2649 | } |
2648 | inc = incList.next(); | 2650 | inc = incList.next(); |
2649 | } | 2651 | } |
2650 | catList.sort(); | 2652 | catList.sort(); |
2651 | KOPrefs::instance()->mCustomCategories = catList; | 2653 | KOPrefs::instance()->mCustomCategories = catList; |
2652 | return count; | 2654 | return count; |
2653 | } | 2655 | } |
2654 | 2656 | ||
2655 | void CalendarView::manageCategories() | 2657 | void CalendarView::manageCategories() |
2656 | { | 2658 | { |
2657 | KOCatPrefs* cp = new KOCatPrefs(); | 2659 | KOCatPrefs* cp = new KOCatPrefs(); |
2658 | cp->show(); | 2660 | cp->show(); |
2659 | int w =cp->sizeHint().width() ; | 2661 | int w =cp->sizeHint().width() ; |
2660 | int h = cp->sizeHint().height() ; | 2662 | int h = cp->sizeHint().height() ; |
2661 | int dw = QApplication::desktop()->width(); | 2663 | int dw = QApplication::desktop()->width(); |
2662 | int dh = QApplication::desktop()->height(); | 2664 | int dh = QApplication::desktop()->height(); |
2663 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2665 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2664 | if ( !cp->exec() ) { | 2666 | if ( !cp->exec() ) { |
2665 | delete cp; | 2667 | delete cp; |
2666 | return; | 2668 | return; |
2667 | } | 2669 | } |
2668 | int count = 0; | 2670 | int count = 0; |
2669 | if ( cp->addCat() ) { | 2671 | if ( cp->addCat() ) { |
2670 | count = addCategories(); | 2672 | count = addCategories(); |
2671 | if ( count ) { | 2673 | if ( count ) { |
2672 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2674 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2673 | writeSettings(); | 2675 | writeSettings(); |
2674 | } else | 2676 | } else |
2675 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2677 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2676 | } else { | 2678 | } else { |
2677 | removeCategories(); | 2679 | removeCategories(); |
2678 | updateView(); | 2680 | updateView(); |
2679 | } | 2681 | } |
2680 | delete cp; | 2682 | delete cp; |
2681 | } | 2683 | } |
2682 | 2684 | ||
2683 | void CalendarView::beamIncidence(Incidence * Inc) | 2685 | void CalendarView::beamIncidence(Incidence * Inc) |
2684 | { | 2686 | { |
2685 | QPtrList<Incidence> delSel ; | 2687 | QPtrList<Incidence> delSel ; |
2686 | delSel.append(Inc); | 2688 | delSel.append(Inc); |
2687 | beamIncidenceList( delSel ); | 2689 | beamIncidenceList( delSel ); |
2688 | } | 2690 | } |
2689 | void CalendarView::beamCalendar() | 2691 | void CalendarView::beamCalendar() |
2690 | { | 2692 | { |
2691 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2693 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2692 | //qDebug("beamCalendar() "); | 2694 | //qDebug("beamCalendar() "); |
2693 | beamIncidenceList( delSel ); | 2695 | beamIncidenceList( delSel ); |
2694 | } | 2696 | } |
2695 | void CalendarView::beamFilteredCalendar() | 2697 | void CalendarView::beamFilteredCalendar() |
2696 | { | 2698 | { |
2697 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2699 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2698 | //qDebug("beamFilteredCalendar() "); | 2700 | //qDebug("beamFilteredCalendar() "); |
2699 | beamIncidenceList( delSel ); | 2701 | beamIncidenceList( delSel ); |
2700 | } | 2702 | } |
2701 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2703 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2702 | { | 2704 | { |
2703 | if ( beamDialog->exec () == QDialog::Rejected ) | 2705 | if ( beamDialog->exec () == QDialog::Rejected ) |
2704 | return; | 2706 | return; |
2705 | #ifdef DESKTOP_VERSION | 2707 | #ifdef DESKTOP_VERSION |
2706 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2708 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2707 | #else | 2709 | #else |
2708 | QString fn = "/tmp/kopibeamfile"; | 2710 | QString fn = "/tmp/kopibeamfile"; |
2709 | #endif | 2711 | #endif |
2710 | QString mes; | 2712 | QString mes; |
2711 | bool createbup = true; | 2713 | bool createbup = true; |
2712 | if ( createbup ) { | 2714 | if ( createbup ) { |
2713 | QString description = "\n"; | 2715 | QString description = "\n"; |
2714 | CalendarLocal* cal = new CalendarLocal(); | 2716 | CalendarLocal* cal = new CalendarLocal(); |
2715 | if ( beamDialog->beamLocal() ) | 2717 | if ( beamDialog->beamLocal() ) |
2716 | cal->setLocalTime(); | 2718 | cal->setLocalTime(); |
2717 | else | 2719 | else |
2718 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2720 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2719 | Incidence *incidence = delSel.first(); | 2721 | Incidence *incidence = delSel.first(); |
2720 | bool addText = false; | 2722 | bool addText = false; |
2721 | if ( delSel.count() < 10 ) | 2723 | if ( delSel.count() < 10 ) |
2722 | addText = true; | 2724 | addText = true; |
2723 | else { | 2725 | else { |
2724 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2726 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2725 | } | 2727 | } |
2726 | while ( incidence ) { | 2728 | while ( incidence ) { |
2727 | Incidence *in = incidence->clone(); | 2729 | Incidence *in = incidence->clone(); |
2728 | if ( ! in->summary().isEmpty() ) { | 2730 | if ( ! in->summary().isEmpty() ) { |
2729 | in->setDescription(""); | 2731 | in->setDescription(""); |
2730 | } else { | 2732 | } else { |
2731 | in->setSummary( in->description().left(20)); | 2733 | in->setSummary( in->description().left(20)); |
2732 | in->setDescription(""); | 2734 | in->setDescription(""); |
2733 | } | 2735 | } |
2734 | if ( addText ) | 2736 | if ( addText ) |
2735 | description += in->summary() + "\n"; | 2737 | description += in->summary() + "\n"; |
2736 | cal->addIncidence( in ); | 2738 | cal->addIncidence( in ); |
2737 | incidence = delSel.next(); | 2739 | incidence = delSel.next(); |
2738 | } | 2740 | } |
2739 | if ( beamDialog->beamVcal() ) { | 2741 | if ( beamDialog->beamVcal() ) { |
2740 | fn += ".vcs"; | 2742 | fn += ".vcs"; |
2741 | FileStorage storage( cal, fn, new VCalFormat ); | 2743 | FileStorage storage( cal, fn, new VCalFormat ); |
2742 | storage.save(); | 2744 | storage.save(); |
2743 | } else { | 2745 | } else { |
2744 | fn += ".ics"; | 2746 | fn += ".ics"; |
2745 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2747 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2746 | storage.save(); | 2748 | storage.save(); |
2747 | } | 2749 | } |
2748 | delete cal; | 2750 | delete cal; |
2749 | mes = i18n("KO/Pi: Ready for beaming"); | 2751 | mes = i18n("KO/Pi: Ready for beaming"); |
2750 | topLevelWidget()->setCaption(mes); | 2752 | topLevelWidget()->setCaption(mes); |
2751 | KApplication::convert2latin1( fn ); | 2753 | KApplication::convert2latin1( fn ); |
2752 | #ifndef DESKTOP_VERSION | 2754 | #ifndef DESKTOP_VERSION |
2753 | Ir *ir = new Ir( this ); | 2755 | Ir *ir = new Ir( this ); |
2754 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2756 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2755 | ir->send( fn, description, "text/x-vCalendar" ); | 2757 | ir->send( fn, description, "text/x-vCalendar" ); |
2756 | #endif | 2758 | #endif |
2757 | } | 2759 | } |
2758 | } | 2760 | } |
2759 | void CalendarView::beamDone( Ir *ir ) | 2761 | void CalendarView::beamDone( Ir *ir ) |
2760 | { | 2762 | { |
2761 | #ifndef DESKTOP_VERSION | 2763 | #ifndef DESKTOP_VERSION |
2762 | delete ir; | 2764 | delete ir; |
2763 | #endif | 2765 | #endif |
2764 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2766 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2765 | topLevelWidget()->raise(); | 2767 | topLevelWidget()->raise(); |
2766 | } | 2768 | } |
2767 | 2769 | ||
2768 | void CalendarView::moveIncidence(Incidence * inc ) | 2770 | void CalendarView::moveIncidence(Incidence * inc ) |
2769 | { | 2771 | { |
2770 | if ( !inc ) return; | 2772 | if ( !inc ) return; |
2771 | showDatePickerPopup(); | 2773 | showDatePickerPopup(); |
2772 | mDatePickerMode = 2; | 2774 | mDatePickerMode = 2; |
2773 | mMoveIncidence = inc ; | 2775 | mMoveIncidence = inc ; |
2774 | QDate da; | 2776 | QDate da; |
2775 | if ( mMoveIncidence->typeID() == todoID ) { | 2777 | if ( mMoveIncidence->typeID() == todoID ) { |
2776 | Todo * to = (Todo *) mMoveIncidence; | 2778 | Todo * to = (Todo *) mMoveIncidence; |
2777 | if ( to->hasDueDate() ) | 2779 | if ( to->hasDueDate() ) |
2778 | da = to->dtDue().date(); | 2780 | da = to->dtDue().date(); |
2779 | else | 2781 | else |
2780 | da = QDate::currentDate(); | 2782 | da = QDate::currentDate(); |
2781 | } else { | 2783 | } else { |
2782 | da = mMoveIncidence->dtStart().date(); | 2784 | da = mMoveIncidence->dtStart().date(); |
2783 | } | 2785 | } |
2784 | //PENDING set date for recurring incidence to date of recurrence | 2786 | //PENDING set date for recurring incidence to date of recurrence |
2785 | //mMoveIncidenceOldDate; | 2787 | //mMoveIncidenceOldDate; |
2786 | mDatePicker->setDate( da ); | 2788 | mDatePicker->setDate( da ); |
2787 | } | 2789 | } |
2788 | void CalendarView::showDatePickerPopup() | 2790 | void CalendarView::showDatePickerPopup() |
2789 | { | 2791 | { |
2790 | if ( mDateFrame->isVisible() ) | 2792 | if ( mDateFrame->isVisible() ) |
2791 | mDateFrame->hide(); | 2793 | mDateFrame->hide(); |
2792 | else { | 2794 | else { |
2793 | int offX = 0, offY = 0; | 2795 | int offX = 0, offY = 0; |
2794 | #ifdef DESKTOP_VERSION | 2796 | #ifdef DESKTOP_VERSION |
2795 | int w =mDatePicker->sizeHint().width() ; | 2797 | int w =mDatePicker->sizeHint().width() ; |
2796 | int h = mDatePicker->sizeHint().height() ; | 2798 | int h = mDatePicker->sizeHint().height() ; |
2797 | int dw = topLevelWidget()->width(); | 2799 | int dw = topLevelWidget()->width(); |
2798 | int dh = topLevelWidget()->height(); | 2800 | int dh = topLevelWidget()->height(); |
2799 | offX = topLevelWidget()->x(); | 2801 | offX = topLevelWidget()->x(); |
2800 | offY = topLevelWidget()->y(); | 2802 | offY = topLevelWidget()->y(); |
2801 | #else | 2803 | #else |
2802 | int w =mDatePicker->sizeHint().width() ; | 2804 | int w =mDatePicker->sizeHint().width() ; |
2803 | int h = mDatePicker->sizeHint().height() ; | 2805 | int h = mDatePicker->sizeHint().height() ; |
2804 | int dw = QApplication::desktop()->width(); | 2806 | int dw = QApplication::desktop()->width(); |
2805 | int dh = QApplication::desktop()->height(); | 2807 | int dh = QApplication::desktop()->height(); |
2806 | #endif | 2808 | #endif |
2807 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2809 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2808 | mDateFrame->show(); | 2810 | mDateFrame->show(); |
2809 | } | 2811 | } |
2810 | } | 2812 | } |
2811 | void CalendarView::showDatePicker( ) | 2813 | void CalendarView::showDatePicker( ) |
2812 | { | 2814 | { |
2813 | showDatePickerPopup(); | 2815 | showDatePickerPopup(); |
2814 | mDatePickerMode = 1; | 2816 | mDatePickerMode = 1; |
2815 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2817 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2816 | } | 2818 | } |
2817 | 2819 | ||
2818 | void CalendarView::showEventEditor() | 2820 | void CalendarView::showEventEditor() |
2819 | { | 2821 | { |
2820 | #ifdef DESKTOP_VERSION | 2822 | #ifdef DESKTOP_VERSION |
2821 | int x,y,w,h; | 2823 | int x,y,w,h; |
2822 | x = mEventEditor->geometry().x(); | 2824 | x = mEventEditor->geometry().x(); |
2823 | y = mEventEditor->geometry().y(); | 2825 | y = mEventEditor->geometry().y(); |
2824 | w = mEventEditor->width(); | 2826 | w = mEventEditor->width(); |
2825 | h = mEventEditor->height(); | 2827 | h = mEventEditor->height(); |
2826 | mEventEditor->show(); | 2828 | mEventEditor->show(); |
2827 | mEventEditor->setGeometry(x,y,w,h); | 2829 | mEventEditor->setGeometry(x,y,w,h); |
2828 | #else | 2830 | #else |
2829 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2831 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2830 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2832 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2831 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2833 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2832 | qApp->processEvents(); | 2834 | qApp->processEvents(); |
2833 | delete mEventEditor; | 2835 | delete mEventEditor; |
2834 | mEventEditor = mDialogManager->getEventEditor(); | 2836 | mEventEditor = mDialogManager->getEventEditor(); |
2835 | topLevelWidget()->setCaption( i18n("") ); | 2837 | topLevelWidget()->setCaption( i18n("") ); |
2836 | } | 2838 | } |
2837 | mEventEditor->showMaximized(); | 2839 | mEventEditor->showMaximized(); |
2838 | #endif | 2840 | #endif |
2839 | } | 2841 | } |
2840 | void CalendarView::showTodoEditor() | 2842 | void CalendarView::showTodoEditor() |
2841 | { | 2843 | { |
2842 | #ifdef DESKTOP_VERSION | 2844 | #ifdef DESKTOP_VERSION |
2843 | int x,y,w,h; | 2845 | int x,y,w,h; |
2844 | x = mTodoEditor->geometry().x(); | 2846 | x = mTodoEditor->geometry().x(); |
2845 | y = mTodoEditor->geometry().y(); | 2847 | y = mTodoEditor->geometry().y(); |
2846 | w = mTodoEditor->width(); | 2848 | w = mTodoEditor->width(); |
2847 | h = mTodoEditor->height(); | 2849 | h = mTodoEditor->height(); |
2848 | mTodoEditor->show(); | 2850 | mTodoEditor->show(); |
2849 | mTodoEditor->setGeometry(x,y,w,h); | 2851 | mTodoEditor->setGeometry(x,y,w,h); |
2850 | #else | 2852 | #else |
2851 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2853 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2852 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2854 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2853 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2855 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2854 | qApp->processEvents(); | 2856 | qApp->processEvents(); |
2855 | delete mTodoEditor; | 2857 | delete mTodoEditor; |
2856 | mTodoEditor = mDialogManager->getTodoEditor(); | 2858 | mTodoEditor = mDialogManager->getTodoEditor(); |
2857 | topLevelWidget()->setCaption( i18n("") ); | 2859 | topLevelWidget()->setCaption( i18n("") ); |
2858 | } | 2860 | } |
2859 | mTodoEditor->showMaximized(); | 2861 | mTodoEditor->showMaximized(); |
2860 | #endif | 2862 | #endif |
2861 | } | 2863 | } |
2862 | 2864 | ||
2863 | void CalendarView::cloneIncidence() | 2865 | void CalendarView::cloneIncidence() |
2864 | { | 2866 | { |
2865 | Incidence *incidence = currentSelection(); | 2867 | Incidence *incidence = currentSelection(); |
2866 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2868 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2867 | if ( incidence ) { | 2869 | if ( incidence ) { |
2868 | cloneIncidence(incidence); | 2870 | cloneIncidence(incidence); |
2869 | } | 2871 | } |
2870 | } | 2872 | } |
2871 | void CalendarView::moveIncidence() | 2873 | void CalendarView::moveIncidence() |
2872 | { | 2874 | { |
2873 | Incidence *incidence = currentSelection(); | 2875 | Incidence *incidence = currentSelection(); |
2874 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2876 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2875 | if ( incidence ) { | 2877 | if ( incidence ) { |
2876 | moveIncidence(incidence); | 2878 | moveIncidence(incidence); |
2877 | } | 2879 | } |
2878 | } | 2880 | } |
2879 | void CalendarView::beamIncidence() | 2881 | void CalendarView::beamIncidence() |
2880 | { | 2882 | { |
2881 | Incidence *incidence = currentSelection(); | 2883 | Incidence *incidence = currentSelection(); |
2882 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2884 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2883 | if ( incidence ) { | 2885 | if ( incidence ) { |
2884 | beamIncidence(incidence); | 2886 | beamIncidence(incidence); |
2885 | } | 2887 | } |
2886 | } | 2888 | } |
2887 | void CalendarView::toggleCancelIncidence() | 2889 | void CalendarView::toggleCancelIncidence() |
2888 | { | 2890 | { |
2889 | Incidence *incidence = currentSelection(); | 2891 | Incidence *incidence = currentSelection(); |
2890 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2892 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2891 | if ( incidence ) { | 2893 | if ( incidence ) { |
2892 | cancelIncidence(incidence); | 2894 | cancelIncidence(incidence); |
2893 | } | 2895 | } |
2894 | } | 2896 | } |
2895 | 2897 | ||
2896 | 2898 | ||
2897 | void CalendarView::cancelIncidence(Incidence * inc ) | 2899 | void CalendarView::cancelIncidence(Incidence * inc ) |
2898 | { | 2900 | { |
2899 | inc->setCancelled( ! inc->cancelled() ); | 2901 | inc->setCancelled( ! inc->cancelled() ); |
2900 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2902 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2901 | updateView(); | 2903 | updateView(); |
2902 | } | 2904 | } |
2903 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2905 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2904 | { | 2906 | { |
2905 | Incidence * newInc = orgInc->clone(); | 2907 | Incidence * newInc = orgInc->clone(); |
2906 | newInc->recreate(); | 2908 | newInc->recreate(); |
2907 | 2909 | ||
2908 | if ( newInc->typeID() == todoID ) { | 2910 | if ( newInc->typeID() == todoID ) { |
2909 | Todo* t = (Todo*) newInc; | 2911 | Todo* t = (Todo*) newInc; |
2910 | bool cloneSub = false; | 2912 | bool cloneSub = false; |
2911 | if ( orgInc->relations().count() ) { | 2913 | if ( orgInc->relations().count() ) { |
2912 | int result = KMessageBox::warningYesNoCancel(this, | 2914 | int result = KMessageBox::warningYesNoCancel(this, |
2913 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 2915 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
2914 | i18n("Todo has subtodos"), | 2916 | i18n("Todo has subtodos"), |
2915 | i18n("Yes"), | 2917 | i18n("Yes"), |
2916 | i18n("No")); | 2918 | i18n("No")); |
2917 | 2919 | ||
2918 | if ( result == KMessageBox::Cancel ) { | 2920 | if ( result == KMessageBox::Cancel ) { |
2919 | delete t; | 2921 | delete t; |
2920 | return; | 2922 | return; |
2921 | } | 2923 | } |
2922 | if (result == KMessageBox::Yes) cloneSub = true; | 2924 | if (result == KMessageBox::Yes) cloneSub = true; |
2923 | } | 2925 | } |
2924 | showTodoEditor(); | 2926 | showTodoEditor(); |
2925 | mTodoEditor->editTodo( t ); | 2927 | mTodoEditor->editTodo( t ); |
2926 | if ( mTodoEditor->exec() ) { | 2928 | if ( mTodoEditor->exec() ) { |
2927 | if ( cloneSub ) { | 2929 | if ( cloneSub ) { |
2928 | orgInc->cloneRelations( t ); | 2930 | orgInc->cloneRelations( t ); |
2929 | mCalendar->addIncidenceBranch( t ); | 2931 | mCalendar->addIncidenceBranch( t ); |
2930 | updateView(); | 2932 | updateView(); |
2931 | 2933 | ||
2932 | } else { | 2934 | } else { |
2933 | mCalendar->addTodo( t ); | 2935 | mCalendar->addTodo( t ); |
2934 | updateView(); | 2936 | updateView(); |
2935 | } | 2937 | } |
2936 | } else { | 2938 | } else { |
2937 | delete t; | 2939 | delete t; |
2938 | } | 2940 | } |
2939 | } | 2941 | } |
2940 | else { | 2942 | else { |
2941 | Event* e = (Event*) newInc; | 2943 | Event* e = (Event*) newInc; |
2942 | showEventEditor(); | 2944 | showEventEditor(); |
2943 | mEventEditor->editEvent( e ); | 2945 | mEventEditor->editEvent( e ); |
2944 | if ( mEventEditor->exec() ) { | 2946 | if ( mEventEditor->exec() ) { |
2945 | mCalendar->addEvent( e ); | 2947 | mCalendar->addEvent( e ); |
2946 | updateView(); | 2948 | updateView(); |
2947 | } else { | 2949 | } else { |
2948 | delete e; | 2950 | delete e; |
2949 | } | 2951 | } |
2950 | } | 2952 | } |
2951 | setActiveWindow(); | 2953 | setActiveWindow(); |
2952 | } | 2954 | } |
2953 | 2955 | ||
2954 | void CalendarView::newEvent() | 2956 | void CalendarView::newEvent() |
2955 | { | 2957 | { |
2956 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2958 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2957 | KOAgendaView *aView = mViewManager->agendaView(); | 2959 | KOAgendaView *aView = mViewManager->agendaView(); |
2958 | if (aView) { | 2960 | if (aView) { |
2959 | if (aView->selectionStart().isValid()) { | 2961 | if (aView->selectionStart().isValid()) { |
2960 | if (aView->selectedIsAllDay()) { | 2962 | if (aView->selectedIsAllDay()) { |
2961 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2963 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2962 | } else { | 2964 | } else { |
2963 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2965 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2964 | } | 2966 | } |
2965 | return; | 2967 | return; |
2966 | } | 2968 | } |
2967 | } | 2969 | } |
2968 | 2970 | ||
2969 | QDate date = mNavigator->selectedDates().first(); | 2971 | QDate date = mNavigator->selectedDates().first(); |
2970 | QDateTime current = QDateTime::currentDateTime(); | 2972 | QDateTime current = QDateTime::currentDateTime(); |
2971 | if ( date <= current.date() ) { | 2973 | if ( date <= current.date() ) { |
2972 | int hour = current.time().hour() +1; | 2974 | int hour = current.time().hour() +1; |
2973 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2975 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2974 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2976 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2975 | } else | 2977 | } else |
2976 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2978 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2977 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2979 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2978 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2980 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2979 | } | 2981 | } |
2980 | 2982 | ||
2981 | void CalendarView::newEvent(QDateTime fh) | 2983 | void CalendarView::newEvent(QDateTime fh) |
2982 | { | 2984 | { |
2983 | newEvent(fh, | 2985 | newEvent(fh, |
2984 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2986 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2985 | } | 2987 | } |
2986 | 2988 | ||
2987 | void CalendarView::newEvent(QDate dt) | 2989 | void CalendarView::newEvent(QDate dt) |
2988 | { | 2990 | { |
2989 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2991 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2990 | QDateTime(dt, QTime(0,0,0)), true); | 2992 | QDateTime(dt, QTime(0,0,0)), true); |
2991 | } | 2993 | } |
2992 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2994 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2993 | { | 2995 | { |
2994 | newEvent(fromHint, toHint, false); | 2996 | newEvent(fromHint, toHint, false); |
2995 | } | 2997 | } |
2996 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2998 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2997 | { | 2999 | { |
2998 | 3000 | ||
2999 | showEventEditor(); | 3001 | showEventEditor(); |
3000 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3002 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3001 | if ( mFilterView->filtersEnabled() ) { | 3003 | if ( mFilterView->filtersEnabled() ) { |
3002 | CalFilter *filter = mFilterView->selectedFilter(); | 3004 | CalFilter *filter = mFilterView->selectedFilter(); |
3003 | if (filter && filter->showCategories()) { | 3005 | if (filter && filter->showCategories()) { |
3004 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3006 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3005 | } | 3007 | } |
3006 | if ( filter ) | 3008 | if ( filter ) |
3007 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3009 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3008 | } | 3010 | } |
3009 | mEventEditor->exec(); | 3011 | mEventEditor->exec(); |
3010 | setActiveWindow(); | 3012 | setActiveWindow(); |
3011 | } | 3013 | } |
3012 | void CalendarView::todoAdded(Todo * t) | 3014 | void CalendarView::todoAdded(Todo * t) |
3013 | { | 3015 | { |
3014 | 3016 | ||
3015 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3017 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3016 | updateTodoViews(); | 3018 | updateTodoViews(); |
3017 | } | 3019 | } |
3018 | void CalendarView::todoChanged(Todo * t) | 3020 | void CalendarView::todoChanged(Todo * t) |
3019 | { | 3021 | { |
3020 | emit todoModified( t, 4 ); | 3022 | emit todoModified( t, 4 ); |
3021 | // updateTodoViews(); | 3023 | // updateTodoViews(); |
3022 | } | 3024 | } |
3023 | void CalendarView::todoToBeDeleted(Todo *) | 3025 | void CalendarView::todoToBeDeleted(Todo *) |
3024 | { | 3026 | { |
3025 | //qDebug("todoToBeDeleted(Todo *) "); | 3027 | //qDebug("todoToBeDeleted(Todo *) "); |
3026 | updateTodoViews(); | 3028 | updateTodoViews(); |
3027 | } | 3029 | } |
3028 | void CalendarView::todoDeleted() | 3030 | void CalendarView::todoDeleted() |
3029 | { | 3031 | { |
3030 | //qDebug(" todoDeleted()"); | 3032 | //qDebug(" todoDeleted()"); |
3031 | updateTodoViews(); | 3033 | updateTodoViews(); |
3032 | } | 3034 | } |
3033 | 3035 | ||
3034 | 3036 | ||
3035 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3037 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3036 | { | 3038 | { |
3037 | showTodoEditor(); | 3039 | showTodoEditor(); |
3038 | mTodoEditor->newTodo(dt,0,allday); | 3040 | mTodoEditor->newTodo(dt,0,allday); |
3039 | if ( mFilterView->filtersEnabled() ) { | 3041 | if ( mFilterView->filtersEnabled() ) { |
3040 | CalFilter *filter = mFilterView->selectedFilter(); | 3042 | CalFilter *filter = mFilterView->selectedFilter(); |
3041 | if (filter && filter->showCategories()) { | 3043 | if (filter && filter->showCategories()) { |
3042 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3044 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3043 | } | 3045 | } |
3044 | if ( filter ) | 3046 | if ( filter ) |
3045 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3047 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3046 | } | 3048 | } |
3047 | mTodoEditor->exec(); | 3049 | mTodoEditor->exec(); |
3048 | setActiveWindow(); | 3050 | setActiveWindow(); |
3049 | } | 3051 | } |
3050 | 3052 | ||
3051 | void CalendarView::newTodo() | 3053 | void CalendarView::newTodo() |
3052 | { | 3054 | { |
3053 | newTodoDateTime( QDateTime(),true ); | 3055 | newTodoDateTime( QDateTime(),true ); |
3054 | } | 3056 | } |
3055 | 3057 | ||
3056 | void CalendarView::newSubTodo() | 3058 | void CalendarView::newSubTodo() |
3057 | { | 3059 | { |
3058 | Todo *todo = selectedTodo(); | 3060 | Todo *todo = selectedTodo(); |
3059 | if ( todo ) newSubTodo( todo ); | 3061 | if ( todo ) newSubTodo( todo ); |
3060 | } | 3062 | } |
3061 | 3063 | ||
3062 | void CalendarView::newSubTodo(Todo *parentEvent) | 3064 | void CalendarView::newSubTodo(Todo *parentEvent) |
3063 | { | 3065 | { |
3064 | 3066 | ||
3065 | showTodoEditor(); | 3067 | showTodoEditor(); |
3066 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3068 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3067 | mTodoEditor->exec(); | 3069 | mTodoEditor->exec(); |
3068 | setActiveWindow(); | 3070 | setActiveWindow(); |
3069 | } | 3071 | } |
3070 | 3072 | ||
3071 | void CalendarView::newFloatingEvent() | 3073 | void CalendarView::newFloatingEvent() |
3072 | { | 3074 | { |
3073 | DateList tmpList = mNavigator->selectedDates(); | 3075 | DateList tmpList = mNavigator->selectedDates(); |
3074 | QDate date = tmpList.first(); | 3076 | QDate date = tmpList.first(); |
3075 | 3077 | ||
3076 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3078 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3077 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3079 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3078 | } | 3080 | } |
3079 | 3081 | ||
3080 | 3082 | ||
3081 | void CalendarView::editEvent( Event *event ) | 3083 | void CalendarView::editEvent( Event *event ) |
3082 | { | 3084 | { |
3083 | 3085 | ||
3084 | if ( !event ) return; | 3086 | if ( !event ) return; |
3085 | if ( event->isReadOnly() ) { | 3087 | if ( event->isReadOnly() ) { |
3086 | showEvent( event ); | 3088 | showEvent( event ); |
3087 | return; | 3089 | return; |
3088 | } | 3090 | } |
3089 | showEventEditor(); | 3091 | showEventEditor(); |
3090 | mEventEditor->editEvent( event , mFlagEditDescription); | 3092 | mEventEditor->editEvent( event , mFlagEditDescription); |
3091 | mEventEditor->exec(); | 3093 | mEventEditor->exec(); |
3092 | setActiveWindow(); | 3094 | setActiveWindow(); |
3093 | 3095 | ||
3094 | } | 3096 | } |
3095 | void CalendarView::editJournal( Journal *jour ) | 3097 | void CalendarView::editJournal( Journal *jour ) |
3096 | { | 3098 | { |
3097 | if ( !jour ) return; | 3099 | if ( !jour ) return; |
3098 | mDialogManager->hideSearchDialog(); | 3100 | mDialogManager->hideSearchDialog(); |
3099 | mViewManager->showJournalView(); | 3101 | mViewManager->showJournalView(); |
3100 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3102 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3101 | } | 3103 | } |
3102 | void CalendarView::editTodo( Todo *todo ) | 3104 | void CalendarView::editTodo( Todo *todo ) |
3103 | { | 3105 | { |
3104 | if ( !todo ) return; | 3106 | if ( !todo ) return; |
3105 | 3107 | ||
3106 | if ( todo->isReadOnly() ) { | 3108 | if ( todo->isReadOnly() ) { |
3107 | showTodo( todo ); | 3109 | showTodo( todo ); |
3108 | return; | 3110 | return; |
3109 | } | 3111 | } |
3110 | showTodoEditor(); | 3112 | showTodoEditor(); |
3111 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3113 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3112 | mTodoEditor->exec(); | 3114 | mTodoEditor->exec(); |
3113 | setActiveWindow(); | 3115 | setActiveWindow(); |
3114 | 3116 | ||
3115 | } | 3117 | } |
3116 | 3118 | ||
3117 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3119 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3118 | { | 3120 | { |
3119 | if ( !mEventViewerDialog ) { | 3121 | if ( !mEventViewerDialog ) { |
3120 | mEventViewerDialog = new KOEventViewerDialog(0); | 3122 | mEventViewerDialog = new KOEventViewerDialog(0); |
3121 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3123 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3122 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3124 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3123 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3125 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3124 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3126 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3125 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3127 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3126 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3128 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3127 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3129 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3128 | this, SLOT( slotViewerClosed() ) ); | 3130 | this, SLOT( slotViewerClosed() ) ); |
3129 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3131 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3130 | this, SLOT( todoChanged(Todo *) ) ); | 3132 | this, SLOT( todoChanged(Todo *) ) ); |
3131 | mEventViewerDialog->resize( 640, 480 ); | 3133 | mEventViewerDialog->resize( 640, 480 ); |
3132 | 3134 | ||
3133 | } | 3135 | } |
3134 | return mEventViewerDialog; | 3136 | return mEventViewerDialog; |
3135 | } | 3137 | } |
3136 | void CalendarView::showEvent(Event *event) | 3138 | void CalendarView::showEvent(Event *event) |
3137 | { | 3139 | { |
3138 | getEventViewerDialog()->setEvent(event); | 3140 | getEventViewerDialog()->setEvent(event); |
3139 | getEventViewerDialog()->showMe(); | 3141 | getEventViewerDialog()->showMe(); |
3140 | } | 3142 | } |
3141 | 3143 | ||
3142 | void CalendarView::showTodo(Todo *event) | 3144 | void CalendarView::showTodo(Todo *event) |
3143 | { | 3145 | { |
3144 | getEventViewerDialog()->setTodo(event); | 3146 | getEventViewerDialog()->setTodo(event); |
3145 | getEventViewerDialog()->showMe(); | 3147 | getEventViewerDialog()->showMe(); |
3146 | } | 3148 | } |
3147 | void CalendarView::showJournal( Journal *jour ) | 3149 | void CalendarView::showJournal( Journal *jour ) |
3148 | { | 3150 | { |
3149 | getEventViewerDialog()->setJournal(jour); | 3151 | getEventViewerDialog()->setJournal(jour); |
3150 | getEventViewerDialog()->showMe(); | 3152 | getEventViewerDialog()->showMe(); |
3151 | 3153 | ||
3152 | } | 3154 | } |
3153 | // void CalendarView::todoModified (Todo *event, int changed) | 3155 | // void CalendarView::todoModified (Todo *event, int changed) |
3154 | // { | 3156 | // { |
3155 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3157 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3156 | // // kdDebug() << "Todo modified and open" << endl; | 3158 | // // kdDebug() << "Todo modified and open" << endl; |
3157 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3159 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3158 | // // temp->modified (changed); | 3160 | // // temp->modified (changed); |
3159 | 3161 | ||
3160 | // // } | 3162 | // // } |
3161 | 3163 | ||
3162 | // mViewManager->updateView(); | 3164 | // mViewManager->updateView(); |
3163 | // } | 3165 | // } |
3164 | 3166 | ||
3165 | void CalendarView::appointment_show() | 3167 | void CalendarView::appointment_show() |
3166 | { | 3168 | { |
3167 | Event *anEvent = 0; | 3169 | Event *anEvent = 0; |
3168 | 3170 | ||
3169 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3171 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3170 | 3172 | ||
3171 | if (mViewManager->currentView()->isEventView()) { | 3173 | if (mViewManager->currentView()->isEventView()) { |
3172 | if ( incidence && incidence->typeID() == eventID ) { | 3174 | if ( incidence && incidence->typeID() == eventID ) { |
3173 | anEvent = static_cast<Event *>(incidence); | 3175 | anEvent = static_cast<Event *>(incidence); |
3174 | } | 3176 | } |
3175 | } | 3177 | } |
3176 | 3178 | ||
3177 | if (!anEvent) { | 3179 | if (!anEvent) { |
3178 | KNotifyClient::beep(); | 3180 | KNotifyClient::beep(); |
3179 | return; | 3181 | return; |
3180 | } | 3182 | } |
3181 | 3183 | ||
3182 | showEvent(anEvent); | 3184 | showEvent(anEvent); |
3183 | } | 3185 | } |
3184 | 3186 | ||
3185 | void CalendarView::appointment_edit() | 3187 | void CalendarView::appointment_edit() |
3186 | { | 3188 | { |
3187 | Event *anEvent = 0; | 3189 | Event *anEvent = 0; |
3188 | 3190 | ||
3189 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3191 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3190 | 3192 | ||
3191 | if (mViewManager->currentView()->isEventView()) { | 3193 | if (mViewManager->currentView()->isEventView()) { |
3192 | if ( incidence && incidence->typeID() == eventID ) { | 3194 | if ( incidence && incidence->typeID() == eventID ) { |
3193 | anEvent = static_cast<Event *>(incidence); | 3195 | anEvent = static_cast<Event *>(incidence); |
3194 | } | 3196 | } |
3195 | } | 3197 | } |
3196 | 3198 | ||
3197 | if (!anEvent) { | 3199 | if (!anEvent) { |
3198 | KNotifyClient::beep(); | 3200 | KNotifyClient::beep(); |
3199 | return; | 3201 | return; |
3200 | } | 3202 | } |
3201 | 3203 | ||
3202 | editEvent(anEvent); | 3204 | editEvent(anEvent); |
3203 | } | 3205 | } |
3204 | 3206 | ||
3205 | void CalendarView::appointment_delete() | 3207 | void CalendarView::appointment_delete() |
3206 | { | 3208 | { |
3207 | Event *anEvent = 0; | 3209 | Event *anEvent = 0; |
3208 | 3210 | ||
3209 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3211 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3210 | 3212 | ||
3211 | if (mViewManager->currentView()->isEventView()) { | 3213 | if (mViewManager->currentView()->isEventView()) { |
3212 | if ( incidence && incidence->typeID() == eventID ) { | 3214 | if ( incidence && incidence->typeID() == eventID ) { |
3213 | anEvent = static_cast<Event *>(incidence); | 3215 | anEvent = static_cast<Event *>(incidence); |
3214 | } | 3216 | } |
3215 | } | 3217 | } |
3216 | 3218 | ||
3217 | if (!anEvent) { | 3219 | if (!anEvent) { |
3218 | KNotifyClient::beep(); | 3220 | KNotifyClient::beep(); |
3219 | return; | 3221 | return; |
3220 | } | 3222 | } |
3221 | 3223 | ||
3222 | deleteEvent(anEvent); | 3224 | deleteEvent(anEvent); |
3223 | } | 3225 | } |
3224 | 3226 | ||
3225 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3227 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3226 | { | 3228 | { |
3227 | if (!sub) return; | 3229 | if (!sub) return; |
3228 | if ( sub->relatedTo() == parent ) | 3230 | if ( sub->relatedTo() == parent ) |
3229 | return; | 3231 | return; |
3230 | sub->setRelatedTo(parent); | 3232 | sub->setRelatedTo(parent); |
3231 | sub->updated(); | 3233 | sub->updated(); |
3232 | setModified(true); | 3234 | setModified(true); |
3233 | updateView(); | 3235 | updateView(); |
3234 | } | 3236 | } |
3235 | void CalendarView::todo_unsub(Todo *anTodo ) | 3237 | void CalendarView::todo_unsub(Todo *anTodo ) |
3236 | { | 3238 | { |
3237 | todo_resub( 0, anTodo ); | 3239 | todo_resub( 0, anTodo ); |
3238 | } | 3240 | } |
3239 | 3241 | ||
3240 | void CalendarView::deleteTodo(Todo *todo) | 3242 | void CalendarView::deleteTodo(Todo *todo) |
3241 | { | 3243 | { |
3242 | if (!todo) { | 3244 | if (!todo) { |
3243 | KNotifyClient::beep(); | 3245 | KNotifyClient::beep(); |
3244 | return; | 3246 | return; |
3245 | } | 3247 | } |
3246 | if (KOPrefs::instance()->mConfirm) { | 3248 | if (KOPrefs::instance()->mConfirm) { |
3247 | QString text = todo->summary().left(20); | 3249 | QString text = todo->summary().left(20); |
3248 | if (!todo->relations().isEmpty()) { | 3250 | if (!todo->relations().isEmpty()) { |
3249 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3251 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3250 | 3252 | ||
3251 | } | 3253 | } |
3252 | switch (msgItemDelete(text)) { | 3254 | switch (msgItemDelete(text)) { |
3253 | case KMessageBox::Continue: // OK | 3255 | case KMessageBox::Continue: // OK |
3254 | bool deleteT = false; | 3256 | bool deleteT = false; |
3255 | if (!todo->relations().isEmpty()) { | 3257 | if (!todo->relations().isEmpty()) { |
3256 | deleteT = removeCompletedSubTodos( todo ); | 3258 | deleteT = removeCompletedSubTodos( todo ); |
3257 | } | 3259 | } |
3258 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3260 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3259 | if ( !deleteT ) { | 3261 | if ( !deleteT ) { |
3260 | checkExternalId( todo ); | 3262 | checkExternalId( todo ); |
3261 | calendar()->deleteTodo(todo); | 3263 | calendar()->deleteTodo(todo); |
3262 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3264 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3263 | updateView(); | 3265 | updateView(); |
3264 | } | 3266 | } |
3265 | break; | 3267 | break; |
3266 | } // switch | 3268 | } // switch |
3267 | } else { | 3269 | } else { |
3268 | checkExternalId( todo ); | 3270 | checkExternalId( todo ); |
3269 | mCalendar->deleteTodo(todo); | 3271 | mCalendar->deleteTodo(todo); |
3270 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3272 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3271 | updateView(); | 3273 | updateView(); |
3272 | } | 3274 | } |
3273 | 3275 | ||
3274 | emit updateSearchDialog(); | 3276 | emit updateSearchDialog(); |
3275 | } | 3277 | } |
3276 | void CalendarView::deleteJournal(Journal *jour) | 3278 | void CalendarView::deleteJournal(Journal *jour) |
3277 | { | 3279 | { |
3278 | if (!jour) { | 3280 | if (!jour) { |
3279 | KNotifyClient::beep(); | 3281 | KNotifyClient::beep(); |
3280 | return; | 3282 | return; |
3281 | } | 3283 | } |
3282 | if (KOPrefs::instance()->mConfirm) { | 3284 | if (KOPrefs::instance()->mConfirm) { |
3283 | switch (msgItemDelete( jour->description().left(20))) { | 3285 | switch (msgItemDelete( jour->description().left(20))) { |
3284 | case KMessageBox::Continue: // OK | 3286 | case KMessageBox::Continue: // OK |
3285 | calendar()->deleteJournal(jour); | 3287 | calendar()->deleteJournal(jour); |
3286 | updateView(); | 3288 | updateView(); |
3287 | break; | 3289 | break; |
3288 | } // switch | 3290 | } // switch |
3289 | } else { | 3291 | } else { |
3290 | calendar()->deleteJournal(jour);; | 3292 | calendar()->deleteJournal(jour);; |
3291 | updateView(); | 3293 | updateView(); |
3292 | } | 3294 | } |
3293 | emit updateSearchDialog(); | 3295 | emit updateSearchDialog(); |
3294 | } | 3296 | } |
3295 | 3297 | ||
3296 | void CalendarView::deleteEvent(Event *anEvent) | 3298 | void CalendarView::deleteEvent(Event *anEvent) |
3297 | { | 3299 | { |
3298 | if (!anEvent) { | 3300 | if (!anEvent) { |
3299 | KNotifyClient::beep(); | 3301 | KNotifyClient::beep(); |
3300 | return; | 3302 | return; |
3301 | } | 3303 | } |
3302 | 3304 | ||
3303 | if (anEvent->recurrence()->doesRecur()) { | 3305 | if (anEvent->recurrence()->doesRecur()) { |
3304 | QDate itemDate = mViewManager->currentSelectionDate(); | 3306 | QDate itemDate = mViewManager->currentSelectionDate(); |
3305 | int km; | 3307 | int km; |
3306 | if (!itemDate.isValid()) { | 3308 | if (!itemDate.isValid()) { |
3307 | //kdDebug() << "Date Not Valid" << endl; | 3309 | //kdDebug() << "Date Not Valid" << endl; |
3308 | if (KOPrefs::instance()->mConfirm) { | 3310 | if (KOPrefs::instance()->mConfirm) { |
3309 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3311 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3310 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3312 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3311 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3313 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3312 | if ( km == KMessageBox::Continue ) | 3314 | if ( km == KMessageBox::Continue ) |
3313 | km = KMessageBox::No; // No = all below | 3315 | km = KMessageBox::No; // No = all below |
3314 | } else | 3316 | } else |
3315 | km = KMessageBox::No; | 3317 | km = KMessageBox::No; |
3316 | } else { | 3318 | } else { |
3317 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3319 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3318 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3320 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3319 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3321 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3320 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3322 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3321 | i18n("All")); | 3323 | i18n("All")); |
3322 | } | 3324 | } |
3323 | switch(km) { | 3325 | switch(km) { |
3324 | 3326 | ||
3325 | case KMessageBox::No: // Continue // all | 3327 | case KMessageBox::No: // Continue // all |
3326 | //qDebug("KMessageBox::No "); | 3328 | //qDebug("KMessageBox::No "); |
3327 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3329 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3328 | schedule(Scheduler::Cancel,anEvent); | 3330 | schedule(Scheduler::Cancel,anEvent); |
3329 | 3331 | ||
3330 | checkExternalId( anEvent); | 3332 | checkExternalId( anEvent); |
3331 | mCalendar->deleteEvent(anEvent); | 3333 | mCalendar->deleteEvent(anEvent); |
3332 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3334 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3333 | break; | 3335 | break; |
3334 | 3336 | ||
3335 | // Disabled because it does not work | 3337 | // Disabled because it does not work |
3336 | //#if 0 | 3338 | //#if 0 |
3337 | case KMessageBox::Yes: // just this one | 3339 | case KMessageBox::Yes: // just this one |
3338 | //QDate qd = mNavigator->selectedDates().first(); | 3340 | //QDate qd = mNavigator->selectedDates().first(); |
3339 | //if (!qd.isValid()) { | 3341 | //if (!qd.isValid()) { |
3340 | // kdDebug() << "no date selected, or invalid date" << endl; | 3342 | // kdDebug() << "no date selected, or invalid date" << endl; |
3341 | // KNotifyClient::beep(); | 3343 | // KNotifyClient::beep(); |
3342 | // return; | 3344 | // return; |
3343 | //} | 3345 | //} |
3344 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3346 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3345 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3347 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3346 | anEvent->addExDate(itemDate); | 3348 | anEvent->addExDate(itemDate); |
3347 | int duration = anEvent->recurrence()->duration(); | 3349 | int duration = anEvent->recurrence()->duration(); |
3348 | if ( duration > 0 ) { | 3350 | if ( duration > 0 ) { |
3349 | anEvent->recurrence()->setDuration( duration - 1 ); | 3351 | anEvent->recurrence()->setDuration( duration - 1 ); |
3350 | } | 3352 | } |
3351 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3353 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3352 | } | 3354 | } |
3353 | break; | 3355 | break; |
3354 | //#endif | 3356 | //#endif |
3355 | } // switch | 3357 | } // switch |
3356 | } else { | 3358 | } else { |
3357 | if (KOPrefs::instance()->mConfirm) { | 3359 | if (KOPrefs::instance()->mConfirm) { |
3358 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3360 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3359 | i18n("\nAre you sure you want\nto delete this event?"), | 3361 | i18n("\nAre you sure you want\nto delete this event?"), |
3360 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3362 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3361 | case KMessageBox::Continue: // OK | 3363 | case KMessageBox::Continue: // OK |
3362 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3364 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3363 | schedule(Scheduler::Cancel,anEvent); | 3365 | schedule(Scheduler::Cancel,anEvent); |
3364 | checkExternalId( anEvent); | 3366 | checkExternalId( anEvent); |
3365 | mCalendar->deleteEvent(anEvent); | 3367 | mCalendar->deleteEvent(anEvent); |
3366 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3368 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3367 | break; | 3369 | break; |
3368 | } // switch | 3370 | } // switch |
3369 | } else { | 3371 | } else { |
3370 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3372 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3371 | schedule(Scheduler::Cancel,anEvent); | 3373 | schedule(Scheduler::Cancel,anEvent); |
3372 | checkExternalId( anEvent); | 3374 | checkExternalId( anEvent); |
3373 | mCalendar->deleteEvent(anEvent); | 3375 | mCalendar->deleteEvent(anEvent); |
3374 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3376 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3375 | } | 3377 | } |
3376 | } // if-else | 3378 | } // if-else |
3377 | emit updateSearchDialog(); | 3379 | emit updateSearchDialog(); |
3378 | } | 3380 | } |
3379 | 3381 | ||
3380 | bool CalendarView::deleteEvent(const QString &uid) | 3382 | bool CalendarView::deleteEvent(const QString &uid) |
3381 | { | 3383 | { |
3382 | Event *ev = mCalendar->event(uid); | 3384 | Event *ev = mCalendar->event(uid); |
3383 | if (ev) { | 3385 | if (ev) { |
3384 | deleteEvent(ev); | 3386 | deleteEvent(ev); |
3385 | return true; | 3387 | return true; |
3386 | } else { | 3388 | } else { |
3387 | return false; | 3389 | return false; |
3388 | } | 3390 | } |
3389 | } | 3391 | } |
3390 | 3392 | ||
3391 | /*****************************************************************************/ | 3393 | /*****************************************************************************/ |
3392 | 3394 | ||
3393 | void CalendarView::action_mail() | 3395 | void CalendarView::action_mail() |
3394 | { | 3396 | { |
3395 | #ifndef KORG_NOMAIL | 3397 | #ifndef KORG_NOMAIL |
3396 | KOMailClient mailClient; | 3398 | KOMailClient mailClient; |
3397 | 3399 | ||
3398 | Incidence *incidence = currentSelection(); | 3400 | Incidence *incidence = currentSelection(); |
3399 | 3401 | ||
3400 | if (!incidence) { | 3402 | if (!incidence) { |
3401 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3403 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3402 | return; | 3404 | return; |
3403 | } | 3405 | } |
3404 | if(incidence->attendeeCount() == 0 ) { | 3406 | if(incidence->attendeeCount() == 0 ) { |
3405 | KMessageBox::sorry(this, | 3407 | KMessageBox::sorry(this, |
3406 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3408 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3407 | return; | 3409 | return; |
3408 | } | 3410 | } |
3409 | 3411 | ||
3410 | CalendarLocal cal_tmp; | 3412 | CalendarLocal cal_tmp; |
3411 | Event *event = 0; | 3413 | Event *event = 0; |
3412 | Event *ev = 0; | 3414 | Event *ev = 0; |
3413 | if ( incidence && incidence->typeID() == eventID ) { | 3415 | if ( incidence && incidence->typeID() == eventID ) { |
3414 | event = static_cast<Event *>(incidence); | 3416 | event = static_cast<Event *>(incidence); |
3415 | ev = new Event(*event); | 3417 | ev = new Event(*event); |
3416 | cal_tmp.addEvent(ev); | 3418 | cal_tmp.addEvent(ev); |
3417 | } | 3419 | } |
3418 | ICalFormat mForm(); | 3420 | ICalFormat mForm(); |
3419 | QString attachment = mForm.toString( &cal_tmp ); | 3421 | QString attachment = mForm.toString( &cal_tmp ); |
3420 | if (ev) delete(ev); | 3422 | if (ev) delete(ev); |
3421 | 3423 | ||
3422 | mailClient.mailAttendees(currentSelection(), attachment); | 3424 | mailClient.mailAttendees(currentSelection(), attachment); |
3423 | 3425 | ||
3424 | #endif | 3426 | #endif |
3425 | 3427 | ||
3426 | #if 0 | 3428 | #if 0 |
3427 | Event *anEvent = 0; | 3429 | Event *anEvent = 0; |
3428 | if (mViewManager->currentView()->isEventView()) { | 3430 | if (mViewManager->currentView()->isEventView()) { |
3429 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3431 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3430 | } | 3432 | } |
3431 | 3433 | ||
3432 | if (!anEvent) { | 3434 | if (!anEvent) { |
3433 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3435 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3434 | return; | 3436 | return; |
3435 | } | 3437 | } |
3436 | if(anEvent->attendeeCount() == 0 ) { | 3438 | if(anEvent->attendeeCount() == 0 ) { |
3437 | KMessageBox::sorry(this, | 3439 | KMessageBox::sorry(this, |
3438 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3440 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3439 | return; | 3441 | return; |
3440 | } | 3442 | } |
3441 | 3443 | ||
3442 | mailobject.emailEvent(anEvent); | 3444 | mailobject.emailEvent(anEvent); |
3443 | #endif | 3445 | #endif |
3444 | } | 3446 | } |
3445 | 3447 | ||
3446 | 3448 | ||
3447 | void CalendarView::schedule_publish(Incidence *incidence) | 3449 | void CalendarView::schedule_publish(Incidence *incidence) |
3448 | { | 3450 | { |
3449 | Event *event = 0; | 3451 | Event *event = 0; |
3450 | Todo *todo = 0; | 3452 | Todo *todo = 0; |
3451 | 3453 | ||
3452 | if (incidence == 0) { | 3454 | if (incidence == 0) { |
3453 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3455 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3454 | if (incidence == 0) { | 3456 | if (incidence == 0) { |
3455 | incidence = mTodoList->selectedIncidences().first(); | 3457 | incidence = mTodoList->selectedIncidences().first(); |
3456 | } | 3458 | } |
3457 | } | 3459 | } |
3458 | if ( incidence && incidence->typeID() == eventID ) { | 3460 | if ( incidence && incidence->typeID() == eventID ) { |
3459 | event = static_cast<Event *>(incidence); | 3461 | event = static_cast<Event *>(incidence); |
3460 | } else { | 3462 | } else { |
3461 | if ( incidence && incidence->typeID() == todoID ) { | 3463 | if ( incidence && incidence->typeID() == todoID ) { |
3462 | todo = static_cast<Todo *>(incidence); | 3464 | todo = static_cast<Todo *>(incidence); |
3463 | } | 3465 | } |
3464 | } | 3466 | } |
3465 | 3467 | ||
3466 | if (!event && !todo) { | 3468 | if (!event && !todo) { |
3467 | KMessageBox::sorry(this,i18n("No event selected.")); | 3469 | KMessageBox::sorry(this,i18n("No event selected.")); |
3468 | return; | 3470 | return; |
3469 | } | 3471 | } |
3470 | 3472 | ||
3471 | PublishDialog *publishdlg = new PublishDialog(); | 3473 | PublishDialog *publishdlg = new PublishDialog(); |
3472 | if (incidence->attendeeCount()>0) { | 3474 | if (incidence->attendeeCount()>0) { |
3473 | QPtrList<Attendee> attendees = incidence->attendees(); | 3475 | QPtrList<Attendee> attendees = incidence->attendees(); |
3474 | attendees.first(); | 3476 | attendees.first(); |
3475 | while ( attendees.current()!=0 ) { | 3477 | while ( attendees.current()!=0 ) { |
3476 | publishdlg->addAttendee(attendees.current()); | 3478 | publishdlg->addAttendee(attendees.current()); |
3477 | attendees.next(); | 3479 | attendees.next(); |
3478 | } | 3480 | } |
3479 | } | 3481 | } |
3480 | bool send = true; | 3482 | bool send = true; |
3481 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3483 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3482 | if ( publishdlg->exec() != QDialog::Accepted ) | 3484 | if ( publishdlg->exec() != QDialog::Accepted ) |
3483 | send = false; | 3485 | send = false; |
3484 | } | 3486 | } |
3485 | if ( send ) { | 3487 | if ( send ) { |
3486 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3488 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3487 | if ( event ) { | 3489 | if ( event ) { |
3488 | Event *ev = new Event(*event); | 3490 | Event *ev = new Event(*event); |
3489 | ev->registerObserver(0); | 3491 | ev->registerObserver(0); |
3490 | ev->clearAttendees(); | 3492 | ev->clearAttendees(); |
3491 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3493 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3492 | delete(ev); | 3494 | delete(ev); |
3493 | } | 3495 | } |
3494 | } else { | 3496 | } else { |
3495 | if ( todo ) { | 3497 | if ( todo ) { |
3496 | Todo *ev = new Todo(*todo); | 3498 | Todo *ev = new Todo(*todo); |
3497 | ev->registerObserver(0); | 3499 | ev->registerObserver(0); |
3498 | ev->clearAttendees(); | 3500 | ev->clearAttendees(); |
3499 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3501 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3500 | delete(ev); | 3502 | delete(ev); |
3501 | } | 3503 | } |
3502 | } | 3504 | } |
3503 | } | 3505 | } |
3504 | } | 3506 | } |
3505 | delete publishdlg; | 3507 | delete publishdlg; |
3506 | } | 3508 | } |
3507 | 3509 | ||
3508 | void CalendarView::schedule_request(Incidence *incidence) | 3510 | void CalendarView::schedule_request(Incidence *incidence) |
3509 | { | 3511 | { |
3510 | schedule(Scheduler::Request,incidence); | 3512 | schedule(Scheduler::Request,incidence); |
3511 | } | 3513 | } |
3512 | 3514 | ||
3513 | void CalendarView::schedule_refresh(Incidence *incidence) | 3515 | void CalendarView::schedule_refresh(Incidence *incidence) |
3514 | { | 3516 | { |
3515 | schedule(Scheduler::Refresh,incidence); | 3517 | schedule(Scheduler::Refresh,incidence); |
3516 | } | 3518 | } |
3517 | 3519 | ||
3518 | void CalendarView::schedule_cancel(Incidence *incidence) | 3520 | void CalendarView::schedule_cancel(Incidence *incidence) |
3519 | { | 3521 | { |
3520 | schedule(Scheduler::Cancel,incidence); | 3522 | schedule(Scheduler::Cancel,incidence); |
3521 | } | 3523 | } |
3522 | 3524 | ||
3523 | void CalendarView::schedule_add(Incidence *incidence) | 3525 | void CalendarView::schedule_add(Incidence *incidence) |
3524 | { | 3526 | { |
3525 | schedule(Scheduler::Add,incidence); | 3527 | schedule(Scheduler::Add,incidence); |
3526 | } | 3528 | } |
3527 | 3529 | ||
3528 | void CalendarView::schedule_reply(Incidence *incidence) | 3530 | void CalendarView::schedule_reply(Incidence *incidence) |
3529 | { | 3531 | { |
3530 | schedule(Scheduler::Reply,incidence); | 3532 | schedule(Scheduler::Reply,incidence); |
3531 | } | 3533 | } |
3532 | 3534 | ||
3533 | void CalendarView::schedule_counter(Incidence *incidence) | 3535 | void CalendarView::schedule_counter(Incidence *incidence) |
3534 | { | 3536 | { |
3535 | schedule(Scheduler::Counter,incidence); | 3537 | schedule(Scheduler::Counter,incidence); |
3536 | } | 3538 | } |
3537 | 3539 | ||
3538 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3540 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3539 | { | 3541 | { |
3540 | schedule(Scheduler::Declinecounter,incidence); | 3542 | schedule(Scheduler::Declinecounter,incidence); |
3541 | } | 3543 | } |
3542 | 3544 | ||
3543 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3545 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3544 | { | 3546 | { |
3545 | QDateTime start = QDateTime::currentDateTime(); | 3547 | QDateTime start = QDateTime::currentDateTime(); |
3546 | QDateTime end = start.addDays(daysToPublish); | 3548 | QDateTime end = start.addDays(daysToPublish); |
3547 | 3549 | ||
3548 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3550 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3549 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3551 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3550 | 3552 | ||
3551 | 3553 | ||
3552 | PublishDialog *publishdlg = new PublishDialog(); | 3554 | PublishDialog *publishdlg = new PublishDialog(); |
3553 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3555 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3554 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3556 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3555 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3557 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3556 | delete(freebusy); | 3558 | delete(freebusy); |
3557 | } | 3559 | } |
3558 | } | 3560 | } |
3559 | delete publishdlg; | 3561 | delete publishdlg; |
3560 | } | 3562 | } |
3561 | 3563 | ||
3562 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3564 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3563 | { | 3565 | { |
3564 | Event *event = 0; | 3566 | Event *event = 0; |
3565 | Todo *todo = 0; | 3567 | Todo *todo = 0; |
3566 | 3568 | ||
3567 | if (incidence == 0) { | 3569 | if (incidence == 0) { |
3568 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3570 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3569 | if (incidence == 0) { | 3571 | if (incidence == 0) { |
3570 | incidence = mTodoList->selectedIncidences().first(); | 3572 | incidence = mTodoList->selectedIncidences().first(); |
3571 | } | 3573 | } |
3572 | } | 3574 | } |
3573 | if ( incidence && incidence->typeID() == eventID ) { | 3575 | if ( incidence && incidence->typeID() == eventID ) { |
3574 | event = static_cast<Event *>(incidence); | 3576 | event = static_cast<Event *>(incidence); |
3575 | } | 3577 | } |
3576 | if ( incidence && incidence->typeID() == todoID ) { | 3578 | if ( incidence && incidence->typeID() == todoID ) { |
3577 | todo = static_cast<Todo *>(incidence); | 3579 | todo = static_cast<Todo *>(incidence); |
3578 | } | 3580 | } |
3579 | 3581 | ||
3580 | if (!event && !todo) { | 3582 | if (!event && !todo) { |
3581 | KMessageBox::sorry(this,i18n("No event selected.")); | 3583 | KMessageBox::sorry(this,i18n("No event selected.")); |
3582 | return; | 3584 | return; |
3583 | } | 3585 | } |
3584 | 3586 | ||
3585 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3587 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3586 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3588 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3587 | return; | 3589 | return; |
3588 | } | 3590 | } |
3589 | 3591 | ||
3590 | Event *ev = 0; | 3592 | Event *ev = 0; |
3591 | if (event) ev = new Event(*event); | 3593 | if (event) ev = new Event(*event); |
3592 | Todo *to = 0; | 3594 | Todo *to = 0; |
3593 | if (todo) to = new Todo(*todo); | 3595 | if (todo) to = new Todo(*todo); |
3594 | 3596 | ||
3595 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3597 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3596 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3598 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3597 | if (!me) { | 3599 | if (!me) { |
3598 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3600 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3599 | return; | 3601 | return; |
3600 | } | 3602 | } |
3601 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3603 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3602 | StatusDialog *statdlg = new StatusDialog(this); | 3604 | StatusDialog *statdlg = new StatusDialog(this); |
3603 | if (!statdlg->exec()==QDialog::Accepted) return; | 3605 | if (!statdlg->exec()==QDialog::Accepted) return; |
3604 | me->setStatus( statdlg->status() ); | 3606 | me->setStatus( statdlg->status() ); |
3605 | delete(statdlg); | 3607 | delete(statdlg); |
3606 | } | 3608 | } |
3607 | Attendee *menew = new Attendee(*me); | 3609 | Attendee *menew = new Attendee(*me); |
3608 | if (ev) { | 3610 | if (ev) { |
3609 | ev->clearAttendees(); | 3611 | ev->clearAttendees(); |
3610 | ev->addAttendee(menew,false); | 3612 | ev->addAttendee(menew,false); |
3611 | } else { | 3613 | } else { |
3612 | if (to) { | 3614 | if (to) { |
3613 | todo->clearAttendees(); | 3615 | todo->clearAttendees(); |
3614 | todo->addAttendee(menew,false); | 3616 | todo->addAttendee(menew,false); |
3615 | } | 3617 | } |
3616 | } | 3618 | } |
3617 | } | 3619 | } |
3618 | 3620 | ||
3619 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3621 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3620 | if (ev) { | 3622 | if (ev) { |
3621 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3623 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3622 | } else { | 3624 | } else { |
3623 | if (to) { | 3625 | if (to) { |
3624 | if ( !dlg->addMessage(to,method) ) delete(to); | 3626 | if ( !dlg->addMessage(to,method) ) delete(to); |
3625 | } | 3627 | } |
3626 | } | 3628 | } |
3627 | } | 3629 | } |
3628 | 3630 | ||
3629 | void CalendarView::openAddressbook() | 3631 | void CalendarView::openAddressbook() |
3630 | { | 3632 | { |
3631 | KRun::runCommand("kaddressbook"); | 3633 | KRun::runCommand("kaddressbook"); |
3632 | } | 3634 | } |
3633 | 3635 | ||
3634 | void CalendarView::setModified(bool modified) | 3636 | void CalendarView::setModified(bool modified) |
3635 | { | 3637 | { |
3636 | if ( modified ) | 3638 | if ( modified ) |
3637 | emit signalmodified(); | 3639 | emit signalmodified(); |
3638 | if (mModified != modified) { | 3640 | if (mModified != modified) { |
3639 | mModified = modified; | 3641 | mModified = modified; |
3640 | emit modifiedChanged(mModified); | 3642 | emit modifiedChanged(mModified); |
3641 | } | 3643 | } |
3642 | } | 3644 | } |
3643 | 3645 | ||
3644 | bool CalendarView::isReadOnly() | 3646 | bool CalendarView::isReadOnly() |
3645 | { | 3647 | { |
3646 | return mReadOnly; | 3648 | return mReadOnly; |
3647 | } | 3649 | } |
3648 | 3650 | ||
3649 | void CalendarView::setReadOnly(bool readOnly) | 3651 | void CalendarView::setReadOnly(bool readOnly) |
3650 | { | 3652 | { |
3651 | if (mReadOnly != readOnly) { | 3653 | if (mReadOnly != readOnly) { |
3652 | mReadOnly = readOnly; | 3654 | mReadOnly = readOnly; |
3653 | emit readOnlyChanged(mReadOnly); | 3655 | emit readOnlyChanged(mReadOnly); |
3654 | } | 3656 | } |
3655 | } | 3657 | } |
3656 | 3658 | ||
3657 | bool CalendarView::isModified() | 3659 | bool CalendarView::isModified() |
3658 | { | 3660 | { |
3659 | return mModified; | 3661 | return mModified; |
3660 | } | 3662 | } |
3661 | void CalendarView::slotprintSelInc() | 3663 | void CalendarView::slotprintSelInc() |
3662 | { | 3664 | { |
3663 | if ( currentSelection() == 0 ) { | 3665 | if ( currentSelection() == 0 ) { |
3664 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3666 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3665 | return; | 3667 | return; |
3666 | } | 3668 | } |
3667 | showIncidence(); | 3669 | showIncidence(); |
3668 | getEventViewerDialog()->print(); | 3670 | getEventViewerDialog()->print(); |
3669 | 3671 | ||
3670 | } | 3672 | } |
3671 | void CalendarView::printSetup() | 3673 | void CalendarView::printSetup() |
3672 | { | 3674 | { |
3673 | #ifndef KORG_NOPRINTER | 3675 | #ifndef KORG_NOPRINTER |
3674 | createPrinter(); | 3676 | createPrinter(); |
3675 | 3677 | ||
3676 | mCalPrinter->setupPrinter(); | 3678 | mCalPrinter->setupPrinter(); |
3677 | #endif | 3679 | #endif |
3678 | } | 3680 | } |
3679 | 3681 | ||
3680 | void CalendarView::print() | 3682 | void CalendarView::print() |
3681 | { | 3683 | { |
3682 | #ifndef KORG_NOPRINTER | 3684 | #ifndef KORG_NOPRINTER |
3683 | createPrinter(); | 3685 | createPrinter(); |
3684 | 3686 | ||
3685 | DateList tmpDateList = mNavigator->selectedDates(); | 3687 | DateList tmpDateList = mNavigator->selectedDates(); |
3686 | mCalPrinter->print(CalPrinter::Month, | 3688 | mCalPrinter->print(CalPrinter::Month, |
3687 | tmpDateList.first(), tmpDateList.last()); | 3689 | tmpDateList.first(), tmpDateList.last()); |
3688 | #endif | 3690 | #endif |
3689 | } | 3691 | } |
3690 | 3692 | ||
3691 | void CalendarView::printPreview() | 3693 | void CalendarView::printPreview() |
3692 | { | 3694 | { |
3693 | #ifndef KORG_NOPRINTER | 3695 | #ifndef KORG_NOPRINTER |
3694 | kdDebug() << "CalendarView::printPreview()" << endl; | 3696 | kdDebug() << "CalendarView::printPreview()" << endl; |
3695 | 3697 | ||
3696 | createPrinter(); | 3698 | createPrinter(); |
3697 | 3699 | ||
3698 | DateList tmpDateList = mNavigator->selectedDates(); | 3700 | DateList tmpDateList = mNavigator->selectedDates(); |
3699 | 3701 | ||
3700 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3702 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3701 | tmpDateList.last()); | 3703 | tmpDateList.last()); |
3702 | #endif | 3704 | #endif |
3703 | } | 3705 | } |
3704 | 3706 | ||
3705 | void CalendarView::exportICalendar() | 3707 | void CalendarView::exportICalendar() |
3706 | { | 3708 | { |
3707 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3709 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3708 | 3710 | ||
3709 | // Force correct extension | 3711 | // Force correct extension |
3710 | if (filename.right(4) != ".ics") filename += ".ics"; | 3712 | if (filename.right(4) != ".ics") filename += ".ics"; |
3711 | 3713 | ||
3712 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3714 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3713 | storage.save(); | 3715 | storage.save(); |
3714 | } | 3716 | } |
3715 | 3717 | ||
3716 | bool CalendarView::exportVCalendar( QString filename ) | 3718 | bool CalendarView::exportVCalendar( QString filename ) |
3717 | { | 3719 | { |
3718 | if (mCalendar->journals().count() > 0) { | 3720 | if (mCalendar->journals().count() > 0) { |
3719 | int result = KMessageBox::warningContinueCancel(this, | 3721 | int result = KMessageBox::warningContinueCancel(this, |
3720 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3722 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3721 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3723 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3722 | true); | 3724 | true); |
3723 | if (result != KMessageBox::Continue) return false; | 3725 | if (result != KMessageBox::Continue) return false; |
3724 | } | 3726 | } |
3725 | 3727 | ||
3726 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3728 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3727 | 3729 | ||
3728 | // Force correct extension | 3730 | // Force correct extension |
3729 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3731 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3730 | 3732 | ||
3731 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3733 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3732 | return storage.save(); | 3734 | return storage.save(); |
3733 | 3735 | ||
3734 | } | 3736 | } |
3735 | 3737 | ||
3736 | void CalendarView::eventUpdated(Incidence *) | 3738 | void CalendarView::eventUpdated(Incidence *) |
3737 | { | 3739 | { |
3738 | setModified(); | 3740 | setModified(); |
3739 | // Don't call updateView here. The code, which has caused the update of the | 3741 | // Don't call updateView here. The code, which has caused the update of the |
3740 | // event is responsible for updating the view. | 3742 | // event is responsible for updating the view. |
3741 | // updateView(); | 3743 | // updateView(); |
3742 | } | 3744 | } |
3743 | 3745 | ||
3744 | void CalendarView::adaptNavigationUnits() | 3746 | void CalendarView::adaptNavigationUnits() |
3745 | { | 3747 | { |
3746 | if (mViewManager->currentView()->isEventView()) { | 3748 | if (mViewManager->currentView()->isEventView()) { |
3747 | int days = mViewManager->currentView()->currentDateCount(); | 3749 | int days = mViewManager->currentView()->currentDateCount(); |
3748 | if (days == 1) { | 3750 | if (days == 1) { |
3749 | emit changeNavStringPrev(i18n("&Previous Day")); | 3751 | emit changeNavStringPrev(i18n("&Previous Day")); |
3750 | emit changeNavStringNext(i18n("&Next Day")); | 3752 | emit changeNavStringNext(i18n("&Next Day")); |
3751 | } else { | 3753 | } else { |
3752 | emit changeNavStringPrev(i18n("&Previous Week")); | 3754 | emit changeNavStringPrev(i18n("&Previous Week")); |
3753 | emit changeNavStringNext(i18n("&Next Week")); | 3755 | emit changeNavStringNext(i18n("&Next Week")); |
3754 | } | 3756 | } |
3755 | } | 3757 | } |
3756 | } | 3758 | } |
3757 | 3759 | ||
3758 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3760 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3759 | { | 3761 | { |
3760 | if ( incidence ) mTodoList->clearSelection(); | 3762 | if ( incidence ) mTodoList->clearSelection(); |
3761 | processIncidenceSelection( incidence ); | 3763 | processIncidenceSelection( incidence ); |
3762 | } | 3764 | } |
3763 | 3765 | ||
3764 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3766 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3765 | { | 3767 | { |
3766 | if ( incidence && mViewManager->currentView() ) { | 3768 | if ( incidence && mViewManager->currentView() ) { |
3767 | mViewManager->currentView()->clearSelection(); | 3769 | mViewManager->currentView()->clearSelection(); |
3768 | } | 3770 | } |
3769 | processIncidenceSelection( incidence ); | 3771 | processIncidenceSelection( incidence ); |
3770 | } | 3772 | } |
3771 | 3773 | ||
3772 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3774 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3773 | { | 3775 | { |
3774 | if ( incidence == mSelectedIncidence ) return; | 3776 | if ( incidence == mSelectedIncidence ) return; |
3775 | 3777 | ||
3776 | mSelectedIncidence = incidence; | 3778 | mSelectedIncidence = incidence; |
3777 | 3779 | ||
3778 | emit incidenceSelected( mSelectedIncidence ); | 3780 | emit incidenceSelected( mSelectedIncidence ); |
3779 | 3781 | ||
3780 | if ( incidence && incidence->typeID() == eventID ) { | 3782 | if ( incidence && incidence->typeID() == eventID ) { |
3781 | Event *event = static_cast<Event *>( incidence ); | 3783 | Event *event = static_cast<Event *>( incidence ); |
3782 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3784 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3783 | emit organizerEventsSelected( true ); | 3785 | emit organizerEventsSelected( true ); |
3784 | } else { | 3786 | } else { |
3785 | emit organizerEventsSelected(false); | 3787 | emit organizerEventsSelected(false); |
3786 | } | 3788 | } |
3787 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3789 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3788 | KOPrefs::instance()->email() ) ) { | 3790 | KOPrefs::instance()->email() ) ) { |
3789 | emit groupEventsSelected( true ); | 3791 | emit groupEventsSelected( true ); |
3790 | } else { | 3792 | } else { |
3791 | emit groupEventsSelected(false); | 3793 | emit groupEventsSelected(false); |
3792 | } | 3794 | } |
3793 | return; | 3795 | return; |
3794 | } else { | 3796 | } else { |
3795 | if ( incidence && incidence->typeID() == todoID ) { | 3797 | if ( incidence && incidence->typeID() == todoID ) { |
3796 | emit todoSelected( true ); | 3798 | emit todoSelected( true ); |
3797 | Todo *event = static_cast<Todo *>( incidence ); | 3799 | Todo *event = static_cast<Todo *>( incidence ); |
3798 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3800 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3799 | emit organizerEventsSelected( true ); | 3801 | emit organizerEventsSelected( true ); |
3800 | } else { | 3802 | } else { |
3801 | emit organizerEventsSelected(false); | 3803 | emit organizerEventsSelected(false); |
3802 | } | 3804 | } |
3803 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3805 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3804 | KOPrefs::instance()->email() ) ) { | 3806 | KOPrefs::instance()->email() ) ) { |
3805 | emit groupEventsSelected( true ); | 3807 | emit groupEventsSelected( true ); |
3806 | } else { | 3808 | } else { |
3807 | emit groupEventsSelected(false); | 3809 | emit groupEventsSelected(false); |
3808 | } | 3810 | } |
3809 | return; | 3811 | return; |
3810 | } else { | 3812 | } else { |
3811 | emit todoSelected( false ); | 3813 | emit todoSelected( false ); |
3812 | emit organizerEventsSelected(false); | 3814 | emit organizerEventsSelected(false); |
3813 | emit groupEventsSelected(false); | 3815 | emit groupEventsSelected(false); |
3814 | } | 3816 | } |
3815 | return; | 3817 | return; |
3816 | } | 3818 | } |
3817 | 3819 | ||
3818 | /* if ( incidence && incidence->typeID() == todoID ) { | 3820 | /* if ( incidence && incidence->typeID() == todoID ) { |
3819 | emit todoSelected( true ); | 3821 | emit todoSelected( true ); |
3820 | } else { | 3822 | } else { |
3821 | emit todoSelected( false ); | 3823 | emit todoSelected( false ); |
3822 | }*/ | 3824 | }*/ |
3823 | } | 3825 | } |
3824 | 3826 | ||
3825 | 3827 | ||
3826 | void CalendarView::checkClipboard() | 3828 | void CalendarView::checkClipboard() |
3827 | { | 3829 | { |
3828 | #ifndef KORG_NODND | 3830 | #ifndef KORG_NODND |
3829 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3831 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3830 | emit pasteEnabled(true); | 3832 | emit pasteEnabled(true); |
3831 | } else { | 3833 | } else { |
3832 | emit pasteEnabled(false); | 3834 | emit pasteEnabled(false); |
3833 | } | 3835 | } |
3834 | #endif | 3836 | #endif |
3835 | } | 3837 | } |
3836 | 3838 | ||
3837 | void CalendarView::showDates(const DateList &selectedDates) | 3839 | void CalendarView::showDates(const DateList &selectedDates) |
3838 | { | 3840 | { |
3839 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3841 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3840 | 3842 | ||
3841 | 3843 | ||
3842 | if ( !mBlockShowDates ) { | 3844 | if ( !mBlockShowDates ) { |
3843 | if ( mViewManager->currentView() ) { | 3845 | if ( mViewManager->currentView() ) { |
3844 | updateView( selectedDates.first(), selectedDates.last() ); | 3846 | updateView( selectedDates.first(), selectedDates.last() ); |
3845 | } else { | 3847 | } else { |
3846 | mViewManager->showAgendaView(); | 3848 | mViewManager->showAgendaView(); |
3847 | } | 3849 | } |
3848 | } | 3850 | } |
3849 | 3851 | ||
3850 | QDate date = selectedDates.first(); | 3852 | QDate date = selectedDates.first(); |
3851 | if ( ! date.isValid() ) { | 3853 | if ( ! date.isValid() ) { |
3852 | topLevelWidget()->setCaption(""); | 3854 | topLevelWidget()->setCaption(""); |
3853 | return; | 3855 | return; |
3854 | } | 3856 | } |
3855 | 3857 | ||
3856 | QString selDates; | 3858 | QString selDates; |
3857 | selDates = KGlobal::locale()->formatDate( date, true); | 3859 | selDates = KGlobal::locale()->formatDate( date, true); |
3858 | if (selectedDates.first() < selectedDates.last() ) | 3860 | if (selectedDates.first() < selectedDates.last() ) |
3859 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3861 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3860 | else { | 3862 | else { |
3861 | QString addString; | 3863 | QString addString; |
3862 | if ( date == QDateTime::currentDateTime().date() ) | 3864 | if ( date == QDateTime::currentDateTime().date() ) |
3863 | addString = i18n("Today"); | 3865 | addString = i18n("Today"); |
3864 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3866 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3865 | addString = i18n("Tomorrow"); | 3867 | addString = i18n("Tomorrow"); |
3866 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3868 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3867 | addString = i18n("Yesterday"); | 3869 | addString = i18n("Yesterday"); |
3868 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 3870 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
3869 | addString = i18n("Day before yesterday"); | 3871 | addString = i18n("Day before yesterday"); |
3870 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 3872 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
3871 | addString = i18n("Day after tomorrow"); | 3873 | addString = i18n("Day after tomorrow"); |
3872 | if ( !addString.isEmpty() ) { | 3874 | if ( !addString.isEmpty() ) { |
3873 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3875 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3874 | return; | 3876 | return; |
3875 | } | 3877 | } |
3876 | } | 3878 | } |
3877 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3879 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3878 | 3880 | ||
3879 | } | 3881 | } |
3880 | 3882 | ||
3881 | QPtrList<CalFilter> CalendarView::filters() | 3883 | QPtrList<CalFilter> CalendarView::filters() |
3882 | { | 3884 | { |
3883 | return mFilters; | 3885 | return mFilters; |
3884 | 3886 | ||
3885 | } | 3887 | } |
3886 | void CalendarView::editFilters() | 3888 | void CalendarView::editFilters() |
3887 | { | 3889 | { |
3888 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3890 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3889 | 3891 | ||
3890 | CalFilter *filter = mFilters.first(); | 3892 | CalFilter *filter = mFilters.first(); |
3891 | while(filter) { | 3893 | while(filter) { |
3892 | kdDebug() << " Filter: " << filter->name() << endl; | 3894 | kdDebug() << " Filter: " << filter->name() << endl; |
3893 | filter = mFilters.next(); | 3895 | filter = mFilters.next(); |
3894 | } | 3896 | } |
3895 | 3897 | ||
3896 | mDialogManager->showFilterEditDialog(&mFilters); | 3898 | mDialogManager->showFilterEditDialog(&mFilters); |
3897 | } | 3899 | } |
3898 | void CalendarView::toggleFilter() | 3900 | void CalendarView::toggleFilter() |
3899 | { | 3901 | { |
3900 | showFilter(! mFilterView->isVisible()); | 3902 | showFilter(! mFilterView->isVisible()); |
3901 | } | 3903 | } |
3902 | 3904 | ||
3903 | KOFilterView *CalendarView::filterView() | 3905 | KOFilterView *CalendarView::filterView() |
3904 | { | 3906 | { |
3905 | return mFilterView; | 3907 | return mFilterView; |
3906 | } | 3908 | } |
3907 | void CalendarView::selectFilter( int fil ) | 3909 | void CalendarView::selectFilter( int fil ) |