-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 18 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 25 | ||||
-rw-r--r-- | korganizer/komonthview.h | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 28 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 37 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 2 |
7 files changed, 64 insertions, 50 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index ce68a1d..b5285bf 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,215 +1,217 @@ | |||
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.0.22 ************ | 3 | ********** VERSION 2.0.22 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Fix for creating events/todos via the abgenda context menu. | 6 | Fix for creating events/todos via the abgenda context menu. |
7 | Added option to split toolbar to 3 toolbars. | 7 | Added option to split toolbar to 3 toolbars. |
8 | Added option to show one small filter-view-toolbar. | 8 | Added option to show one small filter-view-toolbar. |
9 | Added a print option to the desktop version: | 9 | Added a print option to the desktop version: |
10 | Now you can print out the view of the "Event Viewer". | 10 | Now you can print out the view of the "Event Viewer". |
11 | That means you can print all data of one particular event/todo. | 11 | That means you can print all data of one particular event/todo. |
12 | Added scaling options to printout of Event Viewer and What'sNext View. | ||
13 | Fixed some problems in the month view in "week start sunday" mode. | ||
12 | 14 | ||
13 | ********** VERSION 2.0.21 ************ | 15 | ********** VERSION 2.0.21 ************ |
14 | 16 | ||
15 | Fixed another SMTP problem in OM/Pi. | 17 | Fixed another SMTP problem in OM/Pi. |
16 | Some small changed in the new datenavigator in KO/Pi. | 18 | Some small changed in the new datenavigator in KO/Pi. |
17 | Changed default setting for new filter in KA/Pi to "exclude categories". | 19 | Changed default setting for new filter in KA/Pi to "exclude categories". |
18 | Changed the default font size for 640x480 display . | 20 | Changed the default font size for 640x480 display . |
19 | Changed popup menu behaviour in agenda and list view. | 21 | Changed popup menu behaviour in agenda and list view. |
20 | Fixed some layout problems of the date label size in the month view. | 22 | Fixed some layout problems of the date label size in the month view. |
21 | Made month view update faster. | 23 | Made month view update faster. |
22 | Made first datenavigator repainting faster. | 24 | Made first datenavigator repainting faster. |
23 | Changed the title of the event/todo edit dialogs. | 25 | Changed the title of the event/todo edit dialogs. |
24 | Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). | 26 | Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). |
25 | Many small usebility fixes in KO/Pi. | 27 | Many small usebility fixes in KO/Pi. |
26 | Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. | 28 | Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. |
27 | The set of possible "next views" are the views you have toolbar buttons for. | 29 | The set of possible "next views" are the views you have toolbar buttons for. |
28 | 30 | ||
29 | Made alarm sound working on Linux. | 31 | Made alarm sound working on Linux. |
30 | 32 | ||
31 | KO/Pi alarm applet changed: | 33 | KO/Pi alarm applet changed: |
32 | Made buttons in alarm dialog much bigger. | 34 | Made buttons in alarm dialog much bigger. |
33 | Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. | 35 | Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. |
34 | The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. | 36 | The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. |
35 | 37 | ||
36 | And because this version is realeased at Easter, I added an Easter-egg: | 38 | And because this version is realeased at Easter, I added an Easter-egg: |
37 | With a new undocumented command you can get a message box about the next alarm. | 39 | With a new undocumented command you can get a message box about the next alarm. |
38 | Good luck to find it! | 40 | Good luck to find it! |
39 | 41 | ||
40 | 42 | ||
41 | 43 | ||
42 | ********** VERSION 2.0.20 ************ | 44 | ********** VERSION 2.0.20 ************ |
43 | 45 | ||
44 | Two small fixes in OM/Pi. | 46 | Two small fixes in OM/Pi. |
45 | 47 | ||
46 | Better resizing of the new datenavigator in KO/Pi. | 48 | Better resizing of the new datenavigator in KO/Pi. |
47 | 49 | ||
48 | ********** VERSION 2.0.19 ************ | 50 | ********** VERSION 2.0.19 ************ |
49 | KO/Pi: | 51 | KO/Pi: |
50 | Enhancements and bugfixes in the new datenavigator. | 52 | Enhancements and bugfixes in the new datenavigator. |
51 | Bugfix in this changelog: | 53 | Bugfix in this changelog: |
52 | The datenavigator was changed in version 2.0.18, not the datepicker. | 54 | The datenavigator was changed in version 2.0.18, not the datepicker. |
53 | 55 | ||
54 | ********** VERSION 2.0.18 ************ | 56 | ********** VERSION 2.0.18 ************ |
55 | KO/Pi: | 57 | KO/Pi: |
56 | Fixed some minor problems. | 58 | Fixed some minor problems. |
57 | Cleaned up the KO/Pi config dialog. | 59 | Cleaned up the KO/Pi config dialog. |
58 | Fixed problem moving events in aganda view. | 60 | Fixed problem moving events in aganda view. |
59 | Made datepicker scaleable, i.e. if the datenavigator shows now a | 61 | Made datepicker scaleable, i.e. if the datenavigator shows now a |
60 | datenavigator matrix depending on its size. | 62 | datenavigator matrix depending on its size. |
61 | Birthdays are now displayed green in the datenavigator. | 63 | Birthdays are now displayed green in the datenavigator. |
62 | What'sThis Help in datenavigator shows all events of the day. | 64 | What'sThis Help in datenavigator shows all events of the day. |
63 | 65 | ||
64 | OM/Pi: | 66 | OM/Pi: |
65 | Updated the backend mail library to the latest version. | 67 | Updated the backend mail library to the latest version. |
66 | Please backup your mail before using this version. | 68 | Please backup your mail before using this version. |
67 | 69 | ||
68 | ********** VERSION 2.0.17 ************ | 70 | ********** VERSION 2.0.17 ************ |
69 | 71 | ||
70 | KO/Pi: | 72 | KO/Pi: |
71 | Tooltips in month view were not sorted. Fixed. | 73 | Tooltips in month view were not sorted. Fixed. |
72 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. | 74 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. |
73 | Conflict display dialog for syncing was not on top of other windows. Fixed. | 75 | Conflict display dialog for syncing was not on top of other windows. Fixed. |
74 | Fixed some minor problems. | 76 | Fixed some minor problems. |
75 | 77 | ||
76 | Fixed an endless loop when importing vcs file with RESOURCES entry. | 78 | Fixed an endless loop when importing vcs file with RESOURCES entry. |
77 | 79 | ||
78 | ********** VERSION 2.0.16 ************ | 80 | ********** VERSION 2.0.16 ************ |
79 | OM/Pi: | 81 | OM/Pi: |
80 | Fixed the SMTP account setting the option. | 82 | Fixed the SMTP account setting the option. |
81 | Fixed something in mail sending. | 83 | Fixed something in mail sending. |
82 | 84 | ||
83 | KO/Pi: | 85 | KO/Pi: |
84 | Added possibility to export selected events/todos as vcal file. | 86 | Added possibility to export selected events/todos as vcal file. |
85 | 87 | ||
86 | ********** VERSION 2.0.15 ************ | 88 | ********** VERSION 2.0.15 ************ |
87 | 89 | ||
88 | PwM/Pi: | 90 | PwM/Pi: |
89 | Added keyboard shorcuts for | 91 | Added keyboard shorcuts for |
90 | - toggling summary view (space bar) | 92 | - toggling summary view (space bar) |
91 | - delete item (delete + backspace key) | 93 | - delete item (delete + backspace key) |
92 | - add new item ( i + n key) | 94 | - add new item ( i + n key) |
93 | Fixed length of info in the title. | 95 | Fixed length of info in the title. |
94 | 96 | ||
95 | KO/Pi-KA/Pi: | 97 | KO/Pi-KA/Pi: |
96 | Changed "ME" menu bar entry to an icon. | 98 | Changed "ME" menu bar entry to an icon. |
97 | 99 | ||
98 | KO/Pi: | 100 | KO/Pi: |
99 | Fixed two minor bugs in displaying todos. | 101 | Fixed two minor bugs in displaying todos. |
100 | If in month view a cell is selected, the key shortcut "d" shows now that date. | 102 | If in month view a cell is selected, the key shortcut "d" shows now that date. |
101 | Added complete info for a todo in month view as an icon left of the text. | 103 | Added complete info for a todo in month view as an icon left of the text. |
102 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. | 104 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. |
103 | Fixed problem of search dialog size when switching displays. | 105 | Fixed problem of search dialog size when switching displays. |
104 | Cancel key now closes date picker. | 106 | Cancel key now closes date picker. |
105 | Rearranged KO/Pi file menu structure. | 107 | Rearranged KO/Pi file menu structure. |
106 | 108 | ||
107 | OM/Pi: | 109 | OM/Pi: |
108 | Added to the SMTP account setting the option | 110 | Added to the SMTP account setting the option |
109 | "No secure connection". | 111 | "No secure connection". |
110 | You have to configure your SMTP accounts again, sorry. | 112 | You have to configure your SMTP accounts again, sorry. |
111 | 113 | ||
112 | KA/Pi: | 114 | KA/Pi: |
113 | Added support for importing quoted-printable. | 115 | Added support for importing quoted-printable. |
114 | Support was added by Peter P.. Thanks, Peter! | 116 | Support was added by Peter P.. Thanks, Peter! |
115 | 117 | ||
116 | 118 | ||
117 | ********** VERSION 2.0.14 ************ | 119 | ********** VERSION 2.0.14 ************ |
118 | 120 | ||
119 | Made Passwordmanager PwM/Pi more userfriendly: | 121 | Made Passwordmanager PwM/Pi more userfriendly: |
120 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 122 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
121 | Fixed bug in KO/Pi todo printing. | 123 | Fixed bug in KO/Pi todo printing. |
122 | Made Qtopia calendar import possible on desktop . | 124 | Made Qtopia calendar import possible on desktop . |
123 | 125 | ||
124 | ********** VERSION 2.0.13 ************ | 126 | ********** VERSION 2.0.13 ************ |
125 | 127 | ||
126 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. | 128 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. |
127 | 129 | ||
128 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". | 130 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". |
129 | 131 | ||
130 | OM/Pi: | 132 | OM/Pi: |
131 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. | 133 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. |
132 | Added missing German translation. | 134 | Added missing German translation. |
133 | Added warning if path is specified in local folder settings of account config. | 135 | Added warning if path is specified in local folder settings of account config. |
134 | 136 | ||
135 | ********** VERSION 2.0.12 ************ | 137 | ********** VERSION 2.0.12 ************ |
136 | 138 | ||
137 | KO/Pi: | 139 | KO/Pi: |
138 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. | 140 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. |
139 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. | 141 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. |
140 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. | 142 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. |
141 | 143 | ||
142 | Fixed problem in pi-sync mode when wrong password was sent. | 144 | Fixed problem in pi-sync mode when wrong password was sent. |
143 | 145 | ||
144 | OM/Pi: | 146 | OM/Pi: |
145 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. | 147 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. |
146 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. | 148 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. |
147 | 149 | ||
148 | ********** VERSION 2.0.11 ************ | 150 | ********** VERSION 2.0.11 ************ |
149 | 151 | ||
150 | Fixed some problems in pi-sync mode | 152 | Fixed some problems in pi-sync mode |
151 | (e.g. details of events were not synced properly) | 153 | (e.g. details of events were not synced properly) |
152 | 154 | ||
153 | ********** VERSION 2.0.10 ************ | 155 | ********** VERSION 2.0.10 ************ |
154 | 156 | ||
155 | KO/Pi: | 157 | KO/Pi: |
156 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. | 158 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. |
157 | This is fixed. | 159 | This is fixed. |
158 | Changed the search dialog a bit to make it more user friendly. | 160 | Changed the search dialog a bit to make it more user friendly. |
159 | (E.g.: Removed message box about "no items found" and set key focus to search line edit after search). | 161 | (E.g.: Removed message box about "no items found" and set key focus to search line edit after search). |
160 | 162 | ||
161 | Added config option to hide the week number in KO/Pi toolbar. | 163 | Added config option to hide the week number in KO/Pi toolbar. |
162 | 164 | ||
163 | ********** VERSION 2.0.9 ************ | 165 | ********** VERSION 2.0.9 ************ |
164 | 166 | ||
165 | Made month view icons for multiday events a bit nicer. | 167 | Made month view icons for multiday events a bit nicer. |
166 | Some minor fixes in KO/Pi | 168 | Some minor fixes in KO/Pi |
167 | (e.g. go to today did not work for new week view properly). | 169 | (e.g. go to today did not work for new week view properly). |
168 | 170 | ||
169 | 171 | ||
170 | ********** VERSION 2.0.8 ************ | 172 | ********** VERSION 2.0.8 ************ |
171 | 173 | ||
172 | Fixed a problem in dependency info in the ipk files for the Zaurus. | 174 | Fixed a problem in dependency info in the ipk files for the Zaurus. |
173 | 175 | ||
174 | Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. | 176 | Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. |
175 | 177 | ||
176 | Added a "go today" button to the datepicker. | 178 | Added a "go today" button to the datepicker. |
177 | 179 | ||
178 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) | 180 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) |
179 | and made it configureable to show these values. | 181 | and made it configureable to show these values. |
180 | 182 | ||
181 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. | 183 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. |
182 | 184 | ||
183 | 185 | ||
184 | ********** VERSION 2.0.7 ************ | 186 | ********** VERSION 2.0.7 ************ |
185 | 187 | ||
186 | Added global application font settings | 188 | Added global application font settings |
187 | (for all KDE-Pim/Pi apps) to the general settings. | 189 | (for all KDE-Pim/Pi apps) to the general settings. |
188 | 190 | ||
189 | Fixed a problem in OM/Pi when trying to login to some IMAP servers | 191 | Fixed a problem in OM/Pi when trying to login to some IMAP servers |
190 | (like the IMAP server of Apple: mail.mac.com ) | 192 | (like the IMAP server of Apple: mail.mac.com ) |
191 | 193 | ||
192 | Added recurring todos to KO/Pi. | 194 | Added recurring todos to KO/Pi. |
193 | 195 | ||
194 | 196 | ||
195 | ********** VERSION 2.0.6 ************ | 197 | ********** VERSION 2.0.6 ************ |
196 | 198 | ||
197 | Stable release 2.0.6! | 199 | Stable release 2.0.6! |
198 | 200 | ||
199 | Some bugfixes in the pi-sync mode. | 201 | Some bugfixes in the pi-sync mode. |
200 | Added German translation for pi-sync mode. | 202 | Added German translation for pi-sync mode. |
201 | 203 | ||
202 | KO/Pi: | 204 | KO/Pi: |
203 | Made the todolist using alternate background. | 205 | Made the todolist using alternate background. |
204 | 206 | ||
205 | Other minor fixes in KO/Pi. | 207 | Other minor fixes in KO/Pi. |
206 | 208 | ||
207 | 209 | ||
208 | You can find the complete changelog | 210 | You can find the complete changelog |
209 | from version 1.7.7 to 2.0.5 | 211 | from version 1.7.7 to 2.0.5 |
210 | in the source package or on | 212 | in the source package or on |
211 | 213 | ||
212 | http://www.pi-sync.net/html/changelog.html | 214 | http://www.pi-sync.net/html/changelog.html |
213 | 215 | ||
214 | 216 | ||
215 | 217 | ||
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 38bddc2..2fca49e 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,470 +1,468 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,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 <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | headings[i]->installEventFilter(this); | 86 | headings[i]->installEventFilter(this); |
87 | 87 | ||
88 | topLayout->addWidget(headings[i],1,i+1); | 88 | topLayout->addWidget(headings[i],1,i+1); |
89 | } | 89 | } |
90 | 90 | ||
91 | // Create the weeknumber labels | 91 | // Create the weeknumber labels |
92 | for( i = 0; i < 6; i++ ) { | 92 | for( i = 0; i < 6; i++ ) { |
93 | weeknos[i] = new QLabel(this); | 93 | weeknos[i] = new QLabel(this); |
94 | weeknos[i]->setAlignment(AlignCenter); | 94 | weeknos[i]->setAlignment(AlignCenter); |
95 | //weeknos[i]->setFont(QFont("Arial", 10)); | 95 | //weeknos[i]->setFont(QFont("Arial", 10)); |
96 | if(!m_bShowWeekNums) { | 96 | if(!m_bShowWeekNums) { |
97 | weeknos[i]->hide(); | 97 | weeknos[i]->hide(); |
98 | } | 98 | } |
99 | weeknos[i]->installEventFilter(this); | 99 | weeknos[i]->installEventFilter(this); |
100 | 100 | ||
101 | topLayout->addWidget(weeknos[i],i+2,0); | 101 | topLayout->addWidget(weeknos[i],i+2,0); |
102 | } | 102 | } |
103 | 103 | ||
104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
106 | daymatrix->setLineWidth(1); | 106 | daymatrix->setLineWidth(1); |
107 | 107 | ||
108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
110 | 110 | ||
111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
112 | SIGNAL( eventDropped( Event * ) ) ); | 112 | SIGNAL( eventDropped( Event * ) ) ); |
113 | 113 | ||
114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
115 | 115 | ||
116 | // read settings from configuration file. | 116 | // read settings from configuration file. |
117 | updateConfig(); | 117 | updateConfig(); |
118 | enableRollover(FollowMonth); | 118 | enableRollover(FollowMonth); |
119 | mySizeHint = sizeHintTwoButtons(); | 119 | mySizeHint = sizeHintTwoButtons(); |
120 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 120 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
121 | mFontChanged = false; | 121 | mFontChanged = false; |
122 | //resize ( 3,3 ); | 122 | //resize ( 3,3 ); |
123 | 123 | ||
124 | } | 124 | } |
125 | void KDateNavigator::changeFont ( QFont fo ) | 125 | void KDateNavigator::changeFont ( QFont fo ) |
126 | { | 126 | { |
127 | setFont( fo ); | 127 | setFont( fo ); |
128 | mNavigatorBar->resetFont( fo ); | 128 | mNavigatorBar->resetFont( fo ); |
129 | } | 129 | } |
130 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 130 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
131 | { | 131 | { |
132 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 132 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
133 | *b = false; | 133 | *b = false; |
134 | int fontPoint = fo.pointSize(); | 134 | int fontPoint = fo.pointSize(); |
135 | while ( fontPoint > 5 ) { | 135 | while ( fontPoint > 5 ) { |
136 | --fontPoint; | 136 | --fontPoint; |
137 | fo.setPointSize( fontPoint ); | 137 | fo.setPointSize( fontPoint ); |
138 | setFont( fo ); | 138 | setFont( fo ); |
139 | mFontChanged = true; | 139 | mFontChanged = true; |
140 | mNavigatorBar->resetFont( fo ); | 140 | mNavigatorBar->resetFont( fo ); |
141 | QSize sh = sizeHintTwoButtons( 2 ); | 141 | QSize sh = sizeHintTwoButtons( 2 ); |
142 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 142 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
143 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 143 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
144 | if ( si.width() / sh.width() == 1 ) { | 144 | if ( si.width() / sh.width() == 1 ) { |
145 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 145 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
146 | continue; | 146 | continue; |
147 | } | 147 | } |
148 | *b = true; | 148 | *b = true; |
149 | //qDebug("fooooooooooooooooooooooouuuuund "); | 149 | //qDebug("fooooooooooooooooooooooouuuuund "); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 153 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
154 | return fo; | 154 | return fo; |
155 | } | 155 | } |
156 | QSize KDateNavigator::sizeHint() const | 156 | QSize KDateNavigator::sizeHint() const |
157 | { | 157 | { |
158 | QFontMetrics fm ( font() ); | 158 | QFontMetrics fm ( font() ); |
159 | QSize day = daymatrix->sizeHint(); | 159 | QSize day = daymatrix->sizeHint(); |
160 | QSize nav = mNavigatorBar->sizeHint(); | 160 | QSize nav = mNavigatorBar->sizeHint(); |
161 | int wid = fm.width( "30") + day.width()+3; | 161 | int wid = fm.width( "30") + day.width()+3; |
162 | int hei = fm.height() +day.height()+nav.height()+2; | 162 | int hei = fm.height() +day.height()+nav.height()+2; |
163 | if ( wid < nav.width() ) | 163 | if ( wid < nav.width() ) |
164 | wid = nav.width() ; | 164 | wid = nav.width() ; |
165 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 165 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
166 | return QSize ( wid, hei ); | 166 | return QSize ( wid, hei ); |
167 | } | 167 | } |
168 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 168 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
169 | { | 169 | { |
170 | QFontMetrics fm ( font() ); | 170 | QFontMetrics fm ( font() ); |
171 | QSize day = daymatrix->sizeHint(); | 171 | QSize day = daymatrix->sizeHint(); |
172 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 172 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
173 | int wid = fm.width( "30") + day.width()+3; | 173 | int wid = fm.width( "30") + day.width()+3; |
174 | int hei = fm.height() +day.height()+nav.height()+2; | 174 | int hei = fm.height() +day.height()+nav.height()+2; |
175 | if ( wid < nav.width() ) | 175 | if ( wid < nav.width() ) |
176 | wid = nav.width() ; | 176 | wid = nav.width() ; |
177 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 177 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
178 | return QSize ( wid, hei ); | 178 | return QSize ( wid, hei ); |
179 | } | 179 | } |
180 | void KDateNavigator::slotMonthSelected( int m ) | 180 | void KDateNavigator::slotMonthSelected( int m ) |
181 | { | 181 | { |
182 | if ( m_MthYr.month() <= mMonthSignalOffset) | 182 | if ( m_MthYr.month() <= mMonthSignalOffset) |
183 | m += 12; | 183 | m += 12; |
184 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 184 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
185 | emit monthSelected( m - mMonthSignalOffset ); | 185 | emit monthSelected( m - mMonthSignalOffset ); |
186 | 186 | ||
187 | } | 187 | } |
188 | void KDateNavigator::setCalendar( Calendar *cal ) | 188 | void KDateNavigator::setCalendar( Calendar *cal ) |
189 | { | 189 | { |
190 | daymatrix->setCalendar( cal ); | 190 | daymatrix->setCalendar( cal ); |
191 | } | 191 | } |
192 | 192 | ||
193 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 193 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
194 | { | 194 | { |
195 | m_MthYr = date; | 195 | m_MthYr = date; |
196 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 196 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
197 | 197 | ||
198 | updateDates(); | 198 | updateDates(); |
199 | updateView(); | 199 | updateView(); |
200 | 200 | ||
201 | KCal::DateList dates; | 201 | KCal::DateList dates; |
202 | dates.append( date ); | 202 | dates.append( date ); |
203 | mNavigatorBar->selectDates( dates ); | 203 | mNavigatorBar->selectDates( dates ); |
204 | 204 | ||
205 | daymatrix->clearSelection(); | 205 | daymatrix->clearSelection(); |
206 | if ( doRepaint ) | 206 | if ( doRepaint ) |
207 | daymatrix->repaint( false ); | 207 | daymatrix->repaint( false ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void KDateNavigator::enableRollover(RolloverType r) | 210 | void KDateNavigator::enableRollover(RolloverType r) |
211 | { | 211 | { |
212 | switch(r) | 212 | switch(r) |
213 | { | 213 | { |
214 | case None : | 214 | case None : |
215 | if (updateTimer) | 215 | if (updateTimer) |
216 | { | 216 | { |
217 | updateTimer->stop(); | 217 | updateTimer->stop(); |
218 | delete updateTimer; | 218 | delete updateTimer; |
219 | updateTimer=0L; | 219 | updateTimer=0L; |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case FollowDay : | 222 | case FollowDay : |
223 | case FollowMonth : | 223 | case FollowMonth : |
224 | if (!updateTimer) | 224 | if (!updateTimer) |
225 | { | 225 | { |
226 | updateTimer = new QTimer(this); | 226 | updateTimer = new QTimer(this); |
227 | QObject::connect(updateTimer,SIGNAL(timeout()), | 227 | QObject::connect(updateTimer,SIGNAL(timeout()), |
228 | this,SLOT(possiblyPastMidnight())); | 228 | this,SLOT(possiblyPastMidnight())); |
229 | } | 229 | } |
230 | updateTimer->start(0,true); | 230 | updateTimer->start(0,true); |
231 | lastDayChecked = QDate::currentDate(); | 231 | lastDayChecked = QDate::currentDate(); |
232 | } | 232 | } |
233 | updateRollover=r; | 233 | updateRollover=r; |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | KDateNavigator::~KDateNavigator() | 237 | KDateNavigator::~KDateNavigator() |
238 | { | 238 | { |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void KDateNavigator::passedMidnight() | 242 | void KDateNavigator::passedMidnight() |
243 | { | 243 | { |
244 | QDate today = QDate::currentDate(); | 244 | QDate today = QDate::currentDate(); |
245 | bool emitMonth = false; | 245 | bool emitMonth = false; |
246 | 246 | ||
247 | if (today.month() != lastDayChecked.month()) | 247 | if (today.month() != lastDayChecked.month()) |
248 | { | 248 | { |
249 | if (updateRollover==FollowMonth && | 249 | if (updateRollover==FollowMonth && |
250 | daymatrix->isEndOfMonth()) { | 250 | daymatrix->isEndOfMonth()) { |
251 | goNextMonth(); | 251 | goNextMonth(); |
252 | emitMonth=true; | 252 | emitMonth=true; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | daymatrix->recalculateToday(); | 255 | daymatrix->recalculateToday(); |
256 | daymatrix->repaint( false ); | 256 | daymatrix->repaint( false ); |
257 | emit dayPassed(today); | 257 | emit dayPassed(today); |
258 | if (emitMonth) { emit monthPassed(today); } | 258 | if (emitMonth) { emit monthPassed(today); } |
259 | } | 259 | } |
260 | 260 | ||
261 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 261 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
262 | { | 262 | { |
263 | if (lastDayChecked!=QDate::currentDate()) | 263 | if (lastDayChecked!=QDate::currentDate()) |
264 | { | 264 | { |
265 | passedMidnight(); | 265 | passedMidnight(); |
266 | lastDayChecked=QDate::currentDate(); | 266 | lastDayChecked=QDate::currentDate(); |
267 | } | 267 | } |
268 | // Set the timer to go off 1 second after midnight | 268 | // Set the timer to go off 1 second after midnight |
269 | // or after 8 minutes, whichever comes first. | 269 | // or after 8 minutes, whichever comes first. |
270 | if (updateTimer) | 270 | if (updateTimer) |
271 | { | 271 | { |
272 | QTime now = QTime::currentTime(); | 272 | QTime now = QTime::currentTime(); |
273 | QTime midnight = QTime(23,59,59); | 273 | QTime midnight = QTime(23,59,59); |
274 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 274 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
275 | 275 | ||
276 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 276 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
277 | //.arg(now.toString()).arg(midnight.toString())); | 277 | //.arg(now.toString()).arg(midnight.toString())); |
278 | 278 | ||
279 | updateTimer->stop(); | 279 | updateTimer->stop(); |
280 | updateTimer->start(msecsWait,true); | 280 | updateTimer->start(msecsWait,true); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | void KDateNavigator::updateDates() | 284 | void KDateNavigator::updateDates() |
285 | { | 285 | { |
286 | // Find the first day of the week of the current month. | 286 | // Find the first day of the week of the current month. |
287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
290 | //int di = d1 - d2 + 1; | 290 | //int di = d1 - d2 + 1; |
291 | dayone = dayone.addDays( -d2 + 1 ); | 291 | dayone = dayone.addDays( -d2 + 1 ); |
292 | 292 | ||
293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
294 | 294 | ||
295 | // If month begins on Monday and Monday is first day of week, | 295 | // If month begins on Monday and Monday is first day of week, |
296 | // month should begin on second line. Sunday doesn't have this problem. | 296 | // month should begin on second line. Sunday doesn't have this problem. |
297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
299 | 299 | ||
300 | // update the matrix dates | 300 | // update the matrix dates |
301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
302 | 302 | ||
303 | 303 | ||
304 | daymatrix->updateView(dayone.addDays(index)); | 304 | daymatrix->updateView(dayone.addDays(index)); |
305 | //each updateDates is followed by an updateView -> repaint is issued there ! | 305 | //each updateDates is followed by an updateView -> repaint is issued there ! |
306 | // daymatrix->repaint(); | 306 | // daymatrix->repaint(); |
307 | } | 307 | } |
308 | 308 | ||
309 | void KDateNavigator::updateDayMatrix() | 309 | void KDateNavigator::updateDayMatrix() |
310 | { | 310 | { |
311 | daymatrix->updateView(); | 311 | daymatrix->updateView(); |
312 | //daymatrix->repaint(); | 312 | //daymatrix->repaint(); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void KDateNavigator::updateView() | 316 | void KDateNavigator::updateView() |
317 | { | 317 | { |
318 | 318 | ||
319 | setUpdatesEnabled( false ); | 319 | setUpdatesEnabled( false ); |
320 | 320 | ||
321 | int i; | 321 | int i; |
322 | 322 | ||
323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
324 | daymatrix->updateView(); | 324 | daymatrix->updateView(); |
325 | 325 | int sub = 4; | |
326 | if ( ! KGlobal::locale()->weekStartsMonday() ) | ||
327 | --sub; | ||
326 | // set the week numbers. | 328 | // set the week numbers. |
327 | for(i = 0; i < 6; i++) { | 329 | for(i = 0; i < 6; i++) { |
328 | QString weeknum; | ||
329 | // remember, according to ISO 8601, the first week of the year is the | 330 | // remember, according to ISO 8601, the first week of the year is the |
330 | // first week that contains a thursday. Thus we must subtract off 4, | 331 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 332 | // not just 1. |
332 | 333 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 334 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 335 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); |
335 | 336 | int weekNo; | |
336 | int add = 0; | ||
337 | if ( ! KGlobal::locale()->weekStartsMonday() ) | ||
338 | ++add; | ||
339 | if (dayOfYear % 7 != 0) | 337 | if (dayOfYear % 7 != 0) |
340 | weeknum.setNum(dayOfYear / 7 + 1+add); | 338 | weekNo = (dayOfYear / 7 + 1); |
341 | else | 339 | else |
342 | weeknum.setNum(dayOfYear / 7 +add); | 340 | weekNo = (dayOfYear / 7); |
343 | weeknos[i]->setText(weeknum); | 341 | weeknos[i]->setText(QString::number( weekNo )); |
344 | } | 342 | } |
345 | 343 | ||
346 | setUpdatesEnabled( true ); | 344 | setUpdatesEnabled( true ); |
347 | // kdDebug() << "updateView() -> repaint()" << endl; | 345 | // kdDebug() << "updateView() -> repaint()" << endl; |
348 | repaint(); | 346 | repaint(); |
349 | // daymatrix->repaint(); | 347 | // daymatrix->repaint(); |
350 | } | 348 | } |
351 | 349 | ||
352 | void KDateNavigator::updateConfig() | 350 | void KDateNavigator::updateConfig() |
353 | { | 351 | { |
354 | int day; | 352 | int day; |
355 | for(int i=0; i<7; i++) { | 353 | for(int i=0; i<7; i++) { |
356 | // take the first letter of the day name to be the abbreviation | 354 | // take the first letter of the day name to be the abbreviation |
357 | if (KGlobal::locale()->weekStartsMonday()) { | 355 | if (KGlobal::locale()->weekStartsMonday()) { |
358 | day = i+1; | 356 | day = i+1; |
359 | } else { | 357 | } else { |
360 | if (i==0) day = 7; | 358 | if (i==0) day = 7; |
361 | else day = i; | 359 | else day = i; |
362 | } | 360 | } |
363 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 361 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
364 | true ); | 362 | true ); |
365 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 363 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
366 | headings[i]->setText( dayName ); | 364 | headings[i]->setText( dayName ); |
367 | } | 365 | } |
368 | updateDates(); | 366 | updateDates(); |
369 | updateView(); | 367 | updateView(); |
370 | } | 368 | } |
371 | 369 | ||
372 | void KDateNavigator::setShowWeekNums(bool enabled) | 370 | void KDateNavigator::setShowWeekNums(bool enabled) |
373 | { | 371 | { |
374 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | 372 | qDebug("KDateNavigator::setShowWeekNums***************************** "); |
375 | m_bShowWeekNums = enabled; | 373 | m_bShowWeekNums = enabled; |
376 | for(int i=0; i<6; i++) { | 374 | for(int i=0; i<6; i++) { |
377 | if(enabled) | 375 | if(enabled) |
378 | weeknos[i]->show(); | 376 | weeknos[i]->show(); |
379 | else | 377 | else |
380 | weeknos[i]->hide(); | 378 | weeknos[i]->hide(); |
381 | } | 379 | } |
382 | resize(size()); | 380 | resize(size()); |
383 | } | 381 | } |
384 | 382 | ||
385 | void KDateNavigator::selectDates(const DateList& dateList) | 383 | void KDateNavigator::selectDates(const DateList& dateList) |
386 | { | 384 | { |
387 | 385 | ||
388 | if (dateList.count() > 0) { | 386 | if (dateList.count() > 0) { |
389 | mNavigatorBar->selectDates( dateList ); | 387 | mNavigatorBar->selectDates( dateList ); |
390 | mSelectedDates = dateList; | 388 | mSelectedDates = dateList; |
391 | 389 | ||
392 | // set our record of the month and year that this datetbl is | 390 | // set our record of the month and year that this datetbl is |
393 | // displaying. | 391 | // displaying. |
394 | m_MthYr = mSelectedDates.first(); | 392 | m_MthYr = mSelectedDates.first(); |
395 | 393 | ||
396 | 394 | ||
397 | // set our record of the first day of the week of the current | 395 | // set our record of the first day of the week of the current |
398 | // month. This needs to be done before calling dayToIndex, since it | 396 | // month. This needs to be done before calling dayToIndex, since it |
399 | // relies on this information being up to date. | 397 | // relies on this information being up to date. |
400 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 398 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
401 | m_fstDayOfWk = dayone.dayOfWeek(); | 399 | m_fstDayOfWk = dayone.dayOfWeek(); |
402 | 400 | ||
403 | updateDates(); | 401 | updateDates(); |
404 | 402 | ||
405 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 403 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
406 | 404 | ||
407 | updateView(); | 405 | updateView(); |
408 | } | 406 | } |
409 | } | 407 | } |
410 | 408 | ||
411 | int KDateNavigator::dayNum(int row, int col) | 409 | int KDateNavigator::dayNum(int row, int col) |
412 | { | 410 | { |
413 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 411 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
414 | } | 412 | } |
415 | 413 | ||
416 | int KDateNavigator::dayToIndex(int dayNum) | 414 | int KDateNavigator::dayToIndex(int dayNum) |
417 | { | 415 | { |
418 | int row, col; | 416 | int row, col; |
419 | 417 | ||
420 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 418 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
421 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 419 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
422 | row++; | 420 | row++; |
423 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 421 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
424 | return row * 7 + col; | 422 | return row * 7 + col; |
425 | } | 423 | } |
426 | 424 | ||
427 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 425 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
428 | { | 426 | { |
429 | if(e->delta()>0) emit goPrevious(); | 427 | if(e->delta()>0) emit goPrevious(); |
430 | else emit goNext(); | 428 | else emit goNext(); |
431 | 429 | ||
432 | e->accept(); | 430 | e->accept(); |
433 | } | 431 | } |
434 | 432 | ||
435 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 433 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
436 | { | 434 | { |
437 | if (e->type() == QEvent::MouseButtonPress) { | 435 | if (e->type() == QEvent::MouseButtonPress) { |
438 | int i; | 436 | int i; |
439 | for(i=0;i<6;++i) { | 437 | for(i=0;i<6;++i) { |
440 | if (o == weeknos[i]) { | 438 | if (o == weeknos[i]) { |
441 | QDate weekstart = daymatrix->getDate(i*7); | 439 | QDate weekstart = daymatrix->getDate(i*7); |
442 | emit weekClicked(weekstart); | 440 | emit weekClicked(weekstart); |
443 | break; | 441 | break; |
444 | } | 442 | } |
445 | } | 443 | } |
446 | for(i=0;i<7;++i) { | 444 | for(i=0;i<7;++i) { |
447 | if (o == headings[i]) { | 445 | if (o == headings[i]) { |
448 | KCal::DateList selDays; | 446 | KCal::DateList selDays; |
449 | QDate date = daymatrix->getDate(14); | 447 | QDate date = daymatrix->getDate(14); |
450 | emit showMonth(date ); | 448 | emit showMonth(date ); |
451 | #if 0 | 449 | #if 0 |
452 | int dio = date.daysInMonth(); | 450 | int dio = date.daysInMonth(); |
453 | int j; | 451 | int j; |
454 | int ye = date.year(); | 452 | int ye = date.year(); |
455 | int mo = date.month(); | 453 | int mo = date.month(); |
456 | for ( j = 1; j <= dio; ++j ) { | 454 | for ( j = 1; j <= dio; ++j ) { |
457 | selDays.append( QDate( ye, mo, j ) ); | 455 | selDays.append( QDate( ye, mo, j ) ); |
458 | } | 456 | } |
459 | emit datesSelected( selDays ); | 457 | emit datesSelected( selDays ); |
460 | #endif | 458 | #endif |
461 | break; | 459 | break; |
462 | } | 460 | } |
463 | } | 461 | } |
464 | return true; | 462 | return true; |
465 | } else { | 463 | } else { |
466 | return false; | 464 | return false; |
467 | } | 465 | } |
468 | } | 466 | } |
469 | 467 | ||
470 | //#include "kdatenavigator.moc" | 468 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9085775..d825493 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1858 +1,1857 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | } | 86 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 92 | { |
93 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 94 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 96 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | 98 | KOPrefs::instance()->mWTshowDetails, |
99 | KOPrefs::instance()->mWTshowCreated, | 99 | KOPrefs::instance()->mWTshowCreated, |
100 | KOPrefs::instance()->mWTshowChanged); | 100 | KOPrefs::instance()->mWTshowChanged); |
101 | } | 101 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
103 | { | 103 | { |
104 | 104 | ||
105 | switch(e->key()) { | 105 | switch(e->key()) { |
106 | case Key_Right: | 106 | case Key_Right: |
107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
108 | { | 108 | { |
109 | e->ignore(); | 109 | e->ignore(); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | scrollBy(10,0); | 112 | scrollBy(10,0); |
113 | break; | 113 | break; |
114 | case Key_Left: | 114 | case Key_Left: |
115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
116 | { | 116 | { |
117 | e->ignore(); | 117 | e->ignore(); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | scrollBy(-10,0); | 120 | scrollBy(-10,0); |
121 | break; | 121 | break; |
122 | case Key_Up: | 122 | case Key_Up: |
123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | setCurrentItem((currentItem()+count()-1)%count()); | 127 | setCurrentItem((currentItem()+count()-1)%count()); |
128 | if(!itemVisible(currentItem())) { | 128 | if(!itemVisible(currentItem())) { |
129 | if((unsigned int) currentItem() == (count()-1)) { | 129 | if((unsigned int) currentItem() == (count()-1)) { |
130 | setTopItem(currentItem()-numItemsVisible()+1); | 130 | setTopItem(currentItem()-numItemsVisible()+1); |
131 | } else { | 131 | } else { |
132 | setTopItem(topItem()-1); | 132 | setTopItem(topItem()-1); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | break; | 135 | break; |
136 | case Key_Down: | 136 | case Key_Down: |
137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
138 | e->ignore(); | 138 | e->ignore(); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | setCurrentItem((currentItem()+1)%count()); | 141 | setCurrentItem((currentItem()+1)%count()); |
142 | if(!itemVisible(currentItem())) { | 142 | if(!itemVisible(currentItem())) { |
143 | if(currentItem() == 0) { | 143 | if(currentItem() == 0) { |
144 | setTopItem(0); | 144 | setTopItem(0); |
145 | } else { | 145 | } else { |
146 | setTopItem(topItem()+1); | 146 | setTopItem(topItem()+1); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | break; | 149 | break; |
150 | case Key_I: | 150 | case Key_I: |
151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
152 | e->ignore(); | 152 | e->ignore(); |
153 | break; | 153 | break; |
154 | case Key_Shift: | 154 | case Key_Shift: |
155 | emit shiftDown(); | 155 | emit shiftDown(); |
156 | break; | 156 | break; |
157 | default: | 157 | default: |
158 | e->ignore(); | 158 | e->ignore(); |
159 | break; | 159 | break; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | void KNoScrollListBox::oneDown() | 163 | void KNoScrollListBox::oneDown() |
164 | { | 164 | { |
165 | setCurrentItem((currentItem()+1)%count()); | 165 | setCurrentItem((currentItem()+1)%count()); |
166 | if(!itemVisible(currentItem())) { | 166 | if(!itemVisible(currentItem())) { |
167 | if(currentItem() == 0) { | 167 | if(currentItem() == 0) { |
168 | setTopItem(0); | 168 | setTopItem(0); |
169 | } else { | 169 | } else { |
170 | setTopItem(topItem()+1); | 170 | setTopItem(topItem()+1); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
175 | { | 175 | { |
176 | switch(e->key()) { | 176 | switch(e->key()) { |
177 | case Key_Shift: | 177 | case Key_Shift: |
178 | emit shiftUp(); | 178 | emit shiftUp(); |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
186 | { | 186 | { |
187 | QListBox::mousePressEvent(e); | 187 | QListBox::mousePressEvent(e); |
188 | 188 | ||
189 | if(e->button() == RightButton) { | 189 | if(e->button() == RightButton) { |
190 | emit rightClick(); | 190 | emit rightClick(); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
195 | : QListBoxItem() | 195 | : QListBoxItem() |
196 | { | 196 | { |
197 | mblockRepaint = true; | 197 | mblockRepaint = true; |
198 | setText( s ); | 198 | setText( s ); |
199 | mMultiday = 0; | 199 | mMultiday = 0; |
200 | mIncidence = incidence; | 200 | mIncidence = incidence; |
201 | mDate = qd; | 201 | mDate = qd; |
202 | mRecur = false; | 202 | mRecur = false; |
203 | mAlarm = false; | 203 | mAlarm = false; |
204 | mReply = false; | 204 | mReply = false; |
205 | mInfo = false; | 205 | mInfo = false; |
206 | //qDebug("NEWWWWWWWWWWWWW "); | 206 | //qDebug("NEWWWWWWWWWWWWW "); |
207 | } | 207 | } |
208 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 208 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
209 | { | 209 | { |
210 | setText( s ); | 210 | setText( s ); |
211 | mMultiday = 0; | 211 | mMultiday = 0; |
212 | mIncidence = incidence; | 212 | mIncidence = incidence; |
213 | mDate = qd; | 213 | mDate = qd; |
214 | mRecur = false; | 214 | mRecur = false; |
215 | mAlarm = false; | 215 | mAlarm = false; |
216 | mReply = false; | 216 | mReply = false; |
217 | mInfo = false; | 217 | mInfo = false; |
218 | //qDebug("recucleeeeeeeeeeeeeeeee "); | 218 | //qDebug("recucleeeeeeeeeeeeeeeee "); |
219 | } | 219 | } |
220 | 220 | ||
221 | void MonthViewItem::paint(QPainter *p) | 221 | void MonthViewItem::paint(QPainter *p) |
222 | { | 222 | { |
223 | if ( mblockRepaint ) { | 223 | if ( mblockRepaint ) { |
224 | //qDebug("block "); | 224 | //qDebug("block "); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | //qDebug("NON block "); | 227 | //qDebug("NON block "); |
228 | #if QT_VERSION >= 0x030000 | 228 | #if QT_VERSION >= 0x030000 |
229 | bool sel = isSelected(); | 229 | bool sel = isSelected(); |
230 | #else | 230 | #else |
231 | bool sel = selected(); | 231 | bool sel = selected(); |
232 | #endif | 232 | #endif |
233 | 233 | ||
234 | 234 | ||
235 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 235 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
236 | { | 236 | { |
237 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 237 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
238 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 238 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
239 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 239 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
240 | } | 240 | } |
241 | int x = 1; | 241 | int x = 1; |
242 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 242 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
243 | int size = PIXMAP_SIZE; | 243 | int size = PIXMAP_SIZE; |
244 | if ( QApplication::desktop()->width() < 300 ) | 244 | if ( QApplication::desktop()->width() < 300 ) |
245 | size = 3; | 245 | size = 3; |
246 | int heihei = height( listBox () ); | 246 | int heihei = height( listBox () ); |
247 | int y = (heihei - size -1 ) /2; | 247 | int y = (heihei - size -1 ) /2; |
248 | 248 | ||
249 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 249 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
250 | if ( mInfo ) { | 250 | if ( mInfo ) { |
251 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 251 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
252 | x += size + 1; | 252 | x += size + 1; |
253 | } | 253 | } |
254 | if ( mRecur ) { | 254 | if ( mRecur ) { |
255 | p->fillRect ( x, y,size,size, Qt::blue ); | 255 | p->fillRect ( x, y,size,size, Qt::blue ); |
256 | x += size + 1; | 256 | x += size + 1; |
257 | } | 257 | } |
258 | if ( mAlarm ) { | 258 | if ( mAlarm ) { |
259 | p->fillRect ( x, y,size,size, Qt::red ); | 259 | p->fillRect ( x, y,size,size, Qt::red ); |
260 | x += size + 1; | 260 | x += size + 1; |
261 | } | 261 | } |
262 | if ( mReply ) { | 262 | if ( mReply ) { |
263 | p->fillRect ( x, y,size,size, Qt::yellow ); | 263 | p->fillRect ( x, y,size,size, Qt::yellow ); |
264 | x += size + 1; | 264 | x += size + 1; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | if ( mMultiday ) { | 267 | if ( mMultiday ) { |
268 | int yyy = y+(size/2); | 268 | int yyy = y+(size/2); |
269 | int sizeM = size+2; | 269 | int sizeM = size+2; |
270 | p->setBrush( QBrush::SolidPattern ); | 270 | p->setBrush( QBrush::SolidPattern ); |
271 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 271 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
272 | if ( mMultiday == 2 || mMultiday == 3 ) { | 272 | if ( mMultiday == 2 || mMultiday == 3 ) { |
273 | QPointArray pa ( 3 ); | 273 | QPointArray pa ( 3 ); |
274 | pa.setPoint (0, x, yyy ); | 274 | pa.setPoint (0, x, yyy ); |
275 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 275 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
276 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 276 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
277 | p->drawPolygon( pa ); | 277 | p->drawPolygon( pa ); |
278 | } | 278 | } |
279 | if ( mMultiday == 2 || mMultiday == 1 ) { | 279 | if ( mMultiday == 2 || mMultiday == 1 ) { |
280 | QPointArray pa ( 3 ); | 280 | QPointArray pa ( 3 ); |
281 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 281 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
282 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 282 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
283 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 283 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
284 | p->drawPolygon( pa ); | 284 | p->drawPolygon( pa ); |
285 | } | 285 | } |
286 | if ( mMultiday == 1 ) { | 286 | if ( mMultiday == 1 ) { |
287 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 287 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
288 | 288 | ||
289 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 289 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
290 | } | 290 | } |
291 | if ( mMultiday == 3 ) { | 291 | if ( mMultiday == 3 ) { |
292 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 292 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
293 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 293 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
294 | 294 | ||
295 | } | 295 | } |
296 | x += sizeM/2 + 1; | 296 | x += sizeM/2 + 1; |
297 | x += sizeM + 1; | 297 | x += sizeM + 1; |
298 | } | 298 | } |
299 | 299 | ||
300 | if ( mIncidence->type() == "Todo" ){ | 300 | if ( mIncidence->type() == "Todo" ){ |
301 | Todo* td = ( Todo* ) mIncidence; | 301 | Todo* td = ( Todo* ) mIncidence; |
302 | if ( td->isCompleted() ) { | 302 | if ( td->isCompleted() ) { |
303 | int half = size/2; | 303 | int half = size/2; |
304 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 304 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
305 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 305 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
306 | x += half+half + 4; | 306 | x += half+half + 4; |
307 | 307 | ||
308 | } else { | 308 | } else { |
309 | int val = td->percentComplete()/20; | 309 | int val = td->percentComplete()/20; |
310 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); | 310 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); |
311 | p->drawRect ( x, y-1,7,size+2); | 311 | p->drawRect ( x, y-1,7,size+2); |
312 | x += size + 3; | 312 | x += size + 3; |
313 | } | 313 | } |
314 | } | 314 | } |
315 | QFontMetrics fm = p->fontMetrics(); | 315 | QFontMetrics fm = p->fontMetrics(); |
316 | int yPos; | 316 | int yPos; |
317 | int pmheight = size; | 317 | int pmheight = size; |
318 | if( pmheight < fm.height() ) | 318 | if( pmheight < fm.height() ) |
319 | yPos = fm.ascent() + fm.leading()/2; | 319 | yPos = fm.ascent() + fm.leading()/2; |
320 | else | 320 | else |
321 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 321 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
322 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 322 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
323 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 323 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
324 | p->drawText( x, yPos, text() ); | 324 | p->drawText( x, yPos, text() ); |
325 | if ( mIncidence->cancelled() ) { | 325 | if ( mIncidence->cancelled() ) { |
326 | int wid = fm.width( text() ); | 326 | int wid = fm.width( text() ); |
327 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 327 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
328 | } | 328 | } |
329 | 329 | ||
330 | } | 330 | } |
331 | 331 | ||
332 | int MonthViewItem::height(const QListBox *lb) const | 332 | int MonthViewItem::height(const QListBox *lb) const |
333 | { | 333 | { |
334 | int ret = 10; | 334 | int ret = 10; |
335 | if ( lb ) | 335 | if ( lb ) |
336 | ret = lb->fontMetrics().lineSpacing()+1; | 336 | ret = lb->fontMetrics().lineSpacing()+1; |
337 | return ret; | 337 | return ret; |
338 | } | 338 | } |
339 | 339 | ||
340 | int MonthViewItem::width(const QListBox *lb) const | 340 | int MonthViewItem::width(const QListBox *lb) const |
341 | { | 341 | { |
342 | 342 | ||
343 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 343 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
344 | int size = PIXMAP_SIZE; | 344 | int size = PIXMAP_SIZE; |
345 | if ( QApplication::desktop()->width() < 300 ) | 345 | if ( QApplication::desktop()->width() < 300 ) |
346 | size = 3; | 346 | size = 3; |
347 | int x = 1; | 347 | int x = 1; |
348 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 348 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
349 | if ( mInfo ) { | 349 | if ( mInfo ) { |
350 | x += size + 1; | 350 | x += size + 1; |
351 | } | 351 | } |
352 | if( mRecur ) { | 352 | if( mRecur ) { |
353 | x += size+1; | 353 | x += size+1; |
354 | } | 354 | } |
355 | if( mAlarm ) { | 355 | if( mAlarm ) { |
356 | x += size+1; | 356 | x += size+1; |
357 | } | 357 | } |
358 | if( mReply ) { | 358 | if( mReply ) { |
359 | x += size+1; | 359 | x += size+1; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | if( mMultiday ) { | 362 | if( mMultiday ) { |
363 | x += size+1+2+size/2; | 363 | x += size+1+2+size/2; |
364 | } | 364 | } |
365 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 365 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
366 | } | 366 | } |
367 | if ( ! lb ) | 367 | if ( ! lb ) |
368 | return 10; | 368 | return 10; |
369 | //qDebug("ret wid %d ", lb->width()); | 369 | //qDebug("ret wid %d ", lb->width()); |
370 | return lb->width(); | 370 | return lb->width(); |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 374 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
375 | : KNoScrollListBox( par ), | 375 | : KNoScrollListBox( par ), |
376 | mMonthView( parent ) | 376 | mMonthView( parent ) |
377 | { | 377 | { |
378 | 378 | ||
379 | mCurrentAvailItem = 0; | 379 | mCurrentAvailItem = 0; |
380 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 380 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
381 | currentPalette = 0; | 381 | currentPalette = 0; |
382 | // mLabel = new QLabel( this );QPushButton | 382 | // mLabel = new QLabel( this );QPushButton |
383 | mLabel = new QPushButton( this ); | 383 | mLabel = new QPushButton( this ); |
384 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 384 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
385 | //mLabel->setLineWidth( 1 ); | 385 | //mLabel->setLineWidth( 1 ); |
386 | //mLabel->setAlignment( AlignCenter ); | 386 | //mLabel->setAlignment( AlignCenter ); |
387 | mLabel->setFlat( true ); | 387 | mLabel->setFlat( true ); |
388 | mLabel->setFocusPolicy(NoFocus); | 388 | mLabel->setFocusPolicy(NoFocus); |
389 | //mItemList = new KNoScrollListBox( this ); | 389 | //mItemList = new KNoScrollListBox( this ); |
390 | setMinimumSize( 10, 10 ); | 390 | setMinimumSize( 10, 10 ); |
391 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 391 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
392 | setLineWidth( 1 ); | 392 | setLineWidth( 1 ); |
393 | //topLayout->addWidget( mItemList ); | 393 | //topLayout->addWidget( mItemList ); |
394 | mLabel->raise(); | 394 | mLabel->raise(); |
395 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 395 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
396 | mStandardPalette = palette(); | 396 | mStandardPalette = palette(); |
397 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 397 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
398 | 398 | ||
399 | enableScrollBars( false ); | 399 | enableScrollBars( false ); |
400 | updateConfig(); | 400 | updateConfig(); |
401 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 401 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
402 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 402 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
403 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 403 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
404 | SLOT( defaultAction( QListBoxItem * ) ) ); | 404 | SLOT( defaultAction( QListBoxItem * ) ) ); |
405 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 405 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
406 | const QPoint &) ), | 406 | const QPoint &) ), |
407 | SLOT( contextMenu( QListBoxItem * ) ) ); | 407 | SLOT( contextMenu( QListBoxItem * ) ) ); |
408 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 408 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
409 | SLOT( selection( QListBoxItem * ) ) ); | 409 | SLOT( selection( QListBoxItem * ) ) ); |
410 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 410 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
411 | SLOT( cellClicked( QListBoxItem * ) ) ); | 411 | SLOT( cellClicked( QListBoxItem * ) ) ); |
412 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 412 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
413 | SLOT( selection( QListBoxItem * ) ) ); | 413 | SLOT( selection( QListBoxItem * ) ) ); |
414 | } | 414 | } |
415 | #ifdef DESKTOP_VERSION | 415 | #ifdef DESKTOP_VERSION |
416 | QToolTipGroup *MonthViewCell::toolTipGroup() | 416 | QToolTipGroup *MonthViewCell::toolTipGroup() |
417 | { | 417 | { |
418 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 418 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
419 | return mToolTipGroup; | 419 | return mToolTipGroup; |
420 | } | 420 | } |
421 | #endif | 421 | #endif |
422 | 422 | ||
423 | void MonthViewCell::setDate( const QDate &date ) | 423 | void MonthViewCell::setDate( const QDate &date ) |
424 | { | 424 | { |
425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
426 | mDate = date; | 426 | mDate = date; |
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | //resizeEvent( 0 ); | 430 | //resizeEvent( 0 ); |
431 | } | 431 | } |
432 | 432 | ||
433 | QDate MonthViewCell::date() const | 433 | QDate MonthViewCell::date() const |
434 | { | 434 | { |
435 | return mDate; | 435 | return mDate; |
436 | } | 436 | } |
437 | 437 | ||
438 | void MonthViewCell::setPrimary( bool primary ) | 438 | void MonthViewCell::setPrimary( bool primary ) |
439 | { | 439 | { |
440 | mPrimary = primary; | 440 | mPrimary = primary; |
441 | //setMyPalette(); | 441 | //setMyPalette(); |
442 | } | 442 | } |
443 | void MonthViewCell::setMyPalette() | 443 | void MonthViewCell::setMyPalette() |
444 | { | 444 | { |
445 | 445 | ||
446 | if ( mHoliday) { | 446 | if ( mHoliday) { |
447 | if ( currentPalette == 1 ) return; | 447 | if ( currentPalette == 1 ) return; |
448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
449 | setPalette( mHolidayPalette ); | 449 | setPalette( mHolidayPalette ); |
450 | //mLabel->setPalette( mHolidayPalette ); | 450 | //mLabel->setPalette( mHolidayPalette ); |
451 | currentPalette = 1; | 451 | currentPalette = 1; |
452 | 452 | ||
453 | } else { | 453 | } else { |
454 | if ( mPrimary ) { | 454 | if ( mPrimary ) { |
455 | if ( currentPalette == 2 ) return; | 455 | if ( currentPalette == 2 ) return; |
456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
457 | //mLabel->setPalette( mPrimaryPalette ); | 457 | //mLabel->setPalette( mPrimaryPalette ); |
458 | setPalette( mPrimaryPalette ); | 458 | setPalette( mPrimaryPalette ); |
459 | currentPalette = 2; | 459 | currentPalette = 2; |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if ( currentPalette == 3 ) return; | 462 | if ( currentPalette == 3 ) return; |
463 | setPalette( mNonPrimaryPalette ); | 463 | setPalette( mNonPrimaryPalette ); |
464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
465 | //mLabel->setPalette( mNonPrimaryPalette );; | 465 | //mLabel->setPalette( mNonPrimaryPalette );; |
466 | currentPalette = 3; | 466 | currentPalette = 3; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | //QPalette pal = palette(); | 469 | //QPalette pal = palette(); |
470 | 470 | ||
471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
472 | } | 472 | } |
473 | QPalette MonthViewCell::getPalette () | 473 | QPalette MonthViewCell::getPalette () |
474 | { | 474 | { |
475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
476 | return mStandardPalette; | 476 | return mStandardPalette; |
477 | if ( mHoliday) { | 477 | if ( mHoliday) { |
478 | return mHolidayPalette ; | 478 | return mHolidayPalette ; |
479 | } else { | 479 | } else { |
480 | if ( mPrimary ) { | 480 | if ( mPrimary ) { |
481 | return mPrimaryPalette ; | 481 | return mPrimaryPalette ; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | return mNonPrimaryPalette; | 484 | return mNonPrimaryPalette; |
485 | } | 485 | } |
486 | bool MonthViewCell::isPrimary() const | 486 | bool MonthViewCell::isPrimary() const |
487 | { | 487 | { |
488 | return mPrimary; | 488 | return mPrimary; |
489 | } | 489 | } |
490 | 490 | ||
491 | void MonthViewCell::setHoliday( bool holiday ) | 491 | void MonthViewCell::setHoliday( bool holiday ) |
492 | { | 492 | { |
493 | mHoliday = holiday; | 493 | mHoliday = holiday; |
494 | //setMyPalette(); | 494 | //setMyPalette(); |
495 | } | 495 | } |
496 | 496 | ||
497 | void MonthViewCell::setHoliday( const QString &holiday ) | 497 | void MonthViewCell::setHoliday( const QString &holiday ) |
498 | { | 498 | { |
499 | mHolidayString = holiday; | 499 | mHolidayString = holiday; |
500 | 500 | ||
501 | if ( !holiday.isEmpty() ) { | 501 | if ( !holiday.isEmpty() ) { |
502 | setHoliday( true ); | 502 | setHoliday( true ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void MonthViewCell::startUpdateCell() | 506 | void MonthViewCell::startUpdateCell() |
507 | { | 507 | { |
508 | 508 | ||
509 | setFocusPolicy(NoFocus); | 509 | setFocusPolicy(NoFocus); |
510 | if ( !mMonthView->isUpdatePossible() ) | 510 | if ( !mMonthView->isUpdatePossible() ) |
511 | return; | 511 | return; |
512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
513 | while ( mitem ) { | 513 | while ( mitem ) { |
514 | mitem->setBlockRepaint( true ); | 514 | mitem->setBlockRepaint( true ); |
515 | mitem = (MonthViewItem *)mitem->next(); | 515 | mitem = (MonthViewItem *)mitem->next(); |
516 | } | 516 | } |
517 | if ( mAvailItemList.count() > 20 ) { | 517 | if ( mAvailItemList.count() > 20 ) { |
518 | mAvailItemList.setAutoDelete( true ); | 518 | mAvailItemList.setAutoDelete( true ); |
519 | mAvailItemList.clear(); | 519 | mAvailItemList.clear(); |
520 | mAvailItemList.setAutoDelete( false ); | 520 | mAvailItemList.setAutoDelete( false ); |
521 | } | 521 | } |
522 | /* | 522 | /* |
523 | if ( !isVisible() ){ | 523 | if ( !isVisible() ){ |
524 | return; | 524 | return; |
525 | } | 525 | } |
526 | */ | 526 | */ |
527 | // qDebug("MonthViewCell::updateCell() "); | 527 | // qDebug("MonthViewCell::updateCell() "); |
528 | setPrimary( mDate.month()%2 ); | 528 | setPrimary( mDate.month()%2 ); |
529 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 529 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
530 | if ( mDate == QDate::currentDate() ) { | 530 | if ( mDate == QDate::currentDate() ) { |
531 | setLineWidth( 3 ); | 531 | setLineWidth( 3 ); |
532 | } else { | 532 | } else { |
533 | setLineWidth( 1 ); | 533 | setLineWidth( 1 ); |
534 | } | 534 | } |
535 | mCurrentAvailItem = (MonthViewItem*) firstItem (); | 535 | mCurrentAvailItem = (MonthViewItem*) firstItem (); |
536 | //clear(); | 536 | //clear(); |
537 | 537 | ||
538 | #ifdef DESKTOP_VERSION | 538 | #ifdef DESKTOP_VERSION |
539 | QToolTip::remove(this); | 539 | QToolTip::remove(this); |
540 | #endif | 540 | #endif |
541 | mToolTip.clear(); | 541 | mToolTip.clear(); |
542 | //qApp->processEvents(); | 542 | //qApp->processEvents(); |
543 | #if 0 | 543 | #if 0 |
544 | if ( !mHolidayString.isEmpty() ) { | 544 | if ( !mHolidayString.isEmpty() ) { |
545 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 545 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
546 | item->setPalette( mHolidayPalette ); | 546 | item->setPalette( mHolidayPalette ); |
547 | insertItem( item ); | 547 | insertItem( item ); |
548 | mToolTip.append ( mHolidayString ); | 548 | mToolTip.append ( mHolidayString ); |
549 | } | 549 | } |
550 | #endif | 550 | #endif |
551 | } | 551 | } |
552 | 552 | ||
553 | void MonthViewCell::insertEvent(Event *event) | 553 | void MonthViewCell::insertEvent(Event *event) |
554 | { | 554 | { |
555 | QString mToolTipText; | 555 | QString mToolTipText; |
556 | bool insertNewItem = false; | 556 | bool insertNewItem = false; |
557 | setFocusPolicy(WheelFocus); | 557 | setFocusPolicy(WheelFocus); |
558 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 558 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
559 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 559 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
560 | return; | 560 | return; |
561 | else | 561 | else |
562 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 562 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | 565 | ||
566 | if ( event->isHoliday()) { | 566 | if ( event->isHoliday()) { |
567 | setHoliday( true ); | 567 | setHoliday( true ); |
568 | if ( mDate.dayOfWeek() == 7 ) | 568 | if ( mDate.dayOfWeek() == 7 ) |
569 | setLineWidth( 3 ); | 569 | setLineWidth( 3 ); |
570 | } | 570 | } |
571 | QString text; | 571 | QString text; |
572 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 572 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
573 | if (event->isMultiDay()) { | 573 | if (event->isMultiDay()) { |
574 | QString prefix = "<->";multiday = 2; | 574 | QString prefix = "<->";multiday = 2; |
575 | QString time; | 575 | QString time; |
576 | if ( event->doesRecur() ) { | 576 | if ( event->doesRecur() ) { |
577 | if ( event->recursOn( mDate) ) { | 577 | if ( event->recursOn( mDate) ) { |
578 | prefix ="->" ;multiday = 1; | 578 | prefix ="->" ;multiday = 1; |
579 | } | 579 | } |
580 | else { | 580 | else { |
581 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 581 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
582 | if ( event->recursOn( mDate.addDays( -days)) ) { | 582 | if ( event->recursOn( mDate.addDays( -days)) ) { |
583 | prefix ="<-" ;multiday = 3; | 583 | prefix ="<-" ;multiday = 3; |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | } else { | 587 | } else { |
588 | if (mDate == event->dtStart().date()) { | 588 | if (mDate == event->dtStart().date()) { |
589 | prefix ="->" ;multiday = 1; | 589 | prefix ="->" ;multiday = 1; |
590 | } else if (mDate == event->dtEnd().date()) { | 590 | } else if (mDate == event->dtEnd().date()) { |
591 | prefix ="<-" ;multiday = 3; | 591 | prefix ="<-" ;multiday = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | if ( !event->doesFloat() ) { | 594 | if ( !event->doesFloat() ) { |
595 | if ( mDate == event->dtStart().date () ) | 595 | if ( mDate == event->dtStart().date () ) |
596 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 596 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
597 | else if ( mDate == event->dtEnd().date () ) | 597 | else if ( mDate == event->dtEnd().date () ) |
598 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 598 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
599 | 599 | ||
600 | } | 600 | } |
601 | text = time + event->summary(); | 601 | text = time + event->summary(); |
602 | mToolTipText += prefix + text; | 602 | mToolTipText += prefix + text; |
603 | } else { | 603 | } else { |
604 | if (event->doesFloat()) { | 604 | if (event->doesFloat()) { |
605 | text = event->summary(); | 605 | text = event->summary(); |
606 | mToolTipText += text; | 606 | mToolTipText += text; |
607 | } | 607 | } |
608 | else { | 608 | else { |
609 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 609 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
610 | text += " " + event->summary(); | 610 | text += " " + event->summary(); |
611 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 611 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | MonthViewItem *item ; | 614 | MonthViewItem *item ; |
615 | if ( mCurrentAvailItem ) { | 615 | if ( mCurrentAvailItem ) { |
616 | item = mCurrentAvailItem; | 616 | item = mCurrentAvailItem; |
617 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 617 | mCurrentAvailItem = (MonthViewItem*) item->next(); |
618 | item->recycle( event, mDate, text ); | 618 | item->recycle( event, mDate, text ); |
619 | } else { | 619 | } else { |
620 | if ( mAvailItemList.count() ) { | 620 | if ( mAvailItemList.count() ) { |
621 | item = mAvailItemList.first(); | 621 | item = mAvailItemList.first(); |
622 | mAvailItemList.remove( item ); | 622 | mAvailItemList.remove( item ); |
623 | item->recycle( event, mDate, text ); | 623 | item->recycle( event, mDate, text ); |
624 | insertNewItem = true; | 624 | insertNewItem = true; |
625 | } else { | 625 | } else { |
626 | insertNewItem = true; | 626 | insertNewItem = true; |
627 | item = new MonthViewItem( event, mDate, text ); | 627 | item = new MonthViewItem( event, mDate, text ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | QPalette pal; | 630 | QPalette pal; |
631 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 631 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
632 | QStringList categories = event->categories(); | 632 | QStringList categories = event->categories(); |
633 | QString cat = categories.first(); | 633 | QString cat = categories.first(); |
634 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 634 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
635 | pal = getPalette(); | 635 | pal = getPalette(); |
636 | if (cat.isEmpty()) { | 636 | if (cat.isEmpty()) { |
637 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 637 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
638 | } else { | 638 | } else { |
639 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 639 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
640 | } | 640 | } |
641 | 641 | ||
642 | } else { | 642 | } else { |
643 | if (cat.isEmpty()) { | 643 | if (cat.isEmpty()) { |
644 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 644 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
645 | } else { | 645 | } else { |
646 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 646 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
647 | } | 647 | } |
648 | } | 648 | } |
649 | 649 | ||
650 | } else { | 650 | } else { |
651 | pal = mStandardPalette ; | 651 | pal = mStandardPalette ; |
652 | } | 652 | } |
653 | item->setPalette( pal ); | 653 | item->setPalette( pal ); |
654 | item->setRecur( event->recurrence()->doesRecur() ); | 654 | item->setRecur( event->recurrence()->doesRecur() ); |
655 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 655 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
656 | item->setMoreInfo( event->description().length() > 0 ); | 656 | item->setMoreInfo( event->description().length() > 0 ); |
657 | #ifdef DESKTOP_VERSION | 657 | #ifdef DESKTOP_VERSION |
658 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 658 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
659 | KOPrefs::instance()->email()); | 659 | KOPrefs::instance()->email()); |
660 | if ( me != 0 ) { | 660 | if ( me != 0 ) { |
661 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 661 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
662 | item->setReply(true && multiday < 2); | 662 | item->setReply(true && multiday < 2); |
663 | else | 663 | else |
664 | item->setReply(false); | 664 | item->setReply(false); |
665 | } else | 665 | } else |
666 | item->setReply(false); | 666 | item->setReply(false); |
667 | #endif | 667 | #endif |
668 | item->setMultiDay( multiday ); | 668 | item->setMultiDay( multiday ); |
669 | if ( insertNewItem) | 669 | if ( insertNewItem) |
670 | insertItem( item ); | 670 | insertItem( item ); |
671 | mToolTip.append( mToolTipText ); | 671 | mToolTip.append( mToolTipText ); |
672 | } | 672 | } |
673 | void MonthViewCell::insertTodo(Todo *todo) | 673 | void MonthViewCell::insertTodo(Todo *todo) |
674 | { | 674 | { |
675 | bool insertNewItem = false; | 675 | bool insertNewItem = false; |
676 | setFocusPolicy(WheelFocus); | 676 | setFocusPolicy(WheelFocus); |
677 | QString text; | 677 | QString text; |
678 | if (todo->hasDueDate()) { | 678 | if (todo->hasDueDate()) { |
679 | if (!todo->doesFloat()) { | 679 | if (!todo->doesFloat()) { |
680 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 680 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
681 | text += " "; | 681 | text += " "; |
682 | } | 682 | } |
683 | } | 683 | } |
684 | text += todo->summary(); | 684 | text += todo->summary(); |
685 | MonthViewItem *item ; | 685 | MonthViewItem *item ; |
686 | if ( mCurrentAvailItem ) { | 686 | if ( mCurrentAvailItem ) { |
687 | item = mCurrentAvailItem; | 687 | item = mCurrentAvailItem; |
688 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 688 | mCurrentAvailItem = (MonthViewItem*) item->next(); |
689 | item->recycle( todo, mDate, text ); | 689 | item->recycle( todo, mDate, text ); |
690 | } else { | 690 | } else { |
691 | if ( mAvailItemList.count() ) { | 691 | if ( mAvailItemList.count() ) { |
692 | item = mAvailItemList.first(); | 692 | item = mAvailItemList.first(); |
693 | mAvailItemList.remove( item ); | 693 | mAvailItemList.remove( item ); |
694 | item->recycle( todo, mDate, text ); | 694 | item->recycle( todo, mDate, text ); |
695 | insertNewItem = true; | 695 | insertNewItem = true; |
696 | } else { | 696 | } else { |
697 | insertNewItem = true; | 697 | insertNewItem = true; |
698 | item = new MonthViewItem( todo, mDate, text ); | 698 | item = new MonthViewItem( todo, mDate, text ); |
699 | } | 699 | } |
700 | } | 700 | } |
701 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 701 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
702 | //item->setPalette( mStandardPalette ); | 702 | //item->setPalette( mStandardPalette ); |
703 | QPalette pal; | 703 | QPalette pal; |
704 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 704 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
705 | QStringList categories = todo->categories(); | 705 | QStringList categories = todo->categories(); |
706 | QString cat = categories.first(); | 706 | QString cat = categories.first(); |
707 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 707 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
708 | pal = getPalette(); | 708 | pal = getPalette(); |
709 | if (cat.isEmpty()) { | 709 | if (cat.isEmpty()) { |
710 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 710 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
711 | } else { | 711 | } else { |
712 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 712 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
713 | } | 713 | } |
714 | 714 | ||
715 | } else { | 715 | } else { |
716 | if (cat.isEmpty()) { | 716 | if (cat.isEmpty()) { |
717 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 717 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
718 | } else { | 718 | } else { |
719 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 719 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | } else { | 723 | } else { |
724 | pal = mStandardPalette ; | 724 | pal = mStandardPalette ; |
725 | } | 725 | } |
726 | item->setPalette( pal ); | 726 | item->setPalette( pal ); |
727 | item->setRecur( todo->recurrence()->doesRecur() ); | 727 | item->setRecur( todo->recurrence()->doesRecur() ); |
728 | item->setAlarm( todo->isAlarmEnabled() ); | 728 | item->setAlarm( todo->isAlarmEnabled() ); |
729 | item->setMoreInfo( todo->description().length() > 0 ); | 729 | item->setMoreInfo( todo->description().length() > 0 ); |
730 | if ( insertNewItem) | 730 | if ( insertNewItem) |
731 | insertItem( item ); | 731 | insertItem( item ); |
732 | mToolTip.append( text ); | 732 | mToolTip.append( text ); |
733 | } | 733 | } |
734 | void MonthViewCell::repaintfinishUpdateCell() | 734 | void MonthViewCell::repaintfinishUpdateCell() |
735 | { | 735 | { |
736 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 736 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
737 | while ( mitem ) { | 737 | while ( mitem ) { |
738 | mitem->setBlockRepaint( false ); | 738 | mitem->setBlockRepaint( false ); |
739 | updateItem ( mitem ); | 739 | updateItem ( mitem ); |
740 | mitem = (MonthViewItem *)mitem->next(); | 740 | mitem = (MonthViewItem *)mitem->next(); |
741 | } | 741 | } |
742 | } | 742 | } |
743 | void MonthViewCell::finishUpdateCell() | 743 | void MonthViewCell::finishUpdateCell() |
744 | { | 744 | { |
745 | while ( mCurrentAvailItem ) { | 745 | while ( mCurrentAvailItem ) { |
746 | MonthViewItem *item = mCurrentAvailItem; | 746 | MonthViewItem *item = mCurrentAvailItem; |
747 | mCurrentAvailItem = (MonthViewItem *)item->next(); | 747 | mCurrentAvailItem = (MonthViewItem *)item->next(); |
748 | mAvailItemList.append( item ); | 748 | mAvailItemList.append( item ); |
749 | takeItem ( item ); | 749 | takeItem ( item ); |
750 | } | 750 | } |
751 | 751 | ||
752 | 752 | ||
753 | #ifdef DESKTOP_VERSION | 753 | #ifdef DESKTOP_VERSION |
754 | if (mToolTip.count() > 0 ) { | 754 | if (mToolTip.count() > 0 ) { |
755 | mToolTip.sort(); | 755 | mToolTip.sort(); |
756 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 756 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
757 | } | 757 | } |
758 | #endif | 758 | #endif |
759 | sort(); | 759 | sort(); |
760 | //setMyPalette(); | 760 | //setMyPalette(); |
761 | setMyPalette(); | 761 | setMyPalette(); |
762 | 762 | ||
763 | resizeEvent( 0 ); | 763 | resizeEvent( 0 ); |
764 | 764 | ||
765 | } | 765 | } |
766 | void MonthViewCell::updateCell() | 766 | void MonthViewCell::updateCell() |
767 | { | 767 | { |
768 | //qDebug("MonthViewCell::updateCell() "); | 768 | //qDebug("MonthViewCell::updateCell() "); |
769 | if ( !mMonthView->isUpdatePossible() ) | 769 | if ( !mMonthView->isUpdatePossible() ) |
770 | return; | 770 | return; |
771 | startUpdateCell(); | 771 | startUpdateCell(); |
772 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 772 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
773 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 773 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
774 | Event *event; | 774 | Event *event; |
775 | for( event = events.first(); event; event = events.next() ) { // for event | 775 | for( event = events.first(); event; event = events.next() ) { // for event |
776 | insertEvent(event); | 776 | insertEvent(event); |
777 | } | 777 | } |
778 | // insert due todos | 778 | // insert due todos |
779 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 779 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
780 | Todo *todo; | 780 | Todo *todo; |
781 | for(todo = todos.first(); todo; todo = todos.next()) { | 781 | for(todo = todos.first(); todo; todo = todos.next()) { |
782 | insertTodo( todo ); | 782 | insertTodo( todo ); |
783 | } | 783 | } |
784 | finishUpdateCell(); | 784 | finishUpdateCell(); |
785 | // if ( isVisible()) | 785 | // if ( isVisible()) |
786 | //qApp->processEvents(); | 786 | //qApp->processEvents(); |
787 | } | 787 | } |
788 | 788 | ||
789 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 789 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
790 | { | 790 | { |
791 | 791 | ||
792 | if ( bigFont ) { | 792 | if ( bigFont ) { |
793 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 793 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
794 | int ps = fo.pointSize() + 2; | 794 | int ps = fo.pointSize() + 2; |
795 | if ( ps < 18 ) | 795 | if ( ps < 18 ) |
796 | ps += 2; | 796 | ps += 2; |
797 | fo.setPointSize( ps ); | 797 | fo.setPointSize( ps ); |
798 | setFont( fo ); | 798 | setFont( fo ); |
799 | } else | 799 | } else |
800 | setFont( KOPrefs::instance()->mMonthViewFont ); | 800 | setFont( KOPrefs::instance()->mMonthViewFont ); |
801 | 801 | ||
802 | QFontMetrics fm( font() ); | 802 | QFontMetrics fm( font() ); |
803 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 803 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
804 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 804 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
805 | mHolidayPalette = mStandardPalette; | 805 | mHolidayPalette = mStandardPalette; |
806 | mPrimaryPalette = mStandardPalette; | 806 | mPrimaryPalette = mStandardPalette; |
807 | mNonPrimaryPalette = mStandardPalette; | 807 | mNonPrimaryPalette = mStandardPalette; |
808 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 808 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
809 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 809 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
810 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 810 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
811 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 811 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
812 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 812 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
813 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 813 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
814 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 814 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
815 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 815 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
816 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 816 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
817 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 817 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
818 | } | 818 | } |
819 | //updateCell(); | 819 | //updateCell(); |
820 | } | 820 | } |
821 | 821 | ||
822 | void MonthViewCell::enableScrollBars( bool enabled ) | 822 | void MonthViewCell::enableScrollBars( bool enabled ) |
823 | { | 823 | { |
824 | if ( enabled ) { | 824 | if ( enabled ) { |
825 | QListBoxItem *fi = firstItem (); | 825 | QListBoxItem *fi = firstItem (); |
826 | if (fi ) { | 826 | if (fi ) { |
827 | int ihei = fi->height( this ); | 827 | int ihei = fi->height( this ); |
828 | int hei = numRows () * ihei; | 828 | int hei = numRows () * ihei; |
829 | if ( hei < height() - horizontalScrollBar()->height () ) { | 829 | if ( hei < height() - horizontalScrollBar()->height () ) { |
830 | setVScrollBarMode(QScrollView::AlwaysOff); | 830 | setVScrollBarMode(QScrollView::AlwaysOff); |
831 | } | 831 | } |
832 | else | 832 | else |
833 | setVScrollBarMode(QScrollView::Auto); | 833 | setVScrollBarMode(QScrollView::Auto); |
834 | if ( ihei *3 > height() ) | 834 | if ( ihei *3 > height() ) |
835 | setHScrollBarMode(QScrollView::AlwaysOff); | 835 | setHScrollBarMode(QScrollView::AlwaysOff); |
836 | else | 836 | else |
837 | setHScrollBarMode(QScrollView::Auto); | 837 | setHScrollBarMode(QScrollView::Auto); |
838 | } else { | 838 | } else { |
839 | setVScrollBarMode(QScrollView::Auto); | 839 | setVScrollBarMode(QScrollView::Auto); |
840 | setHScrollBarMode(QScrollView::Auto); | 840 | setHScrollBarMode(QScrollView::Auto); |
841 | } | 841 | } |
842 | } else { | 842 | } else { |
843 | setVScrollBarMode(QScrollView::AlwaysOff); | 843 | setVScrollBarMode(QScrollView::AlwaysOff); |
844 | setHScrollBarMode(QScrollView::AlwaysOff); | 844 | setHScrollBarMode(QScrollView::AlwaysOff); |
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | Incidence *MonthViewCell::selectedIncidence() | 848 | Incidence *MonthViewCell::selectedIncidence() |
849 | { | 849 | { |
850 | int index = currentItem(); | 850 | int index = currentItem(); |
851 | if ( index < 0 ) return 0; | 851 | if ( index < 0 ) return 0; |
852 | 852 | ||
853 | MonthViewItem *mitem = | 853 | MonthViewItem *mitem = |
854 | static_cast<MonthViewItem *>( item( index ) ); | 854 | static_cast<MonthViewItem *>( item( index ) ); |
855 | 855 | ||
856 | if ( !mitem ) return 0; | 856 | if ( !mitem ) return 0; |
857 | 857 | ||
858 | return mitem->incidence(); | 858 | return mitem->incidence(); |
859 | } | 859 | } |
860 | 860 | ||
861 | QDate MonthViewCell::selectedIncidenceDate() | 861 | QDate MonthViewCell::selectedIncidenceDate() |
862 | { | 862 | { |
863 | QDate qd; | 863 | QDate qd; |
864 | int index = currentItem(); | 864 | int index = currentItem(); |
865 | if ( index < 0 ) return qd; | 865 | if ( index < 0 ) return qd; |
866 | 866 | ||
867 | MonthViewItem *mitem = | 867 | MonthViewItem *mitem = |
868 | static_cast<MonthViewItem *>( item( index ) ); | 868 | static_cast<MonthViewItem *>( item( index ) ); |
869 | 869 | ||
870 | if ( !mitem ) return qd; | 870 | if ( !mitem ) return qd; |
871 | 871 | ||
872 | return mitem->incidenceDate(); | 872 | return mitem->incidenceDate(); |
873 | } | 873 | } |
874 | 874 | ||
875 | void MonthViewCell::deselect() | 875 | void MonthViewCell::deselect() |
876 | { | 876 | { |
877 | clearSelection(); | 877 | clearSelection(); |
878 | enableScrollBars( false ); | 878 | enableScrollBars( false ); |
879 | // updateCell(); | 879 | // updateCell(); |
880 | } | 880 | } |
881 | void MonthViewCell::select() | 881 | void MonthViewCell::select() |
882 | { | 882 | { |
883 | ;// updateCell(); | 883 | ;// updateCell(); |
884 | } | 884 | } |
885 | 885 | ||
886 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 886 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
887 | { | 887 | { |
888 | if ( !mMonthView->isUpdatePossible() ) | 888 | if ( !mMonthView->isUpdatePossible() ) |
889 | return; | 889 | return; |
890 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 890 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
891 | deselect(); | 891 | deselect(); |
892 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 892 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
893 | 893 | ||
894 | QString text; | 894 | QString text; |
895 | mLabel->setText( text ); | 895 | mLabel->setText( text ); |
896 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 896 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
897 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 897 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
898 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 898 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
899 | mLabel->resize( mLabelBigSize ); | 899 | mLabel->resize( mLabelBigSize ); |
900 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 900 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
901 | } else { | 901 | } else { |
902 | mLabel->resize( mLabelSize ); | 902 | mLabel->resize( mLabelSize ); |
903 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 903 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
904 | } | 904 | } |
905 | mLabel->setText( text ); | 905 | mLabel->setText( text ); |
906 | 906 | ||
907 | int size = height() - mLabel->height() - lineWidth()-1; | 907 | int size = height() - mLabel->height() - lineWidth()-1; |
908 | //qDebug("LW %d ", lineWidth()); | 908 | //qDebug("LW %d ", lineWidth()); |
909 | if ( size > 0 ) | 909 | if ( size > 0 ) |
910 | verticalScrollBar()->setMaximumHeight( size ); | 910 | verticalScrollBar()->setMaximumHeight( size ); |
911 | size = width() - mLabel->width() -lineWidth()-1; | 911 | size = width() - mLabel->width() -lineWidth()-1; |
912 | if ( size > 0 ) | 912 | if ( size > 0 ) |
913 | horizontalScrollBar()->setMaximumWidth( size ); | 913 | horizontalScrollBar()->setMaximumWidth( size ); |
914 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 914 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
915 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 915 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
916 | // mItemList->resize ( width(), height () ); | 916 | // mItemList->resize ( width(), height () ); |
917 | if ( e ) | 917 | if ( e ) |
918 | KNoScrollListBox::resizeEvent ( e ); | 918 | KNoScrollListBox::resizeEvent ( e ); |
919 | } | 919 | } |
920 | 920 | ||
921 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 921 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
922 | { | 922 | { |
923 | if ( !item ) return; | 923 | if ( !item ) return; |
924 | 924 | ||
925 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 925 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
926 | Incidence *incidence = eventItem->incidence(); | 926 | Incidence *incidence = eventItem->incidence(); |
927 | if ( incidence ) mMonthView->defaultAction( incidence ); | 927 | if ( incidence ) mMonthView->defaultAction( incidence ); |
928 | } | 928 | } |
929 | void MonthViewCell::showDay() | 929 | void MonthViewCell::showDay() |
930 | { | 930 | { |
931 | emit showDaySignal( date() ); | 931 | emit showDaySignal( date() ); |
932 | } | 932 | } |
933 | void MonthViewCell::newEvent() | 933 | void MonthViewCell::newEvent() |
934 | { | 934 | { |
935 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 935 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
936 | emit newEventSignal( dt ); | 936 | emit newEventSignal( dt ); |
937 | } | 937 | } |
938 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 938 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
939 | { | 939 | { |
940 | static QListBoxItem * lastClicked = 0; | 940 | static QListBoxItem * lastClicked = 0; |
941 | if ( item == 0 ) { | 941 | if ( item == 0 ) { |
942 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 942 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
943 | emit newEventSignal( dt ); | 943 | emit newEventSignal( dt ); |
944 | return; | 944 | return; |
945 | } | 945 | } |
946 | /* | 946 | /* |
947 | if ( lastClicked ) | 947 | if ( lastClicked ) |
948 | if ( ! item ) { | 948 | if ( ! item ) { |
949 | if ( lastClicked->listBox() != item->listBox() ) | 949 | if ( lastClicked->listBox() != item->listBox() ) |
950 | lastClicked->listBox()->clearSelection(); | 950 | lastClicked->listBox()->clearSelection(); |
951 | } | 951 | } |
952 | */ | 952 | */ |
953 | 953 | ||
954 | mMonthView->setSelectedCell( this ); | 954 | mMonthView->setSelectedCell( this ); |
955 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 955 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
956 | select(); | 956 | select(); |
957 | } | 957 | } |
958 | 958 | ||
959 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 959 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
960 | { | 960 | { |
961 | if ( !item ) return; | 961 | if ( !item ) return; |
962 | 962 | ||
963 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 963 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
964 | Incidence *incidence = eventItem->incidence(); | 964 | Incidence *incidence = eventItem->incidence(); |
965 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 965 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
966 | } | 966 | } |
967 | 967 | ||
968 | void MonthViewCell::selection( QListBoxItem *item ) | 968 | void MonthViewCell::selection( QListBoxItem *item ) |
969 | { | 969 | { |
970 | if ( !item ) return; | 970 | if ( !item ) return; |
971 | 971 | ||
972 | mMonthView->setSelectedCell( this ); | 972 | mMonthView->setSelectedCell( this ); |
973 | } | 973 | } |
974 | 974 | ||
975 | 975 | ||
976 | // ******************************************************************************* | 976 | // ******************************************************************************* |
977 | // ******************************************************************************* | 977 | // ******************************************************************************* |
978 | // ******************************************************************************* | 978 | // ******************************************************************************* |
979 | 979 | ||
980 | 980 | ||
981 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 981 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
982 | : KOEventView( calendar, parent, name ), | 982 | : KOEventView( calendar, parent, name ), |
983 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 983 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
984 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 984 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
985 | { | 985 | { |
986 | mShortDayLabelsM = false; | 986 | mShortDayLabelsM = false; |
987 | mShortDayLabelsW = false; | 987 | mShortDayLabelsW = false; |
988 | skipResize = false; | 988 | skipResize = false; |
989 | clPending = true; | 989 | clPending = true; |
990 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 990 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
991 | mWidStack = new QWidgetStack( this ); | 991 | mWidStack = new QWidgetStack( this ); |
992 | QVBoxLayout* hb = new QVBoxLayout( this ); | 992 | QVBoxLayout* hb = new QVBoxLayout( this ); |
993 | mMonthView = new QWidget( mWidStack ); | 993 | mMonthView = new QWidget( mWidStack ); |
994 | mWeekView = new QWidget( mWidStack ); | 994 | mWeekView = new QWidget( mWidStack ); |
995 | #if QT_VERSION >= 0x030000 | 995 | #if QT_VERSION >= 0x030000 |
996 | mWidStack->addWidget(mMonthView ); | 996 | mWidStack->addWidget(mMonthView ); |
997 | mWidStack->addWidget(mWeekView ); | 997 | mWidStack->addWidget(mWeekView ); |
998 | #else | 998 | #else |
999 | mWidStack->addWidget( mMonthView, 1 ); | 999 | mWidStack->addWidget( mMonthView, 1 ); |
1000 | mWidStack->addWidget( mWeekView , 1 ); | 1000 | mWidStack->addWidget( mWeekView , 1 ); |
1001 | #endif | 1001 | #endif |
1002 | hb->addWidget( mNavigatorBar ); | 1002 | hb->addWidget( mNavigatorBar ); |
1003 | hb->addWidget( mWidStack ); | 1003 | hb->addWidget( mWidStack ); |
1004 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | ||
1005 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1004 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1006 | if ( mShowWeekView ) | ||
1007 | mWeekStartsMonday = true; | ||
1008 | updatePossible = false; | 1005 | updatePossible = false; |
1009 | //updatePossible = true; | 1006 | //updatePossible = true; |
1010 | mCells.setAutoDelete( true ); | 1007 | mCells.setAutoDelete( true ); |
1011 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1008 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1012 | mDayLabels.resize( mDaysPerWeek ); | 1009 | mDayLabels.resize( mDaysPerWeek ); |
1013 | mDayLabelsW.resize( mDaysPerWeek ); | 1010 | mDayLabelsW.resize( mDaysPerWeek ); |
1014 | QFont bfont = font(); | 1011 | QFont bfont = font(); |
1015 | if ( QApplication::desktop()->width() < 650 ) { | 1012 | if ( QApplication::desktop()->width() < 650 ) { |
1016 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1013 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1017 | } | 1014 | } |
1018 | bfont.setBold( true ); | 1015 | bfont.setBold( true ); |
1019 | int i; | 1016 | int i; |
1020 | 1017 | ||
1021 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1018 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1022 | QLabel *label = new QLabel( mMonthView ); | 1019 | QLabel *label = new QLabel( mMonthView ); |
1023 | label->setFont(bfont); | 1020 | label->setFont(bfont); |
1024 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1021 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1025 | label->setLineWidth(1); | 1022 | label->setLineWidth(1); |
1026 | label->setAlignment(AlignCenter); | 1023 | label->setAlignment(AlignCenter); |
1027 | mDayLabels.insert( i, label ); | 1024 | mDayLabels.insert( i, label ); |
1028 | label = new QLabel( mWeekView ); | 1025 | label = new QLabel( mWeekView ); |
1029 | label->setFont(bfont); | 1026 | label->setFont(bfont); |
1030 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1027 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1031 | label->setLineWidth(1); | 1028 | label->setLineWidth(1); |
1032 | label->setAlignment(AlignCenter); | 1029 | label->setAlignment(AlignCenter); |
1033 | mDayLabelsW.insert( i, label ); | 1030 | mDayLabelsW.insert( i, label ); |
1034 | } | 1031 | } |
1035 | 1032 | ||
1036 | bfont.setBold( false ); | 1033 | bfont.setBold( false ); |
1037 | mWeekLabels.resize( mNumWeeks+1 ); | 1034 | mWeekLabels.resize( mNumWeeks+1 ); |
1038 | mWeekLabelsW.resize( 2 ); | 1035 | mWeekLabelsW.resize( 2 ); |
1039 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1036 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1040 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1037 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1041 | label->setFocusPolicy(NoFocus); | 1038 | label->setFocusPolicy(NoFocus); |
1042 | label->setFont(bfont); | 1039 | label->setFont(bfont); |
1043 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1040 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1044 | label->setFlat(true); | 1041 | label->setFlat(true); |
1045 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1042 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1046 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1043 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1047 | //label->setLineWidth(1); | 1044 | //label->setLineWidth(1); |
1048 | //label->setAlignment(AlignCenter); | 1045 | //label->setAlignment(AlignCenter); |
1049 | mWeekLabels.insert( i, label ); | 1046 | mWeekLabels.insert( i, label ); |
1050 | } | 1047 | } |
1051 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1048 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1052 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1049 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1053 | 1050 | ||
1054 | for( i = 0; i < 1+1; i++ ) { | 1051 | for( i = 0; i < 1+1; i++ ) { |
1055 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1052 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1056 | label->setFocusPolicy(NoFocus); | 1053 | label->setFocusPolicy(NoFocus); |
1057 | label->setFont(bfont); | 1054 | label->setFont(bfont); |
1058 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1055 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1059 | label->setFlat(true); | 1056 | label->setFlat(true); |
1060 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1057 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1061 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1058 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1062 | //label->setLineWidth(1); | 1059 | //label->setLineWidth(1); |
1063 | //label->setAlignment(AlignCenter); | 1060 | //label->setAlignment(AlignCenter); |
1064 | mWeekLabelsW.insert( i, label ); | 1061 | mWeekLabelsW.insert( i, label ); |
1065 | } | 1062 | } |
1066 | mWeekLabelsW[1]->setText( i18n("W")); | 1063 | mWeekLabelsW[1]->setText( i18n("W")); |
1067 | 1064 | ||
1068 | 1065 | ||
1069 | int row, col; | 1066 | int row, col; |
1070 | mCells.resize( mNumCells ); | 1067 | mCells.resize( mNumCells ); |
1071 | for( row = 0; row < mNumWeeks; ++row ) { | 1068 | for( row = 0; row < mNumWeeks; ++row ) { |
1072 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1069 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1073 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1070 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1074 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1071 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1075 | 1072 | ||
1076 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1073 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1077 | SLOT( defaultAction( Incidence * ) ) ); | 1074 | SLOT( defaultAction( Incidence * ) ) ); |
1078 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1075 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1079 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1076 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1080 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1077 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1081 | SIGNAL( showDaySignal( QDate ) ) ); | 1078 | SIGNAL( showDaySignal( QDate ) ) ); |
1082 | } | 1079 | } |
1083 | } | 1080 | } |
1084 | mCellsW.resize( mDaysPerWeek ); | 1081 | mCellsW.resize( mDaysPerWeek ); |
1085 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1082 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1086 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1083 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1087 | mCellsW.insert( col, cell ); | 1084 | mCellsW.insert( col, cell ); |
1088 | 1085 | ||
1089 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1086 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1090 | SLOT( defaultAction( Incidence * ) ) ); | 1087 | SLOT( defaultAction( Incidence * ) ) ); |
1091 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1088 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1092 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1089 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1093 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1090 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1094 | SIGNAL( showDaySignal( QDate ) ) ); | 1091 | SIGNAL( showDaySignal( QDate ) ) ); |
1095 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1092 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1096 | } | 1093 | } |
1097 | 1094 | ||
1098 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1095 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1099 | mContextMenu = eventPopup(); | 1096 | mContextMenu = eventPopup(); |
1100 | // updateConfig(); //useless here... | 1097 | // updateConfig(); //useless here... |
1101 | // ... but we need mWidthLongDayLabel computed | 1098 | // ... but we need mWidthLongDayLabel computed |
1102 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1099 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1103 | mWidthLongDayLabel = 0; | 1100 | mWidthLongDayLabel = 0; |
1104 | for (int i = 0; i < 7; i++) { | 1101 | for (int i = 0; i < 7; i++) { |
1105 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1102 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1106 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1103 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1107 | } | 1104 | } |
1108 | 1105 | ||
1109 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1106 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1110 | 1107 | ||
1111 | #if 0 | 1108 | #if 0 |
1112 | if ( mShowWeekView ) | 1109 | if ( mShowWeekView ) |
1113 | mWidStack->raiseWidget( mWeekView ); | 1110 | mWidStack->raiseWidget( mWeekView ); |
1114 | else | 1111 | else |
1115 | mWidStack->raiseWidget( mMonthView ); | 1112 | mWidStack->raiseWidget( mMonthView ); |
1116 | #endif | 1113 | #endif |
1117 | 1114 | ||
1118 | emit incidenceSelected( 0 ); | 1115 | emit incidenceSelected( 0 ); |
1119 | 1116 | ||
1120 | mComputeLayoutTimer = new QTimer( this ); | 1117 | mComputeLayoutTimer = new QTimer( this ); |
1121 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1118 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1122 | 1119 | ||
1123 | 1120 | ||
1124 | #ifndef DESKTOP_VERSION | 1121 | #ifndef DESKTOP_VERSION |
1125 | resize( QApplication::desktop()->size() ); | 1122 | resize( QApplication::desktop()->size() ); |
1126 | #else | 1123 | #else |
1127 | resize(640, 480 ); | 1124 | resize(640, 480 ); |
1128 | updatePossible = true; | 1125 | updatePossible = true; |
1129 | #endif | 1126 | #endif |
1130 | computeLayout(); | 1127 | computeLayout(); |
1131 | 1128 | ||
1132 | if ( mShowWeekView ) | 1129 | if ( mShowWeekView ) |
1133 | mWidStack->raiseWidget( mWeekView ); | 1130 | mWidStack->raiseWidget( mWeekView ); |
1134 | else | 1131 | else |
1135 | mWidStack->raiseWidget( mMonthView ); | 1132 | mWidStack->raiseWidget( mMonthView ); |
1136 | } | 1133 | } |
1137 | 1134 | ||
1138 | KOMonthView::~KOMonthView() | 1135 | KOMonthView::~KOMonthView() |
1139 | { | 1136 | { |
1140 | delete mContextMenu; | 1137 | delete mContextMenu; |
1141 | } | 1138 | } |
1142 | 1139 | ||
1143 | void KOMonthView::selectInternalWeekNum ( int n ) | 1140 | void KOMonthView::selectInternalWeekNum ( int n ) |
1144 | { | 1141 | { |
1145 | switchView(); | 1142 | switchView(); |
1146 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1143 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1147 | emit selectMonth (); | 1144 | emit selectMonth (); |
1148 | else | 1145 | else |
1149 | emit selectWeekNum ( n ); | 1146 | emit selectWeekNum ( n ); |
1150 | } | 1147 | } |
1151 | 1148 | ||
1152 | int KOMonthView::currentWeek() | 1149 | int KOMonthView::currentWeek() |
1153 | { | 1150 | { |
1154 | if ( mShowWeekView ) | 1151 | if ( mShowWeekView ) |
1155 | return mWeekLabelsW[0]->getWeekNum(); | 1152 | return mWeekLabelsW[0]->getWeekNum(); |
1156 | return mWeekLabels[0]->getWeekNum(); | 1153 | return mWeekLabels[0]->getWeekNum(); |
1157 | } | 1154 | } |
1158 | void KOMonthView::switchView() | 1155 | void KOMonthView::switchView() |
1159 | { | 1156 | { |
1160 | if ( selectedCell( ) ) | 1157 | if ( selectedCell( ) ) |
1161 | selectedCell()->deselect(); | 1158 | selectedCell()->deselect(); |
1162 | mShowWeekView = !mShowWeekView; | 1159 | mShowWeekView = !mShowWeekView; |
1163 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1160 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1164 | if ( clPending ) { | 1161 | if ( clPending ) { |
1165 | computeLayout(); | 1162 | computeLayout(); |
1166 | updateConfig(); | 1163 | updateConfig(); |
1167 | } | 1164 | } |
1168 | if ( mShowWeekView ) | 1165 | if ( mShowWeekView ) |
1169 | mWidStack->raiseWidget( mWeekView ); | 1166 | mWidStack->raiseWidget( mWeekView ); |
1170 | else | 1167 | else |
1171 | mWidStack->raiseWidget( mMonthView ); | 1168 | mWidStack->raiseWidget( mMonthView ); |
1172 | clPending = false; | 1169 | clPending = false; |
1173 | } | 1170 | } |
1174 | 1171 | ||
1175 | int KOMonthView::maxDatesHint() | 1172 | int KOMonthView::maxDatesHint() |
1176 | { | 1173 | { |
1177 | return mNumCells; | 1174 | return mNumCells; |
1178 | } | 1175 | } |
1179 | 1176 | ||
1180 | int KOMonthView::currentDateCount() | 1177 | int KOMonthView::currentDateCount() |
1181 | { | 1178 | { |
1182 | return mNumCells; | 1179 | return mNumCells; |
1183 | } | 1180 | } |
1184 | 1181 | ||
1185 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1182 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1186 | { | 1183 | { |
1187 | QPtrList<Incidence> selected; | 1184 | QPtrList<Incidence> selected; |
1188 | 1185 | ||
1189 | if ( mSelectedCell ) { | 1186 | if ( mSelectedCell ) { |
1190 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1187 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1191 | if ( incidence ) selected.append( incidence ); | 1188 | if ( incidence ) selected.append( incidence ); |
1192 | } | 1189 | } |
1193 | 1190 | ||
1194 | return selected; | 1191 | return selected; |
1195 | } | 1192 | } |
1196 | 1193 | ||
1197 | DateList KOMonthView::selectedDates() | 1194 | DateList KOMonthView::selectedDates() |
1198 | { | 1195 | { |
1199 | DateList selected; | 1196 | DateList selected; |
1200 | 1197 | ||
1201 | if ( mSelectedCell ) { | 1198 | if ( mSelectedCell ) { |
1202 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1199 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1203 | if ( qd.isValid() ) selected.append( qd ); | 1200 | if ( qd.isValid() ) selected.append( qd ); |
1204 | } | 1201 | } |
1205 | 1202 | ||
1206 | return selected; | 1203 | return selected; |
1207 | } | 1204 | } |
1208 | 1205 | ||
1209 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1206 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1210 | const QDate &td) | 1207 | const QDate &td) |
1211 | { | 1208 | { |
1212 | #ifndef KORG_NOPRINTER | 1209 | #ifndef KORG_NOPRINTER |
1213 | calPrinter->preview(CalPrinter::Month, fd, td); | 1210 | calPrinter->preview(CalPrinter::Month, fd, td); |
1214 | #endif | 1211 | #endif |
1215 | } | 1212 | } |
1216 | 1213 | ||
1217 | void KOMonthView::updateConfig() | 1214 | void KOMonthView::updateConfig() |
1218 | { | 1215 | { |
1219 | 1216 | ||
1220 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1217 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1221 | 1218 | ||
1222 | if ( mShowWeekView ) { | 1219 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1223 | mWeekStartsMonday = true; | 1220 | mWeekStartsMonday = true; |
1224 | } | 1221 | } |
1225 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1222 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1226 | mWidthLongDayLabel = 0; | 1223 | mWidthLongDayLabel = 0; |
1227 | 1224 | ||
1228 | for (int i = 0; i < 7; i++) { | 1225 | for (int i = 0; i < 7; i++) { |
1229 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1226 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1230 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1227 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1231 | } | 1228 | } |
1232 | bool temp = mShowSatSunComp ; | 1229 | bool temp = mShowSatSunComp ; |
1233 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1230 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1234 | if ( ! mShowWeekView ) { | 1231 | if ( ! mShowWeekView ) { |
1235 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1232 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1236 | computeLayout(); | 1233 | computeLayout(); |
1237 | } | 1234 | } |
1238 | updateDayLabels(); | 1235 | updateDayLabels(); |
1239 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1236 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1240 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1237 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1241 | //resizeEvent( 0 ); | 1238 | //resizeEvent( 0 ); |
1242 | for (uint i = 0; i < mCells.count(); ++i) { | 1239 | for (uint i = 0; i < mCells.count(); ++i) { |
1243 | mCells[i]->updateConfig(); | 1240 | mCells[i]->updateConfig(); |
1244 | } | 1241 | } |
1245 | 1242 | ||
1246 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1243 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1247 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1244 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1248 | } | 1245 | } |
1249 | #ifdef DESKTOP_VERSION | 1246 | #ifdef DESKTOP_VERSION |
1250 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1247 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1251 | #endif | 1248 | #endif |
1252 | updateView(); | 1249 | updateView(); |
1253 | } | 1250 | } |
1254 | 1251 | ||
1255 | void KOMonthView::updateDayLabels() | 1252 | void KOMonthView::updateDayLabels() |
1256 | { | 1253 | { |
1257 | 1254 | ||
1258 | QPtrVector<QLabel> *mDayLabelsT; | 1255 | QPtrVector<QLabel> *mDayLabelsT; |
1259 | 1256 | ||
1260 | mDayLabelsT = &mDayLabelsW; | 1257 | mDayLabelsT = &mDayLabelsW; |
1261 | for (int i = 0; i < 7; i++) { | 1258 | for (int i = 0; i < 7; i++) { |
1262 | if (mWeekStartsMonday) { | 1259 | { |
1263 | bool show = mShortDayLabelsW; | 1260 | bool show = mShortDayLabelsW; |
1264 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1261 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1265 | show = true; | 1262 | show = true; |
1266 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1263 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1267 | } else { | ||
1268 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | ||
1269 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | ||
1270 | |||
1271 | } | 1264 | } |
1272 | } | 1265 | } |
1273 | mDayLabelsT = &mDayLabels; | 1266 | mDayLabelsT = &mDayLabels; |
1274 | for (int i = 0; i < 7; i++) { | 1267 | for (int i = 0; i < 7; i++) { |
1275 | if (mWeekStartsMonday) { | 1268 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1276 | bool show = mShortDayLabelsM; | 1269 | bool show = mShortDayLabelsM; |
1277 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1270 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1278 | show = true; | 1271 | show = true; |
1279 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1272 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1280 | } else { | 1273 | } else { |
1281 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1274 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1282 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1275 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1283 | 1276 | ||
1284 | } | 1277 | } |
1285 | } | 1278 | } |
1286 | 1279 | ||
1287 | } | 1280 | } |
1288 | 1281 | ||
1289 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1282 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1290 | { | 1283 | { |
1291 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1284 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1292 | 1285 | ||
1293 | QPtrVector<MonthViewCell> *cells; | 1286 | QPtrVector<MonthViewCell> *cells; |
1294 | QPtrVector<QLabel> *dayLabels; | 1287 | QPtrVector<QLabel> *dayLabels; |
1295 | QPtrVector<KOWeekButton> *weekLabels; | 1288 | QPtrVector<KOWeekButton> *weekLabels; |
1296 | int weekNum = 6; | 1289 | int weekNum = 6; |
1290 | mStartDate = start; | ||
1297 | if ( mShowWeekView ) { | 1291 | if ( mShowWeekView ) { |
1298 | weekNum = 1; | 1292 | weekNum = 1; |
1299 | cells = &mCellsW; | 1293 | cells = &mCellsW; |
1300 | dayLabels = &mDayLabelsW; | 1294 | dayLabels = &mDayLabelsW; |
1301 | weekLabels = &mWeekLabelsW; | 1295 | weekLabels = &mWeekLabelsW; |
1296 | if ( !KGlobal::locale()->weekStartsMonday() ) { | ||
1297 | mStartDate = mStartDate.addDays( 1 ); | ||
1298 | } | ||
1302 | } else { | 1299 | } else { |
1303 | cells = &mCells; | 1300 | cells = &mCells; |
1304 | dayLabels = &mDayLabels; | 1301 | dayLabels = &mDayLabels; |
1305 | weekLabels = &mWeekLabels; | 1302 | weekLabels = &mWeekLabels; |
1306 | } | 1303 | } |
1307 | 1304 | ||
1308 | mStartDate = start; | 1305 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1309 | 1306 | ||
1307 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | ||
1308 | mWeekStartsMonday = true; | ||
1309 | } | ||
1310 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1310 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1311 | 1311 | ||
1312 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1312 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1313 | mStartDate = mStartDate.addDays( -1 ); | 1313 | mStartDate = mStartDate.addDays( -1 ); |
1314 | } | 1314 | } |
1315 | |||
1316 | bool primary = false; | 1315 | bool primary = false; |
1317 | uint i; | 1316 | uint i; |
1318 | for( i = 0; i < (*cells).size(); ++i ) { | 1317 | for( i = 0; i < (*cells).size(); ++i ) { |
1319 | QDate date = mStartDate.addDays( i ); | 1318 | QDate date = mStartDate.addDays( i ); |
1320 | (*cells)[i]->setDate( date ); | 1319 | (*cells)[i]->setDate( date ); |
1321 | 1320 | ||
1322 | #ifndef KORG_NOPLUGINS | 1321 | #ifndef KORG_NOPLUGINS |
1323 | // add holiday, if present | 1322 | // add holiday, if present |
1324 | QString hstring(KOCore::self()->holiday(date)); | 1323 | QString hstring(KOCore::self()->holiday(date)); |
1325 | (*cells)[i]->setHoliday( hstring ); | 1324 | (*cells)[i]->setHoliday( hstring ); |
1326 | #endif | 1325 | #endif |
1327 | 1326 | ||
1328 | } | 1327 | } |
1329 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1328 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1330 | for( i = 0; i < weekNum; ++i ) { | 1329 | for( i = 0; i < weekNum; ++i ) { |
1331 | int wno; | 1330 | int wno; |
1332 | // remember, according to ISO 8601, the first week of the year is the | 1331 | // remember, according to ISO 8601, the first week of the year is the |
1333 | // first week that contains a thursday. Thus we must subtract off 4, | 1332 | // first week that contains a thursday. Thus we must subtract off 4, |
1334 | // not just 1. | 1333 | // not just 1. |
1335 | int dayOfYear = date.dayOfYear(); | 1334 | int dayOfYear = date.dayOfYear(); |
1336 | if (dayOfYear % 7 != 0) | 1335 | if (dayOfYear % 7 != 0) |
1337 | wno = dayOfYear / 7 + 1; | 1336 | wno = dayOfYear / 7 + 1; |
1338 | else | 1337 | else |
1339 | wno =dayOfYear / 7; | 1338 | wno =dayOfYear / 7; |
1340 | (*weekLabels)[i]->setWeekNum( wno ); | 1339 | (*weekLabels)[i]->setWeekNum( wno ); |
1341 | date = date.addDays( 7 ); | 1340 | date = date.addDays( 7 ); |
1342 | } | 1341 | } |
1343 | updateView(); | 1342 | updateView(); |
1344 | } | 1343 | } |
1345 | 1344 | ||
1346 | void KOMonthView::showEvents(QPtrList<Event>) | 1345 | void KOMonthView::showEvents(QPtrList<Event>) |
1347 | { | 1346 | { |
1348 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1347 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1349 | } | 1348 | } |
1350 | 1349 | ||
1351 | void KOMonthView::changeEventDisplay(Event *, int) | 1350 | void KOMonthView::changeEventDisplay(Event *, int) |
1352 | { | 1351 | { |
1353 | // this should be re-written to be much more efficient, but this | 1352 | // this should be re-written to be much more efficient, but this |
1354 | // quick-and-dirty-hack gets the job done for right now. | 1353 | // quick-and-dirty-hack gets the job done for right now. |
1355 | updateView(); | 1354 | updateView(); |
1356 | } | 1355 | } |
1357 | 1356 | ||
1358 | void KOMonthView::updateView() | 1357 | void KOMonthView::updateView() |
1359 | { | 1358 | { |
1360 | 1359 | ||
1361 | if ( !updatePossible ) | 1360 | if ( !updatePossible ) |
1362 | return; | 1361 | return; |
1363 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1362 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1364 | //QTime ti; | 1363 | //QTime ti; |
1365 | //ti.start(); | 1364 | //ti.start(); |
1366 | clearSelection(); | 1365 | clearSelection(); |
1367 | QPtrVector<MonthViewCell> *cells; | 1366 | QPtrVector<MonthViewCell> *cells; |
1368 | if ( mShowWeekView ) { | 1367 | if ( mShowWeekView ) { |
1369 | cells = &mCellsW; | 1368 | cells = &mCellsW; |
1370 | } else { | 1369 | } else { |
1371 | cells = &mCells; | 1370 | cells = &mCells; |
1372 | } | 1371 | } |
1373 | #if 1 | 1372 | #if 1 |
1374 | int i; | 1373 | int i; |
1375 | int timeSpan = (*cells).size()-1; | 1374 | int timeSpan = (*cells).size()-1; |
1376 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1375 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1377 | timeSpan = 6; | 1376 | timeSpan = 6; |
1378 | for( i = 0; i < timeSpan + 1; ++i ) { | 1377 | for( i = 0; i < timeSpan + 1; ++i ) { |
1379 | (*cells)[i]->startUpdateCell(); | 1378 | (*cells)[i]->startUpdateCell(); |
1380 | } | 1379 | } |
1381 | 1380 | ||
1382 | QPtrList<Event> events = calendar()->events(); | 1381 | QPtrList<Event> events = calendar()->events(); |
1383 | Event *event; | 1382 | Event *event; |
1384 | QDateTime dt; | 1383 | QDateTime dt; |
1385 | bool ok; | 1384 | bool ok; |
1386 | QDate endDate = mStartDate.addDays( timeSpan ); | 1385 | QDate endDate = mStartDate.addDays( timeSpan ); |
1387 | for( event = events.first(); event; event = events.next() ) { // for event | 1386 | for( event = events.first(); event; event = events.next() ) { // for event |
1388 | if ( event->doesRecur() ) { | 1387 | if ( event->doesRecur() ) { |
1389 | bool last; | 1388 | bool last; |
1390 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1389 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1391 | QDateTime incidenceEnd; | 1390 | QDateTime incidenceEnd; |
1392 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1391 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1393 | bool invalid = false; | 1392 | bool invalid = false; |
1394 | while( true ) { | 1393 | while( true ) { |
1395 | if ( incidenceStart.isValid() ) { | 1394 | if ( incidenceStart.isValid() ) { |
1396 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1395 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1397 | int st = incidenceStart.date().daysTo( endDate ); | 1396 | int st = incidenceStart.date().daysTo( endDate ); |
1398 | if ( st >= 0 ) { // start before timeend | 1397 | if ( st >= 0 ) { // start before timeend |
1399 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1398 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1400 | if ( end >= 0 ) { // end after timestart --- got one! | 1399 | if ( end >= 0 ) { // end after timestart --- got one! |
1401 | //normalize | 1400 | //normalize |
1402 | st = timeSpan - st; | 1401 | st = timeSpan - st; |
1403 | if ( st < 0 ) st = 0; | 1402 | if ( st < 0 ) st = 0; |
1404 | if ( end > timeSpan ) end = timeSpan; | 1403 | if ( end > timeSpan ) end = timeSpan; |
1405 | int iii; | 1404 | int iii; |
1406 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1405 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1407 | for ( iii = st;iii<= end;++iii) | 1406 | for ( iii = st;iii<= end;++iii) |
1408 | (*cells)[iii]->insertEvent( event ); | 1407 | (*cells)[iii]->insertEvent( event ); |
1409 | } | 1408 | } |
1410 | } | 1409 | } |
1411 | } else { | 1410 | } else { |
1412 | if ( invalid ) | 1411 | if ( invalid ) |
1413 | break; | 1412 | break; |
1414 | invalid = true; | 1413 | invalid = true; |
1415 | //qDebug("invalid %s", event->summary().latin1()); | 1414 | //qDebug("invalid %s", event->summary().latin1()); |
1416 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1415 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1417 | } | 1416 | } |
1418 | if ( last ) | 1417 | if ( last ) |
1419 | break; | 1418 | break; |
1420 | bool ok; | 1419 | bool ok; |
1421 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1420 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1422 | if ( ! ok ) | 1421 | if ( ! ok ) |
1423 | break; | 1422 | break; |
1424 | if ( incidenceStart.date() > endDate ) | 1423 | if ( incidenceStart.date() > endDate ) |
1425 | break; | 1424 | break; |
1426 | } | 1425 | } |
1427 | } else { // no recur | 1426 | } else { // no recur |
1428 | int st = event->dtStart().date().daysTo( endDate ); | 1427 | int st = event->dtStart().date().daysTo( endDate ); |
1429 | if ( st >= 0 ) { // start before timeend | 1428 | if ( st >= 0 ) { // start before timeend |
1430 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1429 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1431 | if ( end >= 0 ) { // end after timestart --- got one! | 1430 | if ( end >= 0 ) { // end after timestart --- got one! |
1432 | //normalize | 1431 | //normalize |
1433 | st = timeSpan - st; | 1432 | st = timeSpan - st; |
1434 | if ( st < 0 ) st = 0; | 1433 | if ( st < 0 ) st = 0; |
1435 | if ( end > timeSpan ) end = timeSpan; | 1434 | if ( end > timeSpan ) end = timeSpan; |
1436 | int iii; | 1435 | int iii; |
1437 | for ( iii = st;iii<= end;++iii) | 1436 | for ( iii = st;iii<= end;++iii) |
1438 | (*cells)[iii]->insertEvent( event ); | 1437 | (*cells)[iii]->insertEvent( event ); |
1439 | } | 1438 | } |
1440 | } | 1439 | } |
1441 | } | 1440 | } |
1442 | } | 1441 | } |
1443 | // insert due todos | 1442 | // insert due todos |
1444 | QPtrList<Todo> todos = calendar()->todos( ); | 1443 | QPtrList<Todo> todos = calendar()->todos( ); |
1445 | Todo *todo; | 1444 | Todo *todo; |
1446 | for(todo = todos.first(); todo; todo = todos.next()) { | 1445 | for(todo = todos.first(); todo; todo = todos.next()) { |
1447 | //insertTodo( todo ); | 1446 | //insertTodo( todo ); |
1448 | if ( todo->hasDueDate() ) { | 1447 | if ( todo->hasDueDate() ) { |
1449 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1448 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1450 | if ( day >= 0 && day < timeSpan + 1) { | 1449 | if ( day >= 0 && day < timeSpan + 1) { |
1451 | (*cells)[day]->insertTodo( todo ); | 1450 | (*cells)[day]->insertTodo( todo ); |
1452 | } | 1451 | } |
1453 | } | 1452 | } |
1454 | } | 1453 | } |
1455 | 1454 | ||
1456 | for( i = 0; i < timeSpan+1; ++i ) { | 1455 | for( i = 0; i < timeSpan+1; ++i ) { |
1457 | (*cells)[i]->finishUpdateCell(); | 1456 | (*cells)[i]->finishUpdateCell(); |
1458 | } | 1457 | } |
1459 | processSelectionChange(); | 1458 | processSelectionChange(); |
1460 | //qApp->processEvents(); | 1459 | //qApp->processEvents(); |
1461 | for( i = 0; i < timeSpan+1; ++i ) { | 1460 | for( i = 0; i < timeSpan+1; ++i ) { |
1462 | (*cells)[i]->repaintfinishUpdateCell(); | 1461 | (*cells)[i]->repaintfinishUpdateCell(); |
1463 | } | 1462 | } |
1464 | (*cells)[0]->setFocus(); | 1463 | (*cells)[0]->setFocus(); |
1465 | 1464 | ||
1466 | 1465 | ||
1467 | #else | 1466 | #else |
1468 | // old code | 1467 | // old code |
1469 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1468 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1470 | int i; | 1469 | int i; |
1471 | for( i = 0; i < (*cells).count(); ++i ) { | 1470 | for( i = 0; i < (*cells).count(); ++i ) { |
1472 | (*cells)[i]->updateCell(); | 1471 | (*cells)[i]->updateCell(); |
1473 | } | 1472 | } |
1474 | 1473 | ||
1475 | //qDebug("KOMonthView::updateView() "); | 1474 | //qDebug("KOMonthView::updateView() "); |
1476 | processSelectionChange(); | 1475 | processSelectionChange(); |
1477 | // qDebug("---------------------------------------------------------------------+ "); | 1476 | // qDebug("---------------------------------------------------------------------+ "); |
1478 | (*cells)[0]->setFocus(); | 1477 | (*cells)[0]->setFocus(); |
1479 | #endif | 1478 | #endif |
1480 | 1479 | ||
1481 | //qDebug("update time %d ", ti.elapsed()); | 1480 | //qDebug("update time %d ", ti.elapsed()); |
1482 | } | 1481 | } |
1483 | 1482 | ||
1484 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1483 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1485 | { | 1484 | { |
1486 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1485 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1487 | if ( isVisible() ) { | 1486 | if ( isVisible() ) { |
1488 | //qDebug("KOMonthView::isVisible "); | 1487 | //qDebug("KOMonthView::isVisible "); |
1489 | slotComputeLayout(); | 1488 | slotComputeLayout(); |
1490 | } else | 1489 | } else |
1491 | mComputeLayoutTimer->start( 100 ); | 1490 | mComputeLayoutTimer->start( 100 ); |
1492 | } | 1491 | } |
1493 | 1492 | ||
1494 | void KOMonthView::slotComputeLayout() | 1493 | void KOMonthView::slotComputeLayout() |
1495 | { | 1494 | { |
1496 | mComputeLayoutTimer->stop(); | 1495 | mComputeLayoutTimer->stop(); |
1497 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1496 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1498 | computeLayout(); | 1497 | computeLayout(); |
1499 | clPending = true; | 1498 | clPending = true; |
1500 | if ( mShowWeekView ) | 1499 | if ( mShowWeekView ) |
1501 | mCellsW[0]->setFocus(); | 1500 | mCellsW[0]->setFocus(); |
1502 | else | 1501 | else |
1503 | mCells[0]->setFocus(); | 1502 | mCells[0]->setFocus(); |
1504 | 1503 | ||
1505 | } | 1504 | } |
1506 | void KOMonthView::computeLayoutWeek() | 1505 | void KOMonthView::computeLayoutWeek() |
1507 | { | 1506 | { |
1508 | static int lastWid = 0; | 1507 | static int lastWid = 0; |
1509 | static int lastHei = 0; | 1508 | static int lastHei = 0; |
1510 | int daysToShow; | 1509 | int daysToShow; |
1511 | bool combinedSatSun = false; | 1510 | bool combinedSatSun = false; |
1512 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1511 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1513 | daysToShow = 6; | 1512 | daysToShow = 6; |
1514 | combinedSatSun = true; | 1513 | combinedSatSun = true; |
1515 | } | 1514 | } |
1516 | int tWid = topLevelWidget()->size().width(); | 1515 | int tWid = topLevelWidget()->size().width(); |
1517 | int tHei = topLevelWidget()->size().height(); | 1516 | int tHei = topLevelWidget()->size().height(); |
1518 | 1517 | ||
1519 | int wid = width();//e | 1518 | int wid = width();//e |
1520 | int hei = height()-1-mNavigatorBar->height(); | 1519 | int hei = height()-1-mNavigatorBar->height(); |
1521 | 1520 | ||
1522 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1521 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1523 | return; | 1522 | return; |
1524 | 1523 | ||
1525 | if ( lastWid == width() && lastHei == height() ) { | 1524 | if ( lastWid == width() && lastHei == height() ) { |
1526 | //qDebug("KOListWeekView::No compute layout needed "); | 1525 | //qDebug("KOListWeekView::No compute layout needed "); |
1527 | return; | 1526 | return; |
1528 | } | 1527 | } |
1529 | lastWid = width(); | 1528 | lastWid = width(); |
1530 | lastHei = height(); | 1529 | lastHei = height(); |
1531 | 1530 | ||
1532 | 1531 | ||
1533 | if ( wid < hei ) | 1532 | if ( wid < hei ) |
1534 | daysToShow = 2; | 1533 | daysToShow = 2; |
1535 | else | 1534 | else |
1536 | daysToShow = 3; | 1535 | daysToShow = 3; |
1537 | mShowSatSunComp = true; | 1536 | mShowSatSunComp = true; |
1538 | combinedSatSun = true; | 1537 | combinedSatSun = true; |
1539 | 1538 | ||
1540 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1539 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1541 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1540 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1542 | int weeklabelwid = fm.width( "888" ); | 1541 | int weeklabelwid = fm.width( "888" ); |
1543 | wid -= weeklabelwid; | 1542 | wid -= weeklabelwid; |
1544 | 1543 | ||
1545 | int colWid = wid / daysToShow; | 1544 | int colWid = wid / daysToShow; |
1546 | int lastCol = wid - ( colWid*6 ); | 1545 | int lastCol = wid - ( colWid*6 ); |
1547 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1546 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1548 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1547 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1549 | int colModulo = wid % daysToShow; | 1548 | int colModulo = wid % daysToShow; |
1550 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1549 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1551 | //qDebug("rowmod %d ", rowModulo); | 1550 | //qDebug("rowmod %d ", rowModulo); |
1552 | int i; | 1551 | int i; |
1553 | int x,y,w,h; | 1552 | int x,y,w,h; |
1554 | x= 0; | 1553 | x= 0; |
1555 | y= 0; | 1554 | y= 0; |
1556 | w = colWid; | 1555 | w = colWid; |
1557 | h = dayLabelHei ; | 1556 | h = dayLabelHei ; |
1558 | for ( i = 0; i < 7; i++) { | 1557 | for ( i = 0; i < 7; i++) { |
1559 | if ( i && !( i % daysToShow) && i < 6) { | 1558 | if ( i && !( i % daysToShow) && i < 6) { |
1560 | y += hei/(5-daysToShow); | 1559 | y += hei/(5-daysToShow); |
1561 | x = 0; | 1560 | x = 0; |
1562 | w = colWid; | 1561 | w = colWid; |
1563 | } | 1562 | } |
1564 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1563 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1565 | ++w; | 1564 | ++w; |
1566 | } | 1565 | } |
1567 | if ( i >= 5 ) { | 1566 | if ( i >= 5 ) { |
1568 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1567 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1569 | x -= (w/2 ); | 1568 | x -= (w/2 ); |
1570 | } | 1569 | } |
1571 | else | 1570 | else |
1572 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1571 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1573 | x += w; | 1572 | x += w; |
1574 | } | 1573 | } |
1575 | x= 0; | 1574 | x= 0; |
1576 | y= dayLabelHei; | 1575 | y= dayLabelHei; |
1577 | w = colWid; | 1576 | w = colWid; |
1578 | h = cellHei; | 1577 | h = cellHei; |
1579 | int max = 0; | 1578 | int max = 0; |
1580 | for ( i = 0; i < mCellsW.count(); ++i) { | 1579 | for ( i = 0; i < mCellsW.count(); ++i) { |
1581 | if ( i > 6 ) { | 1580 | if ( i > 6 ) { |
1582 | mCellsW[i]->hide(); | 1581 | mCellsW[i]->hide(); |
1583 | continue; | 1582 | continue; |
1584 | } | 1583 | } |
1585 | 1584 | ||
1586 | w = colWid; | 1585 | w = colWid; |
1587 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1586 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1588 | ++w; | 1587 | ++w; |
1589 | } | 1588 | } |
1590 | if ( i == (daysToShow-1-rowModulo)*7) | 1589 | if ( i == (daysToShow-1-rowModulo)*7) |
1591 | ++h; | 1590 | ++h; |
1592 | 1591 | ||
1593 | if ( i >= 5 ) { | 1592 | if ( i >= 5 ) { |
1594 | if ( i ==5 ) { | 1593 | if ( i ==5 ) { |
1595 | max = h/2; | 1594 | max = h/2; |
1596 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1595 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1597 | x -= w ;y += h/2; | 1596 | x -= w ;y += h/2; |
1598 | } else { | 1597 | } else { |
1599 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1598 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1600 | ++w; | 1599 | ++w; |
1601 | } | 1600 | } |
1602 | max = h-h/2; | 1601 | max = h-h/2; |
1603 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1602 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1604 | y -= h/2; | 1603 | y -= h/2; |
1605 | } | 1604 | } |
1606 | } else { | 1605 | } else { |
1607 | max = h; | 1606 | max = h; |
1608 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1607 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1609 | } | 1608 | } |
1610 | 1609 | ||
1611 | 1610 | ||
1612 | x += w; | 1611 | x += w; |
1613 | if ( x + w/2 > wid ) { | 1612 | if ( x + w/2 > wid ) { |
1614 | x = 0; | 1613 | x = 0; |
1615 | y += h+dayLabelHei ; | 1614 | y += h+dayLabelHei ; |
1616 | } | 1615 | } |
1617 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1616 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1618 | } | 1617 | } |
1619 | y= dayLabelHei; | 1618 | y= dayLabelHei; |
1620 | h = cellHei ; | 1619 | h = cellHei ; |
1621 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1620 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1622 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1621 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1623 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1622 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1624 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1623 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1625 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1624 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1626 | updateDayLabels(); | 1625 | updateDayLabels(); |
1627 | //bool forceUpdate = !updatePossible; | 1626 | //bool forceUpdate = !updatePossible; |
1628 | updatePossible = true; | 1627 | updatePossible = true; |
1629 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1628 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1630 | //if ( forceUpdate ) | 1629 | //if ( forceUpdate ) |
1631 | // updateView(); | 1630 | // updateView(); |
1632 | } | 1631 | } |
1633 | void KOMonthView::computeLayout() | 1632 | void KOMonthView::computeLayout() |
1634 | { | 1633 | { |
1635 | 1634 | ||
1636 | 1635 | ||
1637 | static int lastWid = 0; | 1636 | static int lastWid = 0; |
1638 | static int lastHei = 0; | 1637 | static int lastHei = 0; |
1639 | 1638 | ||
1640 | if ( mShowWeekView ){ | 1639 | if ( mShowWeekView ){ |
1641 | computeLayoutWeek(); | 1640 | computeLayoutWeek(); |
1642 | return; | 1641 | return; |
1643 | } | 1642 | } |
1644 | int daysToShow = 7; | 1643 | int daysToShow = 7; |
1645 | bool combinedSatSun = false; | 1644 | bool combinedSatSun = false; |
1646 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1645 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1647 | daysToShow = 6; | 1646 | daysToShow = 6; |
1648 | combinedSatSun = true; | 1647 | combinedSatSun = true; |
1649 | } | 1648 | } |
1650 | int tWid = topLevelWidget()->size().width(); | 1649 | int tWid = topLevelWidget()->size().width(); |
1651 | int tHei = topLevelWidget()->size().height(); | 1650 | int tHei = topLevelWidget()->size().height(); |
1652 | 1651 | ||
1653 | int wid = width();//e | 1652 | int wid = width();//e |
1654 | int hei = height()-1-mNavigatorBar->height(); | 1653 | int hei = height()-1-mNavigatorBar->height(); |
1655 | 1654 | ||
1656 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1655 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1657 | return; | 1656 | return; |
1658 | } | 1657 | } |
1659 | if ( lastWid == width() && lastHei == height() ){ | 1658 | if ( lastWid == width() && lastHei == height() ){ |
1660 | //qDebug("KOMonthview::No compute layout needed "); | 1659 | //qDebug("KOMonthview::No compute layout needed "); |
1661 | return; | 1660 | return; |
1662 | } | 1661 | } |
1663 | 1662 | ||
1664 | lastWid = width(); | 1663 | lastWid = width(); |
1665 | lastHei = height(); | 1664 | lastHei = height(); |
1666 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 1665 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1667 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1666 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1668 | int weeklabelwid = fm.width( "888" ); | 1667 | int weeklabelwid = fm.width( "888" ); |
1669 | wid -= weeklabelwid; | 1668 | wid -= weeklabelwid; |
1670 | 1669 | ||
1671 | int colWid = wid / daysToShow; | 1670 | int colWid = wid / daysToShow; |
1672 | int lastCol = wid - ( colWid*6 ); | 1671 | int lastCol = wid - ( colWid*6 ); |
1673 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1672 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1674 | int cellHei = (hei - dayLabelHei) /6; | 1673 | int cellHei = (hei - dayLabelHei) /6; |
1675 | int colModulo = wid % daysToShow; | 1674 | int colModulo = wid % daysToShow; |
1676 | int rowModulo = (hei- dayLabelHei) % 6; | 1675 | int rowModulo = (hei- dayLabelHei) % 6; |
1677 | //qDebug("rowmod %d ", rowModulo); | 1676 | //qDebug("rowmod %d ", rowModulo); |
1678 | int i; | 1677 | int i; |
1679 | int x,y,w,h; | 1678 | int x,y,w,h; |
1680 | x= 0; | 1679 | x= 0; |
1681 | y= 0; | 1680 | y= 0; |
1682 | w = colWid; | 1681 | w = colWid; |
1683 | h = dayLabelHei ; | 1682 | h = dayLabelHei ; |
1684 | for ( i = 0; i < 7; i++) { | 1683 | for ( i = 0; i < 7; i++) { |
1685 | if ( i == daysToShow-colModulo ) | 1684 | if ( i == daysToShow-colModulo ) |
1686 | ++w; | 1685 | ++w; |
1687 | if ( combinedSatSun ) { | 1686 | if ( combinedSatSun ) { |
1688 | if ( i >= daysToShow-1 ) { | 1687 | if ( i >= daysToShow-1 ) { |
1689 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1688 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1690 | x -= w/2 ; | 1689 | x -= w/2 ; |
1691 | } | 1690 | } |
1692 | else | 1691 | else |
1693 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1692 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1694 | } else | 1693 | } else |
1695 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1694 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1696 | x += w; | 1695 | x += w; |
1697 | } | 1696 | } |
1698 | x= 0; | 1697 | x= 0; |
1699 | y= dayLabelHei; | 1698 | y= dayLabelHei; |
1700 | w = colWid; | 1699 | w = colWid; |
1701 | h = cellHei ; | 1700 | h = cellHei ; |
1702 | int max = 0; | 1701 | int max = 0; |
1703 | for ( i = 0; i < mCells.count(); ++i) { | 1702 | for ( i = 0; i < mCells.count(); ++i) { |
1704 | //qDebug("iii %d ", i); | 1703 | //qDebug("iii %d ", i); |
1705 | w = colWid; | 1704 | w = colWid; |
1706 | if ( ((i) % 7) >= 7-colModulo ) { | 1705 | if ( ((i) % 7) >= 7-colModulo ) { |
1707 | ++w; | 1706 | ++w; |
1708 | } | 1707 | } |
1709 | if ( i == (6-rowModulo)*7) | 1708 | if ( i == (6-rowModulo)*7) |
1710 | ++h; | 1709 | ++h; |
1711 | if ( combinedSatSun ) { | 1710 | if ( combinedSatSun ) { |
1712 | if ( (i)%7 >= daysToShow-1 ) { | 1711 | if ( (i)%7 >= daysToShow-1 ) { |
1713 | if ( (i)%7 == daysToShow-1 ) { | 1712 | if ( (i)%7 == daysToShow-1 ) { |
1714 | max = h/2; | 1713 | max = h/2; |
1715 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1714 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1716 | x -= w ;y += h/2; | 1715 | x -= w ;y += h/2; |
1717 | } else { | 1716 | } else { |
1718 | max = h-h/2; | 1717 | max = h-h/2; |
1719 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1718 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1720 | y -= h/2; | 1719 | y -= h/2; |
1721 | } | 1720 | } |
1722 | } else { | 1721 | } else { |
1723 | max = h; | 1722 | max = h; |
1724 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1723 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1725 | } | 1724 | } |
1726 | 1725 | ||
1727 | } | 1726 | } |
1728 | else { | 1727 | else { |
1729 | max = h; | 1728 | max = h; |
1730 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1729 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1731 | } | 1730 | } |
1732 | x += w; | 1731 | x += w; |
1733 | if ( x + w/2 > wid ) { | 1732 | if ( x + w/2 > wid ) { |
1734 | x = 0; | 1733 | x = 0; |
1735 | y += h; | 1734 | y += h; |
1736 | } | 1735 | } |
1737 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 1736 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
1738 | } | 1737 | } |
1739 | y= dayLabelHei; | 1738 | y= dayLabelHei; |
1740 | h = cellHei ; | 1739 | h = cellHei ; |
1741 | for ( i = 0; i < 6; i++) { | 1740 | for ( i = 0; i < 6; i++) { |
1742 | if ( i == (6-rowModulo)) | 1741 | if ( i == (6-rowModulo)) |
1743 | ++h; | 1742 | ++h; |
1744 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1743 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1745 | y += h; | 1744 | y += h; |
1746 | } | 1745 | } |
1747 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1746 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1748 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1747 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1749 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1748 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1750 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1749 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1751 | updateDayLabels(); | 1750 | updateDayLabels(); |
1752 | //bool forceUpdate = !updatePossible; | 1751 | //bool forceUpdate = !updatePossible; |
1753 | updatePossible = true; | 1752 | updatePossible = true; |
1754 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1753 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1755 | } | 1754 | } |
1756 | 1755 | ||
1757 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1756 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1758 | { | 1757 | { |
1759 | mContextMenu->showIncidencePopup(incidence); | 1758 | mContextMenu->showIncidencePopup(incidence); |
1760 | /* | 1759 | /* |
1761 | if( incidence && incidence->type() == "Event" ) { | 1760 | if( incidence && incidence->type() == "Event" ) { |
1762 | Event *event = static_cast<Event *>(incidence); | 1761 | Event *event = static_cast<Event *>(incidence); |
1763 | mContextMenu->showEventPopup(event); | 1762 | mContextMenu->showEventPopup(event); |
1764 | } else { | 1763 | } else { |
1765 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1764 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1766 | } | 1765 | } |
1767 | */ | 1766 | */ |
1768 | } | 1767 | } |
1769 | MonthViewCell * KOMonthView::selectedCell( ) | 1768 | MonthViewCell * KOMonthView::selectedCell( ) |
1770 | { | 1769 | { |
1771 | return mSelectedCell; | 1770 | return mSelectedCell; |
1772 | } | 1771 | } |
1773 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1772 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1774 | { | 1773 | { |
1775 | //qDebug("KOMonthView::setSelectedCell "); | 1774 | //qDebug("KOMonthView::setSelectedCell "); |
1776 | if ( mSelectedCell && mSelectedCell != cell ) { | 1775 | if ( mSelectedCell && mSelectedCell != cell ) { |
1777 | MonthViewCell * mvc = mSelectedCell; | 1776 | MonthViewCell * mvc = mSelectedCell; |
1778 | mSelectedCell = cell; | 1777 | mSelectedCell = cell; |
1779 | mvc->deselect(); | 1778 | mvc->deselect(); |
1780 | } else | 1779 | } else |
1781 | mSelectedCell = cell; | 1780 | mSelectedCell = cell; |
1782 | // if ( mSelectedCell ) | 1781 | // if ( mSelectedCell ) |
1783 | // mSelectedCell->select(); | 1782 | // mSelectedCell->select(); |
1784 | if ( !mSelectedCell ) | 1783 | if ( !mSelectedCell ) |
1785 | emit incidenceSelected( 0 ); | 1784 | emit incidenceSelected( 0 ); |
1786 | else | 1785 | else |
1787 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1786 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1788 | } | 1787 | } |
1789 | 1788 | ||
1790 | void KOMonthView::processSelectionChange() | 1789 | void KOMonthView::processSelectionChange() |
1791 | { | 1790 | { |
1792 | QPtrList<Incidence> incidences = selectedIncidences(); | 1791 | QPtrList<Incidence> incidences = selectedIncidences(); |
1793 | if (incidences.count() > 0) { | 1792 | if (incidences.count() > 0) { |
1794 | emit incidenceSelected( incidences.first() ); | 1793 | emit incidenceSelected( incidences.first() ); |
1795 | } else { | 1794 | } else { |
1796 | emit incidenceSelected( 0 ); | 1795 | emit incidenceSelected( 0 ); |
1797 | clearSelection(); | 1796 | clearSelection(); |
1798 | } | 1797 | } |
1799 | } | 1798 | } |
1800 | 1799 | ||
1801 | void KOMonthView::clearSelection() | 1800 | void KOMonthView::clearSelection() |
1802 | { | 1801 | { |
1803 | if ( mSelectedCell ) { | 1802 | if ( mSelectedCell ) { |
1804 | mSelectedCell->deselect(); | 1803 | mSelectedCell->deselect(); |
1805 | mSelectedCell = 0; | 1804 | mSelectedCell = 0; |
1806 | } | 1805 | } |
1807 | } | 1806 | } |
1808 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1807 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1809 | { | 1808 | { |
1810 | //qDebug("KOMonthView::keyPressEvent "); | 1809 | //qDebug("KOMonthView::keyPressEvent "); |
1811 | switch(e->key()) { | 1810 | switch(e->key()) { |
1812 | case Key_Up: | 1811 | case Key_Up: |
1813 | { | 1812 | { |
1814 | if ( mShowWeekView ) { | 1813 | if ( mShowWeekView ) { |
1815 | mCellsW[0]->setFocus(); | 1814 | mCellsW[0]->setFocus(); |
1816 | emit selectWeekNum ( currentWeek() - 1 ); | 1815 | emit selectWeekNum ( currentWeek() - 1 ); |
1817 | } | 1816 | } |
1818 | else { | 1817 | else { |
1819 | mCells[0]->setFocus(); | 1818 | mCells[0]->setFocus(); |
1820 | emit prevMonth(); | 1819 | emit prevMonth(); |
1821 | } | 1820 | } |
1822 | } | 1821 | } |
1823 | e->accept(); | 1822 | e->accept(); |
1824 | break; | 1823 | break; |
1825 | case Key_Down: | 1824 | case Key_Down: |
1826 | { | 1825 | { |
1827 | if ( mShowWeekView ) { | 1826 | if ( mShowWeekView ) { |
1828 | mCellsW[0]->setFocus(); | 1827 | mCellsW[0]->setFocus(); |
1829 | emit selectWeekNum ( currentWeek() +1); | 1828 | emit selectWeekNum ( currentWeek() +1); |
1830 | } | 1829 | } |
1831 | else { | 1830 | else { |
1832 | mCells[0]->setFocus(); | 1831 | mCells[0]->setFocus(); |
1833 | emit nextMonth(); | 1832 | emit nextMonth(); |
1834 | } | 1833 | } |
1835 | 1834 | ||
1836 | } | 1835 | } |
1837 | e->accept(); | 1836 | e->accept(); |
1838 | break; | 1837 | break; |
1839 | case Key_Return: | 1838 | case Key_Return: |
1840 | case Key_Enter: | 1839 | case Key_Enter: |
1841 | { | 1840 | { |
1842 | selectInternalWeekNum ( currentWeek() ); | 1841 | selectInternalWeekNum ( currentWeek() ); |
1843 | } | 1842 | } |
1844 | e->accept(); | 1843 | e->accept(); |
1845 | break; | 1844 | break; |
1846 | case Key_D: | 1845 | case Key_D: |
1847 | if ( mSelectedCell ) { | 1846 | if ( mSelectedCell ) { |
1848 | mSelectedCell->showDay(); | 1847 | mSelectedCell->showDay(); |
1849 | e->accept(); | 1848 | e->accept(); |
1850 | } else { | 1849 | } else { |
1851 | e->ignore(); | 1850 | e->ignore(); |
1852 | } | 1851 | } |
1853 | break; | 1852 | break; |
1854 | default: | 1853 | default: |
1855 | e->ignore(); | 1854 | e->ignore(); |
1856 | break; | 1855 | break; |
1857 | } | 1856 | } |
1858 | } | 1857 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index a58f6b8..9e724c7 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,314 +1,314 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qintdict.h> | 31 | #include <qintdict.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | #include <qptrvector.h> | 34 | #include <qptrvector.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | #include <libkcal/event.h> | 37 | #include <libkcal/event.h> |
38 | 38 | ||
39 | #include "koeventview.h" | 39 | #include "koeventview.h" |
40 | #include "navigatorbar.h" | 40 | #include "navigatorbar.h" |
41 | 41 | ||
42 | #ifdef DESKTOP_VERSION | 42 | #ifdef DESKTOP_VERSION |
43 | class QToolTipGroup; | 43 | class QToolTipGroup; |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | class KNOWhatsThis; | 46 | class KNOWhatsThis; |
47 | class KOWeekButton : public QPushButton | 47 | class KOWeekButton : public QPushButton |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
52 | QPushButton( parent, name) | 52 | QPushButton( parent, name) |
53 | { | 53 | { |
54 | connect( this, SIGNAL( clicked() ), | 54 | connect( this, SIGNAL( clicked() ), |
55 | SLOT( bottonClicked() )); | 55 | SLOT( bottonClicked() )); |
56 | mNumber = -1; | 56 | mNumber = -1; |
57 | } | 57 | } |
58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
59 | int getWeekNum() { return mNumber;} | 59 | int getWeekNum() { return mNumber;} |
60 | signals: | 60 | signals: |
61 | void selectWeekNum ( int ); | 61 | void selectWeekNum ( int ); |
62 | private: | 62 | private: |
63 | int mNumber; | 63 | int mNumber; |
64 | private slots : | 64 | private slots : |
65 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 65 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
66 | }; | 66 | }; |
67 | 67 | ||
68 | class KNoScrollListBox: public QListBox | 68 | class KNoScrollListBox: public QListBox |
69 | { | 69 | { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | public: | 71 | public: |
72 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 72 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
73 | ~KNoScrollListBox(); | 73 | ~KNoScrollListBox(); |
74 | QString getWhatsThisText(QPoint p) ; | 74 | QString getWhatsThisText(QPoint p) ; |
75 | 75 | ||
76 | signals: | 76 | signals: |
77 | void shiftDown(); | 77 | void shiftDown(); |
78 | void shiftUp(); | 78 | void shiftUp(); |
79 | void rightClick(); | 79 | void rightClick(); |
80 | 80 | ||
81 | protected slots: | 81 | protected slots: |
82 | void oneDown(); | 82 | void oneDown(); |
83 | void keyPressEvent(QKeyEvent *); | 83 | void keyPressEvent(QKeyEvent *); |
84 | void keyReleaseEvent(QKeyEvent *); | 84 | void keyReleaseEvent(QKeyEvent *); |
85 | void mousePressEvent(QMouseEvent *); | 85 | void mousePressEvent(QMouseEvent *); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | KNOWhatsThis * mWT; | 88 | KNOWhatsThis * mWT; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | class MonthViewItem: public QListBoxItem | 92 | class MonthViewItem: public QListBoxItem |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 95 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
96 | void recycle( Incidence *incidence, QDate qd, const QString & s); | 96 | void recycle( Incidence *incidence, QDate qd, const QString & s); |
97 | void setRecur(bool on) { mRecur = on; } | 97 | void setRecur(bool on) { mRecur = on; } |
98 | void setAlarm(bool on) { mAlarm = on; } | 98 | void setAlarm(bool on) { mAlarm = on; } |
99 | void setReply(bool on) { mReply = on; } | 99 | void setReply(bool on) { mReply = on; } |
100 | void setMoreInfo(bool on) { mInfo = on; } | 100 | void setMoreInfo(bool on) { mInfo = on; } |
101 | void setMultiDay(int type) { mMultiday = type; } | 101 | void setMultiDay(int type) { mMultiday = type; } |
102 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 102 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
103 | 103 | ||
104 | 104 | ||
105 | void setPalette(const QPalette &p) { mPalette = p; } | 105 | void setPalette(const QPalette &p) { mPalette = p; } |
106 | QPalette palette() const { return mPalette; } | 106 | QPalette palette() const { return mPalette; } |
107 | 107 | ||
108 | Incidence *incidence() const { return mIncidence; } | 108 | Incidence *incidence() const { return mIncidence; } |
109 | QDate incidenceDate() { return mDate; } | 109 | QDate incidenceDate() { return mDate; } |
110 | 110 | ||
111 | protected: | 111 | protected: |
112 | virtual void paint(QPainter *); | 112 | virtual void paint(QPainter *); |
113 | virtual int height(const QListBox *) const; | 113 | virtual int height(const QListBox *) const; |
114 | virtual int width(const QListBox *) const; | 114 | virtual int width(const QListBox *) const; |
115 | 115 | ||
116 | private: | 116 | private: |
117 | bool mblockRepaint; | 117 | bool mblockRepaint; |
118 | int mMultiday; | 118 | int mMultiday; |
119 | bool mRecur; | 119 | bool mRecur; |
120 | bool mAlarm; | 120 | bool mAlarm; |
121 | bool mReply; | 121 | bool mReply; |
122 | bool mInfo; | 122 | bool mInfo; |
123 | 123 | ||
124 | QPalette mPalette; | 124 | QPalette mPalette; |
125 | QDate mDate; | 125 | QDate mDate; |
126 | 126 | ||
127 | Incidence *mIncidence; | 127 | Incidence *mIncidence; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | 130 | ||
131 | class KOMonthView; | 131 | class KOMonthView; |
132 | 132 | ||
133 | class MonthViewCell : public KNoScrollListBox | 133 | class MonthViewCell : public KNoScrollListBox |
134 | { | 134 | { |
135 | Q_OBJECT | 135 | Q_OBJECT |
136 | public: | 136 | public: |
137 | MonthViewCell(KOMonthView *,QWidget* ); | 137 | MonthViewCell(KOMonthView *,QWidget* ); |
138 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 138 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
139 | 139 | ||
140 | void setDate( const QDate & ); | 140 | void setDate( const QDate & ); |
141 | QDate date() const; | 141 | QDate date() const; |
142 | 142 | ||
143 | void setPrimary( bool ); | 143 | void setPrimary( bool ); |
144 | bool isPrimary() const; | 144 | bool isPrimary() const; |
145 | 145 | ||
146 | void setHoliday( bool ); | 146 | void setHoliday( bool ); |
147 | void setHoliday( const QString & ); | 147 | void setHoliday( const QString & ); |
148 | 148 | ||
149 | void updateCell(); | 149 | void updateCell(); |
150 | void startUpdateCell(); | 150 | void startUpdateCell(); |
151 | void finishUpdateCell(); | 151 | void finishUpdateCell(); |
152 | void repaintfinishUpdateCell(); | 152 | void repaintfinishUpdateCell(); |
153 | void insertEvent(Event *); | 153 | void insertEvent(Event *); |
154 | void insertTodo(Todo *); | 154 | void insertTodo(Todo *); |
155 | 155 | ||
156 | void updateConfig( bool bigFont = false ); | 156 | void updateConfig( bool bigFont = false ); |
157 | 157 | ||
158 | void enableScrollBars( bool ); | 158 | void enableScrollBars( bool ); |
159 | 159 | ||
160 | Incidence *selectedIncidence(); | 160 | Incidence *selectedIncidence(); |
161 | QDate selectedIncidenceDate(); | 161 | QDate selectedIncidenceDate(); |
162 | QPushButton * dateLabel() { return mLabel; } | 162 | QPushButton * dateLabel() { return mLabel; } |
163 | 163 | ||
164 | void deselect(); | 164 | void deselect(); |
165 | void select(); | 165 | void select(); |
166 | 166 | ||
167 | #ifdef DESKTOP_VERSION | 167 | #ifdef DESKTOP_VERSION |
168 | static QToolTipGroup *toolTipGroup(); | 168 | static QToolTipGroup *toolTipGroup(); |
169 | #endif | 169 | #endif |
170 | signals: | 170 | signals: |
171 | void defaultAction( Incidence * ); | 171 | void defaultAction( Incidence * ); |
172 | void newEventSignal( QDateTime ); | 172 | void newEventSignal( QDateTime ); |
173 | void showDaySignal( QDate ); | 173 | void showDaySignal( QDate ); |
174 | 174 | ||
175 | protected: | 175 | protected: |
176 | QStringList mToolTip; | 176 | QStringList mToolTip; |
177 | void resizeEvent( QResizeEvent * ); | 177 | void resizeEvent( QResizeEvent * ); |
178 | 178 | ||
179 | 179 | ||
180 | public slots: | 180 | public slots: |
181 | void showDay(); | 181 | void showDay(); |
182 | 182 | ||
183 | protected slots: | 183 | protected slots: |
184 | void defaultAction( QListBoxItem * ); | 184 | void defaultAction( QListBoxItem * ); |
185 | void contextMenu( QListBoxItem * ); | 185 | void contextMenu( QListBoxItem * ); |
186 | void selection( QListBoxItem * ); | 186 | void selection( QListBoxItem * ); |
187 | void cellClicked( QListBoxItem * ); | 187 | void cellClicked( QListBoxItem * ); |
188 | void newEvent(); | 188 | void newEvent(); |
189 | 189 | ||
190 | private: | 190 | private: |
191 | MonthViewItem* mCurrentAvailItem; | 191 | MonthViewItem* mCurrentAvailItem; |
192 | QPtrList <MonthViewItem> mAvailItemList; | 192 | QPtrList <MonthViewItem> mAvailItemList; |
193 | KOMonthView *mMonthView; | 193 | KOMonthView *mMonthView; |
194 | int currentPalette; | 194 | int currentPalette; |
195 | 195 | ||
196 | QDate mDate; | 196 | QDate mDate; |
197 | bool mPrimary; | 197 | bool mPrimary; |
198 | bool mHoliday; | 198 | bool mHoliday; |
199 | QString mHolidayString; | 199 | QString mHolidayString; |
200 | 200 | ||
201 | //QLabel *mLabel; | 201 | //QLabel *mLabel; |
202 | QPushButton *mLabel; | 202 | QPushButton *mLabel; |
203 | //QListBox *mItemList; | 203 | //QListBox *mItemList; |
204 | #ifdef DESKTOP_VERSION | 204 | #ifdef DESKTOP_VERSION |
205 | static QToolTipGroup *mToolTipGroup; | 205 | static QToolTipGroup *mToolTipGroup; |
206 | #endif | 206 | #endif |
207 | QSize mLabelSize; | 207 | QSize mLabelSize; |
208 | QSize mLabelBigSize; | 208 | QSize mLabelBigSize; |
209 | QPalette mHolidayPalette; | 209 | QPalette mHolidayPalette; |
210 | QPalette mStandardPalette; | 210 | QPalette mStandardPalette; |
211 | QPalette mPrimaryPalette; | 211 | QPalette mPrimaryPalette; |
212 | QPalette mNonPrimaryPalette; | 212 | QPalette mNonPrimaryPalette; |
213 | void setMyPalette(); | 213 | void setMyPalette(); |
214 | QPalette getPalette (); | 214 | QPalette getPalette (); |
215 | 215 | ||
216 | }; | 216 | }; |
217 | 217 | ||
218 | 218 | ||
219 | class KOMonthView: public KOEventView | 219 | class KOMonthView: public KOEventView |
220 | { | 220 | { |
221 | Q_OBJECT | 221 | Q_OBJECT |
222 | public: | 222 | public: |
223 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 223 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
224 | ~KOMonthView(); | 224 | ~KOMonthView(); |
225 | 225 | ||
226 | /** Returns maximum number of days supported by the komonthview */ | 226 | /** Returns maximum number of days supported by the komonthview */ |
227 | virtual int maxDatesHint(); | 227 | virtual int maxDatesHint(); |
228 | 228 | ||
229 | /** Returns number of currently shown dates. */ | 229 | /** Returns number of currently shown dates. */ |
230 | virtual int currentDateCount(); | 230 | virtual int currentDateCount(); |
231 | 231 | ||
232 | /** returns the currently selected events */ | 232 | /** returns the currently selected events */ |
233 | virtual QPtrList<Incidence> selectedIncidences(); | 233 | virtual QPtrList<Incidence> selectedIncidences(); |
234 | 234 | ||
235 | /** returns dates of the currently selected events */ | 235 | /** returns dates of the currently selected events */ |
236 | virtual DateList selectedDates(); | 236 | virtual DateList selectedDates(); |
237 | 237 | ||
238 | virtual void printPreview(CalPrinter *calPrinter, | 238 | virtual void printPreview(CalPrinter *calPrinter, |
239 | const QDate &, const QDate &); | 239 | const QDate &, const QDate &); |
240 | bool isMonthView() { return !mShowWeekView; } | 240 | bool isMonthView() { return !mShowWeekView; } |
241 | bool isUpdatePossible() { return updatePossible; } | 241 | bool isUpdatePossible() { return updatePossible; } |
242 | 242 | ||
243 | MonthViewCell * selectedCell(); | 243 | MonthViewCell * selectedCell(); |
244 | bool skipResize; | 244 | bool skipResize; |
245 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 245 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
246 | public slots: | 246 | public slots: |
247 | virtual void updateView(); | 247 | virtual void updateView(); |
248 | virtual void updateConfig(); | 248 | virtual void updateConfig(); |
249 | virtual void showDates(const QDate &start, const QDate &end); | 249 | virtual void showDates(const QDate &start, const QDate &end); |
250 | virtual void showEvents(QPtrList<Event> eventList); | 250 | virtual void showEvents(QPtrList<Event> eventList); |
251 | 251 | ||
252 | void changeEventDisplay(Event *, int); | 252 | void changeEventDisplay(Event *, int); |
253 | 253 | ||
254 | void clearSelection(); | 254 | void clearSelection(); |
255 | 255 | ||
256 | void showContextMenu( Incidence * ); | 256 | void showContextMenu( Incidence * ); |
257 | 257 | ||
258 | void setSelectedCell( MonthViewCell * ); | 258 | void setSelectedCell( MonthViewCell * ); |
259 | void switchView(); | 259 | void switchView(); |
260 | 260 | ||
261 | protected slots: | 261 | protected slots: |
262 | void slotComputeLayout(); | 262 | void slotComputeLayout(); |
263 | void selectInternalWeekNum ( int ); | 263 | void selectInternalWeekNum ( int ); |
264 | void processSelectionChange(); | 264 | void processSelectionChange(); |
265 | signals: | 265 | signals: |
266 | void nextMonth(); | 266 | void nextMonth(); |
267 | void prevMonth(); | 267 | void prevMonth(); |
268 | void selectWeekNum ( int ); | 268 | void selectWeekNum ( int ); |
269 | void selectMonth (); | 269 | void selectMonth (); |
270 | void showDaySignal( QDate ); | 270 | void showDaySignal( QDate ); |
271 | protected: | 271 | protected: |
272 | void resizeEvent(QResizeEvent *); | 272 | void resizeEvent(QResizeEvent *); |
273 | void viewChanged(); | 273 | void viewChanged(); |
274 | void updateDayLabels(); | 274 | void updateDayLabels(); |
275 | 275 | ||
276 | private: | 276 | private: |
277 | QTimer* mComputeLayoutTimer; | 277 | QTimer* mComputeLayoutTimer; |
278 | NavigatorBar* mNavigatorBar; | 278 | NavigatorBar* mNavigatorBar; |
279 | int currentWeek(); | 279 | int currentWeek(); |
280 | bool clPending; | 280 | bool clPending; |
281 | QWidgetStack * mWidStack; | 281 | QWidgetStack * mWidStack; |
282 | QWidget* mMonthView; | 282 | QWidget* mMonthView; |
283 | QWidget* mWeekView; | 283 | QWidget* mWeekView; |
284 | bool mShowWeekView; | 284 | bool mShowWeekView; |
285 | bool updatePossible; | 285 | bool updatePossible; |
286 | int mDaysPerWeek; | 286 | int mDaysPerWeek; |
287 | int mNumWeeks; | 287 | int mNumWeeks; |
288 | int mNumCells; | 288 | int mNumCells; |
289 | bool mWeekStartsMonday; | 289 | //bool mWeekStartsMonday; |
290 | bool mShowSatSunComp; | 290 | bool mShowSatSunComp; |
291 | void computeLayout(); | 291 | void computeLayout(); |
292 | void computeLayoutWeek(); | 292 | void computeLayoutWeek(); |
293 | 293 | ||
294 | QPtrVector<MonthViewCell> mCells; | 294 | QPtrVector<MonthViewCell> mCells; |
295 | QPtrVector<QLabel> mDayLabels; | 295 | QPtrVector<QLabel> mDayLabels; |
296 | QPtrVector<KOWeekButton> mWeekLabels; | 296 | QPtrVector<KOWeekButton> mWeekLabels; |
297 | QPtrVector<MonthViewCell> mCellsW; | 297 | QPtrVector<MonthViewCell> mCellsW; |
298 | QPtrVector<QLabel> mDayLabelsW; | 298 | QPtrVector<QLabel> mDayLabelsW; |
299 | QPtrVector<KOWeekButton> mWeekLabelsW; | 299 | QPtrVector<KOWeekButton> mWeekLabelsW; |
300 | 300 | ||
301 | bool mShortDayLabelsM; | 301 | bool mShortDayLabelsM; |
302 | bool mShortDayLabelsW; | 302 | bool mShortDayLabelsW; |
303 | int mWidthLongDayLabel; | 303 | int mWidthLongDayLabel; |
304 | 304 | ||
305 | QDate mStartDate; | 305 | QDate mStartDate; |
306 | 306 | ||
307 | MonthViewCell *mSelectedCell; | 307 | MonthViewCell *mSelectedCell; |
308 | 308 | ||
309 | KOEventPopupMenu *mContextMenu; | 309 | KOEventPopupMenu *mContextMenu; |
310 | void keyPressEvent ( QKeyEvent * ) ; | 310 | void keyPressEvent ( QKeyEvent * ) ; |
311 | 311 | ||
312 | }; | 312 | }; |
313 | 313 | ||
314 | #endif | 314 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2da592b..8e52968 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -457,1890 +457,1868 @@ void MainWindow::closeEvent( QCloseEvent* ce ) | |||
457 | 457 | ||
458 | default: | 458 | default: |
459 | break; | 459 | break; |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | } | 463 | } |
464 | 464 | ||
465 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 465 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
466 | { | 466 | { |
467 | QDataStream stream( data, IO_ReadOnly ); | 467 | QDataStream stream( data, IO_ReadOnly ); |
468 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 468 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
469 | //QString datamess; | 469 | //QString datamess; |
470 | //qDebug("message "); | 470 | //qDebug("message "); |
471 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 471 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
472 | 472 | ||
473 | if ( cmsg == "setDocument(QString)" ) { | 473 | if ( cmsg == "setDocument(QString)" ) { |
474 | QDataStream stream( data, IO_ReadOnly ); | 474 | QDataStream stream( data, IO_ReadOnly ); |
475 | QString fileName; | 475 | QString fileName; |
476 | stream >> fileName; | 476 | stream >> fileName; |
477 | //qDebug("filename %s ", fileName.latin1()); | 477 | //qDebug("filename %s ", fileName.latin1()); |
478 | showMaximized(); | 478 | showMaximized(); |
479 | raise(); | 479 | raise(); |
480 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 480 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
481 | mSyncManager->slotSyncMenu( 1002 ); | 481 | mSyncManager->slotSyncMenu( 1002 ); |
482 | return; | 482 | return; |
483 | } | 483 | } |
484 | 484 | ||
485 | if ( cmsg == "-writeFile" ) { | 485 | if ( cmsg == "-writeFile" ) { |
486 | // I made from the "-writeFile" an "-writeAlarm" | 486 | // I made from the "-writeFile" an "-writeAlarm" |
487 | mView->viewManager()->showWhatsNextView(); | 487 | mView->viewManager()->showWhatsNextView(); |
488 | mCalendar->checkAlarmForIncidence( 0, true); | 488 | mCalendar->checkAlarmForIncidence( 0, true); |
489 | showMaximized(); | 489 | showMaximized(); |
490 | raise(); | 490 | raise(); |
491 | return; | 491 | return; |
492 | 492 | ||
493 | } | 493 | } |
494 | if ( cmsg == "-writeFileSilent" ) { | 494 | if ( cmsg == "-writeFileSilent" ) { |
495 | // I made from the "-writeFile" an "-writeAlarm" | 495 | // I made from the "-writeFile" an "-writeAlarm" |
496 | // mView->viewManager()->showWhatsNextView(); | 496 | // mView->viewManager()->showWhatsNextView(); |
497 | mCalendar->checkAlarmForIncidence( 0, true); | 497 | mCalendar->checkAlarmForIncidence( 0, true); |
498 | //showMaximized(); | 498 | //showMaximized(); |
499 | //raise(); | 499 | //raise(); |
500 | hide(); | 500 | hide(); |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | if ( cmsg == "-newCountdown" ) { | 503 | if ( cmsg == "-newCountdown" ) { |
504 | qDebug("newCountdown "); | 504 | qDebug("newCountdown "); |
505 | 505 | ||
506 | } | 506 | } |
507 | QString msg ; | 507 | QString msg ; |
508 | QString allmsg = cmsg; | 508 | QString allmsg = cmsg; |
509 | while ( allmsg.length() > 0 ) { | 509 | while ( allmsg.length() > 0 ) { |
510 | int nextC = allmsg.find( "-", 1 ); | 510 | int nextC = allmsg.find( "-", 1 ); |
511 | if ( nextC == -1 ) { | 511 | if ( nextC == -1 ) { |
512 | msg = allmsg; | 512 | msg = allmsg; |
513 | allmsg = ""; | 513 | allmsg = ""; |
514 | } else{ | 514 | } else{ |
515 | msg = allmsg.left( nextC ); | 515 | msg = allmsg.left( nextC ); |
516 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 516 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
517 | } | 517 | } |
518 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 518 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
519 | if ( msg == "-newEvent" ) { | 519 | if ( msg == "-newEvent" ) { |
520 | mView->newEvent(); | 520 | mView->newEvent(); |
521 | } | 521 | } |
522 | if ( msg == "-newTodo" ) { | 522 | if ( msg == "-newTodo" ) { |
523 | mView->newTodo(); | 523 | mView->newTodo(); |
524 | 524 | ||
525 | } | 525 | } |
526 | if ( msg == "-showWN" ) { | 526 | if ( msg == "-showWN" ) { |
527 | mView->viewManager()->showWhatsNextView(); | 527 | mView->viewManager()->showWhatsNextView(); |
528 | } | 528 | } |
529 | if ( msg == "-showTodo" ) { | 529 | if ( msg == "-showTodo" ) { |
530 | mView->viewManager()->showTodoView(); | 530 | mView->viewManager()->showTodoView(); |
531 | } | 531 | } |
532 | if ( msg == "-showList" ) { | 532 | if ( msg == "-showList" ) { |
533 | mView->viewManager()->showListView(); | 533 | mView->viewManager()->showListView(); |
534 | } | 534 | } |
535 | else if ( msg == "-showDay" ) { | 535 | else if ( msg == "-showDay" ) { |
536 | mView->viewManager()->showDayView(); | 536 | mView->viewManager()->showDayView(); |
537 | } | 537 | } |
538 | else if ( msg == "-showWWeek" ) { | 538 | else if ( msg == "-showWWeek" ) { |
539 | mView->viewManager()->showWorkWeekView(); | 539 | mView->viewManager()->showWorkWeekView(); |
540 | } | 540 | } |
541 | else if ( msg == "-ringSync" ) { | 541 | else if ( msg == "-ringSync" ) { |
542 | mSyncManager->multiSync( false ); | 542 | mSyncManager->multiSync( false ); |
543 | } | 543 | } |
544 | else if ( msg == "-showWeek" ) { | 544 | else if ( msg == "-showWeek" ) { |
545 | mView->viewManager()->showWeekView(); | 545 | mView->viewManager()->showWeekView(); |
546 | } | 546 | } |
547 | else if ( msg == "-showTodo" ) { | 547 | else if ( msg == "-showTodo" ) { |
548 | mView->viewManager()->showTodoView(); | 548 | mView->viewManager()->showTodoView(); |
549 | } | 549 | } |
550 | else if ( msg == "-showJournal" ) { | 550 | else if ( msg == "-showJournal" ) { |
551 | mView->dateNavigator()->selectDates( 1 ); | 551 | mView->dateNavigator()->selectDates( 1 ); |
552 | mView->dateNavigator()->selectToday(); | 552 | mView->dateNavigator()->selectToday(); |
553 | mView->viewManager()->showJournalView(); | 553 | mView->viewManager()->showJournalView(); |
554 | } | 554 | } |
555 | else if ( msg == "-showKO" ) { | 555 | else if ( msg == "-showKO" ) { |
556 | mView->viewManager()->showNextXView(); | 556 | mView->viewManager()->showNextXView(); |
557 | } | 557 | } |
558 | else if ( msg == "-showWNext" ) { | 558 | else if ( msg == "-showWNext" ) { |
559 | mView->viewManager()->showWhatsNextView(); | 559 | mView->viewManager()->showWhatsNextView(); |
560 | } | 560 | } |
561 | else if ( msg == "nextView()" ) { | 561 | else if ( msg == "nextView()" ) { |
562 | mView->viewManager()->showNextView(); | 562 | mView->viewManager()->showNextView(); |
563 | } | 563 | } |
564 | else if ( msg == "-showNextXView" ) { | 564 | else if ( msg == "-showNextXView" ) { |
565 | mView->viewManager()->showNextXView(); | 565 | mView->viewManager()->showNextXView(); |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | } | 569 | } |
570 | 570 | ||
571 | showMaximized(); | 571 | showMaximized(); |
572 | raise(); | 572 | raise(); |
573 | } | 573 | } |
574 | 574 | ||
575 | QPixmap MainWindow::loadPixmap( QString name ) | 575 | QPixmap MainWindow::loadPixmap( QString name ) |
576 | { | 576 | { |
577 | return SmallIcon( name ); | 577 | return SmallIcon( name ); |
578 | 578 | ||
579 | } | 579 | } |
580 | void MainWindow::initActions() | 580 | void MainWindow::initActions() |
581 | { | 581 | { |
582 | //KOPrefs::instance()->mShowFullMenu | 582 | //KOPrefs::instance()->mShowFullMenu |
583 | iconToolBar->clear(); | 583 | iconToolBar->clear(); |
584 | KOPrefs *p = KOPrefs::instance(); | 584 | KOPrefs *p = KOPrefs::instance(); |
585 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 585 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
586 | 586 | ||
587 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 587 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
588 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 588 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
589 | QPopupMenu *importMenu = new QPopupMenu( this ); | 589 | QPopupMenu *importMenu = new QPopupMenu( this ); |
590 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 590 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
591 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 591 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
592 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 592 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
593 | selectFilterMenu = new QPopupMenu( this ); | 593 | selectFilterMenu = new QPopupMenu( this ); |
594 | selectFilterMenu->setCheckable( true ); | 594 | selectFilterMenu->setCheckable( true ); |
595 | syncMenu = new QPopupMenu( this ); | 595 | syncMenu = new QPopupMenu( this ); |
596 | configureAgendaMenu = new QPopupMenu( this ); | 596 | configureAgendaMenu = new QPopupMenu( this ); |
597 | configureToolBarMenu = new QPopupMenu( this ); | 597 | configureToolBarMenu = new QPopupMenu( this ); |
598 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 598 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
599 | QIconSet icon; | 599 | QIconSet icon; |
600 | int pixWid = 22, pixHei = 22; | 600 | int pixWid = 22, pixHei = 22; |
601 | QString pathString = ""; | 601 | QString pathString = ""; |
602 | if ( !p->mToolBarMiniIcons ) { | 602 | if ( !p->mToolBarMiniIcons ) { |
603 | if ( QApplication::desktop()->width() < 480 ) { | 603 | if ( QApplication::desktop()->width() < 480 ) { |
604 | pathString += "icons16/"; | 604 | pathString += "icons16/"; |
605 | pixWid = 18; pixHei = 16; | 605 | pixWid = 18; pixHei = 16; |
606 | } | 606 | } |
607 | } else { | 607 | } else { |
608 | pathString += "iconsmini/"; | 608 | pathString += "iconsmini/"; |
609 | pixWid = 18; pixHei = 16; | 609 | pixWid = 18; pixHei = 16; |
610 | } | 610 | } |
611 | if ( KOPrefs::instance()->mShowFullMenu ) { | 611 | if ( KOPrefs::instance()->mShowFullMenu ) { |
612 | QMenuBar *menuBar1; | 612 | QMenuBar *menuBar1; |
613 | menuBar1 = menuBar(); | 613 | menuBar1 = menuBar(); |
614 | menuBar1->insertItem( i18n("File"), importMenu ); | 614 | menuBar1->insertItem( i18n("File"), importMenu ); |
615 | menuBar1->insertItem( i18n("View"), viewMenu ); | 615 | menuBar1->insertItem( i18n("View"), viewMenu ); |
616 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 616 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
617 | #ifdef DESKTOP_VERSION | 617 | #ifdef DESKTOP_VERSION |
618 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 618 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
619 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 619 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
620 | #else | 620 | #else |
621 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 621 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
622 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 622 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
623 | #endif | 623 | #endif |
624 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 624 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
625 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 625 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
626 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 626 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
627 | } else { | 627 | } else { |
628 | QPEMenuBar *menuBar1; | 628 | QPEMenuBar *menuBar1; |
629 | menuBar1 = new QPEMenuBar( iconToolBar ); | 629 | menuBar1 = new QPEMenuBar( iconToolBar ); |
630 | QPopupMenu *menuBar = new QPopupMenu( this ); | 630 | QPopupMenu *menuBar = new QPopupMenu( this ); |
631 | icon = loadPixmap( pathString + "z_menu" ); | 631 | icon = loadPixmap( pathString + "z_menu" ); |
632 | menuBar1->insertItem( icon.pixmap(), menuBar); | 632 | menuBar1->insertItem( icon.pixmap(), menuBar); |
633 | //menuBar1->insertItem( i18n("ME"), menuBar); | 633 | //menuBar1->insertItem( i18n("ME"), menuBar); |
634 | menuBar->insertItem( i18n("File"), importMenu ); | 634 | menuBar->insertItem( i18n("File"), importMenu ); |
635 | menuBar->insertItem( i18n("View"), viewMenu ); | 635 | menuBar->insertItem( i18n("View"), viewMenu ); |
636 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 636 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
637 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 637 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
638 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 638 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
639 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 639 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
640 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 640 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
641 | menuBar->insertItem( i18n("Help"), helpMenu ); | 641 | menuBar->insertItem( i18n("Help"), helpMenu ); |
642 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 642 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
643 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 643 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
644 | } | 644 | } |
645 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 645 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
646 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 646 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
647 | mWeekBgColor = iconToolBar->backgroundColor(); | 647 | mWeekBgColor = iconToolBar->backgroundColor(); |
648 | mWeekPixmap.resize( pixWid , pixHei ); | 648 | mWeekPixmap.resize( pixWid , pixHei ); |
649 | mWeekPixmap.fill( mWeekBgColor ); | 649 | mWeekPixmap.fill( mWeekBgColor ); |
650 | icon = mWeekPixmap; | 650 | icon = mWeekPixmap; |
651 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 651 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
652 | if ( p-> mShowIconWeekNum ) | 652 | if ( p-> mShowIconWeekNum ) |
653 | mWeekAction->addTo( iconToolBar ); | 653 | mWeekAction->addTo( iconToolBar ); |
654 | mWeekFont = font(); | 654 | mWeekFont = font(); |
655 | 655 | ||
656 | int fontPoint = mWeekFont.pointSize(); | 656 | int fontPoint = mWeekFont.pointSize(); |
657 | QFontMetrics f( mWeekFont ); | 657 | QFontMetrics f( mWeekFont ); |
658 | int fontWid = f.width( "30" ); | 658 | int fontWid = f.width( "30" ); |
659 | while ( fontWid > pixWid ) { | 659 | while ( fontWid > pixWid ) { |
660 | --fontPoint; | 660 | --fontPoint; |
661 | mWeekFont.setPointSize( fontPoint ); | 661 | mWeekFont.setPointSize( fontPoint ); |
662 | QFontMetrics f( mWeekFont ); | 662 | QFontMetrics f( mWeekFont ); |
663 | fontWid = f.width( "30" ); | 663 | fontWid = f.width( "30" ); |
664 | //qDebug("dec-- "); | 664 | //qDebug("dec-- "); |
665 | } | 665 | } |
666 | 666 | ||
667 | connect( mWeekAction, SIGNAL( activated() ), | 667 | connect( mWeekAction, SIGNAL( activated() ), |
668 | this, SLOT( weekAction() ) ); | 668 | this, SLOT( weekAction() ) ); |
669 | 669 | ||
670 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 670 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
671 | 671 | ||
672 | //#endif | 672 | //#endif |
673 | // ****************** | 673 | // ****************** |
674 | QAction *action; | 674 | QAction *action; |
675 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 675 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
676 | configureToolBarMenu->setCheckable( true ); | 676 | configureToolBarMenu->setCheckable( true ); |
677 | 677 | ||
678 | 678 | ||
679 | configureAgendaMenu->setCheckable( true ); | 679 | configureAgendaMenu->setCheckable( true ); |
680 | int iii ; | 680 | int iii ; |
681 | for ( iii = 1;iii<= 10 ;++iii ){ | 681 | for ( iii = 1;iii<= 10 ;++iii ){ |
682 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 682 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
683 | } | 683 | } |
684 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 684 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
685 | 685 | ||
686 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 686 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
687 | this, SLOT( showConfigureAgenda( ) ) ); | 687 | this, SLOT( showConfigureAgenda( ) ) ); |
688 | 688 | ||
689 | icon = loadPixmap( pathString + "configure" ); | 689 | icon = loadPixmap( pathString + "configure" ); |
690 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 690 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
691 | action->addTo( actionMenu ); | 691 | action->addTo( actionMenu ); |
692 | connect( action, SIGNAL( activated() ), | 692 | connect( action, SIGNAL( activated() ), |
693 | mView, SLOT( edit_options() ) ); | 693 | mView, SLOT( edit_options() ) ); |
694 | actionMenu->insertSeparator(); | 694 | actionMenu->insertSeparator(); |
695 | 695 | ||
696 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 696 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
697 | action->addTo( actionMenu ); | 697 | action->addTo( actionMenu ); |
698 | connect( action, SIGNAL( activated() ), | 698 | connect( action, SIGNAL( activated() ), |
699 | mView, SLOT( undo_delete() ) ); | 699 | mView, SLOT( undo_delete() ) ); |
700 | actionMenu->insertSeparator(); | 700 | actionMenu->insertSeparator(); |
701 | 701 | ||
702 | icon = loadPixmap( pathString + "newevent" ); | 702 | icon = loadPixmap( pathString + "newevent" ); |
703 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 703 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
704 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 704 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
705 | configureToolBarMenu->insertSeparator(); | 705 | configureToolBarMenu->insertSeparator(); |
706 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 706 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
707 | configureToolBarMenu->insertSeparator(); | 707 | configureToolBarMenu->insertSeparator(); |
708 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 708 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
709 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 709 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
710 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 710 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
711 | ne_action->addTo( actionMenu ); | 711 | ne_action->addTo( actionMenu ); |
712 | connect( ne_action, SIGNAL( activated() ), | 712 | connect( ne_action, SIGNAL( activated() ), |
713 | mView, SLOT( newEvent() ) ); | 713 | mView, SLOT( newEvent() ) ); |
714 | icon = loadPixmap( pathString + "newtodo" ); | 714 | icon = loadPixmap( pathString + "newtodo" ); |
715 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 715 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
716 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 716 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
717 | nt_action->addTo( actionMenu ); | 717 | nt_action->addTo( actionMenu ); |
718 | connect( nt_action, SIGNAL( activated() ), | 718 | connect( nt_action, SIGNAL( activated() ), |
719 | mView, SLOT( newTodo() ) ); | 719 | mView, SLOT( newTodo() ) ); |
720 | 720 | ||
721 | icon = loadPixmap( pathString + "today" ); | 721 | icon = loadPixmap( pathString + "today" ); |
722 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 722 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
723 | today_action->addTo( viewMenu ); | 723 | today_action->addTo( viewMenu ); |
724 | connect( today_action, SIGNAL( activated() ), | 724 | connect( today_action, SIGNAL( activated() ), |
725 | mView, SLOT( goToday() ) ); | 725 | mView, SLOT( goToday() ) ); |
726 | viewMenu->insertSeparator(); | 726 | viewMenu->insertSeparator(); |
727 | 727 | ||
728 | icon = loadPixmap( pathString + "navi" ); | 728 | icon = loadPixmap( pathString + "navi" ); |
729 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 729 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
730 | action->addTo( viewMenu ); | 730 | action->addTo( viewMenu ); |
731 | connect( action, SIGNAL( activated() ), | 731 | connect( action, SIGNAL( activated() ), |
732 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 732 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
733 | mToggleNav = action ; | 733 | mToggleNav = action ; |
734 | icon = loadPixmap( pathString + "filter" ); | 734 | icon = loadPixmap( pathString + "filter" ); |
735 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 735 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
736 | action->addTo( viewMenu ); | 736 | action->addTo( viewMenu ); |
737 | connect( action, SIGNAL( activated() ), | 737 | connect( action, SIGNAL( activated() ), |
738 | mView, SLOT( toggleFilter() ) ); | 738 | mView, SLOT( toggleFilter() ) ); |
739 | mToggleFilter = action; | 739 | mToggleFilter = action; |
740 | icon = loadPixmap( pathString + "allday" ); | 740 | icon = loadPixmap( pathString + "allday" ); |
741 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 741 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
742 | action->addTo( viewMenu ); | 742 | action->addTo( viewMenu ); |
743 | connect( action, SIGNAL( activated() ), | 743 | connect( action, SIGNAL( activated() ), |
744 | mView, SLOT( toggleAllDaySize() ) ); | 744 | mView, SLOT( toggleAllDaySize() ) ); |
745 | mToggleAllday = action; | 745 | mToggleAllday = action; |
746 | 746 | ||
747 | 747 | ||
748 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 748 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
749 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 749 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
750 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 750 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
751 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 751 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
752 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 752 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
753 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 753 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
754 | 754 | ||
755 | viewMenu->insertSeparator(); | 755 | viewMenu->insertSeparator(); |
756 | icon = loadPixmap( pathString + "picker" ); | 756 | icon = loadPixmap( pathString + "picker" ); |
757 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 757 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
758 | action->addTo( viewMenu ); | 758 | action->addTo( viewMenu ); |
759 | connect( action, SIGNAL( activated() ), | 759 | connect( action, SIGNAL( activated() ), |
760 | mView, SLOT( showDatePicker() ) ); | 760 | mView, SLOT( showDatePicker() ) ); |
761 | action->addTo( iconToolBar ); | 761 | action->addTo( iconToolBar ); |
762 | viewMenu->insertSeparator(); | 762 | viewMenu->insertSeparator(); |
763 | 763 | ||
764 | 764 | ||
765 | icon = loadPixmap( pathString + "whatsnext" ); | 765 | icon = loadPixmap( pathString + "whatsnext" ); |
766 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 766 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
767 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 767 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
768 | whatsnext_action->addTo( viewMenu ); | 768 | whatsnext_action->addTo( viewMenu ); |
769 | connect( whatsnext_action, SIGNAL( activated() ), | 769 | connect( whatsnext_action, SIGNAL( activated() ), |
770 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 770 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
771 | 771 | ||
772 | icon = loadPixmap( pathString + "xdays" ); | 772 | icon = loadPixmap( pathString + "xdays" ); |
773 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 773 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
774 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 774 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
775 | xdays_action->addTo( viewMenu ); | 775 | xdays_action->addTo( viewMenu ); |
776 | connect( xdays_action, SIGNAL( activated() ), | 776 | connect( xdays_action, SIGNAL( activated() ), |
777 | mView->viewManager(), SLOT( showNextXView() ) ); | 777 | mView->viewManager(), SLOT( showNextXView() ) ); |
778 | 778 | ||
779 | 779 | ||
780 | icon = loadPixmap( pathString + "journal" ); | 780 | icon = loadPixmap( pathString + "journal" ); |
781 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 781 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
782 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 782 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
783 | viewjournal_action->addTo( viewMenu ); | 783 | viewjournal_action->addTo( viewMenu ); |
784 | connect( viewjournal_action, SIGNAL( activated() ), | 784 | connect( viewjournal_action, SIGNAL( activated() ), |
785 | mView->viewManager(), SLOT( showJournalView() ) ); | 785 | mView->viewManager(), SLOT( showJournalView() ) ); |
786 | 786 | ||
787 | 787 | ||
788 | icon = loadPixmap( pathString + "day" ); | 788 | icon = loadPixmap( pathString + "day" ); |
789 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 789 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
790 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 790 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
791 | day1_action->addTo( viewMenu ); | 791 | day1_action->addTo( viewMenu ); |
792 | // action->addTo( toolBar ); | 792 | // action->addTo( toolBar ); |
793 | connect( day1_action, SIGNAL( activated() ), | 793 | connect( day1_action, SIGNAL( activated() ), |
794 | mView->viewManager(), SLOT( showDayView() ) ); | 794 | mView->viewManager(), SLOT( showDayView() ) ); |
795 | 795 | ||
796 | icon = loadPixmap( pathString + "workweek" ); | 796 | icon = loadPixmap( pathString + "workweek" ); |
797 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 797 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
798 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 798 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
799 | day5_action->addTo( viewMenu ); | 799 | day5_action->addTo( viewMenu ); |
800 | connect( day5_action, SIGNAL( activated() ), | 800 | connect( day5_action, SIGNAL( activated() ), |
801 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 801 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
802 | 802 | ||
803 | icon = loadPixmap( pathString + "week" ); | 803 | icon = loadPixmap( pathString + "week" ); |
804 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 804 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
805 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 805 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
806 | day7_action->addTo( viewMenu ); | 806 | day7_action->addTo( viewMenu ); |
807 | connect( day7_action, SIGNAL( activated() ), | 807 | connect( day7_action, SIGNAL( activated() ), |
808 | mView->viewManager(), SLOT( showWeekView() ) ); | 808 | mView->viewManager(), SLOT( showWeekView() ) ); |
809 | 809 | ||
810 | icon = loadPixmap( pathString + "workweek2" ); | 810 | icon = loadPixmap( pathString + "workweek2" ); |
811 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 811 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
812 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 812 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
813 | day6_action->addTo( viewMenu ); | 813 | day6_action->addTo( viewMenu ); |
814 | connect( day6_action, SIGNAL( activated() ), | 814 | connect( day6_action, SIGNAL( activated() ), |
815 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 815 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
816 | 816 | ||
817 | icon = loadPixmap( pathString + "month" ); | 817 | icon = loadPixmap( pathString + "month" ); |
818 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 818 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
819 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 819 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
820 | month_action->addTo( viewMenu ); | 820 | month_action->addTo( viewMenu ); |
821 | connect( month_action, SIGNAL( activated() ), | 821 | connect( month_action, SIGNAL( activated() ), |
822 | mView->viewManager(), SLOT( showMonthView() ) ); | 822 | mView->viewManager(), SLOT( showMonthView() ) ); |
823 | 823 | ||
824 | icon = loadPixmap( pathString + "list" ); | 824 | icon = loadPixmap( pathString + "list" ); |
825 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 825 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
826 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 826 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
827 | showlist_action->addTo( viewMenu ); | 827 | showlist_action->addTo( viewMenu ); |
828 | connect( showlist_action, SIGNAL( activated() ), | 828 | connect( showlist_action, SIGNAL( activated() ), |
829 | mView->viewManager(), SLOT( showListView() ) ); | 829 | mView->viewManager(), SLOT( showListView() ) ); |
830 | 830 | ||
831 | icon = loadPixmap( pathString + "todo" ); | 831 | icon = loadPixmap( pathString + "todo" ); |
832 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 832 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
833 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 833 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
834 | todoview_action->addTo( viewMenu ); | 834 | todoview_action->addTo( viewMenu ); |
835 | connect( todoview_action, SIGNAL( activated() ), | 835 | connect( todoview_action, SIGNAL( activated() ), |
836 | mView->viewManager(), SLOT( showTodoView() ) ); | 836 | mView->viewManager(), SLOT( showTodoView() ) ); |
837 | 837 | ||
838 | 838 | ||
839 | 839 | ||
840 | #if 0 | 840 | #if 0 |
841 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 841 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
842 | action->addTo( viewMenu ); | 842 | action->addTo( viewMenu ); |
843 | connect( action, SIGNAL( activated() ), | 843 | connect( action, SIGNAL( activated() ), |
844 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 844 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
845 | #endif | 845 | #endif |
846 | 846 | ||
847 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 847 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
848 | this ); | 848 | this ); |
849 | mNewSubTodoAction->addTo( actionMenu ); | 849 | mNewSubTodoAction->addTo( actionMenu ); |
850 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 850 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
851 | mView, SLOT( newSubTodo() ) ); | 851 | mView, SLOT( newSubTodo() ) ); |
852 | 852 | ||
853 | actionMenu->insertSeparator(); | 853 | actionMenu->insertSeparator(); |
854 | 854 | ||
855 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 855 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
856 | mShowAction->addTo( actionMenu ); | 856 | mShowAction->addTo( actionMenu ); |
857 | connect( mShowAction, SIGNAL( activated() ), | 857 | connect( mShowAction, SIGNAL( activated() ), |
858 | mView, SLOT( showIncidence() ) ); | 858 | mView, SLOT( showIncidence() ) ); |
859 | 859 | ||
860 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 860 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
861 | mEditAction->addTo( actionMenu ); | 861 | mEditAction->addTo( actionMenu ); |
862 | connect( mEditAction, SIGNAL( activated() ), | 862 | connect( mEditAction, SIGNAL( activated() ), |
863 | mView, SLOT( editIncidence() ) ); | 863 | mView, SLOT( editIncidence() ) ); |
864 | 864 | ||
865 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 865 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
866 | mDeleteAction->addTo( actionMenu ); | 866 | mDeleteAction->addTo( actionMenu ); |
867 | connect( mDeleteAction, SIGNAL( activated() ), | 867 | connect( mDeleteAction, SIGNAL( activated() ), |
868 | mView, SLOT( deleteIncidence() ) ); | 868 | mView, SLOT( deleteIncidence() ) ); |
869 | 869 | ||
870 | 870 | ||
871 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 871 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
872 | mCloneAction->addTo( actionMenu ); | 872 | mCloneAction->addTo( actionMenu ); |
873 | connect( mCloneAction, SIGNAL( activated() ), | 873 | connect( mCloneAction, SIGNAL( activated() ), |
874 | mView, SLOT( cloneIncidence() ) ); | 874 | mView, SLOT( cloneIncidence() ) ); |
875 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 875 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
876 | mMoveAction->addTo( actionMenu ); | 876 | mMoveAction->addTo( actionMenu ); |
877 | connect( mMoveAction, SIGNAL( activated() ), | 877 | connect( mMoveAction, SIGNAL( activated() ), |
878 | mView, SLOT( moveIncidence() ) ); | 878 | mView, SLOT( moveIncidence() ) ); |
879 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 879 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
880 | mBeamAction->addTo( actionMenu ); | 880 | mBeamAction->addTo( actionMenu ); |
881 | connect( mBeamAction, SIGNAL( activated() ), | 881 | connect( mBeamAction, SIGNAL( activated() ), |
882 | mView, SLOT( beamIncidence() ) ); | 882 | mView, SLOT( beamIncidence() ) ); |
883 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 883 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
884 | mCancelAction->addTo( actionMenu ); | 884 | mCancelAction->addTo( actionMenu ); |
885 | connect( mCancelAction, SIGNAL( activated() ), | 885 | connect( mCancelAction, SIGNAL( activated() ), |
886 | mView, SLOT( toggleCancelIncidence() ) ); | 886 | mView, SLOT( toggleCancelIncidence() ) ); |
887 | 887 | ||
888 | actionMenu->insertSeparator(); | 888 | actionMenu->insertSeparator(); |
889 | 889 | ||
890 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 890 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
891 | this ); | 891 | this ); |
892 | action->addTo( actionMenu ); | 892 | action->addTo( actionMenu ); |
893 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 893 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
894 | 894 | ||
895 | icon = loadPixmap( pathString + "search" ); | 895 | icon = loadPixmap( pathString + "search" ); |
896 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 896 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
897 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 897 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
898 | search_action->addTo( actionMenu ); | 898 | search_action->addTo( actionMenu ); |
899 | connect( search_action, SIGNAL( activated() ), | 899 | connect( search_action, SIGNAL( activated() ), |
900 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 900 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | if ( KOPrefs::instance()->mShowFullMenu ) { | 904 | if ( KOPrefs::instance()->mShowFullMenu ) { |
905 | actionMenu->insertSeparator(); | 905 | actionMenu->insertSeparator(); |
906 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 906 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
907 | 907 | ||
908 | } | 908 | } |
909 | // actionMenu->insertSeparator(); | 909 | // actionMenu->insertSeparator(); |
910 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 910 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
911 | this ); | 911 | this ); |
912 | action->addTo( importMenu_X ); | 912 | action->addTo( importMenu_X ); |
913 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 913 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
914 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 914 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
915 | this ); | 915 | this ); |
916 | action->addTo( importMenu_X ); | 916 | action->addTo( importMenu_X ); |
917 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 917 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
918 | importMenu_X->insertSeparator(); | 918 | importMenu_X->insertSeparator(); |
919 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 919 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
920 | this ); | 920 | this ); |
921 | action->addTo( importMenu_X ); | 921 | action->addTo( importMenu_X ); |
922 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 922 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
923 | //#ifndef DESKTOP_VERSION | 923 | //#ifndef DESKTOP_VERSION |
924 | importMenu_X->insertSeparator(); | 924 | importMenu_X->insertSeparator(); |
925 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 925 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
926 | this ); | 926 | this ); |
927 | action->addTo( importMenu_X ); | 927 | action->addTo( importMenu_X ); |
928 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 928 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
929 | //#else | 929 | //#else |
930 | #ifdef _OL_IMPORT_ | 930 | #ifdef _OL_IMPORT_ |
931 | importMenu_X->insertSeparator(); | 931 | importMenu_X->insertSeparator(); |
932 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 932 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
933 | this ); | 933 | this ); |
934 | action->addTo( importMenu_X ); | 934 | action->addTo( importMenu_X ); |
935 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 935 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
936 | #endif | 936 | #endif |
937 | //#endif | 937 | //#endif |
938 | 938 | ||
939 | //importMenu->insertSeparator(); | 939 | //importMenu->insertSeparator(); |
940 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 940 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
941 | this ); | 941 | this ); |
942 | action->addTo( importMenu ); | 942 | action->addTo( importMenu ); |
943 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 943 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
944 | 944 | ||
945 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 945 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
946 | this ); | 946 | this ); |
947 | action->addTo( importMenu ); | 947 | action->addTo( importMenu ); |
948 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 948 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
949 | importMenu->insertSeparator(); | 949 | importMenu->insertSeparator(); |
950 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 950 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
951 | //importMenu->insertSeparator(); | 951 | //importMenu->insertSeparator(); |
952 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 952 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
953 | this ); | 953 | this ); |
954 | action->addTo( exportMenu_X ); | 954 | action->addTo( exportMenu_X ); |
955 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 955 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
956 | 956 | ||
957 | 957 | ||
958 | //LR | 958 | //LR |
959 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 959 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
960 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 960 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
961 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 961 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
962 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 962 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
963 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 963 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
964 | 964 | ||
965 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 965 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
966 | #ifndef DESKTOP_VERSION | 966 | #ifndef DESKTOP_VERSION |
967 | //importMenu->insertSeparator(); | 967 | //importMenu->insertSeparator(); |
968 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 968 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
969 | this ); | 969 | this ); |
970 | brAction->addTo( beamMenu_X ); | 970 | brAction->addTo( beamMenu_X ); |
971 | brAction->setToggleAction (true ) ; | 971 | brAction->setToggleAction (true ) ; |
972 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 972 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
973 | 973 | ||
974 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 974 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
975 | this ); | 975 | this ); |
976 | action->addTo( beamMenu_X ); | 976 | action->addTo( beamMenu_X ); |
977 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 977 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
978 | 978 | ||
979 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 979 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
980 | this ); | 980 | this ); |
981 | action->addTo( beamMenu_X ); | 981 | action->addTo( beamMenu_X ); |
982 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 982 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
983 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 983 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
984 | #else | 984 | #else |
985 | //importMenu->insertSeparator(); | 985 | //importMenu->insertSeparator(); |
986 | icon = loadPixmap( pathString + "print" ); | 986 | icon = loadPixmap( pathString + "print" ); |
987 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 987 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
988 | action->addTo( beamMenu_X ); | 988 | action->addTo( beamMenu_X ); |
989 | connect( action, SIGNAL( activated() ), | 989 | connect( action, SIGNAL( activated() ), |
990 | this, SLOT( printCal() ) ); | 990 | this, SLOT( printCal() ) ); |
991 | 991 | ||
992 | icon = loadPixmap( pathString + "print" ); | 992 | icon = loadPixmap( pathString + "print" ); |
993 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 993 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
994 | action->addTo( beamMenu_X ); | 994 | action->addTo( beamMenu_X ); |
995 | connect( action, SIGNAL( activated() ), | 995 | connect( action, SIGNAL( activated() ), |
996 | this, SLOT( printSel() ) ); | 996 | this, SLOT( printSel() ) ); |
997 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 997 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
998 | action->addTo( beamMenu_X ); | 998 | action->addTo( beamMenu_X ); |
999 | connect( action, SIGNAL( activated() ), | 999 | connect( action, SIGNAL( activated() ), |
1000 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1000 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1001 | 1001 | ||
1002 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1002 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1003 | action->addTo( beamMenu_X ); | 1003 | action->addTo( beamMenu_X ); |
1004 | connect( action, SIGNAL( activated() ), | 1004 | connect( action, SIGNAL( activated() ), |
1005 | mView, SLOT( slotprintSelInc() ) ); | 1005 | mView, SLOT( slotprintSelInc() ) ); |
1006 | 1006 | ||
1007 | 1007 | ||
1008 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1008 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1009 | #endif | 1009 | #endif |
1010 | importMenu->insertSeparator(); | 1010 | importMenu->insertSeparator(); |
1011 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1011 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1012 | this ); | 1012 | this ); |
1013 | action->addTo( importMenu ); | 1013 | action->addTo( importMenu ); |
1014 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1014 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1015 | importMenu->insertSeparator(); | 1015 | importMenu->insertSeparator(); |
1016 | action = new QAction( "beam all", i18n("Save"), 0, | 1016 | action = new QAction( "beam all", i18n("Save"), 0, |
1017 | this ); | 1017 | this ); |
1018 | action->addTo( importMenu ); | 1018 | action->addTo( importMenu ); |
1019 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1019 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1020 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1020 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1021 | this ); | 1021 | this ); |
1022 | action->addTo( importMenu ); | 1022 | action->addTo( importMenu ); |
1023 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1023 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1024 | 1024 | ||
1025 | //menuBar->insertItem( "Configure",configureMenu ); | 1025 | //menuBar->insertItem( "Configure",configureMenu ); |
1026 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1026 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1027 | icon = loadPixmap( "korganizer/korganizer" ); | 1027 | icon = loadPixmap( "korganizer/korganizer" ); |
1028 | 1028 | ||
1029 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1029 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1030 | action->addTo( helpMenu ); | 1030 | action->addTo( helpMenu ); |
1031 | connect( action, SIGNAL( activated() ), | 1031 | connect( action, SIGNAL( activated() ), |
1032 | SLOT( whatsNew() ) ); | 1032 | SLOT( whatsNew() ) ); |
1033 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1033 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1034 | action->addTo( helpMenu ); | 1034 | action->addTo( helpMenu ); |
1035 | connect( action, SIGNAL( activated() ), | 1035 | connect( action, SIGNAL( activated() ), |
1036 | SLOT( features() ) ); | 1036 | SLOT( features() ) ); |
1037 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1037 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1038 | action->addTo( helpMenu ); | 1038 | action->addTo( helpMenu ); |
1039 | connect( action, SIGNAL( activated() ), | 1039 | connect( action, SIGNAL( activated() ), |
1040 | SLOT( keyBindings() ) ); | 1040 | SLOT( keyBindings() ) ); |
1041 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1041 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1042 | action->addTo( helpMenu ); | 1042 | action->addTo( helpMenu ); |
1043 | connect( action, SIGNAL( activated() ), | 1043 | connect( action, SIGNAL( activated() ), |
1044 | SLOT( synchowto() ) ); | 1044 | SLOT( synchowto() ) ); |
1045 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1045 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1046 | action->addTo( helpMenu ); | 1046 | action->addTo( helpMenu ); |
1047 | connect( action, SIGNAL( activated() ), | 1047 | connect( action, SIGNAL( activated() ), |
1048 | SLOT( kdesynchowto() ) ); | 1048 | SLOT( kdesynchowto() ) ); |
1049 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1049 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1050 | action->addTo( helpMenu ); | 1050 | action->addTo( helpMenu ); |
1051 | connect( action, SIGNAL( activated() ), | 1051 | connect( action, SIGNAL( activated() ), |
1052 | SLOT( multisynchowto() ) ); | 1052 | SLOT( multisynchowto() ) ); |
1053 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1053 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1054 | action->addTo( helpMenu ); | 1054 | action->addTo( helpMenu ); |
1055 | connect( action, SIGNAL( activated() ), | 1055 | connect( action, SIGNAL( activated() ), |
1056 | SLOT( aboutAutoSaving() ) ); | 1056 | SLOT( aboutAutoSaving() ) ); |
1057 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1057 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1058 | action->addTo( helpMenu ); | 1058 | action->addTo( helpMenu ); |
1059 | connect( action, SIGNAL( activated() ), | 1059 | connect( action, SIGNAL( activated() ), |
1060 | SLOT( aboutKnownBugs() ) ); | 1060 | SLOT( aboutKnownBugs() ) ); |
1061 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1061 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1062 | action->addTo( helpMenu ); | 1062 | action->addTo( helpMenu ); |
1063 | connect( action, SIGNAL( activated() ), | 1063 | connect( action, SIGNAL( activated() ), |
1064 | SLOT( usertrans() ) ); | 1064 | SLOT( usertrans() ) ); |
1065 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1065 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1066 | action->addTo( helpMenu ); | 1066 | action->addTo( helpMenu ); |
1067 | connect( action, SIGNAL( activated() ), | 1067 | connect( action, SIGNAL( activated() ), |
1068 | SLOT( faq() ) ); | 1068 | SLOT( faq() ) ); |
1069 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1069 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1070 | action->addTo( helpMenu ); | 1070 | action->addTo( helpMenu ); |
1071 | connect( action, SIGNAL( activated() ), | 1071 | connect( action, SIGNAL( activated() ), |
1072 | SLOT( licence() ) ); | 1072 | SLOT( licence() ) ); |
1073 | action = new QAction( "about", i18n("About..."), 0, this ); | 1073 | action = new QAction( "about", i18n("About..."), 0, this ); |
1074 | action->addTo( helpMenu ); | 1074 | action->addTo( helpMenu ); |
1075 | connect( action, SIGNAL( activated() ), | 1075 | connect( action, SIGNAL( activated() ), |
1076 | SLOT( about() ) ); | 1076 | SLOT( about() ) ); |
1077 | //menuBar->insertSeparator(); | 1077 | //menuBar->insertSeparator(); |
1078 | 1078 | ||
1079 | // ****************************************************** | 1079 | // ****************************************************** |
1080 | // menubar icons | 1080 | // menubar icons |
1081 | 1081 | ||
1082 | 1082 | ||
1083 | 1083 | ||
1084 | //menuBar->insertItem( iconToolBar ); | 1084 | //menuBar->insertItem( iconToolBar ); |
1085 | //xdays_action | 1085 | //xdays_action |
1086 | if (p-> mShowIconNewEvent) | 1086 | if (p-> mShowIconNewEvent) |
1087 | ne_action->addTo( iconToolBar ); | 1087 | ne_action->addTo( iconToolBar ); |
1088 | if (p->mShowIconNewTodo ) | 1088 | if (p->mShowIconNewTodo ) |
1089 | nt_action->addTo( iconToolBar ); | 1089 | nt_action->addTo( iconToolBar ); |
1090 | if (p-> mShowIconSearch) | 1090 | if (p-> mShowIconSearch) |
1091 | search_action->addTo( iconToolBar ); | 1091 | search_action->addTo( iconToolBar ); |
1092 | if (p-> mShowIconWhatsThis) | 1092 | if (p-> mShowIconWhatsThis) |
1093 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1093 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1094 | if (p-> mShowIconNext) | 1094 | if (p-> mShowIconNext) |
1095 | whatsnext_action->addTo( viewToolBar ); | 1095 | whatsnext_action->addTo( viewToolBar ); |
1096 | if (p-> mShowIconNextDays) | 1096 | if (p-> mShowIconNextDays) |
1097 | xdays_action->addTo( viewToolBar ); | 1097 | xdays_action->addTo( viewToolBar ); |
1098 | if (p-> mShowIconJournal) | 1098 | if (p-> mShowIconJournal) |
1099 | viewjournal_action->addTo( viewToolBar ); | 1099 | viewjournal_action->addTo( viewToolBar ); |
1100 | if (p-> mShowIconDay1) | 1100 | if (p-> mShowIconDay1) |
1101 | day1_action->addTo( viewToolBar ); | 1101 | day1_action->addTo( viewToolBar ); |
1102 | if (p-> mShowIconDay5) | 1102 | if (p-> mShowIconDay5) |
1103 | day5_action->addTo( viewToolBar ); | 1103 | day5_action->addTo( viewToolBar ); |
1104 | if (p-> mShowIconDay7) | 1104 | if (p-> mShowIconDay7) |
1105 | day7_action->addTo( viewToolBar ); | 1105 | day7_action->addTo( viewToolBar ); |
1106 | if (p-> mShowIconDay6) | 1106 | if (p-> mShowIconDay6) |
1107 | day6_action->addTo( viewToolBar ); | 1107 | day6_action->addTo( viewToolBar ); |
1108 | if (p-> mShowIconMonth) | 1108 | if (p-> mShowIconMonth) |
1109 | month_action->addTo( viewToolBar ); | 1109 | month_action->addTo( viewToolBar ); |
1110 | if (p-> mShowIconList) | 1110 | if (p-> mShowIconList) |
1111 | showlist_action->addTo( viewToolBar ); | 1111 | showlist_action->addTo( viewToolBar ); |
1112 | if (p-> mShowIconTodoview) | 1112 | if (p-> mShowIconTodoview) |
1113 | todoview_action->addTo( viewToolBar ); | 1113 | todoview_action->addTo( viewToolBar ); |
1114 | 1114 | ||
1115 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1115 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1116 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1116 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1117 | if (p-> mShowIconBackFast) { | 1117 | if (p-> mShowIconBackFast) { |
1118 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1118 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1119 | connect( action, SIGNAL( activated() ), | 1119 | connect( action, SIGNAL( activated() ), |
1120 | mView, SLOT( goPreviousMonth() ) ); | 1120 | mView, SLOT( goPreviousMonth() ) ); |
1121 | action->addTo( navigatorToolBar ); | 1121 | action->addTo( navigatorToolBar ); |
1122 | } | 1122 | } |
1123 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1123 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1124 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1124 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1125 | if (p-> mShowIconBack) { | 1125 | if (p-> mShowIconBack) { |
1126 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1126 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1127 | connect( action, SIGNAL( activated() ), | 1127 | connect( action, SIGNAL( activated() ), |
1128 | mView, SLOT( goPrevious() ) ); | 1128 | mView, SLOT( goPrevious() ) ); |
1129 | action->addTo( navigatorToolBar ); | 1129 | action->addTo( navigatorToolBar ); |
1130 | } | 1130 | } |
1131 | icon = loadPixmap( pathString + "today" ); | 1131 | icon = loadPixmap( pathString + "today" ); |
1132 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1132 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1133 | if (p-> mShowIconToday) | 1133 | if (p-> mShowIconToday) |
1134 | today_action->addTo( navigatorToolBar ); | 1134 | today_action->addTo( navigatorToolBar ); |
1135 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1135 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1136 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1136 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1137 | if (p-> mShowIconForward) { | 1137 | if (p-> mShowIconForward) { |
1138 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1138 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1139 | connect( action, SIGNAL( activated() ), | 1139 | connect( action, SIGNAL( activated() ), |
1140 | mView, SLOT( goNext() ) ); | 1140 | mView, SLOT( goNext() ) ); |
1141 | action->addTo( navigatorToolBar ); | 1141 | action->addTo( navigatorToolBar ); |
1142 | } | 1142 | } |
1143 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1143 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1144 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1144 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1145 | if (p-> mShowIconForwardFast) { | 1145 | if (p-> mShowIconForwardFast) { |
1146 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1146 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1147 | connect( action, SIGNAL( activated() ), | 1147 | connect( action, SIGNAL( activated() ), |
1148 | mView, SLOT( goNextMonth() ) ); | 1148 | mView, SLOT( goNextMonth() ) ); |
1149 | action->addTo( navigatorToolBar ); | 1149 | action->addTo( navigatorToolBar ); |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1153 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1154 | 1154 | ||
1155 | if (p-> mShowIconNewEvent) | 1155 | if (p-> mShowIconNewEvent) |
1156 | configureToolBarMenu->setItemChecked( 10, true ); | 1156 | configureToolBarMenu->setItemChecked( 10, true ); |
1157 | if (p->mShowIconNewTodo ) | 1157 | if (p->mShowIconNewTodo ) |
1158 | configureToolBarMenu->setItemChecked( 20, true ); | 1158 | configureToolBarMenu->setItemChecked( 20, true ); |
1159 | if (p-> mShowIconSearch) | 1159 | if (p-> mShowIconSearch) |
1160 | configureToolBarMenu->setItemChecked( 120, true ); | 1160 | configureToolBarMenu->setItemChecked( 120, true ); |
1161 | if (p-> mShowIconList) | 1161 | if (p-> mShowIconList) |
1162 | configureToolBarMenu->setItemChecked( 30, true ); | 1162 | configureToolBarMenu->setItemChecked( 30, true ); |
1163 | if (p-> mShowIconDay1) | 1163 | if (p-> mShowIconDay1) |
1164 | configureToolBarMenu->setItemChecked( 40, true ); | 1164 | configureToolBarMenu->setItemChecked( 40, true ); |
1165 | if (p-> mShowIconDay5) | 1165 | if (p-> mShowIconDay5) |
1166 | configureToolBarMenu->setItemChecked( 50, true ); | 1166 | configureToolBarMenu->setItemChecked( 50, true ); |
1167 | if (p-> mShowIconDay6) | 1167 | if (p-> mShowIconDay6) |
1168 | configureToolBarMenu->setItemChecked( 75, true ); | 1168 | configureToolBarMenu->setItemChecked( 75, true ); |
1169 | if (p-> mShowIconDay7) | 1169 | if (p-> mShowIconDay7) |
1170 | configureToolBarMenu->setItemChecked( 60, true ); | 1170 | configureToolBarMenu->setItemChecked( 60, true ); |
1171 | if (p-> mShowIconMonth) | 1171 | if (p-> mShowIconMonth) |
1172 | configureToolBarMenu->setItemChecked( 70, true ); | 1172 | configureToolBarMenu->setItemChecked( 70, true ); |
1173 | if (p-> mShowIconTodoview) | 1173 | if (p-> mShowIconTodoview) |
1174 | configureToolBarMenu->setItemChecked( 80, true ); | 1174 | configureToolBarMenu->setItemChecked( 80, true ); |
1175 | if (p-> mShowIconBackFast) | 1175 | if (p-> mShowIconBackFast) |
1176 | configureToolBarMenu->setItemChecked( 200, true ); | 1176 | configureToolBarMenu->setItemChecked( 200, true ); |
1177 | if (p-> mShowIconBack) | 1177 | if (p-> mShowIconBack) |
1178 | configureToolBarMenu->setItemChecked( 210, true ); | 1178 | configureToolBarMenu->setItemChecked( 210, true ); |
1179 | if (p-> mShowIconToday) | 1179 | if (p-> mShowIconToday) |
1180 | configureToolBarMenu->setItemChecked( 130, true ); | 1180 | configureToolBarMenu->setItemChecked( 130, true ); |
1181 | if (p-> mShowIconForward) | 1181 | if (p-> mShowIconForward) |
1182 | configureToolBarMenu->setItemChecked( 220, true ); | 1182 | configureToolBarMenu->setItemChecked( 220, true ); |
1183 | if (p-> mShowIconForwardFast) | 1183 | if (p-> mShowIconForwardFast) |
1184 | configureToolBarMenu->setItemChecked( 230, true ); | 1184 | configureToolBarMenu->setItemChecked( 230, true ); |
1185 | if (p-> mShowIconNextDays) | 1185 | if (p-> mShowIconNextDays) |
1186 | configureToolBarMenu->setItemChecked( 100, true ); | 1186 | configureToolBarMenu->setItemChecked( 100, true ); |
1187 | if (p-> mShowIconNext) | 1187 | if (p-> mShowIconNext) |
1188 | configureToolBarMenu->setItemChecked( 110, true ); | 1188 | configureToolBarMenu->setItemChecked( 110, true ); |
1189 | if (p-> mShowIconJournal) | 1189 | if (p-> mShowIconJournal) |
1190 | configureToolBarMenu->setItemChecked( 90, true ); | 1190 | configureToolBarMenu->setItemChecked( 90, true ); |
1191 | if (p-> mShowIconWhatsThis) | 1191 | if (p-> mShowIconWhatsThis) |
1192 | configureToolBarMenu->setItemChecked( 300, true ); | 1192 | configureToolBarMenu->setItemChecked( 300, true ); |
1193 | if (p-> mShowIconWeekNum) | 1193 | if (p-> mShowIconWeekNum) |
1194 | configureToolBarMenu->setItemChecked( 400, true ); | 1194 | configureToolBarMenu->setItemChecked( 400, true ); |
1195 | if (!p-> mShowIconStretch) { | 1195 | if (!p-> mShowIconStretch) { |
1196 | QLabel* dummy = new QLabel( iconToolBar ); | 1196 | QLabel* dummy = new QLabel( iconToolBar ); |
1197 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1197 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1198 | dummy->setMinimumWidth( 0 ); | 1198 | dummy->setMinimumWidth( 0 ); |
1199 | iconToolBar->setStretchableWidget ( dummy ) ; | 1199 | iconToolBar->setStretchableWidget ( dummy ) ; |
1200 | } | 1200 | } |
1201 | else { | 1201 | else { |
1202 | iconToolBar->setHorizontalStretchable (true ); | 1202 | iconToolBar->setHorizontalStretchable (true ); |
1203 | viewToolBar->setHorizontalStretchable (true ); | 1203 | viewToolBar->setHorizontalStretchable (true ); |
1204 | navigatorToolBar->setHorizontalStretchable (true ); | 1204 | navigatorToolBar->setHorizontalStretchable (true ); |
1205 | iconToolBar->setVerticalStretchable (true ); | 1205 | iconToolBar->setVerticalStretchable (true ); |
1206 | viewToolBar->setVerticalStretchable (true ); | 1206 | viewToolBar->setVerticalStretchable (true ); |
1207 | navigatorToolBar->setVerticalStretchable (true ); | 1207 | navigatorToolBar->setVerticalStretchable (true ); |
1208 | configureToolBarMenu->setItemChecked( 5, true ); | 1208 | configureToolBarMenu->setItemChecked( 5, true ); |
1209 | } | 1209 | } |
1210 | if (p-> mShowIconFilter) | 1210 | if (p-> mShowIconFilter) |
1211 | configureToolBarMenu->setItemChecked( 7, true ); | 1211 | configureToolBarMenu->setItemChecked( 7, true ); |
1212 | if (p-> mShowIconOnetoolbar) | 1212 | if (p-> mShowIconOnetoolbar) |
1213 | configureToolBarMenu->setItemChecked( 6, true ); | 1213 | configureToolBarMenu->setItemChecked( 6, true ); |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | if ( filterMenubar ) | 1216 | if ( filterMenubar ) |
1217 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); | 1217 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); |
1218 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1218 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1219 | configureAgenda( p->mHourSize ); | 1219 | configureAgenda( p->mHourSize ); |
1220 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1220 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | void MainWindow::exportToPhone( int mode ) | 1223 | void MainWindow::exportToPhone( int mode ) |
1224 | { | 1224 | { |
1225 | 1225 | ||
1226 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1226 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1227 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1227 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1228 | KOex2phonePrefs ex2phone; | 1228 | KOex2phonePrefs ex2phone; |
1229 | 1229 | ||
1230 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1230 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1231 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1231 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1232 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1232 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1233 | if ( mode == 1 ) | 1233 | if ( mode == 1 ) |
1234 | ex2phone.setCaption(i18n("Export complete calendar")); | 1234 | ex2phone.setCaption(i18n("Export complete calendar")); |
1235 | if ( mode == 2 ) | 1235 | if ( mode == 2 ) |
1236 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1236 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1237 | 1237 | ||
1238 | if ( !ex2phone.exec() ) { | 1238 | if ( !ex2phone.exec() ) { |
1239 | return; | 1239 | return; |
1240 | } | 1240 | } |
1241 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1241 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1242 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1242 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1243 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1243 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1244 | 1244 | ||
1245 | int inFuture = 0; | 1245 | int inFuture = 0; |
1246 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1246 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1247 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1247 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1248 | QPtrList<Incidence> delSel; | 1248 | QPtrList<Incidence> delSel; |
1249 | if ( mode == 1 ) | 1249 | if ( mode == 1 ) |
1250 | delSel = mCalendar->rawIncidences(); | 1250 | delSel = mCalendar->rawIncidences(); |
1251 | if ( mode == 2 ) | 1251 | if ( mode == 2 ) |
1252 | delSel = mCalendar->incidences(); | 1252 | delSel = mCalendar->incidences(); |
1253 | CalendarLocal* cal = new CalendarLocal(); | 1253 | CalendarLocal* cal = new CalendarLocal(); |
1254 | cal->setLocalTime(); | 1254 | cal->setLocalTime(); |
1255 | Incidence *incidence = delSel.first(); | 1255 | Incidence *incidence = delSel.first(); |
1256 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1256 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1257 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1257 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1258 | while ( incidence ) { | 1258 | while ( incidence ) { |
1259 | if ( incidence->type() != "Journal" ) { | 1259 | if ( incidence->type() != "Journal" ) { |
1260 | bool add = true; | 1260 | bool add = true; |
1261 | if ( inFuture ) { | 1261 | if ( inFuture ) { |
1262 | QDateTime dt; | 1262 | QDateTime dt; |
1263 | if ( incidence->type() == "Todo" ) { | 1263 | if ( incidence->type() == "Todo" ) { |
1264 | Todo * t = (Todo*)incidence; | 1264 | Todo * t = (Todo*)incidence; |
1265 | if ( t->hasDueDate() ) | 1265 | if ( t->hasDueDate() ) |
1266 | dt = t->dtDue(); | 1266 | dt = t->dtDue(); |
1267 | else | 1267 | else |
1268 | dt = cur.addSecs( 62 ); | 1268 | dt = cur.addSecs( 62 ); |
1269 | } | 1269 | } |
1270 | else { | 1270 | else { |
1271 | bool ok; | 1271 | bool ok; |
1272 | dt = incidence->getNextOccurence( cur, &ok ); | 1272 | dt = incidence->getNextOccurence( cur, &ok ); |
1273 | if ( !ok ) | 1273 | if ( !ok ) |
1274 | dt = cur.addSecs( -62 ); | 1274 | dt = cur.addSecs( -62 ); |
1275 | } | 1275 | } |
1276 | if ( dt < cur || dt > end ) { | 1276 | if ( dt < cur || dt > end ) { |
1277 | add = false; | 1277 | add = false; |
1278 | } | 1278 | } |
1279 | } | 1279 | } |
1280 | if ( add ) { | 1280 | if ( add ) { |
1281 | Incidence *in = incidence->clone(); | 1281 | Incidence *in = incidence->clone(); |
1282 | cal->addIncidence( in ); | 1282 | cal->addIncidence( in ); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | incidence = delSel.next(); | 1285 | incidence = delSel.next(); |
1286 | } | 1286 | } |
1287 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1287 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1288 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1288 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1289 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1289 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1290 | 1290 | ||
1291 | setCaption( i18n("Writing to phone...")); | 1291 | setCaption( i18n("Writing to phone...")); |
1292 | if ( PhoneFormat::writeToPhone( cal ) ) | 1292 | if ( PhoneFormat::writeToPhone( cal ) ) |
1293 | setCaption( i18n("Export to phone successful!")); | 1293 | setCaption( i18n("Export to phone successful!")); |
1294 | else | 1294 | else |
1295 | setCaption( i18n("Error exporting to phone!")); | 1295 | setCaption( i18n("Error exporting to phone!")); |
1296 | delete cal; | 1296 | delete cal; |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | void MainWindow::setDefaultPreferences() | 1300 | void MainWindow::setDefaultPreferences() |
1301 | { | 1301 | { |
1302 | KOPrefs *p = KOPrefs::instance(); | 1302 | KOPrefs *p = KOPrefs::instance(); |
1303 | 1303 | ||
1304 | p->mCompactDialogs = true; | 1304 | p->mCompactDialogs = true; |
1305 | p->mConfirm = true; | 1305 | p->mConfirm = true; |
1306 | // p->mEnableQuickTodo = false; | 1306 | // p->mEnableQuickTodo = false; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | QString MainWindow::resourcePath() | 1310 | QString MainWindow::resourcePath() |
1311 | { | 1311 | { |
1312 | return KGlobal::iconLoader()->iconPath(); | 1312 | return KGlobal::iconLoader()->iconPath(); |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | void MainWindow::displayText( QString text ,QString cap ) | 1315 | void MainWindow::displayText( QString text ,QString cap ) |
1316 | { | 1316 | { |
1317 | QDialog dia( this, "name", true ); ; | 1317 | QDialog dia( this, "name", true ); ; |
1318 | dia.setCaption( cap ); | 1318 | dia.setCaption( cap ); |
1319 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1319 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1320 | lay->setSpacing( 3 ); | 1320 | lay->setSpacing( 3 ); |
1321 | lay->setMargin( 3 ); | 1321 | lay->setMargin( 3 ); |
1322 | QTextBrowser tb ( &dia ); | 1322 | QTextBrowser tb ( &dia ); |
1323 | lay->addWidget( &tb ); | 1323 | lay->addWidget( &tb ); |
1324 | tb.setText( text ); | 1324 | tb.setText( text ); |
1325 | #ifdef DESKTOP_VERSION | 1325 | #ifdef DESKTOP_VERSION |
1326 | dia.resize( 640, 480); | 1326 | dia.resize( 640, 480); |
1327 | #else | 1327 | #else |
1328 | dia.showMaximized(); | 1328 | dia.showMaximized(); |
1329 | #endif | 1329 | #endif |
1330 | dia.exec(); | 1330 | dia.exec(); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | void MainWindow::features() | 1333 | void MainWindow::features() |
1334 | { | 1334 | { |
1335 | 1335 | ||
1336 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1336 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | void MainWindow::usertrans() | 1339 | void MainWindow::usertrans() |
1340 | { | 1340 | { |
1341 | 1341 | ||
1342 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1342 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | void MainWindow::kdesynchowto() | 1345 | void MainWindow::kdesynchowto() |
1346 | { | 1346 | { |
1347 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1347 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1348 | } | 1348 | } |
1349 | void MainWindow::multisynchowto() | 1349 | void MainWindow::multisynchowto() |
1350 | { | 1350 | { |
1351 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1351 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1352 | } | 1352 | } |
1353 | void MainWindow::synchowto() | 1353 | void MainWindow::synchowto() |
1354 | { | 1354 | { |
1355 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1355 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1356 | } | 1356 | } |
1357 | void MainWindow::faq() | 1357 | void MainWindow::faq() |
1358 | { | 1358 | { |
1359 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1359 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1360 | 1360 | ||
1361 | } | 1361 | } |
1362 | void MainWindow::whatsNew() | 1362 | void MainWindow::whatsNew() |
1363 | { | 1363 | { |
1364 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1364 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1365 | 1365 | ||
1366 | } | 1366 | } |
1367 | void MainWindow::licence() | 1367 | void MainWindow::licence() |
1368 | { | 1368 | { |
1369 | KApplication::showLicence(); | 1369 | KApplication::showLicence(); |
1370 | 1370 | ||
1371 | } | 1371 | } |
1372 | void MainWindow::about() | 1372 | void MainWindow::about() |
1373 | { | 1373 | { |
1374 | QString version; | 1374 | QString version; |
1375 | #include <../version> | 1375 | #include <../version> |
1376 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1376 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1377 | i18n("KOrganizer/Platform-independent\n") + | 1377 | i18n("KOrganizer/Platform-independent\n") + |
1378 | "(KO/Pi) " + version + " - " + | 1378 | "(KO/Pi) " + version + " - " + |
1379 | 1379 | ||
1380 | #ifdef DESKTOP_VERSION | 1380 | #ifdef DESKTOP_VERSION |
1381 | i18n("Desktop Edition\n") + | 1381 | i18n("Desktop Edition\n") + |
1382 | #else | 1382 | #else |
1383 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1383 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1384 | #endif | 1384 | #endif |
1385 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); | 1385 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); |
1386 | } | 1386 | } |
1387 | void MainWindow::keyBindings() | 1387 | void MainWindow::keyBindings() |
1388 | { | 1388 | { |
1389 | QString cap = i18n("KO/Pi Keys + Colors"); | 1389 | QString cap = i18n("KO/Pi Keys + Colors"); |
1390 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1390 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1391 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1391 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1392 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1392 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1393 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1393 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1394 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1394 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1395 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1395 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1396 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1396 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1397 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1397 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1398 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1398 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1399 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1399 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1400 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1400 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1401 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1401 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1402 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1402 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1403 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1403 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1404 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1404 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1405 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1405 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1406 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1406 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1407 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1407 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1408 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1408 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1409 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1409 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1410 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1410 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1411 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1411 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1412 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1412 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1413 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1413 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1414 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1414 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1415 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1415 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1416 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1416 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1417 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1417 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1418 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1418 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1419 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1419 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1420 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1420 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1421 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1421 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1422 | i18n("<p><h3>In list view:</h3></p>\n") + | 1422 | i18n("<p><h3>In list view:</h3></p>\n") + |
1423 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1423 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1424 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1424 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1425 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1425 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1426 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1426 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1427 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1427 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1428 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1428 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1429 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1429 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1430 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1430 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1431 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1431 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1432 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1432 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1433 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1433 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1434 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1434 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1435 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1435 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1436 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1436 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1437 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1437 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1438 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1438 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1439 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1439 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1440 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1440 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1441 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1441 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1442 | displayText( text, cap); | 1442 | displayText( text, cap); |
1443 | } | 1443 | } |
1444 | void MainWindow::aboutAutoSaving() | 1444 | void MainWindow::aboutAutoSaving() |
1445 | { | 1445 | { |
1446 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1446 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1447 | 1447 | ||
1448 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1448 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1449 | 1449 | ||
1450 | } | 1450 | } |
1451 | void MainWindow::aboutKnownBugs() | 1451 | void MainWindow::aboutKnownBugs() |
1452 | { | 1452 | { |
1453 | QMessageBox* msg; | 1453 | QMessageBox* msg; |
1454 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1454 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1455 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1455 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1456 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1456 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1457 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1457 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1458 | i18n("\nor report them in the bugtracker on\n") + | 1458 | i18n("\nor report them in the bugtracker on\n") + |
1459 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1459 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1460 | QMessageBox::NoIcon, | 1460 | QMessageBox::NoIcon, |
1461 | QMessageBox::Ok, | 1461 | QMessageBox::Ok, |
1462 | QMessageBox::NoButton, | 1462 | QMessageBox::NoButton, |
1463 | QMessageBox::NoButton); | 1463 | QMessageBox::NoButton); |
1464 | msg->exec(); | 1464 | msg->exec(); |
1465 | delete msg; | 1465 | delete msg; |
1466 | 1466 | ||
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | QString MainWindow::defaultFileName() | 1469 | QString MainWindow::defaultFileName() |
1470 | { | 1470 | { |
1471 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1471 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1472 | } | 1472 | } |
1473 | QString MainWindow::syncFileName() | 1473 | QString MainWindow::syncFileName() |
1474 | { | 1474 | { |
1475 | #ifdef DESKTOP_VERSION | 1475 | #ifdef DESKTOP_VERSION |
1476 | return locateLocal( "tmp", "synccalendar.ics" ); | 1476 | return locateLocal( "tmp", "synccalendar.ics" ); |
1477 | #else | 1477 | #else |
1478 | return QString( "/tmp/synccalendar.ics" ); | 1478 | return QString( "/tmp/synccalendar.ics" ); |
1479 | #endif | 1479 | #endif |
1480 | } | 1480 | } |
1481 | #include "koglobals.h" | ||
1482 | #include <kcalendarsystem.h> | ||
1481 | void MainWindow::updateWeek(QDate seda) | 1483 | void MainWindow::updateWeek(QDate seda) |
1482 | { | 1484 | { |
1483 | int weekNum = 0; | 1485 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1484 | QDate d = QDate ( seda.year(), 1,1); | ||
1485 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | ||
1486 | if ( seda.addDays(6).year() != seda.year() ) { | ||
1487 | if ( seda.year() != d.year() ) { | ||
1488 | if ( d.dayOfWeek() > 4 ) | ||
1489 | d = QDate ( seda.year(), 1,1); | ||
1490 | else | ||
1491 | weekNum = 1; | ||
1492 | } else { | ||
1493 | QDate dd( seda.year()+1, 1,1); | ||
1494 | if ( dd.dayOfWeek() <= 4 ) | ||
1495 | weekNum = 1; | ||
1496 | } | ||
1497 | } | ||
1498 | if ( weekNum == 0 ){ | ||
1499 | int dow = d.dayOfWeek(); | ||
1500 | if ( dow <= 4 ) | ||
1501 | d = d.addDays( 1-dow ); | ||
1502 | else // 5,6,7 | ||
1503 | d = d.addDays( 8-dow ); | ||
1504 | // we have the first week of the year.we are on monday | ||
1505 | weekNum = d.daysTo( seda ) / 7 +1; | ||
1506 | } | ||
1507 | |||
1508 | mWeekPixmap.fill( mWeekBgColor ); | 1486 | mWeekPixmap.fill( mWeekBgColor ); |
1509 | QPainter p ( &mWeekPixmap ); | 1487 | QPainter p ( &mWeekPixmap ); |
1510 | p.setFont( mWeekFont ); | 1488 | p.setFont( mWeekFont ); |
1511 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1489 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1512 | p.end(); | 1490 | p.end(); |
1513 | QIconSet icon3 ( mWeekPixmap ); | 1491 | QIconSet icon3 ( mWeekPixmap ); |
1514 | mWeekAction->setIconSet ( icon3 ); | 1492 | mWeekAction->setIconSet ( icon3 ); |
1515 | 1493 | ||
1516 | } | 1494 | } |
1517 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1495 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1518 | { | 1496 | { |
1519 | updateWeek( selectedDates.first() ); | 1497 | updateWeek( selectedDates.first() ); |
1520 | } | 1498 | } |
1521 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1499 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1522 | { | 1500 | { |
1523 | 1501 | ||
1524 | if ( !incidence ) { | 1502 | if ( !incidence ) { |
1525 | enableIncidenceActions( false ); | 1503 | enableIncidenceActions( false ); |
1526 | 1504 | ||
1527 | mNewSubTodoAction->setEnabled( false ); | 1505 | mNewSubTodoAction->setEnabled( false ); |
1528 | setCaptionToDates(); | 1506 | setCaptionToDates(); |
1529 | return; | 1507 | return; |
1530 | 1508 | ||
1531 | } | 1509 | } |
1532 | 1510 | ||
1533 | //KGlobal::locale()->formatDateTime(nextA, true); | 1511 | //KGlobal::locale()->formatDateTime(nextA, true); |
1534 | QString startString = ""; | 1512 | QString startString = ""; |
1535 | if ( incidence->type() != "Todo" ) { | 1513 | if ( incidence->type() != "Todo" ) { |
1536 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1514 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1537 | if ( incidence->doesFloat() ) { | 1515 | if ( incidence->doesFloat() ) { |
1538 | startString += ": "+incidence->dtStartDateStr( true ); | 1516 | startString += ": "+incidence->dtStartDateStr( true ); |
1539 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1517 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1540 | 1518 | ||
1541 | } else { | 1519 | } else { |
1542 | startString = ": "+incidence->dtStartStr(true); | 1520 | startString = ": "+incidence->dtStartStr(true); |
1543 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1521 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1544 | 1522 | ||
1545 | } | 1523 | } |
1546 | 1524 | ||
1547 | } else { | 1525 | } else { |
1548 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1526 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1549 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1527 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1550 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1528 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1551 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { | 1529 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { |
1552 | bool ok; | 1530 | bool ok; |
1553 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1531 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1554 | if ( ok ) { | 1532 | if ( ok ) { |
1555 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1533 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1556 | startString += i18n(" (%1 y.)"). arg( years ); | 1534 | startString += i18n(" (%1 y.)"). arg( years ); |
1557 | } | 1535 | } |
1558 | } | 1536 | } |
1559 | else | 1537 | else |
1560 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1538 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1561 | } | 1539 | } |
1562 | 1540 | ||
1563 | } | 1541 | } |
1564 | else | 1542 | else |
1565 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1543 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1566 | if ( !incidence->location().isEmpty() ) | 1544 | if ( !incidence->location().isEmpty() ) |
1567 | startString += " (" +incidence->location()+")"; | 1545 | startString += " (" +incidence->location()+")"; |
1568 | setCaption( incidence->summary()+startString); | 1546 | setCaption( incidence->summary()+startString); |
1569 | 1547 | ||
1570 | enableIncidenceActions( true ); | 1548 | enableIncidenceActions( true ); |
1571 | 1549 | ||
1572 | if ( incidence->type() == "Event" ) { | 1550 | if ( incidence->type() == "Event" ) { |
1573 | mShowAction->setText( i18n("Show Event...") ); | 1551 | mShowAction->setText( i18n("Show Event...") ); |
1574 | mEditAction->setText( i18n("Edit Event...") ); | 1552 | mEditAction->setText( i18n("Edit Event...") ); |
1575 | mDeleteAction->setText( i18n("Delete Event...") ); | 1553 | mDeleteAction->setText( i18n("Delete Event...") ); |
1576 | 1554 | ||
1577 | mNewSubTodoAction->setEnabled( false ); | 1555 | mNewSubTodoAction->setEnabled( false ); |
1578 | } else if ( incidence->type() == "Todo" ) { | 1556 | } else if ( incidence->type() == "Todo" ) { |
1579 | mShowAction->setText( i18n("Show Todo...") ); | 1557 | mShowAction->setText( i18n("Show Todo...") ); |
1580 | mEditAction->setText( i18n("Edit Todo...") ); | 1558 | mEditAction->setText( i18n("Edit Todo...") ); |
1581 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1559 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1582 | 1560 | ||
1583 | mNewSubTodoAction->setEnabled( true ); | 1561 | mNewSubTodoAction->setEnabled( true ); |
1584 | } else { | 1562 | } else { |
1585 | mShowAction->setText( i18n("Show...") ); | 1563 | mShowAction->setText( i18n("Show...") ); |
1586 | mShowAction->setText( i18n("Edit...") ); | 1564 | mShowAction->setText( i18n("Edit...") ); |
1587 | mShowAction->setText( i18n("Delete...") ); | 1565 | mShowAction->setText( i18n("Delete...") ); |
1588 | 1566 | ||
1589 | mNewSubTodoAction->setEnabled( false ); | 1567 | mNewSubTodoAction->setEnabled( false ); |
1590 | } | 1568 | } |
1591 | } | 1569 | } |
1592 | 1570 | ||
1593 | void MainWindow::enableIncidenceActions( bool enabled ) | 1571 | void MainWindow::enableIncidenceActions( bool enabled ) |
1594 | { | 1572 | { |
1595 | mShowAction->setEnabled( enabled ); | 1573 | mShowAction->setEnabled( enabled ); |
1596 | mEditAction->setEnabled( enabled ); | 1574 | mEditAction->setEnabled( enabled ); |
1597 | mDeleteAction->setEnabled( enabled ); | 1575 | mDeleteAction->setEnabled( enabled ); |
1598 | 1576 | ||
1599 | mCloneAction->setEnabled( enabled ); | 1577 | mCloneAction->setEnabled( enabled ); |
1600 | mMoveAction->setEnabled( enabled ); | 1578 | mMoveAction->setEnabled( enabled ); |
1601 | mBeamAction->setEnabled( enabled ); | 1579 | mBeamAction->setEnabled( enabled ); |
1602 | mCancelAction->setEnabled( enabled ); | 1580 | mCancelAction->setEnabled( enabled ); |
1603 | } | 1581 | } |
1604 | 1582 | ||
1605 | void MainWindow::importOL() | 1583 | void MainWindow::importOL() |
1606 | { | 1584 | { |
1607 | #ifdef _OL_IMPORT_ | 1585 | #ifdef _OL_IMPORT_ |
1608 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1586 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1609 | id->exec(); | 1587 | id->exec(); |
1610 | delete id; | 1588 | delete id; |
1611 | mView->updateView(); | 1589 | mView->updateView(); |
1612 | #endif | 1590 | #endif |
1613 | } | 1591 | } |
1614 | void MainWindow::importBday() | 1592 | void MainWindow::importBday() |
1615 | { | 1593 | { |
1616 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1594 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1617 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1595 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1618 | i18n("Import!"), i18n("Cancel"), 0, | 1596 | i18n("Import!"), i18n("Cancel"), 0, |
1619 | 0, 1 ); | 1597 | 0, 1 ); |
1620 | if ( result == 0 ) { | 1598 | if ( result == 0 ) { |
1621 | mView->importBday(); | 1599 | mView->importBday(); |
1622 | 1600 | ||
1623 | } | 1601 | } |
1624 | 1602 | ||
1625 | 1603 | ||
1626 | } | 1604 | } |
1627 | void MainWindow::importQtopia() | 1605 | void MainWindow::importQtopia() |
1628 | { | 1606 | { |
1629 | //#ifndef DESKTOP_VERSION | 1607 | //#ifndef DESKTOP_VERSION |
1630 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); | 1608 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); |
1631 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1632 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1610 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1633 | #endif | 1611 | #endif |
1634 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1612 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1635 | i18n("Import!"), i18n("Cancel"), 0, | 1613 | i18n("Import!"), i18n("Cancel"), 0, |
1636 | 0, 1 ); | 1614 | 0, 1 ); |
1637 | if ( result == 0 ) { | 1615 | if ( result == 0 ) { |
1638 | #ifndef DESKTOP_VERSION | 1616 | #ifndef DESKTOP_VERSION |
1639 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1617 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1640 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1618 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1641 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1619 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1642 | #else | 1620 | #else |
1643 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1621 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1644 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1622 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1645 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1623 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1646 | #endif | 1624 | #endif |
1647 | mView->importQtopia( categories, datebook, todolist ); | 1625 | mView->importQtopia( categories, datebook, todolist ); |
1648 | } | 1626 | } |
1649 | #if 0 | 1627 | #if 0 |
1650 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1628 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1651 | i18n("Not supported \non desktop!\n"), | 1629 | i18n("Not supported \non desktop!\n"), |
1652 | i18n("Ok"), i18n("Cancel"), 0, | 1630 | i18n("Ok"), i18n("Cancel"), 0, |
1653 | 0, 1 ); | 1631 | 0, 1 ); |
1654 | 1632 | ||
1655 | #endif | 1633 | #endif |
1656 | } | 1634 | } |
1657 | 1635 | ||
1658 | void MainWindow::saveOnClose() | 1636 | void MainWindow::saveOnClose() |
1659 | { | 1637 | { |
1660 | KOPrefs *p = KOPrefs::instance(); | 1638 | KOPrefs *p = KOPrefs::instance(); |
1661 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1639 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1662 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1640 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1663 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1641 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1664 | if ( filterToolBar ) { | 1642 | if ( filterToolBar ) { |
1665 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1643 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1666 | } | 1644 | } |
1667 | #ifdef DESKTOP_VERSION | 1645 | #ifdef DESKTOP_VERSION |
1668 | 1646 | ||
1669 | QPoint myP; | 1647 | QPoint myP; |
1670 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1648 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1671 | if ( p->mToolBarHor ) | 1649 | if ( p->mToolBarHor ) |
1672 | p->mToolBarUp = myP.y() > height()/2; | 1650 | p->mToolBarUp = myP.y() > height()/2; |
1673 | else | 1651 | else |
1674 | p->mToolBarUp = myP.x() > width()/2; | 1652 | p->mToolBarUp = myP.x() > width()/2; |
1675 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1653 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1676 | if ( p->mToolBarHorV ) | 1654 | if ( p->mToolBarHorV ) |
1677 | p->mToolBarUpV = myP.y() > height()/2; | 1655 | p->mToolBarUpV = myP.y() > height()/2; |
1678 | else | 1656 | else |
1679 | p->mToolBarUpV = myP.x() > width()/2 ; | 1657 | p->mToolBarUpV = myP.x() > width()/2 ; |
1680 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1658 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1681 | if ( p->mToolBarHorN ) | 1659 | if ( p->mToolBarHorN ) |
1682 | p->mToolBarUpN = myP.y() > height()/2; | 1660 | p->mToolBarUpN = myP.y() > height()/2; |
1683 | else | 1661 | else |
1684 | p->mToolBarUpN = myP.x() > width()/2 ; | 1662 | p->mToolBarUpN = myP.x() > width()/2 ; |
1685 | if ( filterToolBar ) { | 1663 | if ( filterToolBar ) { |
1686 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1664 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1687 | if ( p->mToolBarHorF ) | 1665 | if ( p->mToolBarHorF ) |
1688 | p->mToolBarUpF = myP.y() > height()/2; | 1666 | p->mToolBarUpF = myP.y() > height()/2; |
1689 | else | 1667 | else |
1690 | p->mToolBarUpF = myP.x() > width()/2 ; | 1668 | p->mToolBarUpF = myP.x() > width()/2 ; |
1691 | } | 1669 | } |
1692 | #else | 1670 | #else |
1693 | if ( p->mToolBarHor ) | 1671 | if ( p->mToolBarHor ) |
1694 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1672 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1695 | else | 1673 | else |
1696 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1674 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1697 | if ( p->mToolBarHorV ) | 1675 | if ( p->mToolBarHorV ) |
1698 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1676 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1699 | else | 1677 | else |
1700 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1678 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1701 | 1679 | ||
1702 | if ( p->mToolBarHorN ) | 1680 | if ( p->mToolBarHorN ) |
1703 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1681 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1704 | else | 1682 | else |
1705 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1683 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1706 | if ( filterToolBar ) { | 1684 | if ( filterToolBar ) { |
1707 | if ( p->mToolBarHorF ) | 1685 | if ( p->mToolBarHorF ) |
1708 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1686 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1709 | else | 1687 | else |
1710 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1688 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1711 | } | 1689 | } |
1712 | #endif | 1690 | #endif |
1713 | 1691 | ||
1714 | 1692 | ||
1715 | mView->writeSettings(); | 1693 | mView->writeSettings(); |
1716 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1694 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1717 | save(); | 1695 | save(); |
1718 | } | 1696 | } |
1719 | void MainWindow::slotModifiedChanged( bool changed ) | 1697 | void MainWindow::slotModifiedChanged( bool changed ) |
1720 | { | 1698 | { |
1721 | if ( mBlockAtStartup ) | 1699 | if ( mBlockAtStartup ) |
1722 | return; | 1700 | return; |
1723 | 1701 | ||
1724 | int msec; | 1702 | int msec; |
1725 | // we store the changes after 1 minute, | 1703 | // we store the changes after 1 minute, |
1726 | // and for safety reasons after 10 minutes again | 1704 | // and for safety reasons after 10 minutes again |
1727 | if ( !mSyncManager->blockSave() ) | 1705 | if ( !mSyncManager->blockSave() ) |
1728 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1706 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1729 | else | 1707 | else |
1730 | msec = 1000 * 600; | 1708 | msec = 1000 * 600; |
1731 | mSaveTimer.start( msec, true ); // 1 minute | 1709 | mSaveTimer.start( msec, true ); // 1 minute |
1732 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1710 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1733 | mCalendarModifiedFlag = true; | 1711 | mCalendarModifiedFlag = true; |
1734 | } | 1712 | } |
1735 | void MainWindow::saveStopTimer() | 1713 | void MainWindow::saveStopTimer() |
1736 | { | 1714 | { |
1737 | mSaveTimer.stop(); | 1715 | mSaveTimer.stop(); |
1738 | if (mSaveTimer.isActive() ) | 1716 | if (mSaveTimer.isActive() ) |
1739 | qDebug("ti active "); | 1717 | qDebug("ti active "); |
1740 | else | 1718 | else |
1741 | qDebug("KO: Save timer stopped"); | 1719 | qDebug("KO: Save timer stopped"); |
1742 | } | 1720 | } |
1743 | void MainWindow::save() | 1721 | void MainWindow::save() |
1744 | { | 1722 | { |
1745 | if ( !mCalendarModifiedFlag ) { | 1723 | if ( !mCalendarModifiedFlag ) { |
1746 | qDebug("KO: Calendar not modified. Nothing saved."); | 1724 | qDebug("KO: Calendar not modified. Nothing saved."); |
1747 | return; | 1725 | return; |
1748 | } | 1726 | } |
1749 | if ( mSyncManager->blockSave() ) | 1727 | if ( mSyncManager->blockSave() ) |
1750 | return; | 1728 | return; |
1751 | mSyncManager->setBlockSave(true); | 1729 | mSyncManager->setBlockSave(true); |
1752 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1730 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1753 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1731 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1754 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1732 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1755 | qDebug("KO: Start saving data to file!"); | 1733 | qDebug("KO: Start saving data to file!"); |
1756 | mView->saveCalendar( defaultFileName() ); | 1734 | mView->saveCalendar( defaultFileName() ); |
1757 | mCalendarModifiedFlag = false; | 1735 | mCalendarModifiedFlag = false; |
1758 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1736 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1759 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1737 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1760 | QString savemes; | 1738 | QString savemes; |
1761 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1739 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1762 | setCaption(savemes); | 1740 | setCaption(savemes); |
1763 | } else | 1741 | } else |
1764 | setCaption(i18n("Saving cancelled!")); | 1742 | setCaption(i18n("Saving cancelled!")); |
1765 | mSyncManager->setBlockSave( false ); | 1743 | mSyncManager->setBlockSave( false ); |
1766 | } | 1744 | } |
1767 | 1745 | ||
1768 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1746 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1769 | { | 1747 | { |
1770 | if ( !e->isAutoRepeat() ) { | 1748 | if ( !e->isAutoRepeat() ) { |
1771 | mFlagKeyPressed = false; | 1749 | mFlagKeyPressed = false; |
1772 | } | 1750 | } |
1773 | } | 1751 | } |
1774 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1752 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1775 | { | 1753 | { |
1776 | qApp->processEvents(); | 1754 | qApp->processEvents(); |
1777 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1755 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1778 | e->ignore(); | 1756 | e->ignore(); |
1779 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1757 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1780 | return; | 1758 | return; |
1781 | } | 1759 | } |
1782 | if (! e->isAutoRepeat() ) | 1760 | if (! e->isAutoRepeat() ) |
1783 | mFlagKeyPressed = true; | 1761 | mFlagKeyPressed = true; |
1784 | KOPrefs *p = KOPrefs::instance(); | 1762 | KOPrefs *p = KOPrefs::instance(); |
1785 | bool showSelectedDates = false; | 1763 | bool showSelectedDates = false; |
1786 | int size; | 1764 | int size; |
1787 | int pro = 0; | 1765 | int pro = 0; |
1788 | //qDebug("MainWindow::keyPressEvent "); | 1766 | //qDebug("MainWindow::keyPressEvent "); |
1789 | switch ( e->key() ) { | 1767 | switch ( e->key() ) { |
1790 | case Qt::Key_Right: | 1768 | case Qt::Key_Right: |
1791 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1769 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1792 | mView->goNextMonth(); | 1770 | mView->goNextMonth(); |
1793 | else | 1771 | else |
1794 | mView->goNext(); | 1772 | mView->goNext(); |
1795 | showSelectedDates = true; | 1773 | showSelectedDates = true; |
1796 | break; | 1774 | break; |
1797 | case Qt::Key_Left: | 1775 | case Qt::Key_Left: |
1798 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1776 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1799 | mView->goPreviousMonth(); | 1777 | mView->goPreviousMonth(); |
1800 | else | 1778 | else |
1801 | mView->goPrevious(); | 1779 | mView->goPrevious(); |
1802 | showSelectedDates = true; | 1780 | showSelectedDates = true; |
1803 | break; | 1781 | break; |
1804 | case Qt::Key_Down: | 1782 | case Qt::Key_Down: |
1805 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1783 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1806 | break; | 1784 | break; |
1807 | case Qt::Key_Up: | 1785 | case Qt::Key_Up: |
1808 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1786 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1809 | break; | 1787 | break; |
1810 | case Qt::Key_K: | 1788 | case Qt::Key_K: |
1811 | mView->viewManager()->showMonthViewWeek(); | 1789 | mView->viewManager()->showMonthViewWeek(); |
1812 | break; | 1790 | break; |
1813 | case Qt::Key_I: | 1791 | case Qt::Key_I: |
1814 | mView->showIncidence(); | 1792 | mView->showIncidence(); |
1815 | break; | 1793 | break; |
1816 | case Qt::Key_Delete: | 1794 | case Qt::Key_Delete: |
1817 | case Qt::Key_Backspace: | 1795 | case Qt::Key_Backspace: |
1818 | mView->deleteIncidence(); | 1796 | mView->deleteIncidence(); |
1819 | break; | 1797 | break; |
1820 | case Qt::Key_D: | 1798 | case Qt::Key_D: |
1821 | mView->viewManager()->showDayView(); | 1799 | mView->viewManager()->showDayView(); |
1822 | showSelectedDates = true; | 1800 | showSelectedDates = true; |
1823 | break; | 1801 | break; |
1824 | case Qt::Key_O: | 1802 | case Qt::Key_O: |
1825 | mView->toggleFilerEnabled( ); | 1803 | mView->toggleFilerEnabled( ); |
1826 | break; | 1804 | break; |
1827 | case Qt::Key_0: | 1805 | case Qt::Key_0: |
1828 | case Qt::Key_1: | 1806 | case Qt::Key_1: |
1829 | case Qt::Key_2: | 1807 | case Qt::Key_2: |
1830 | case Qt::Key_3: | 1808 | case Qt::Key_3: |
1831 | case Qt::Key_4: | 1809 | case Qt::Key_4: |
1832 | case Qt::Key_5: | 1810 | case Qt::Key_5: |
1833 | case Qt::Key_6: | 1811 | case Qt::Key_6: |
1834 | case Qt::Key_7: | 1812 | case Qt::Key_7: |
1835 | case Qt::Key_8: | 1813 | case Qt::Key_8: |
1836 | case Qt::Key_9: | 1814 | case Qt::Key_9: |
1837 | pro = e->key()-48; | 1815 | pro = e->key()-48; |
1838 | if ( pro == 0 ) | 1816 | if ( pro == 0 ) |
1839 | pro = 10; | 1817 | pro = 10; |
1840 | if ( e->state() == Qt::ControlButton) | 1818 | if ( e->state() == Qt::ControlButton) |
1841 | pro += 10; | 1819 | pro += 10; |
1842 | break; | 1820 | break; |
1843 | case Qt::Key_M: | 1821 | case Qt::Key_M: |
1844 | mView->viewManager()->showMonthView(); | 1822 | mView->viewManager()->showMonthView(); |
1845 | showSelectedDates = true; | 1823 | showSelectedDates = true; |
1846 | break; | 1824 | break; |
1847 | case Qt::Key_Insert: | 1825 | case Qt::Key_Insert: |
1848 | mView->newEvent(); | 1826 | mView->newEvent(); |
1849 | break; | 1827 | break; |
1850 | case Qt::Key_S : | 1828 | case Qt::Key_S : |
1851 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1829 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1852 | mView->newSubTodo(); | 1830 | mView->newSubTodo(); |
1853 | else | 1831 | else |
1854 | mView->dialogManager()->showSearchDialog(); | 1832 | mView->dialogManager()->showSearchDialog(); |
1855 | break; | 1833 | break; |
1856 | case Qt::Key_Y : | 1834 | case Qt::Key_Y : |
1857 | case Qt::Key_Z : | 1835 | case Qt::Key_Z : |
1858 | mView->viewManager()->showWorkWeekView(); | 1836 | mView->viewManager()->showWorkWeekView(); |
1859 | showSelectedDates = true; | 1837 | showSelectedDates = true; |
1860 | break; | 1838 | break; |
1861 | case Qt::Key_U : | 1839 | case Qt::Key_U : |
1862 | mView->viewManager()->showWeekView(); | 1840 | mView->viewManager()->showWeekView(); |
1863 | showSelectedDates = true; | 1841 | showSelectedDates = true; |
1864 | break; | 1842 | break; |
1865 | case Qt::Key_H : | 1843 | case Qt::Key_H : |
1866 | keyBindings(); | 1844 | keyBindings(); |
1867 | break; | 1845 | break; |
1868 | case Qt::Key_W: | 1846 | case Qt::Key_W: |
1869 | mView->viewManager()->showWhatsNextView(); | 1847 | mView->viewManager()->showWhatsNextView(); |
1870 | break; | 1848 | break; |
1871 | case Qt::Key_L: | 1849 | case Qt::Key_L: |
1872 | mView->viewManager()->showListView(); | 1850 | mView->viewManager()->showListView(); |
1873 | break; | 1851 | break; |
1874 | case Qt::Key_N: | 1852 | case Qt::Key_N: |
1875 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1853 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1876 | mView->viewManager()->showNextView(); | 1854 | mView->viewManager()->showNextView(); |
1877 | else { | 1855 | else { |
1878 | mView->viewManager()->showNextXView(); | 1856 | mView->viewManager()->showNextXView(); |
1879 | showSelectedDates = true; | 1857 | showSelectedDates = true; |
1880 | } | 1858 | } |
1881 | break; | 1859 | break; |
1882 | case Qt::Key_V: | 1860 | case Qt::Key_V: |
1883 | mView->viewManager()->showTodoView(); | 1861 | mView->viewManager()->showTodoView(); |
1884 | break; | 1862 | break; |
1885 | case Qt::Key_C: | 1863 | case Qt::Key_C: |
1886 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1864 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1887 | break; | 1865 | break; |
1888 | case Qt::Key_P: | 1866 | case Qt::Key_P: |
1889 | mView->showDatePicker( ); | 1867 | mView->showDatePicker( ); |
1890 | break; | 1868 | break; |
1891 | case Qt::Key_F: | 1869 | case Qt::Key_F: |
1892 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1870 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1893 | mView->editFilters(); | 1871 | mView->editFilters(); |
1894 | else | 1872 | else |
1895 | mView->toggleFilter(); | 1873 | mView->toggleFilter(); |
1896 | break; | 1874 | break; |
1897 | case Qt::Key_X: | 1875 | case Qt::Key_X: |
1898 | mView->toggleDateNavigatorWidget(); | 1876 | mView->toggleDateNavigatorWidget(); |
1899 | break; | 1877 | break; |
1900 | case Qt::Key_Space: | 1878 | case Qt::Key_Space: |
1901 | mView->toggleExpand(); | 1879 | mView->toggleExpand(); |
1902 | break; | 1880 | break; |
1903 | case Qt::Key_A: | 1881 | case Qt::Key_A: |
1904 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 1882 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
1905 | mView->showNextAlarms(); | 1883 | mView->showNextAlarms(); |
1906 | else | 1884 | else |
1907 | mView->toggleAllDaySize(); | 1885 | mView->toggleAllDaySize(); |
1908 | break; | 1886 | break; |
1909 | case Qt::Key_T: | 1887 | case Qt::Key_T: |
1910 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1888 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1911 | mView->newTodo(); | 1889 | mView->newTodo(); |
1912 | else { | 1890 | else { |
1913 | mView->goToday(); | 1891 | mView->goToday(); |
1914 | showSelectedDates = true; | 1892 | showSelectedDates = true; |
1915 | } | 1893 | } |
1916 | break; | 1894 | break; |
1917 | case Qt::Key_J: | 1895 | case Qt::Key_J: |
1918 | mView->viewManager()->showJournalView(); | 1896 | mView->viewManager()->showJournalView(); |
1919 | break; | 1897 | break; |
1920 | case Qt::Key_B: | 1898 | case Qt::Key_B: |
1921 | mView->editIncidenceDescription();; | 1899 | mView->editIncidenceDescription();; |
1922 | break; | 1900 | break; |
1923 | // case Qt::Key_Return: | 1901 | // case Qt::Key_Return: |
1924 | case Qt::Key_E: | 1902 | case Qt::Key_E: |
1925 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1903 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1926 | mView->newEvent(); | 1904 | mView->newEvent(); |
1927 | else | 1905 | else |
1928 | mView->editIncidence(); | 1906 | mView->editIncidence(); |
1929 | break; | 1907 | break; |
1930 | case Qt::Key_Plus: | 1908 | case Qt::Key_Plus: |
1931 | size = p->mHourSize +2; | 1909 | size = p->mHourSize +2; |
1932 | if ( size <= 22 ) | 1910 | if ( size <= 22 ) |
1933 | configureAgenda( size ); | 1911 | configureAgenda( size ); |
1934 | break; | 1912 | break; |
1935 | case Qt::Key_Minus: | 1913 | case Qt::Key_Minus: |
1936 | size = p->mHourSize - 2; | 1914 | size = p->mHourSize - 2; |
1937 | if ( size >= 4 ) | 1915 | if ( size >= 4 ) |
1938 | configureAgenda( size ); | 1916 | configureAgenda( size ); |
1939 | break; | 1917 | break; |
1940 | 1918 | ||
1941 | 1919 | ||
1942 | default: | 1920 | default: |
1943 | e->ignore(); | 1921 | e->ignore(); |
1944 | } | 1922 | } |
1945 | if ( pro > 0 ) { | 1923 | if ( pro > 0 ) { |
1946 | mView->selectFilter( pro-1 ); | 1924 | mView->selectFilter( pro-1 ); |
1947 | } | 1925 | } |
1948 | if ( showSelectedDates ) { | 1926 | if ( showSelectedDates ) { |
1949 | ;// setCaptionToDates(); | 1927 | ;// setCaptionToDates(); |
1950 | } | 1928 | } |
1951 | 1929 | ||
1952 | } | 1930 | } |
1953 | 1931 | ||
1954 | void MainWindow::fillFilterMenu() | 1932 | void MainWindow::fillFilterMenu() |
1955 | { | 1933 | { |
1956 | selectFilterMenu->clear(); | 1934 | selectFilterMenu->clear(); |
1957 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1935 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1958 | selectFilterMenu->insertSeparator(); | 1936 | selectFilterMenu->insertSeparator(); |
1959 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 1937 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
1960 | 1938 | ||
1961 | selectFilterMenu->insertSeparator(); | 1939 | selectFilterMenu->insertSeparator(); |
1962 | QPtrList<CalFilter> fili = mView->filters(); | 1940 | QPtrList<CalFilter> fili = mView->filters(); |
1963 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1941 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1964 | CalFilter *filter = fili.first(); | 1942 | CalFilter *filter = fili.first(); |
1965 | int iii = 2; | 1943 | int iii = 2; |
1966 | bool checkitem = mView->filterView()->filtersEnabled(); | 1944 | bool checkitem = mView->filterView()->filtersEnabled(); |
1967 | while(filter) { | 1945 | while(filter) { |
1968 | selectFilterMenu->insertItem( filter->name(), iii ); | 1946 | selectFilterMenu->insertItem( filter->name(), iii ); |
1969 | if ( filter == curfilter) | 1947 | if ( filter == curfilter) |
1970 | selectFilterMenu->setItemChecked( iii, checkitem ); | 1948 | selectFilterMenu->setItemChecked( iii, checkitem ); |
1971 | filter = fili.next(); | 1949 | filter = fili.next(); |
1972 | ++iii; | 1950 | ++iii; |
1973 | } | 1951 | } |
1974 | if ( !checkitem ) | 1952 | if ( !checkitem ) |
1975 | selectFilterMenu->setItemChecked( 1, true ); | 1953 | selectFilterMenu->setItemChecked( 1, true ); |
1976 | } | 1954 | } |
1977 | void MainWindow::fillFilterMenuPopup() | 1955 | void MainWindow::fillFilterMenuPopup() |
1978 | { | 1956 | { |
1979 | filterPopupMenu->clear(); | 1957 | filterPopupMenu->clear(); |
1980 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 1958 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
1981 | 1959 | ||
1982 | filterPopupMenu->insertSeparator(); | 1960 | filterPopupMenu->insertSeparator(); |
1983 | QPtrList<CalFilter> fili = mView->filters(); | 1961 | QPtrList<CalFilter> fili = mView->filters(); |
1984 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1962 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1985 | CalFilter *filter = fili.first(); | 1963 | CalFilter *filter = fili.first(); |
1986 | int iii = 1; | 1964 | int iii = 1; |
1987 | bool checkitem = mView->filterView()->filtersEnabled(); | 1965 | bool checkitem = mView->filterView()->filtersEnabled(); |
1988 | while(filter) { | 1966 | while(filter) { |
1989 | filterPopupMenu->insertItem( filter->name(), iii ); | 1967 | filterPopupMenu->insertItem( filter->name(), iii ); |
1990 | if ( filter == curfilter) | 1968 | if ( filter == curfilter) |
1991 | filterPopupMenu->setItemChecked( iii, checkitem ); | 1969 | filterPopupMenu->setItemChecked( iii, checkitem ); |
1992 | filter = fili.next(); | 1970 | filter = fili.next(); |
1993 | ++iii; | 1971 | ++iii; |
1994 | } | 1972 | } |
1995 | if ( !checkitem ) | 1973 | if ( !checkitem ) |
1996 | filterPopupMenu->setItemChecked( 0, true ); | 1974 | filterPopupMenu->setItemChecked( 0, true ); |
1997 | } | 1975 | } |
1998 | void MainWindow::selectFilter( int fil ) | 1976 | void MainWindow::selectFilter( int fil ) |
1999 | { | 1977 | { |
2000 | 1978 | ||
2001 | if ( fil == 0 ) { | 1979 | if ( fil == 0 ) { |
2002 | mView->editFilters( ); | 1980 | mView->editFilters( ); |
2003 | } else if ( fil == 1 ){ | 1981 | } else if ( fil == 1 ){ |
2004 | if ( mView->filterView()->filtersEnabled() ) | 1982 | if ( mView->filterView()->filtersEnabled() ) |
2005 | mView->toggleFilerEnabled( ); | 1983 | mView->toggleFilerEnabled( ); |
2006 | } else { | 1984 | } else { |
2007 | if ( !mView->filterView()->filtersEnabled() ) { | 1985 | if ( !mView->filterView()->filtersEnabled() ) { |
2008 | mView->filterView()->blockSignals( true ); | 1986 | mView->filterView()->blockSignals( true ); |
2009 | mView->toggleFilerEnabled( ); | 1987 | mView->toggleFilerEnabled( ); |
2010 | mView->filterView()->blockSignals( false ); | 1988 | mView->filterView()->blockSignals( false ); |
2011 | } | 1989 | } |
2012 | mView->selectFilter( fil-2 ); | 1990 | mView->selectFilter( fil-2 ); |
2013 | } | 1991 | } |
2014 | } | 1992 | } |
2015 | void MainWindow::updateFilterToolbar() | 1993 | void MainWindow::updateFilterToolbar() |
2016 | { | 1994 | { |
2017 | if ( filterMenubar ) { | 1995 | if ( filterMenubar ) { |
2018 | if ( !mView->filterView()->filtersEnabled() ) { | 1996 | if ( !mView->filterView()->filtersEnabled() ) { |
2019 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 1997 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2020 | } else { | 1998 | } else { |
2021 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1999 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2022 | if ( curfilter ) { | 2000 | if ( curfilter ) { |
2023 | filterMenubar->changeItem( 0, curfilter->name() ); | 2001 | filterMenubar->changeItem( 0, curfilter->name() ); |
2024 | } | 2002 | } |
2025 | } | 2003 | } |
2026 | } | 2004 | } |
2027 | } | 2005 | } |
2028 | void MainWindow::selectFilterPopup( int fil ) | 2006 | void MainWindow::selectFilterPopup( int fil ) |
2029 | { | 2007 | { |
2030 | selectFilter( fil + 1 ); | 2008 | selectFilter( fil + 1 ); |
2031 | 2009 | ||
2032 | } | 2010 | } |
2033 | void MainWindow::configureToolBar( int item ) | 2011 | void MainWindow::configureToolBar( int item ) |
2034 | { | 2012 | { |
2035 | 2013 | ||
2036 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2014 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2037 | KOPrefs *p = KOPrefs::instance(); | 2015 | KOPrefs *p = KOPrefs::instance(); |
2038 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2016 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2039 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2017 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2040 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2018 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2041 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2019 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2042 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2020 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2043 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2021 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2044 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2022 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2045 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2023 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2046 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2024 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2047 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2025 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2048 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2026 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2049 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2027 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2050 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2028 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2051 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2029 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2052 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2030 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2053 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2031 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2054 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2032 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2055 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2033 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2056 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2034 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2057 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2035 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2058 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2036 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2059 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2037 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2060 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2038 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2061 | // initActions(); | 2039 | // initActions(); |
2062 | } | 2040 | } |
2063 | void MainWindow::setCaption ( const QString & c ) | 2041 | void MainWindow::setCaption ( const QString & c ) |
2064 | { | 2042 | { |
2065 | QString cap = c; | 2043 | QString cap = c; |
2066 | cap.replace( QRegExp("\n"), " " ); | 2044 | cap.replace( QRegExp("\n"), " " ); |
2067 | cap = cap.stripWhiteSpace(); | 2045 | cap = cap.stripWhiteSpace(); |
2068 | if ( cap.isEmpty() ) | 2046 | if ( cap.isEmpty() ) |
2069 | cap = "KO/Pi"; | 2047 | cap = "KO/Pi"; |
2070 | QWidget::setCaption( cap ); | 2048 | QWidget::setCaption( cap ); |
2071 | } | 2049 | } |
2072 | void MainWindow::setCaptionToDates() | 2050 | void MainWindow::setCaptionToDates() |
2073 | { | 2051 | { |
2074 | QString selDates; | 2052 | QString selDates; |
2075 | QDate date = mView->startDate(); | 2053 | QDate date = mView->startDate(); |
2076 | if ( ! date.isValid() ) { | 2054 | if ( ! date.isValid() ) { |
2077 | setCaption(""); | 2055 | setCaption(""); |
2078 | return; | 2056 | return; |
2079 | } | 2057 | } |
2080 | selDates = KGlobal::locale()->formatDate( date, true); | 2058 | selDates = KGlobal::locale()->formatDate( date, true); |
2081 | if (mView->startDate() < mView->endDate() ) | 2059 | if (mView->startDate() < mView->endDate() ) |
2082 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2060 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2083 | else { | 2061 | else { |
2084 | QString addString; | 2062 | QString addString; |
2085 | if ( date == QDateTime::currentDateTime().date() ) | 2063 | if ( date == QDateTime::currentDateTime().date() ) |
2086 | addString = i18n("Today"); | 2064 | addString = i18n("Today"); |
2087 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2065 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2088 | addString = i18n("Tomorrow"); | 2066 | addString = i18n("Tomorrow"); |
2089 | if ( !addString.isEmpty() ) | 2067 | if ( !addString.isEmpty() ) |
2090 | selDates = addString+", "+selDates ; | 2068 | selDates = addString+", "+selDates ; |
2091 | } | 2069 | } |
2092 | setCaption( i18n("Dates: ") + selDates ); | 2070 | setCaption( i18n("Dates: ") + selDates ); |
2093 | 2071 | ||
2094 | } | 2072 | } |
2095 | void MainWindow::showConfigureAgenda( ) | 2073 | void MainWindow::showConfigureAgenda( ) |
2096 | { | 2074 | { |
2097 | int iii; | 2075 | int iii; |
2098 | for ( iii = 1;iii<= 10 ;++iii ){ | 2076 | for ( iii = 1;iii<= 10 ;++iii ){ |
2099 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2077 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2100 | } | 2078 | } |
2101 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2079 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2102 | } | 2080 | } |
2103 | void MainWindow::configureAgenda( int item ) | 2081 | void MainWindow::configureAgenda( int item ) |
2104 | { | 2082 | { |
2105 | if ( KOPrefs::instance()->mHourSize == item ) | 2083 | if ( KOPrefs::instance()->mHourSize == item ) |
2106 | return; | 2084 | return; |
2107 | KOPrefs::instance()->mHourSize=item; | 2085 | KOPrefs::instance()->mHourSize=item; |
2108 | mView->viewManager()->agendaView()->updateConfig(); | 2086 | mView->viewManager()->agendaView()->updateConfig(); |
2109 | } | 2087 | } |
2110 | 2088 | ||
2111 | void MainWindow::saveCalendar() | 2089 | void MainWindow::saveCalendar() |
2112 | { | 2090 | { |
2113 | QString fn = KOPrefs::instance()->mLastSaveFile; | 2091 | QString fn = KOPrefs::instance()->mLastSaveFile; |
2114 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 2092 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
2115 | 2093 | ||
2116 | if ( fn == "" ) | 2094 | if ( fn == "" ) |
2117 | return; | 2095 | return; |
2118 | QFileInfo info; | 2096 | QFileInfo info; |
2119 | info.setFile( fn ); | 2097 | info.setFile( fn ); |
2120 | QString mes; | 2098 | QString mes; |
2121 | bool createbup = true; | 2099 | bool createbup = true; |
2122 | if ( info. exists() ) { | 2100 | if ( info. exists() ) { |
2123 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 2101 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
2124 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2102 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2125 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2103 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2126 | 0, 1 ); | 2104 | 0, 1 ); |
2127 | if ( result != 0 ) { | 2105 | if ( result != 0 ) { |
2128 | createbup = false; | 2106 | createbup = false; |
2129 | } | 2107 | } |
2130 | } | 2108 | } |
2131 | if ( createbup ) { | 2109 | if ( createbup ) { |
2132 | mView->saveCalendar( fn ); | 2110 | mView->saveCalendar( fn ); |
2133 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 2111 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
2134 | KOPrefs::instance()->mLastSaveFile = fn; | 2112 | KOPrefs::instance()->mLastSaveFile = fn; |
2135 | setCaption(mes); | 2113 | setCaption(mes); |
2136 | } | 2114 | } |
2137 | } | 2115 | } |
2138 | void MainWindow::loadCalendar() | 2116 | void MainWindow::loadCalendar() |
2139 | { | 2117 | { |
2140 | 2118 | ||
2141 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2119 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2142 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2120 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2143 | 2121 | ||
2144 | if ( fn == "" ) | 2122 | if ( fn == "" ) |
2145 | return; | 2123 | return; |
2146 | QFileInfo info; | 2124 | QFileInfo info; |
2147 | info.setFile( fn ); | 2125 | info.setFile( fn ); |
2148 | QString mess; | 2126 | QString mess; |
2149 | bool loadbup = true; | 2127 | bool loadbup = true; |
2150 | if ( info. exists() ) { | 2128 | if ( info. exists() ) { |
2151 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2129 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2152 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2130 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2153 | mess, | 2131 | mess, |
2154 | i18n("Load!"), i18n("Cancel"), 0, | 2132 | i18n("Load!"), i18n("Cancel"), 0, |
2155 | 0, 1 ); | 2133 | 0, 1 ); |
2156 | if ( result != 0 ) { | 2134 | if ( result != 0 ) { |
2157 | loadbup = false; | 2135 | loadbup = false; |
2158 | } | 2136 | } |
2159 | } else { | 2137 | } else { |
2160 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2138 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2161 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2139 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2162 | 0, 1 ); | 2140 | 0, 1 ); |
2163 | 2141 | ||
2164 | return; | 2142 | return; |
2165 | } | 2143 | } |
2166 | if ( loadbup ) { | 2144 | if ( loadbup ) { |
2167 | mView->openCalendar( fn ); | 2145 | mView->openCalendar( fn ); |
2168 | KOPrefs::instance()->mLastLoadFile = fn; | 2146 | KOPrefs::instance()->mLastLoadFile = fn; |
2169 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2147 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2170 | setCaption(mess); | 2148 | setCaption(mess); |
2171 | } | 2149 | } |
2172 | 2150 | ||
2173 | } | 2151 | } |
2174 | void MainWindow::quickImportIcal() | 2152 | void MainWindow::quickImportIcal() |
2175 | { | 2153 | { |
2176 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2154 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2177 | } | 2155 | } |
2178 | void MainWindow::importFile( QString fn, bool quick ) | 2156 | void MainWindow::importFile( QString fn, bool quick ) |
2179 | { | 2157 | { |
2180 | QFileInfo info; | 2158 | QFileInfo info; |
2181 | info.setFile( fn ); | 2159 | info.setFile( fn ); |
2182 | QString mess; | 2160 | QString mess; |
2183 | bool loadbup = true; | 2161 | bool loadbup = true; |
2184 | if ( !info. exists() ) { | 2162 | if ( !info. exists() ) { |
2185 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2163 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2186 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2164 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2187 | mess ); | 2165 | mess ); |
2188 | return; | 2166 | return; |
2189 | } | 2167 | } |
2190 | int result = 0; | 2168 | int result = 0; |
2191 | if ( !quick ) { | 2169 | if ( !quick ) { |
2192 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2170 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2193 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2171 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2194 | mess, | 2172 | mess, |
2195 | "Import", "Cancel", 0, | 2173 | "Import", "Cancel", 0, |
2196 | 0, 1 ); | 2174 | 0, 1 ); |
2197 | } | 2175 | } |
2198 | if ( result == 0 ) { | 2176 | if ( result == 0 ) { |
2199 | if ( mView->openCalendar( fn, true )) { | 2177 | if ( mView->openCalendar( fn, true )) { |
2200 | KOPrefs::instance()->mLastImportFile = fn; | 2178 | KOPrefs::instance()->mLastImportFile = fn; |
2201 | setCaption(i18n("Imported file successfully")); | 2179 | setCaption(i18n("Imported file successfully")); |
2202 | } else { | 2180 | } else { |
2203 | setCaption(i18n("Error importing file")); | 2181 | setCaption(i18n("Error importing file")); |
2204 | } | 2182 | } |
2205 | } | 2183 | } |
2206 | } | 2184 | } |
2207 | 2185 | ||
2208 | void MainWindow::importIcal() | 2186 | void MainWindow::importIcal() |
2209 | { | 2187 | { |
2210 | 2188 | ||
2211 | QString fn =KOPrefs::instance()->mLastImportFile; | 2189 | QString fn =KOPrefs::instance()->mLastImportFile; |
2212 | 2190 | ||
2213 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2191 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2214 | if ( fn == "" ) | 2192 | if ( fn == "" ) |
2215 | return; | 2193 | return; |
2216 | importFile( fn, true ); | 2194 | importFile( fn, true ); |
2217 | 2195 | ||
2218 | } | 2196 | } |
2219 | 2197 | ||
2220 | void MainWindow::exportVCalendar() | 2198 | void MainWindow::exportVCalendar() |
2221 | { | 2199 | { |
2222 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2200 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2223 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2201 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2224 | if ( fn == "" ) | 2202 | if ( fn == "" ) |
2225 | return; | 2203 | return; |
2226 | QFileInfo info; | 2204 | QFileInfo info; |
2227 | info.setFile( fn ); | 2205 | info.setFile( fn ); |
2228 | QString mes; | 2206 | QString mes; |
2229 | bool createbup = true; | 2207 | bool createbup = true; |
2230 | if ( info. exists() ) { | 2208 | if ( info. exists() ) { |
2231 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2209 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2232 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2210 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2233 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2211 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2234 | 0, 1 ); | 2212 | 0, 1 ); |
2235 | if ( result != 0 ) { | 2213 | if ( result != 0 ) { |
2236 | createbup = false; | 2214 | createbup = false; |
2237 | } | 2215 | } |
2238 | } | 2216 | } |
2239 | if ( createbup ) { | 2217 | if ( createbup ) { |
2240 | if ( mView->exportVCalendar( fn ) ) { | 2218 | if ( mView->exportVCalendar( fn ) ) { |
2241 | KOPrefs::instance()->mLastVcalFile = fn; | 2219 | KOPrefs::instance()->mLastVcalFile = fn; |
2242 | if ( fn.length() > 20 ) | 2220 | if ( fn.length() > 20 ) |
2243 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2221 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2244 | else | 2222 | else |
2245 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2223 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2246 | setCaption(mes); | 2224 | setCaption(mes); |
2247 | } | 2225 | } |
2248 | } | 2226 | } |
2249 | 2227 | ||
2250 | } | 2228 | } |
2251 | QString MainWindow::sentSyncFile() | 2229 | QString MainWindow::sentSyncFile() |
2252 | { | 2230 | { |
2253 | #ifdef DESKTOP_VERSION | 2231 | #ifdef DESKTOP_VERSION |
2254 | return locateLocal( "tmp", "copysynccal.ics" ); | 2232 | return locateLocal( "tmp", "copysynccal.ics" ); |
2255 | #else | 2233 | #else |
2256 | return QString( "/tmp/copysynccal.ics" ); | 2234 | return QString( "/tmp/copysynccal.ics" ); |
2257 | #endif | 2235 | #endif |
2258 | } | 2236 | } |
2259 | 2237 | ||
2260 | void MainWindow::syncFileRequest() | 2238 | void MainWindow::syncFileRequest() |
2261 | { | 2239 | { |
2262 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2240 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2263 | mSyncManager->slotSyncMenu( 999 ); | 2241 | mSyncManager->slotSyncMenu( 999 ); |
2264 | } | 2242 | } |
2265 | 2243 | ||
2266 | setCaption(i18n("Saving Data to temp file ..." )); | 2244 | setCaption(i18n("Saving Data to temp file ..." )); |
2267 | mView->saveCalendar( sentSyncFile() ); | 2245 | mView->saveCalendar( sentSyncFile() ); |
2268 | setCaption(i18n("Data saved to temp file!" )); | 2246 | setCaption(i18n("Data saved to temp file!" )); |
2269 | 2247 | ||
2270 | } | 2248 | } |
2271 | void MainWindow::getFile( bool success ) | 2249 | void MainWindow::getFile( bool success ) |
2272 | { | 2250 | { |
2273 | if ( ! success ) { | 2251 | if ( ! success ) { |
2274 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2252 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2275 | return; | 2253 | return; |
2276 | } | 2254 | } |
2277 | mView->openCalendar( sentSyncFile() ); | 2255 | mView->openCalendar( sentSyncFile() ); |
2278 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2256 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2279 | mSyncManager->slotSyncMenu( 999 ); | 2257 | mSyncManager->slotSyncMenu( 999 ); |
2280 | } | 2258 | } |
2281 | setCaption( i18n("Pi-Sync successful!") ); | 2259 | setCaption( i18n("Pi-Sync successful!") ); |
2282 | } | 2260 | } |
2283 | 2261 | ||
2284 | void MainWindow::printSel( ) | 2262 | void MainWindow::printSel( ) |
2285 | { | 2263 | { |
2286 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2264 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2287 | } | 2265 | } |
2288 | 2266 | ||
2289 | void MainWindow::printCal() | 2267 | void MainWindow::printCal() |
2290 | { | 2268 | { |
2291 | mView->print();//mCp->showDialog(); | 2269 | mView->print();//mCp->showDialog(); |
2292 | } | 2270 | } |
2293 | 2271 | ||
2294 | 2272 | ||
2295 | #include "libkdepim/kdatepicker.h" | 2273 | #include "libkdepim/kdatepicker.h" |
2296 | #include <kdatetbl.h> | 2274 | #include <kdatetbl.h> |
2297 | void MainWindow::weekAction() | 2275 | void MainWindow::weekAction() |
2298 | { | 2276 | { |
2299 | int month; | 2277 | int month; |
2300 | KPopupFrame* popup = new KPopupFrame(this); | 2278 | KPopupFrame* popup = new KPopupFrame(this); |
2301 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2279 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2302 | // ----- | 2280 | // ----- |
2303 | picker->resize(picker->sizeHint()); | 2281 | picker->resize(picker->sizeHint()); |
2304 | popup->setMainWidget(picker); | 2282 | popup->setMainWidget(picker); |
2305 | picker->setFocus(); | 2283 | picker->setFocus(); |
2306 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2284 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2307 | int x = 0; | 2285 | int x = 0; |
2308 | int y = iconToolBar->height(); | 2286 | int y = iconToolBar->height(); |
2309 | int dX = 0; | 2287 | int dX = 0; |
2310 | int dY = 0; | 2288 | int dY = 0; |
2311 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2289 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2312 | if ( iconToolBar->y() > height()/2 ) { | 2290 | if ( iconToolBar->y() > height()/2 ) { |
2313 | dY = picker->sizeHint().height()+8; | 2291 | dY = picker->sizeHint().height()+8; |
2314 | y = 0; | 2292 | y = 0; |
2315 | } | 2293 | } |
2316 | } else { | 2294 | } else { |
2317 | if ( iconToolBar->x() > width()/2 ) { // right side | 2295 | if ( iconToolBar->x() > width()/2 ) { // right side |
2318 | x=0; | 2296 | x=0; |
2319 | dX= picker->sizeHint().width()+8; | 2297 | dX= picker->sizeHint().width()+8; |
2320 | y = 0; | 2298 | y = 0; |
2321 | } else { | 2299 | } else { |
2322 | x= iconToolBar->width(); | 2300 | x= iconToolBar->width(); |
2323 | y = 0; | 2301 | y = 0; |
2324 | } | 2302 | } |
2325 | } | 2303 | } |
2326 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2304 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2327 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2305 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2328 | { | 2306 | { |
2329 | month = picker->getResult(); | 2307 | month = picker->getResult(); |
2330 | emit selectWeek ( month ); | 2308 | emit selectWeek ( month ); |
2331 | //qDebug("weekSelected %d ", month); | 2309 | //qDebug("weekSelected %d ", month); |
2332 | } | 2310 | } |
2333 | delete popup; | 2311 | delete popup; |
2334 | } | 2312 | } |
2335 | 2313 | ||
2336 | void MainWindow::hideEvent ( QHideEvent * ) | 2314 | void MainWindow::hideEvent ( QHideEvent * ) |
2337 | { | 2315 | { |
2338 | QString message; | 2316 | QString message; |
2339 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2317 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2340 | if ( nextA.isValid() ) { | 2318 | if ( nextA.isValid() ) { |
2341 | QString sum = mCalendar->nextSummary(); | 2319 | QString sum = mCalendar->nextSummary(); |
2342 | 2320 | ||
2343 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2321 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2344 | setCaption( message ); | 2322 | setCaption( message ); |
2345 | } | 2323 | } |
2346 | } | 2324 | } |
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 7f31ab1..1d8ae9f 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,1085 +1,1122 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | 3 | ||
4 | #include "kdebug.h" | 4 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 5 | #include "kcalendarsystemgregorian.h" |
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | 8 | ||
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | 10 | ||
11 | //#define COLLECT_TRANSLATION | 11 | //#define COLLECT_TRANSLATION |
12 | 12 | ||
13 | 13 | ||
14 | QDict<QString> *mLocaleDict = 0; | 14 | QDict<QString> *mLocaleDict = 0; |
15 | void setLocaleDict( QDict<QString> * dict ) | 15 | void setLocaleDict( QDict<QString> * dict ) |
16 | { | 16 | { |
17 | mLocaleDict = dict; | 17 | mLocaleDict = dict; |
18 | 18 | ||
19 | } | 19 | } |
20 | 20 | ||
21 | #ifdef COLLECT_TRANSLATION | 21 | #ifdef COLLECT_TRANSLATION |
22 | 22 | ||
23 | QStringList missingTrans; | 23 | QStringList missingTrans; |
24 | QStringList existingTrans1; | 24 | QStringList existingTrans1; |
25 | QStringList existingTrans2; | 25 | QStringList existingTrans2; |
26 | 26 | ||
27 | void addMissing(const char *text) | 27 | void addMissing(const char *text) |
28 | { | 28 | { |
29 | 29 | ||
30 | QString mis ( text ); | 30 | QString mis ( text ); |
31 | if ( !missingTrans.contains( mis ) ) | 31 | if ( !missingTrans.contains( mis ) ) |
32 | missingTrans.append(mis); | 32 | missingTrans.append(mis); |
33 | 33 | ||
34 | } | 34 | } |
35 | void addExist(const char *text,QString trans ) | 35 | void addExist(const char *text,QString trans ) |
36 | { | 36 | { |
37 | //return; | 37 | //return; |
38 | QString mis ( text ); | 38 | QString mis ( text ); |
39 | if ( !existingTrans1.contains( mis ) ) { | 39 | if ( !existingTrans1.contains( mis ) ) { |
40 | existingTrans1.append(mis); | 40 | existingTrans1.append(mis); |
41 | existingTrans2.append(trans); | 41 | existingTrans2.append(trans); |
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qtextstream.h> | 48 | #include <qtextstream.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #endif | 50 | #endif |
51 | void dumpMissing() | 51 | void dumpMissing() |
52 | { | 52 | { |
53 | #ifdef COLLECT_TRANSLATION | 53 | #ifdef COLLECT_TRANSLATION |
54 | QString fileName = "/tmp/usernewtrans.txt"; | 54 | QString fileName = "/tmp/usernewtrans.txt"; |
55 | QFile file( fileName ); | 55 | QFile file( fileName ); |
56 | if (!file.open( IO_WriteOnly ) ) { | 56 | if (!file.open( IO_WriteOnly ) ) { |
57 | return ; | 57 | return ; |
58 | } | 58 | } |
59 | QTextStream ts( &file ); | 59 | QTextStream ts( &file ); |
60 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 60 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
61 | 61 | ||
62 | int i; | 62 | int i; |
63 | for ( i = 0; i< missingTrans.count(); ++i ) { | 63 | for ( i = 0; i< missingTrans.count(); ++i ) { |
64 | 64 | ||
65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
67 | 67 | ||
68 | } | 68 | } |
69 | file.close(); | 69 | file.close(); |
70 | { | 70 | { |
71 | QString fileName = "/tmp/usertrans.txt"; | 71 | QString fileName = "/tmp/usertrans.txt"; |
72 | QFile file( fileName ); | 72 | QFile file( fileName ); |
73 | if (!file.open( IO_WriteOnly ) ) { | 73 | if (!file.open( IO_WriteOnly ) ) { |
74 | return ; | 74 | return ; |
75 | } | 75 | } |
76 | QTextStream ts( &file ); | 76 | QTextStream ts( &file ); |
77 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 77 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | for ( i = 0; i< existingTrans1.count(); ++i ) { | 80 | for ( i = 0; i< existingTrans1.count(); ++i ) { |
81 | 81 | ||
82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); | 82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); |
83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); | 83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); |
84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; | 84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; |
85 | 85 | ||
86 | } | 86 | } |
87 | file.close(); | 87 | file.close(); |
88 | } | 88 | } |
89 | #endif | 89 | #endif |
90 | } | 90 | } |
91 | QString i18n(const char *text) | 91 | QString i18n(const char *text) |
92 | { | 92 | { |
93 | if ( ! mLocaleDict ) { | 93 | if ( ! mLocaleDict ) { |
94 | #ifdef COLLECT_TRANSLATION | 94 | #ifdef COLLECT_TRANSLATION |
95 | addMissing( text ); | 95 | addMissing( text ); |
96 | #endif | 96 | #endif |
97 | return QString( text ); | 97 | return QString( text ); |
98 | } | 98 | } |
99 | else { | 99 | else { |
100 | QString* ret = mLocaleDict->find(QString(text)) ; | 100 | QString* ret = mLocaleDict->find(QString(text)) ; |
101 | if ( ret == 0 ) { | 101 | if ( ret == 0 ) { |
102 | #ifdef COLLECT_TRANSLATION | 102 | #ifdef COLLECT_TRANSLATION |
103 | addMissing( text ); | 103 | addMissing( text ); |
104 | #endif | 104 | #endif |
105 | return QString( text ); | 105 | return QString( text ); |
106 | } | 106 | } |
107 | else { | 107 | else { |
108 | if ( (*ret).isEmpty() ) { | 108 | if ( (*ret).isEmpty() ) { |
109 | #ifdef COLLECT_TRANSLATION | 109 | #ifdef COLLECT_TRANSLATION |
110 | addMissing( text ); | 110 | addMissing( text ); |
111 | #endif | 111 | #endif |
112 | return QString( text ); | 112 | return QString( text ); |
113 | } | 113 | } |
114 | else { | 114 | else { |
115 | #ifdef COLLECT_TRANSLATION | 115 | #ifdef COLLECT_TRANSLATION |
116 | addExist( text, *ret ); | 116 | addExist( text, *ret ); |
117 | #endif | 117 | #endif |
118 | return (*ret); | 118 | return (*ret); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | QString i18n(const char *,const char *text) | 125 | QString i18n(const char *,const char *text) |
126 | { | 126 | { |
127 | return i18n( text ); | 127 | return i18n( text ); |
128 | } | 128 | } |
129 | 129 | ||
130 | QString i18n(const char *text1, const char *textn, int num) | 130 | QString i18n(const char *text1, const char *textn, int num) |
131 | { | 131 | { |
132 | if ( num == 1 ) return i18n( text1 ); | 132 | if ( num == 1 ) return i18n( text1 ); |
133 | else { | 133 | else { |
134 | QString text = i18n( textn ); | 134 | QString text = i18n( textn ); |
135 | int pos = text.find( "%n" ); | 135 | int pos = text.find( "%n" ); |
136 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 136 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
137 | return text; | 137 | return text; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 141 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
142 | { | 142 | { |
143 | for ( uint l = 0; l < s.length(); l++ ) | 143 | for ( uint l = 0; l < s.length(); l++ ) |
144 | buffer[index++] = s.at( l ); | 144 | buffer[index++] = s.at( l ); |
145 | } | 145 | } |
146 | 146 | ||
147 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 147 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
148 | { | 148 | { |
149 | buffer[index++] = number / 10 + '0'; | 149 | buffer[index++] = number / 10 + '0'; |
150 | buffer[index++] = number % 10 + '0'; | 150 | buffer[index++] = number % 10 + '0'; |
151 | } | 151 | } |
152 | 152 | ||
153 | static int readInt(const QString &str, uint &pos) | 153 | static int readInt(const QString &str, uint &pos) |
154 | { | 154 | { |
155 | if (!str.at(pos).isDigit()) return -1; | 155 | if (!str.at(pos).isDigit()) return -1; |
156 | int result = 0; | 156 | int result = 0; |
157 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 157 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
158 | { | 158 | { |
159 | result *= 10; | 159 | result *= 10; |
160 | result += str.at(pos).digitValue(); | 160 | result += str.at(pos).digitValue(); |
161 | } | 161 | } |
162 | 162 | ||
163 | return result; | 163 | return result; |
164 | } | 164 | } |
165 | 165 | ||
166 | KLocale::KLocale() : mCalendarSystem( 0 ) | 166 | KLocale::KLocale() : mCalendarSystem( 0 ) |
167 | { | 167 | { |
168 | 168 | ||
169 | m_decimalSymbol = "."; | 169 | m_decimalSymbol = "."; |
170 | m_positiveSign = ""; | 170 | m_positiveSign = ""; |
171 | m_negativeSign = "-"; | 171 | m_negativeSign = "-"; |
172 | m_thousandsSeparator = ","; | 172 | m_thousandsSeparator = ","; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | mWeekStartsMonday = true; | 177 | mWeekStartsMonday = true; |
178 | mHourF24Format = true; | 178 | mHourF24Format = true; |
179 | mIntDateFormat = Default; | 179 | mIntDateFormat = Default; |
180 | mIntTimeFormat = Default; | 180 | mIntTimeFormat = Default; |
181 | mLanguage = 0; | 181 | mLanguage = 0; |
182 | mDateFormat = "%a %Y %b %d"; | 182 | mDateFormat = "%a %Y %b %d"; |
183 | mDateFormatShort = "%Y-%m-%d"; | 183 | mDateFormatShort = "%Y-%m-%d"; |
184 | mTimeZoneList << ("-11:00 US/Samoa") | 184 | mTimeZoneList << ("-11:00 US/Samoa") |
185 | << ("-10:00 US/Hawaii") | 185 | << ("-10:00 US/Hawaii") |
186 | << ("-09:00 US/Alaska") | 186 | << ("-09:00 US/Alaska") |
187 | << ("-08:00 US/Pacific") | 187 | << ("-08:00 US/Pacific") |
188 | << ("-07:00 US/Mountain") | 188 | << ("-07:00 US/Mountain") |
189 | << ("-06:00 US/Central") | 189 | << ("-06:00 US/Central") |
190 | << ("-05:00 US/Eastern") | 190 | << ("-05:00 US/Eastern") |
191 | << ("-04:00 Brazil/West") | 191 | << ("-04:00 Brazil/West") |
192 | << ("-03:00 Brazil/East") | 192 | << ("-03:00 Brazil/East") |
193 | << ("-02:00 Brazil/DeNoronha") | 193 | << ("-02:00 Brazil/DeNoronha") |
194 | << ("-01:00 Atlantic/Azores") | 194 | << ("-01:00 Atlantic/Azores") |
195 | << (" 00:00 Europe/London(UTC)") | 195 | << (" 00:00 Europe/London(UTC)") |
196 | << ("+01:00 Europe/Oslo(CET)") | 196 | << ("+01:00 Europe/Oslo(CET)") |
197 | << ("+02:00 Europe/Helsinki") | 197 | << ("+02:00 Europe/Helsinki") |
198 | << ("+03:00 Europe/Moscow") | 198 | << ("+03:00 Europe/Moscow") |
199 | << ("+04:00 Indian/Mauritius") | 199 | << ("+04:00 Indian/Mauritius") |
200 | << ("+05:00 Indian/Maldives") | 200 | << ("+05:00 Indian/Maldives") |
201 | << ("+06:00 Indian/Chagos") | 201 | << ("+06:00 Indian/Chagos") |
202 | << ("+07:00 Asia/Bangkok") | 202 | << ("+07:00 Asia/Bangkok") |
203 | << ("+08:00 Asia/Hongkong") | 203 | << ("+08:00 Asia/Hongkong") |
204 | << ("+09:00 Asia/Tokyo") | 204 | << ("+09:00 Asia/Tokyo") |
205 | << ("+10:00 Asia/Vladivostok") | 205 | << ("+10:00 Asia/Vladivostok") |
206 | << ("+11:00 Asia/Magadan") | 206 | << ("+11:00 Asia/Magadan") |
207 | << ("+12:00 Asia/Kamchatka") | 207 | << ("+12:00 Asia/Kamchatka") |
208 | // << (" xx:xx User defined offset") | 208 | // << (" xx:xx User defined offset") |
209 | << i18n (" Local Time"); | 209 | << i18n (" Local Time"); |
210 | mSouthDaylight = false; | 210 | mSouthDaylight = false; |
211 | mTimeZoneOffset = 0; | 211 | mTimeZoneOffset = 0; |
212 | daylightEnabled = false; | 212 | daylightEnabled = false; |
213 | } | 213 | } |
214 | 214 | ||
215 | void KLocale::setDateFormat( QString s ) | 215 | void KLocale::setDateFormat( QString s ) |
216 | { | 216 | { |
217 | mDateFormat = s; | 217 | mDateFormat = s; |
218 | } | 218 | } |
219 | 219 | ||
220 | void KLocale::setDateFormatShort( QString s ) | 220 | void KLocale::setDateFormatShort( QString s ) |
221 | { | 221 | { |
222 | mDateFormatShort = s; | 222 | mDateFormatShort = s; |
223 | } | 223 | } |
224 | 224 | ||
225 | void KLocale::setHore24Format ( bool b ) | 225 | void KLocale::setHore24Format ( bool b ) |
226 | { | 226 | { |
227 | mHourF24Format = b; | 227 | mHourF24Format = b; |
228 | } | 228 | } |
229 | void KLocale::setWeekStartMonday( bool b ) | 229 | void KLocale::setWeekStartMonday( bool b ) |
230 | { | 230 | { |
231 | mWeekStartsMonday = b; | 231 | mWeekStartsMonday = b; |
232 | } | 232 | } |
233 | 233 | ||
234 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) | 234 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
235 | { | 235 | { |
236 | return mIntDateFormat; | 236 | return mIntDateFormat; |
237 | 237 | ||
238 | } | 238 | } |
239 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) | 239 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) |
240 | { | 240 | { |
241 | mIntDateFormat = i; | 241 | mIntDateFormat = i; |
242 | } | 242 | } |
243 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) | 243 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) |
244 | { | 244 | { |
245 | return mIntTimeFormat; | 245 | return mIntTimeFormat; |
246 | 246 | ||
247 | } | 247 | } |
248 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) | 248 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) |
249 | { | 249 | { |
250 | mIntTimeFormat = i; | 250 | mIntTimeFormat = i; |
251 | } | 251 | } |
252 | 252 | ||
253 | void KLocale::setLanguage( int i ) | 253 | void KLocale::setLanguage( int i ) |
254 | { | 254 | { |
255 | mLanguage = i; | 255 | mLanguage = i; |
256 | } | 256 | } |
257 | int KLocale::language( ) | 257 | int KLocale::language( ) |
258 | { | 258 | { |
259 | return mLanguage; | 259 | return mLanguage; |
260 | } | 260 | } |
261 | QString KLocale::translate( const char *index ) const | 261 | QString KLocale::translate( const char *index ) const |
262 | { | 262 | { |
263 | return i18n( index ); | 263 | return i18n( index ); |
264 | } | 264 | } |
265 | 265 | ||
266 | QString KLocale::translate( const char *, const char *fallback) const | 266 | QString KLocale::translate( const char *, const char *fallback) const |
267 | { | 267 | { |
268 | return i18n( fallback ); | 268 | return i18n( fallback ); |
269 | } | 269 | } |
270 | 270 | ||
271 | int KLocale::weekNum ( const QDate & date ) | ||
272 | { | ||
273 | QDate seda = date; | ||
274 | int weekNum = 0; | ||
275 | int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4 | ||
276 | int daystoprevthursday = (dayofweek + 3) % 7 ; | ||
277 | int dayofyear = seda.dayOfYear(); | ||
278 | int prevThursday = dayofyear - ( daystoprevthursday ); | ||
279 | int subweeknum = 0; | ||
280 | if ( prevThursday < 1 ) { | ||
281 | seda = seda.addDays( - daystoprevthursday ); | ||
282 | dayofyear = seda.dayOfYear(); | ||
283 | prevThursday = dayofyear; | ||
284 | subweeknum = prevThursday / 7; | ||
285 | if ( prevThursday % 7 != 0 ) | ||
286 | ++subweeknum; | ||
287 | } else { | ||
288 | if ( dayofyear >= 360 ) { //maybe week 1 | ||
289 | seda = seda.addDays( 7 - daystoprevthursday ); | ||
290 | dayofyear = seda.dayOfYear(); | ||
291 | if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) ) | ||
292 | return 1; | ||
293 | } | ||
294 | } | ||
295 | if ( ! weekNum ) { | ||
296 | weekNum = prevThursday / 7; | ||
297 | if ( prevThursday % 7 != 0 ) | ||
298 | ++weekNum; | ||
299 | if ( dayofweek < 4 ) | ||
300 | ++weekNum; | ||
301 | else if ( dayofweek == 7 && !mWeekStartsMonday ) | ||
302 | ++weekNum; | ||
303 | if ( weekNum > subweeknum ) | ||
304 | weekNum -= subweeknum; | ||
305 | } | ||
306 | return weekNum; | ||
307 | } | ||
271 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const | 308 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const |
272 | { | 309 | { |
273 | const QString rst = timeFormat(intIntDateFormat); | 310 | const QString rst = timeFormat(intIntDateFormat); |
274 | 311 | ||
275 | // only "pm/am" here can grow, the rest shrinks, but | 312 | // only "pm/am" here can grow, the rest shrinks, but |
276 | // I'm rather safe than sorry | 313 | // I'm rather safe than sorry |
277 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | 314 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; |
278 | 315 | ||
279 | uint index = 0; | 316 | uint index = 0; |
280 | bool escape = false; | 317 | bool escape = false; |
281 | int number = 0; | 318 | int number = 0; |
282 | 319 | ||
283 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | 320 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) |
284 | { | 321 | { |
285 | if ( !escape ) | 322 | if ( !escape ) |
286 | { | 323 | { |
287 | if ( rst.at( format_index ).unicode() == '%' ) | 324 | if ( rst.at( format_index ).unicode() == '%' ) |
288 | escape = true; | 325 | escape = true; |
289 | else | 326 | else |
290 | buffer[index++] = rst.at( format_index ); | 327 | buffer[index++] = rst.at( format_index ); |
291 | } | 328 | } |
292 | else | 329 | else |
293 | { | 330 | { |
294 | switch ( rst.at( format_index ).unicode() ) | 331 | switch ( rst.at( format_index ).unicode() ) |
295 | { | 332 | { |
296 | case '%': | 333 | case '%': |
297 | buffer[index++] = '%'; | 334 | buffer[index++] = '%'; |
298 | break; | 335 | break; |
299 | case 'H': | 336 | case 'H': |
300 | put_it_in( buffer, index, pTime.hour() ); | 337 | put_it_in( buffer, index, pTime.hour() ); |
301 | break; | 338 | break; |
302 | case 'I': | 339 | case 'I': |
303 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | 340 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); |
304 | break; | 341 | break; |
305 | case 'M': | 342 | case 'M': |
306 | put_it_in( buffer, index, pTime.minute() ); | 343 | put_it_in( buffer, index, pTime.minute() ); |
307 | break; | 344 | break; |
308 | case 'S': | 345 | case 'S': |
309 | if (includeSecs) | 346 | if (includeSecs) |
310 | put_it_in( buffer, index, pTime.second() ); | 347 | put_it_in( buffer, index, pTime.second() ); |
311 | else | 348 | else |
312 | { | 349 | { |
313 | // we remove the seperator sign before the seconds and | 350 | // we remove the seperator sign before the seconds and |
314 | // assume that works everywhere | 351 | // assume that works everywhere |
315 | --index; | 352 | --index; |
316 | break; | 353 | break; |
317 | } | 354 | } |
318 | break; | 355 | break; |
319 | case 'k': | 356 | case 'k': |
320 | number = pTime.hour(); | 357 | number = pTime.hour(); |
321 | case 'l': | 358 | case 'l': |
322 | // to share the code | 359 | // to share the code |
323 | if ( rst.at( format_index ).unicode() == 'l' ) | 360 | if ( rst.at( format_index ).unicode() == 'l' ) |
324 | number = (pTime.hour() + 11) % 12 + 1; | 361 | number = (pTime.hour() + 11) % 12 + 1; |
325 | if ( number / 10 ) | 362 | if ( number / 10 ) |
326 | buffer[index++] = number / 10 + '0'; | 363 | buffer[index++] = number / 10 + '0'; |
327 | buffer[index++] = number % 10 + '0'; | 364 | buffer[index++] = number % 10 + '0'; |
328 | break; | 365 | break; |
329 | case 'p': | 366 | case 'p': |
330 | { | 367 | { |
331 | QString s; | 368 | QString s; |
332 | if ( pTime.hour() >= 12 ) | 369 | if ( pTime.hour() >= 12 ) |
333 | put_it_in( buffer, index, i18n("pm") ); | 370 | put_it_in( buffer, index, i18n("pm") ); |
334 | else | 371 | else |
335 | put_it_in( buffer, index, i18n("am") ); | 372 | put_it_in( buffer, index, i18n("am") ); |
336 | break; | 373 | break; |
337 | } | 374 | } |
338 | default: | 375 | default: |
339 | buffer[index++] = rst.at( format_index ); | 376 | buffer[index++] = rst.at( format_index ); |
340 | break; | 377 | break; |
341 | } | 378 | } |
342 | escape = false; | 379 | escape = false; |
343 | } | 380 | } |
344 | } | 381 | } |
345 | QString ret( buffer, index ); | 382 | QString ret( buffer, index ); |
346 | delete [] buffer; | 383 | delete [] buffer; |
347 | return ret; | 384 | return ret; |
348 | } | 385 | } |
349 | 386 | ||
350 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const | 387 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const |
351 | { | 388 | { |
352 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); | 389 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); |
353 | 390 | ||
354 | // I'm rather safe than sorry | 391 | // I'm rather safe than sorry |
355 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; | 392 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; |
356 | 393 | ||
357 | unsigned int index = 0; | 394 | unsigned int index = 0; |
358 | bool escape = false; | 395 | bool escape = false; |
359 | int number = 0; | 396 | int number = 0; |
360 | 397 | ||
361 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) | 398 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) |
362 | { | 399 | { |
363 | if ( !escape ) | 400 | if ( !escape ) |
364 | { | 401 | { |
365 | if ( rst.at( format_index ).unicode() == '%' ) | 402 | if ( rst.at( format_index ).unicode() == '%' ) |
366 | escape = true; | 403 | escape = true; |
367 | else | 404 | else |
368 | buffer[index++] = rst.at( format_index ); | 405 | buffer[index++] = rst.at( format_index ); |
369 | } | 406 | } |
370 | else | 407 | else |
371 | { | 408 | { |
372 | switch ( rst.at( format_index ).unicode() ) | 409 | switch ( rst.at( format_index ).unicode() ) |
373 | { | 410 | { |
374 | case '%': | 411 | case '%': |
375 | buffer[index++] = '%'; | 412 | buffer[index++] = '%'; |
376 | break; | 413 | break; |
377 | case 'Y': | 414 | case 'Y': |
378 | put_it_in( buffer, index, pDate.year() / 100 ); | 415 | put_it_in( buffer, index, pDate.year() / 100 ); |
379 | case 'y': | 416 | case 'y': |
380 | put_it_in( buffer, index, pDate.year() % 100 ); | 417 | put_it_in( buffer, index, pDate.year() % 100 ); |
381 | break; | 418 | break; |
382 | case 'n': | 419 | case 'n': |
383 | number = pDate.month(); | 420 | number = pDate.month(); |
384 | case 'e': | 421 | case 'e': |
385 | // to share the code | 422 | // to share the code |
386 | if ( rst.at( format_index ).unicode() == 'e' ) | 423 | if ( rst.at( format_index ).unicode() == 'e' ) |
387 | number = pDate.day(); | 424 | number = pDate.day(); |
388 | if ( number / 10 ) | 425 | if ( number / 10 ) |
389 | buffer[index++] = number / 10 + '0'; | 426 | buffer[index++] = number / 10 + '0'; |
390 | buffer[index++] = number % 10 + '0'; | 427 | buffer[index++] = number % 10 + '0'; |
391 | break; | 428 | break; |
392 | case 'm': | 429 | case 'm': |
393 | put_it_in( buffer, index, pDate.month() ); | 430 | put_it_in( buffer, index, pDate.month() ); |
394 | break; | 431 | break; |
395 | case 'b': | 432 | case 'b': |
396 | put_it_in( buffer, index, monthName(pDate.month(), true) ); | 433 | put_it_in( buffer, index, monthName(pDate.month(), true) ); |
397 | break; | 434 | break; |
398 | case 'B': | 435 | case 'B': |
399 | put_it_in( buffer, index, monthName(pDate.month(), false) ); | 436 | put_it_in( buffer, index, monthName(pDate.month(), false) ); |
400 | break; | 437 | break; |
401 | case 'd': | 438 | case 'd': |
402 | put_it_in( buffer, index, pDate.day() ); | 439 | put_it_in( buffer, index, pDate.day() ); |
403 | break; | 440 | break; |
404 | case 'a': | 441 | case 'a': |
405 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); | 442 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); |
406 | break; | 443 | break; |
407 | case 'A': | 444 | case 'A': |
408 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); | 445 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); |
409 | break; | 446 | break; |
410 | default: | 447 | default: |
411 | buffer[index++] = rst.at( format_index ); | 448 | buffer[index++] = rst.at( format_index ); |
412 | break; | 449 | break; |
413 | } | 450 | } |
414 | escape = false; | 451 | escape = false; |
415 | } | 452 | } |
416 | } | 453 | } |
417 | QString ret( buffer, index ); | 454 | QString ret( buffer, index ); |
418 | delete [] buffer; | 455 | delete [] buffer; |
419 | return ret; | 456 | return ret; |
420 | } | 457 | } |
421 | 458 | ||
422 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 459 | QString KLocale::formatDateTime(const QDateTime &pDateTime, |
423 | bool shortFormat, | 460 | bool shortFormat, |
424 | bool includeSeconds, | 461 | bool includeSeconds, |
425 | IntDateFormat intIntDateFormat) const | 462 | IntDateFormat intIntDateFormat) const |
426 | { | 463 | { |
427 | QString format("%1 %2"); | 464 | QString format("%1 %2"); |
428 | 465 | ||
429 | if ( intIntDateFormat == Default ) | 466 | if ( intIntDateFormat == Default ) |
430 | format = "%1 %2"; | 467 | format = "%1 %2"; |
431 | else if ( intIntDateFormat == Format1 ) | 468 | else if ( intIntDateFormat == Format1 ) |
432 | format = "%1 %2"; | 469 | format = "%1 %2"; |
433 | else if ( intIntDateFormat == ISODate ) | 470 | else if ( intIntDateFormat == ISODate ) |
434 | format = "%1T%2"; | 471 | format = "%1T%2"; |
435 | 472 | ||
436 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) | 473 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) |
437 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); | 474 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); |
438 | 475 | ||
439 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); | 476 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); |
440 | 477 | ||
441 | return res; | 478 | return res; |
442 | } | 479 | } |
443 | 480 | ||
444 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const | 481 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const |
445 | { | 482 | { |
446 | return formatDateTime(pDateTime, true, true, intIntDateFormat); | 483 | return formatDateTime(pDateTime, true, true, intIntDateFormat); |
447 | } | 484 | } |
448 | 485 | ||
449 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 486 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
450 | { | 487 | { |
451 | QDate date; | 488 | QDate date; |
452 | date = readDate(intstr, true, ok); | 489 | date = readDate(intstr, true, ok); |
453 | if (date.isValid()) return date; | 490 | if (date.isValid()) return date; |
454 | return readDate(intstr, false, ok); | 491 | return readDate(intstr, false, ok); |
455 | } | 492 | } |
456 | 493 | ||
457 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | 494 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const |
458 | { | 495 | { |
459 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | 496 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); |
460 | return readDate( intstr, fmt, ok ); | 497 | return readDate( intstr, fmt, ok ); |
461 | } | 498 | } |
462 | 499 | ||
463 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const | 500 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const |
464 | { | 501 | { |
465 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; | 502 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; |
466 | QString str = intstr.simplifyWhiteSpace().lower(); | 503 | QString str = intstr.simplifyWhiteSpace().lower(); |
467 | int day = -1, month = -1; | 504 | int day = -1, month = -1; |
468 | // allow the year to be omitted if not in the format | 505 | // allow the year to be omitted if not in the format |
469 | int year = QDate::currentDate().year(); | 506 | int year = QDate::currentDate().year(); |
470 | uint strpos = 0; | 507 | uint strpos = 0; |
471 | uint fmtpos = 0; | 508 | uint fmtpos = 0; |
472 | 509 | ||
473 | while (fmt.length() > fmtpos || str.length() > strpos) | 510 | while (fmt.length() > fmtpos || str.length() > strpos) |
474 | { | 511 | { |
475 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | 512 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) |
476 | goto error; | 513 | goto error; |
477 | 514 | ||
478 | QChar c = fmt.at(fmtpos++); | 515 | QChar c = fmt.at(fmtpos++); |
479 | 516 | ||
480 | if (c != '%') { | 517 | if (c != '%') { |
481 | if (c.isSpace()) | 518 | if (c.isSpace()) |
482 | strpos++; | 519 | strpos++; |
483 | else if (c != str.at(strpos++)) | 520 | else if (c != str.at(strpos++)) |
484 | goto error; | 521 | goto error; |
485 | continue; | 522 | continue; |
486 | } | 523 | } |
487 | 524 | ||
488 | // remove space at the begining | 525 | // remove space at the begining |
489 | if (str.length() > strpos && str.at(strpos).isSpace()) | 526 | if (str.length() > strpos && str.at(strpos).isSpace()) |
490 | strpos++; | 527 | strpos++; |
491 | 528 | ||
492 | c = fmt.at(fmtpos++); | 529 | c = fmt.at(fmtpos++); |
493 | switch (c) | 530 | switch (c) |
494 | { | 531 | { |
495 | case 'a': | 532 | case 'a': |
496 | case 'A': | 533 | case 'A': |
497 | // this will just be ignored | 534 | // this will just be ignored |
498 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 535 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
499 | for (int j = 1; j < 8; j++) { | 536 | for (int j = 1; j < 8; j++) { |
500 | QString s = weekDayName(j, c == 'a').lower(); | 537 | QString s = weekDayName(j, c == 'a').lower(); |
501 | int len = s.length(); | 538 | int len = s.length(); |
502 | if (str.mid(strpos, len) == s) | 539 | if (str.mid(strpos, len) == s) |
503 | strpos += len; | 540 | strpos += len; |
504 | } | 541 | } |
505 | break; | 542 | break; |
506 | } | 543 | } |
507 | case 'b': | 544 | case 'b': |
508 | case 'B': | 545 | case 'B': |
509 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 546 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
510 | for (int j = 1; j < 13; j++) { | 547 | for (int j = 1; j < 13; j++) { |
511 | QString s = monthName(j, c == 'b').lower(); | 548 | QString s = monthName(j, c == 'b').lower(); |
512 | int len = s.length(); | 549 | int len = s.length(); |
513 | if (str.mid(strpos, len) == s) { | 550 | if (str.mid(strpos, len) == s) { |
514 | month = j; | 551 | month = j; |
515 | strpos += len; | 552 | strpos += len; |
516 | } | 553 | } |
517 | } | 554 | } |
518 | break; | 555 | break; |
519 | } | 556 | } |
520 | case 'd': | 557 | case 'd': |
521 | case 'e': | 558 | case 'e': |
522 | day = readInt(str, strpos); | 559 | day = readInt(str, strpos); |
523 | if (day < 1 || day > 31) | 560 | if (day < 1 || day > 31) |
524 | goto error; | 561 | goto error; |
525 | 562 | ||
526 | break; | 563 | break; |
527 | 564 | ||
528 | case 'n': | 565 | case 'n': |
529 | case 'm': | 566 | case 'm': |
530 | month = readInt(str, strpos); | 567 | month = readInt(str, strpos); |
531 | if (month < 1 || month > 12) | 568 | if (month < 1 || month > 12) |
532 | goto error; | 569 | goto error; |
533 | 570 | ||
534 | break; | 571 | break; |
535 | 572 | ||
536 | case 'Y': | 573 | case 'Y': |
537 | case 'y': | 574 | case 'y': |
538 | year = readInt(str, strpos); | 575 | year = readInt(str, strpos); |
539 | if (year < 0) | 576 | if (year < 0) |
540 | goto error; | 577 | goto error; |
541 | // Qt treats a year in the range 0-100 as 1900-1999. | 578 | // Qt treats a year in the range 0-100 as 1900-1999. |
542 | // It is nicer for the user if we treat 0-68 as 2000-2068 | 579 | // It is nicer for the user if we treat 0-68 as 2000-2068 |
543 | if (year < 69) | 580 | if (year < 69) |
544 | year += 2000; | 581 | year += 2000; |
545 | else if (c == 'y') | 582 | else if (c == 'y') |
546 | year += 1900; | 583 | year += 1900; |
547 | 584 | ||
548 | break; | 585 | break; |
549 | } | 586 | } |
550 | } | 587 | } |
551 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | 588 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; |
552 | if ( year != -1 && month != -1 && day != -1 ) | 589 | if ( year != -1 && month != -1 && day != -1 ) |
553 | { | 590 | { |
554 | if (ok) *ok = true; | 591 | if (ok) *ok = true; |
555 | return QDate(year, month, day); | 592 | return QDate(year, month, day); |
556 | } | 593 | } |
557 | error: | 594 | error: |
558 | if (ok) *ok = false; | 595 | if (ok) *ok = false; |
559 | return QDate(); // invalid date | 596 | return QDate(); // invalid date |
560 | } | 597 | } |
561 | 598 | ||
562 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | 599 | QTime KLocale::readTime(const QString &intstr, bool *ok) const |
563 | { | 600 | { |
564 | QTime _time; | 601 | QTime _time; |
565 | _time = readTime(intstr, false, ok); | 602 | _time = readTime(intstr, false, ok); |
566 | if (_time.isValid()) return _time; | 603 | if (_time.isValid()) return _time; |
567 | return readTime(intstr, true, ok); | 604 | return readTime(intstr, true, ok); |
568 | } | 605 | } |
569 | 606 | ||
570 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | 607 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const |
571 | { | 608 | { |
572 | QString str = intstr.simplifyWhiteSpace().lower(); | 609 | QString str = intstr.simplifyWhiteSpace().lower(); |
573 | QString Format = timeFormat().simplifyWhiteSpace(); | 610 | QString Format = timeFormat().simplifyWhiteSpace(); |
574 | if (!seconds) | 611 | if (!seconds) |
575 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 612 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
576 | 613 | ||
577 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 614 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
578 | 615 | ||
579 | bool g_12h = false; | 616 | bool g_12h = false; |
580 | bool pm = false; | 617 | bool pm = false; |
581 | uint strpos = 0; | 618 | uint strpos = 0; |
582 | uint Formatpos = 0; | 619 | uint Formatpos = 0; |
583 | 620 | ||
584 | while (Format.length() > Formatpos || str.length() > strpos) | 621 | while (Format.length() > Formatpos || str.length() > strpos) |
585 | { | 622 | { |
586 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | 623 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; |
587 | 624 | ||
588 | QChar c = Format.at(Formatpos++); | 625 | QChar c = Format.at(Formatpos++); |
589 | 626 | ||
590 | if (c != '%') | 627 | if (c != '%') |
591 | { | 628 | { |
592 | if (c.isSpace()) | 629 | if (c.isSpace()) |
593 | strpos++; | 630 | strpos++; |
594 | else if (c != str.at(strpos++)) | 631 | else if (c != str.at(strpos++)) |
595 | goto error; | 632 | goto error; |
596 | continue; | 633 | continue; |
597 | } | 634 | } |
598 | 635 | ||
599 | // remove space at the begining | 636 | // remove space at the begining |
600 | if (str.length() > strpos && str.at(strpos).isSpace()) | 637 | if (str.length() > strpos && str.at(strpos).isSpace()) |
601 | strpos++; | 638 | strpos++; |
602 | 639 | ||
603 | c = Format.at(Formatpos++); | 640 | c = Format.at(Formatpos++); |
604 | switch (c) | 641 | switch (c) |
605 | { | 642 | { |
606 | case 'p': | 643 | case 'p': |
607 | { | 644 | { |
608 | QString s; | 645 | QString s; |
609 | s = i18n("pm").lower(); | 646 | s = i18n("pm").lower(); |
610 | int len = s.length(); | 647 | int len = s.length(); |
611 | if (str.mid(strpos, len) == s) | 648 | if (str.mid(strpos, len) == s) |
612 | { | 649 | { |
613 | pm = true; | 650 | pm = true; |
614 | strpos += len; | 651 | strpos += len; |
615 | } | 652 | } |
616 | else | 653 | else |
617 | { | 654 | { |
618 | s = i18n("am").lower(); | 655 | s = i18n("am").lower(); |
619 | len = s.length(); | 656 | len = s.length(); |
620 | if (str.mid(strpos, len) == s) { | 657 | if (str.mid(strpos, len) == s) { |
621 | pm = false; | 658 | pm = false; |
622 | strpos += len; | 659 | strpos += len; |
623 | } | 660 | } |
624 | else | 661 | else |
625 | goto error; | 662 | goto error; |
626 | } | 663 | } |
627 | } | 664 | } |
628 | break; | 665 | break; |
629 | 666 | ||
630 | case 'k': | 667 | case 'k': |
631 | case 'H': | 668 | case 'H': |
632 | g_12h = false; | 669 | g_12h = false; |
633 | hour = readInt(str, strpos); | 670 | hour = readInt(str, strpos); |
634 | if (hour < 0 || hour > 23) | 671 | if (hour < 0 || hour > 23) |
635 | goto error; | 672 | goto error; |
636 | 673 | ||
637 | break; | 674 | break; |
638 | 675 | ||
639 | case 'l': | 676 | case 'l': |
640 | case 'I': | 677 | case 'I': |
641 | g_12h = true; | 678 | g_12h = true; |
642 | hour = readInt(str, strpos); | 679 | hour = readInt(str, strpos); |
643 | if (hour < 1 || hour > 12) | 680 | if (hour < 1 || hour > 12) |
644 | goto error; | 681 | goto error; |
645 | 682 | ||
646 | break; | 683 | break; |
647 | 684 | ||
648 | case 'M': | 685 | case 'M': |
649 | minute = readInt(str, strpos); | 686 | minute = readInt(str, strpos); |
650 | if (minute < 0 || minute > 59) | 687 | if (minute < 0 || minute > 59) |
651 | goto error; | 688 | goto error; |
652 | 689 | ||
653 | break; | 690 | break; |
654 | 691 | ||
655 | case 'S': | 692 | case 'S': |
656 | second = readInt(str, strpos); | 693 | second = readInt(str, strpos); |
657 | if (second < 0 || second > 59) | 694 | if (second < 0 || second > 59) |
658 | goto error; | 695 | goto error; |
659 | 696 | ||
660 | break; | 697 | break; |
661 | } | 698 | } |
662 | } | 699 | } |
663 | if (g_12h) | 700 | if (g_12h) |
664 | { | 701 | { |
665 | hour %= 12; | 702 | hour %= 12; |
666 | if (pm) hour += 12; | 703 | if (pm) hour += 12; |
667 | } | 704 | } |
668 | 705 | ||
669 | if (ok) *ok = true; | 706 | if (ok) *ok = true; |
670 | return QTime(hour, minute, second); | 707 | return QTime(hour, minute, second); |
671 | 708 | ||
672 | error: | 709 | error: |
673 | if (ok) *ok = false; | 710 | if (ok) *ok = false; |
674 | return QTime(-1, -1, -1); // return invalid date if it didn't work | 711 | return QTime(-1, -1, -1); // return invalid date if it didn't work |
675 | // This will be removed in the near future, since it gives a warning on stderr. | 712 | // This will be removed in the near future, since it gives a warning on stderr. |
676 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | 713 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. |
677 | } | 714 | } |
678 | 715 | ||
679 | QDateTime KLocale::readDateTime(const QString &intstr, | 716 | QDateTime KLocale::readDateTime(const QString &intstr, |
680 | IntDateFormat intIntDateFormat, | 717 | IntDateFormat intIntDateFormat, |
681 | bool* ok) const | 718 | bool* ok) const |
682 | { | 719 | { |
683 | bool ok1, ok2; | 720 | bool ok1, ok2; |
684 | 721 | ||
685 | // AT the moment we can not read any other format then ISODate | 722 | // AT the moment we can not read any other format then ISODate |
686 | if ( intIntDateFormat != ISODate ) | 723 | if ( intIntDateFormat != ISODate ) |
687 | { | 724 | { |
688 | qDebug("KLocale::readDateTime, only ISODate is supported."); | 725 | qDebug("KLocale::readDateTime, only ISODate is supported."); |
689 | return QDateTime(); | 726 | return QDateTime(); |
690 | } | 727 | } |
691 | 728 | ||
692 | int pos = intstr.find("T"); | 729 | int pos = intstr.find("T"); |
693 | QString date = intstr.left(pos); | 730 | QString date = intstr.left(pos); |
694 | QString time = intstr.mid(pos+1); | 731 | QString time = intstr.mid(pos+1); |
695 | 732 | ||
696 | QString dformat = dateFormat(intIntDateFormat); | 733 | QString dformat = dateFormat(intIntDateFormat); |
697 | QString tformat = timeFormat(intIntDateFormat); | 734 | QString tformat = timeFormat(intIntDateFormat); |
698 | 735 | ||
699 | QDate m_date = readDate(date, dformat, &ok1); | 736 | QDate m_date = readDate(date, dformat, &ok1); |
700 | QTime m_time = readTime(time, tformat, &ok2); | 737 | QTime m_time = readTime(time, tformat, &ok2); |
701 | 738 | ||
702 | QDateTime m_dt; | 739 | QDateTime m_dt; |
703 | 740 | ||
704 | if (ok) | 741 | if (ok) |
705 | { | 742 | { |
706 | if ((ok1 == false) || (ok2 == false)) | 743 | if ((ok1 == false) || (ok2 == false)) |
707 | *ok = false; | 744 | *ok = false; |
708 | else | 745 | else |
709 | *ok = true; | 746 | *ok = true; |
710 | } | 747 | } |
711 | 748 | ||
712 | //only set values if both operations returned true. | 749 | //only set values if both operations returned true. |
713 | if ((ok1 == true) && (ok2 == true)) | 750 | if ((ok1 == true) && (ok2 == true)) |
714 | { | 751 | { |
715 | m_dt.setDate(m_date); | 752 | m_dt.setDate(m_date); |
716 | m_dt.setTime(m_time); | 753 | m_dt.setTime(m_time); |
717 | } | 754 | } |
718 | 755 | ||
719 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 756 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
720 | return m_dt; | 757 | return m_dt; |
721 | } | 758 | } |
722 | 759 | ||
723 | QDate KLocale::readDate(const QString &intstr, | 760 | QDate KLocale::readDate(const QString &intstr, |
724 | IntDateFormat intIntDateFormat, | 761 | IntDateFormat intIntDateFormat, |
725 | bool* ok) const | 762 | bool* ok) const |
726 | { | 763 | { |
727 | bool ok1; | 764 | bool ok1; |
728 | 765 | ||
729 | QString dformat = dateFormat(intIntDateFormat); | 766 | QString dformat = dateFormat(intIntDateFormat); |
730 | 767 | ||
731 | QDate m_date = readDate(intstr, dformat, &ok1); | 768 | QDate m_date = readDate(intstr, dformat, &ok1); |
732 | 769 | ||
733 | if (ok) | 770 | if (ok) |
734 | *ok = ok1; | 771 | *ok = ok1; |
735 | 772 | ||
736 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 773 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
737 | return m_date; | 774 | return m_date; |
738 | } | 775 | } |
739 | 776 | ||
740 | 777 | ||
741 | bool KLocale::use12Clock() const | 778 | bool KLocale::use12Clock() const |
742 | { | 779 | { |
743 | return !mHourF24Format ;; | 780 | return !mHourF24Format ;; |
744 | } | 781 | } |
745 | 782 | ||
746 | bool KLocale::weekStartsMonday() const | 783 | bool KLocale::weekStartsMonday() const |
747 | { | 784 | { |
748 | return mWeekStartsMonday; | 785 | return mWeekStartsMonday; |
749 | } | 786 | } |
750 | 787 | ||
751 | int KLocale::weekStartDay() const | 788 | int KLocale::weekStartDay() const |
752 | { | 789 | { |
753 | if ( mWeekStartsMonday ) | 790 | if ( mWeekStartsMonday ) |
754 | return 1; | 791 | return 1; |
755 | return 7; | 792 | return 7; |
756 | } | 793 | } |
757 | 794 | ||
758 | QString KLocale::weekDayName(int i,bool shortName) const | 795 | QString KLocale::weekDayName(int i,bool shortName) const |
759 | { | 796 | { |
760 | if ( shortName ) | 797 | if ( shortName ) |
761 | switch ( i ) | 798 | switch ( i ) |
762 | { | 799 | { |
763 | case 1: return i18n("Monday", "Mon"); | 800 | case 1: return i18n("Monday", "Mon"); |
764 | case 2: return i18n("Tuesday", "Tue"); | 801 | case 2: return i18n("Tuesday", "Tue"); |
765 | case 3: return i18n("Wednesday", "Wed"); | 802 | case 3: return i18n("Wednesday", "Wed"); |
766 | case 4: return i18n("Thursday", "Thu"); | 803 | case 4: return i18n("Thursday", "Thu"); |
767 | case 5: return i18n("Friday", "Fri"); | 804 | case 5: return i18n("Friday", "Fri"); |
768 | case 6: return i18n("Saturday", "Sat"); | 805 | case 6: return i18n("Saturday", "Sat"); |
769 | case 7: return i18n("Sunday", "Sun"); | 806 | case 7: return i18n("Sunday", "Sun"); |
770 | } | 807 | } |
771 | else | 808 | else |
772 | switch ( i ) | 809 | switch ( i ) |
773 | { | 810 | { |
774 | case 1: return i18n("Monday"); | 811 | case 1: return i18n("Monday"); |
775 | case 2: return i18n("Tuesday"); | 812 | case 2: return i18n("Tuesday"); |
776 | case 3: return i18n("Wednesday"); | 813 | case 3: return i18n("Wednesday"); |
777 | case 4: return i18n("Thursday"); | 814 | case 4: return i18n("Thursday"); |
778 | case 5: return i18n("Friday"); | 815 | case 5: return i18n("Friday"); |
779 | case 6: return i18n("Saturday"); | 816 | case 6: return i18n("Saturday"); |
780 | case 7: return i18n("Sunday"); | 817 | case 7: return i18n("Sunday"); |
781 | } | 818 | } |
782 | 819 | ||
783 | return QString::null; | 820 | return QString::null; |
784 | } | 821 | } |
785 | 822 | ||
786 | QString KLocale::monthName(int i,bool shortName) const | 823 | QString KLocale::monthName(int i,bool shortName) const |
787 | { | 824 | { |
788 | if ( shortName ) | 825 | if ( shortName ) |
789 | switch ( i ) | 826 | switch ( i ) |
790 | { | 827 | { |
791 | case 1: return i18n("January", "Jan"); | 828 | case 1: return i18n("January", "Jan"); |
792 | case 2: return i18n("February", "Feb"); | 829 | case 2: return i18n("February", "Feb"); |
793 | case 3: return i18n("March", "Mar"); | 830 | case 3: return i18n("March", "Mar"); |
794 | case 4: return i18n("April", "Apr"); | 831 | case 4: return i18n("April", "Apr"); |
795 | case 5: return i18n("May short", "May"); | 832 | case 5: return i18n("May short", "May"); |
796 | case 6: return i18n("June", "Jun"); | 833 | case 6: return i18n("June", "Jun"); |
797 | case 7: return i18n("July", "Jul"); | 834 | case 7: return i18n("July", "Jul"); |
798 | case 8: return i18n("August", "Aug"); | 835 | case 8: return i18n("August", "Aug"); |
799 | case 9: return i18n("September", "Sep"); | 836 | case 9: return i18n("September", "Sep"); |
800 | case 10: return i18n("October", "Oct"); | 837 | case 10: return i18n("October", "Oct"); |
801 | case 11: return i18n("November", "Nov"); | 838 | case 11: return i18n("November", "Nov"); |
802 | case 12: return i18n("December", "Dec"); | 839 | case 12: return i18n("December", "Dec"); |
803 | } | 840 | } |
804 | else | 841 | else |
805 | switch (i) | 842 | switch (i) |
806 | { | 843 | { |
807 | case 1: return i18n("January"); | 844 | case 1: return i18n("January"); |
808 | case 2: return i18n("February"); | 845 | case 2: return i18n("February"); |
809 | case 3: return i18n("March"); | 846 | case 3: return i18n("March"); |
810 | case 4: return i18n("April"); | 847 | case 4: return i18n("April"); |
811 | case 5: return i18n("May long", "May"); | 848 | case 5: return i18n("May long", "May"); |
812 | case 6: return i18n("June"); | 849 | case 6: return i18n("June"); |
813 | case 7: return i18n("July"); | 850 | case 7: return i18n("July"); |
814 | case 8: return i18n("August"); | 851 | case 8: return i18n("August"); |
815 | case 9: return i18n("September"); | 852 | case 9: return i18n("September"); |
816 | case 10: return i18n("October"); | 853 | case 10: return i18n("October"); |
817 | case 11: return i18n("November"); | 854 | case 11: return i18n("November"); |
818 | case 12: return i18n("December"); | 855 | case 12: return i18n("December"); |
819 | } | 856 | } |
820 | 857 | ||
821 | return QString::null; | 858 | return QString::null; |
822 | } | 859 | } |
823 | 860 | ||
824 | QString KLocale::country() const | 861 | QString KLocale::country() const |
825 | { | 862 | { |
826 | return QString::null; | 863 | return QString::null; |
827 | } | 864 | } |
828 | 865 | ||
829 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const | 866 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const |
830 | { | 867 | { |
831 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 868 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
832 | 869 | ||
833 | if ( dformat == ISODate ) | 870 | if ( dformat == ISODate ) |
834 | return "%Y-%m-%d"; | 871 | return "%Y-%m-%d"; |
835 | 872 | ||
836 | if ( QApplication::desktop()->width() < 480 ) { | 873 | if ( QApplication::desktop()->width() < 480 ) { |
837 | if ( dformat == Default ) | 874 | if ( dformat == Default ) |
838 | return "%a %d %b %Y"; | 875 | return "%a %d %b %Y"; |
839 | else if ( dformat == Format1 ) | 876 | else if ( dformat == Format1 ) |
840 | return "%a %b %d %Y"; | 877 | return "%a %b %d %Y"; |
841 | } else { | 878 | } else { |
842 | if ( dformat == Default ) | 879 | if ( dformat == Default ) |
843 | return "%A %d %B %Y"; | 880 | return "%A %d %B %Y"; |
844 | else if ( dformat == Format1 ) | 881 | else if ( dformat == Format1 ) |
845 | return "%A %B %d %Y"; | 882 | return "%A %B %d %Y"; |
846 | 883 | ||
847 | } | 884 | } |
848 | return mDateFormat ; | 885 | return mDateFormat ; |
849 | } | 886 | } |
850 | 887 | ||
851 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const | 888 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const |
852 | { | 889 | { |
853 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 890 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
854 | 891 | ||
855 | if ( dformat == Default ) | 892 | if ( dformat == Default ) |
856 | return "%d.%m.%Y"; | 893 | return "%d.%m.%Y"; |
857 | else if ( dformat == Format1 ) | 894 | else if ( dformat == Format1 ) |
858 | return "%m.%d.%Y"; | 895 | return "%m.%d.%Y"; |
859 | else if ( dformat == ISODate ) // = Qt::ISODate | 896 | else if ( dformat == ISODate ) // = Qt::ISODate |
860 | return "%Y-%m-%d"; | 897 | return "%Y-%m-%d"; |
861 | return mDateFormatShort ; | 898 | return mDateFormatShort ; |
862 | 899 | ||
863 | } | 900 | } |
864 | 901 | ||
865 | 902 | ||
866 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const | 903 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const |
867 | { | 904 | { |
868 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; | 905 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; |
869 | 906 | ||
870 | if ( tformat == Default ) | 907 | if ( tformat == Default ) |
871 | if ( mHourF24Format) | 908 | if ( mHourF24Format) |
872 | return "%H:%M:%S"; | 909 | return "%H:%M:%S"; |
873 | else | 910 | else |
874 | return "%I:%M:%S%p"; | 911 | return "%I:%M:%S%p"; |
875 | 912 | ||
876 | else if ( tformat == Format1 ) | 913 | else if ( tformat == Format1 ) |
877 | if ( mHourF24Format) | 914 | if ( mHourF24Format) |
878 | return "%H:%M:%S"; | 915 | return "%H:%M:%S"; |
879 | else | 916 | else |
880 | return "%I:%M:%S%p"; | 917 | return "%I:%M:%S%p"; |
881 | 918 | ||
882 | else if ( tformat == ISODate ) // = Qt::ISODate | 919 | else if ( tformat == ISODate ) // = Qt::ISODate |
883 | if ( mHourF24Format) | 920 | if ( mHourF24Format) |
884 | return "%H:%M:%S"; | 921 | return "%H:%M:%S"; |
885 | else | 922 | else |
886 | return "%I:%M:%S%p"; | 923 | return "%I:%M:%S%p"; |
887 | // to satisfy the compiler | 924 | // to satisfy the compiler |
888 | return "%H:%M:%S"; | 925 | return "%H:%M:%S"; |
889 | } | 926 | } |
890 | 927 | ||
891 | void KLocale::insertCatalogue ( const QString & ) | 928 | void KLocale::insertCatalogue ( const QString & ) |
892 | { | 929 | { |
893 | } | 930 | } |
894 | 931 | ||
895 | KCalendarSystem *KLocale::calendar() | 932 | KCalendarSystem *KLocale::calendar() |
896 | { | 933 | { |
897 | if ( !mCalendarSystem ) { | 934 | if ( !mCalendarSystem ) { |
898 | mCalendarSystem = new KCalendarSystemGregorian; | 935 | mCalendarSystem = new KCalendarSystemGregorian; |
899 | } | 936 | } |
900 | 937 | ||
901 | return mCalendarSystem; | 938 | return mCalendarSystem; |
902 | } | 939 | } |
903 | 940 | ||
904 | int KLocale::timezoneOffset( QString timeZone ) | 941 | int KLocale::timezoneOffset( QString timeZone ) |
905 | { | 942 | { |
906 | int ret = 1001; | 943 | int ret = 1001; |
907 | int index = mTimeZoneList.findIndex( timeZone ); | 944 | int index = mTimeZoneList.findIndex( timeZone ); |
908 | if ( index < 24 ) | 945 | if ( index < 24 ) |
909 | ret = ( index-11 ) * 60 ; | 946 | ret = ( index-11 ) * 60 ; |
910 | return ret; | 947 | return ret; |
911 | } | 948 | } |
912 | 949 | ||
913 | QStringList KLocale::timeZoneList() const | 950 | QStringList KLocale::timeZoneList() const |
914 | { | 951 | { |
915 | return mTimeZoneList; | 952 | return mTimeZoneList; |
916 | } | 953 | } |
917 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) | 954 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) |
918 | { | 955 | { |
919 | mTimeZoneOffset = timezoneOffset( timeZone ); | 956 | mTimeZoneOffset = timezoneOffset( timeZone ); |
920 | if ( oddTZ ) | 957 | if ( oddTZ ) |
921 | mTimeZoneOffset += 30; | 958 | mTimeZoneOffset += 30; |
922 | } | 959 | } |
923 | 960 | ||
924 | void KLocale::setDaylightSaving( bool b, int start , int end ) | 961 | void KLocale::setDaylightSaving( bool b, int start , int end ) |
925 | { | 962 | { |
926 | daylightEnabled = b; | 963 | daylightEnabled = b; |
927 | daylightStart = start; | 964 | daylightStart = start; |
928 | daylightEnd = end; | 965 | daylightEnd = end; |
929 | mSouthDaylight = (end < start); | 966 | mSouthDaylight = (end < start); |
930 | // qDebug("klocale daylight %d %d %d ", b, start , end ); | 967 | // qDebug("klocale daylight %d %d %d ", b, start , end ); |
931 | } | 968 | } |
932 | 969 | ||
933 | int KLocale::localTimeOffset( const QDateTime &dt ) | 970 | int KLocale::localTimeOffset( const QDateTime &dt ) |
934 | { | 971 | { |
935 | bool addDaylight = false; | 972 | bool addDaylight = false; |
936 | if ( daylightEnabled ) { | 973 | if ( daylightEnabled ) { |
937 | int d_end, d_start; | 974 | int d_end, d_start; |
938 | int dayofyear = dt.date().dayOfYear(); | 975 | int dayofyear = dt.date().dayOfYear(); |
939 | int year = dt.date().year(); | 976 | int year = dt.date().year(); |
940 | int add = 0; | 977 | int add = 0; |
941 | if ( QDate::leapYear(year) ) | 978 | if ( QDate::leapYear(year) ) |
942 | add = 1; | 979 | add = 1; |
943 | QDate date ( year,1,1 ); | 980 | QDate date ( year,1,1 ); |
944 | if ( daylightEnd > 59 ) | 981 | if ( daylightEnd > 59 ) |
945 | d_end = daylightEnd +add; | 982 | d_end = daylightEnd +add; |
946 | else | 983 | else |
947 | d_end = daylightEnd; | 984 | d_end = daylightEnd; |
948 | if ( daylightStart > 59 ) | 985 | if ( daylightStart > 59 ) |
949 | d_start = daylightStart +add; | 986 | d_start = daylightStart +add; |
950 | else | 987 | else |
951 | d_start = daylightStart; | 988 | d_start = daylightStart; |
952 | QDate s_date = date.addDays( d_start -1 ); | 989 | QDate s_date = date.addDays( d_start -1 ); |
953 | QDate e_date = date.addDays( d_end -1 ); | 990 | QDate e_date = date.addDays( d_end -1 ); |
954 | int dof = s_date.dayOfWeek(); | 991 | int dof = s_date.dayOfWeek(); |
955 | if ( dof < 7 ) | 992 | if ( dof < 7 ) |
956 | s_date = s_date.addDays( -dof ); | 993 | s_date = s_date.addDays( -dof ); |
957 | dof = e_date.dayOfWeek(); | 994 | dof = e_date.dayOfWeek(); |
958 | if ( dof < 7 ) | 995 | if ( dof < 7 ) |
959 | e_date = e_date.addDays( -dof ); | 996 | e_date = e_date.addDays( -dof ); |
960 | QTime startTime ( 3,0,0 ); | 997 | QTime startTime ( 3,0,0 ); |
961 | QDateTime startDt( s_date, startTime ); | 998 | QDateTime startDt( s_date, startTime ); |
962 | QDateTime endDt( e_date, startTime ); | 999 | QDateTime endDt( e_date, startTime ); |
963 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); | 1000 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); |
964 | if ( mSouthDaylight ) { | 1001 | if ( mSouthDaylight ) { |
965 | if ( ! ( endDt < dt && dt < startDt) ) | 1002 | if ( ! ( endDt < dt && dt < startDt) ) |
966 | addDaylight = true; | 1003 | addDaylight = true; |
967 | } else { | 1004 | } else { |
968 | if ( startDt < dt && dt < endDt ) | 1005 | if ( startDt < dt && dt < endDt ) |
969 | addDaylight = true; | 1006 | addDaylight = true; |
970 | 1007 | ||
971 | 1008 | ||
972 | } | 1009 | } |
973 | } | 1010 | } |
974 | int addMin = 0; | 1011 | int addMin = 0; |
975 | if ( addDaylight ) | 1012 | if ( addDaylight ) |
976 | addMin = 60; | 1013 | addMin = 60; |
977 | return mTimeZoneOffset + addMin; | 1014 | return mTimeZoneOffset + addMin; |
978 | } | 1015 | } |
979 | // ****************************************************************** | 1016 | // ****************************************************************** |
980 | // added LR | 1017 | // added LR |
981 | QString KLocale::formatNumber(double num, int precision) const | 1018 | QString KLocale::formatNumber(double num, int precision) const |
982 | { | 1019 | { |
983 | bool neg = num < 0; | 1020 | bool neg = num < 0; |
984 | if (precision == -1) precision = 2; | 1021 | if (precision == -1) precision = 2; |
985 | QString res = QString::number(neg?-num:num, 'f', precision); | 1022 | QString res = QString::number(neg?-num:num, 'f', precision); |
986 | int pos = res.find('.'); | 1023 | int pos = res.find('.'); |
987 | if (pos == -1) pos = res.length(); | 1024 | if (pos == -1) pos = res.length(); |
988 | else res.replace(pos, 1, decimalSymbol()); | 1025 | else res.replace(pos, 1, decimalSymbol()); |
989 | 1026 | ||
990 | while (0 < (pos -= 3)) | 1027 | while (0 < (pos -= 3)) |
991 | res.insert(pos, thousandsSeparator()); // thousand sep | 1028 | res.insert(pos, thousandsSeparator()); // thousand sep |
992 | 1029 | ||
993 | // How can we know where we should put the sign? | 1030 | // How can we know where we should put the sign? |
994 | res.prepend(neg?negativeSign():positiveSign()); | 1031 | res.prepend(neg?negativeSign():positiveSign()); |
995 | 1032 | ||
996 | return res; | 1033 | return res; |
997 | } | 1034 | } |
998 | QString KLocale::formatNumber(const QString &numStr) const | 1035 | QString KLocale::formatNumber(const QString &numStr) const |
999 | { | 1036 | { |
1000 | return formatNumber(numStr.toDouble()); | 1037 | return formatNumber(numStr.toDouble()); |
1001 | } | 1038 | } |
1002 | double KLocale::readNumber(const QString &_str, bool * ok) const | 1039 | double KLocale::readNumber(const QString &_str, bool * ok) const |
1003 | { | 1040 | { |
1004 | QString str = _str.stripWhiteSpace(); | 1041 | QString str = _str.stripWhiteSpace(); |
1005 | bool neg = str.find(negativeSign()) == 0; | 1042 | bool neg = str.find(negativeSign()) == 0; |
1006 | if (neg) | 1043 | if (neg) |
1007 | str.remove( 0, negativeSign().length() ); | 1044 | str.remove( 0, negativeSign().length() ); |
1008 | 1045 | ||
1009 | /* will hold the scientific notation portion of the number. | 1046 | /* will hold the scientific notation portion of the number. |
1010 | Example, with 2.34E+23, exponentialPart == "E+23" | 1047 | Example, with 2.34E+23, exponentialPart == "E+23" |
1011 | */ | 1048 | */ |
1012 | QString exponentialPart; | 1049 | QString exponentialPart; |
1013 | int EPos; | 1050 | int EPos; |
1014 | 1051 | ||
1015 | EPos = str.find('E', 0, false); | 1052 | EPos = str.find('E', 0, false); |
1016 | 1053 | ||
1017 | if (EPos != -1) | 1054 | if (EPos != -1) |
1018 | { | 1055 | { |
1019 | exponentialPart = str.mid(EPos); | 1056 | exponentialPart = str.mid(EPos); |
1020 | str = str.left(EPos); | 1057 | str = str.left(EPos); |
1021 | } | 1058 | } |
1022 | 1059 | ||
1023 | int pos = str.find(decimalSymbol()); | 1060 | int pos = str.find(decimalSymbol()); |
1024 | QString major; | 1061 | QString major; |
1025 | QString minor; | 1062 | QString minor; |
1026 | if ( pos == -1 ) | 1063 | if ( pos == -1 ) |
1027 | major = str; | 1064 | major = str; |
1028 | else | 1065 | else |
1029 | { | 1066 | { |
1030 | major = str.left(pos); | 1067 | major = str.left(pos); |
1031 | minor = str.mid(pos + decimalSymbol().length()); | 1068 | minor = str.mid(pos + decimalSymbol().length()); |
1032 | } | 1069 | } |
1033 | 1070 | ||
1034 | // Remove thousand separators | 1071 | // Remove thousand separators |
1035 | int thlen = thousandsSeparator().length(); | 1072 | int thlen = thousandsSeparator().length(); |
1036 | int lastpos = 0; | 1073 | int lastpos = 0; |
1037 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) | 1074 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) |
1038 | { | 1075 | { |
1039 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N | 1076 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N |
1040 | int fromEnd = major.length() - pos; | 1077 | int fromEnd = major.length() - pos; |
1041 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error | 1078 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error |
1042 | || pos - lastpos > 3 // More than 3 digits between two separators -> error | 1079 | || pos - lastpos > 3 // More than 3 digits between two separators -> error |
1043 | || pos == 0 // Can't start with a separator | 1080 | || pos == 0 // Can't start with a separator |
1044 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators | 1081 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators |
1045 | { | 1082 | { |
1046 | if (ok) *ok = false; | 1083 | if (ok) *ok = false; |
1047 | return 0.0; | 1084 | return 0.0; |
1048 | } | 1085 | } |
1049 | 1086 | ||
1050 | lastpos = pos; | 1087 | lastpos = pos; |
1051 | major.remove( pos, thlen ); | 1088 | major.remove( pos, thlen ); |
1052 | } | 1089 | } |
1053 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator | 1090 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator |
1054 | { | 1091 | { |
1055 | if (ok) *ok = false; | 1092 | if (ok) *ok = false; |
1056 | return 0.0; | 1093 | return 0.0; |
1057 | } | 1094 | } |
1058 | 1095 | ||
1059 | QString tot; | 1096 | QString tot; |
1060 | if (neg) tot = '-'; | 1097 | if (neg) tot = '-'; |
1061 | 1098 | ||
1062 | tot += major + '.' + minor + exponentialPart; | 1099 | tot += major + '.' + minor + exponentialPart; |
1063 | 1100 | ||
1064 | return tot.toDouble(ok); | 1101 | return tot.toDouble(ok); |
1065 | } | 1102 | } |
1066 | QString KLocale::decimalSymbol() const | 1103 | QString KLocale::decimalSymbol() const |
1067 | { | 1104 | { |
1068 | 1105 | ||
1069 | return m_decimalSymbol; | 1106 | return m_decimalSymbol; |
1070 | } | 1107 | } |
1071 | 1108 | ||
1072 | QString KLocale::thousandsSeparator() const | 1109 | QString KLocale::thousandsSeparator() const |
1073 | { | 1110 | { |
1074 | 1111 | ||
1075 | return m_thousandsSeparator; | 1112 | return m_thousandsSeparator; |
1076 | } | 1113 | } |
1077 | QString KLocale::positiveSign() const | 1114 | QString KLocale::positiveSign() const |
1078 | { | 1115 | { |
1079 | return m_positiveSign; | 1116 | return m_positiveSign; |
1080 | } | 1117 | } |
1081 | 1118 | ||
1082 | QString KLocale::negativeSign() const | 1119 | QString KLocale::negativeSign() const |
1083 | { | 1120 | { |
1084 | return m_negativeSign; | 1121 | return m_negativeSign; |
1085 | } | 1122 | } |
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 14660d6..58e0b39 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h | |||
@@ -1,119 +1,119 @@ | |||
1 | #ifndef MINIKDE_KLOCALE_H | 1 | #ifndef MINIKDE_KLOCALE_H |
2 | #define MINIKDE_KLOCALE_H | 2 | #define MINIKDE_KLOCALE_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qdatetime.h> | 6 | #include <qdatetime.h> |
7 | #include <qdict.h> | 7 | #include <qdict.h> |
8 | 8 | ||
9 | #ifndef I18N_NOOP | 9 | #ifndef I18N_NOOP |
10 | #define I18N_NOOP(x) (x) | 10 | #define I18N_NOOP(x) (x) |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | class KCalendarSystem; | 13 | class KCalendarSystem; |
14 | void setLocaleDict( QDict<QString> * dict ); | 14 | void setLocaleDict( QDict<QString> * dict ); |
15 | QString i18n(const char *text); | 15 | QString i18n(const char *text); |
16 | QString i18n(const char *hint, const char *text); | 16 | QString i18n(const char *hint, const char *text); |
17 | QString i18n(const char *text1, const char *textn, int num); | 17 | QString i18n(const char *text1, const char *textn, int num); |
18 | 18 | ||
19 | // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict | 19 | // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict |
20 | // with our i18n method. we use uic -tr tr2i18n to redirect | 20 | // with our i18n method. we use uic -tr tr2i18n to redirect |
21 | // to the right i18n() function | 21 | // to the right i18n() function |
22 | inline QString tr2i18n(const char* message, const char* =0) { | 22 | inline QString tr2i18n(const char* message, const char* =0) { |
23 | return i18n( message); | 23 | return i18n( message); |
24 | } | 24 | } |
25 | 25 | ||
26 | class KLocale | 26 | class KLocale |
27 | { | 27 | { |
28 | public: | 28 | public: |
29 | KLocale(); | 29 | KLocale(); |
30 | 30 | ||
31 | QString formatNumber(double num, int precision = -1) const; | 31 | QString formatNumber(double num, int precision = -1) const; |
32 | QString formatNumber(const QString &numStr) const; | 32 | QString formatNumber(const QString &numStr) const; |
33 | double readNumber(const QString &numStr, bool * ok = 0) const; | 33 | double readNumber(const QString &numStr, bool * ok = 0) const; |
34 | 34 | ||
35 | QString decimalSymbol() const; | 35 | QString decimalSymbol() const; |
36 | QString thousandsSeparator() const; | 36 | QString thousandsSeparator() const; |
37 | QString positiveSign() const; | 37 | QString positiveSign() const; |
38 | QString negativeSign() const; | 38 | QString negativeSign() const; |
39 | 39 | ||
40 | 40 | ||
41 | QString translate( const char *index ) const; | 41 | QString translate( const char *index ) const; |
42 | QString translate( const char *index, const char *fallback) const; | 42 | QString translate( const char *index, const char *fallback) const; |
43 | 43 | ||
44 | enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; | 44 | enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; |
45 | 45 | ||
46 | QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; | 46 | QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; |
47 | QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; | 47 | QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; |
48 | QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; | 48 | QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; |
49 | QString formatDateTime(const QDateTime &pDateTime, | 49 | QString formatDateTime(const QDateTime &pDateTime, |
50 | bool shortFormat, | 50 | bool shortFormat, |
51 | bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; | 51 | bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; |
52 | 52 | ||
53 | QDate readDate(const QString &str, bool* ok = 0) const; | 53 | QDate readDate(const QString &str, bool* ok = 0) const; |
54 | QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; | 54 | QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; |
55 | QTime readTime(const QString &str, bool* ok = 0) const; | 55 | QTime readTime(const QString &str, bool* ok = 0) const; |
56 | QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; | 56 | QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; |
57 | 57 | ||
58 | QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; | 58 | QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; |
59 | 59 | ||
60 | bool use12Clock() const; | 60 | bool use12Clock() const; |
61 | bool weekStartsMonday() const; | 61 | bool weekStartsMonday() const; |
62 | int weekStartDay() const; | 62 | int weekStartDay() const; |
63 | 63 | ||
64 | QString weekDayName(int,bool=false) const; | 64 | QString weekDayName(int,bool=false) const; |
65 | QString monthName(int,bool=false) const; | 65 | QString monthName(int,bool=false) const; |
66 | 66 | ||
67 | QString country() const; | 67 | QString country() const; |
68 | 68 | int weekNum ( const QDate & ); | |
69 | QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; | 69 | QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; |
70 | QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; | 70 | QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; |
71 | QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; | 71 | QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; |
72 | 72 | ||
73 | void insertCatalogue ( const QString & ); | 73 | void insertCatalogue ( const QString & ); |
74 | 74 | ||
75 | KCalendarSystem *calendar(); | 75 | KCalendarSystem *calendar(); |
76 | void setHore24Format ( bool ); | 76 | void setHore24Format ( bool ); |
77 | void setWeekStartMonday( bool ); | 77 | void setWeekStartMonday( bool ); |
78 | void setIntDateFormat( IntDateFormat ); | 78 | void setIntDateFormat( IntDateFormat ); |
79 | void setIntTimeFormat( IntDateFormat ); | 79 | void setIntTimeFormat( IntDateFormat ); |
80 | IntDateFormat getIntDateFormat( ); | 80 | IntDateFormat getIntDateFormat( ); |
81 | IntDateFormat getIntTimeFormat( ); | 81 | IntDateFormat getIntTimeFormat( ); |
82 | void setLanguage( int ); | 82 | void setLanguage( int ); |
83 | int language(); | 83 | int language(); |
84 | void setDateFormat( QString ); | 84 | void setDateFormat( QString ); |
85 | void setDateFormatShort( QString ); | 85 | void setDateFormatShort( QString ); |
86 | 86 | ||
87 | QString m_decimalSymbol; | 87 | QString m_decimalSymbol; |
88 | QString m_thousandsSeparator; | 88 | QString m_thousandsSeparator; |
89 | QString m_currencySymbol; | 89 | QString m_currencySymbol; |
90 | QString m_monetaryDecimalSymbol; | 90 | QString m_monetaryDecimalSymbol; |
91 | QString m_monetaryThousandsSeparator; | 91 | QString m_monetaryThousandsSeparator; |
92 | QString m_positiveSign; | 92 | QString m_positiveSign; |
93 | QString m_negativeSign; | 93 | QString m_negativeSign; |
94 | 94 | ||
95 | int timezoneOffset( QString ); | 95 | int timezoneOffset( QString ); |
96 | QStringList timeZoneList() const; | 96 | QStringList timeZoneList() const; |
97 | void setDaylightSaving( bool, int , int ); | 97 | void setDaylightSaving( bool, int , int ); |
98 | int localTimeOffset(const QDateTime &); | 98 | int localTimeOffset(const QDateTime &); |
99 | void setTimezone( const QString &timeZone , bool oddTZ); | 99 | void setTimezone( const QString &timeZone , bool oddTZ); |
100 | private: | 100 | private: |
101 | QTime readTime(const QString &str, bool seconds, bool *ok) const; | 101 | QTime readTime(const QString &str, bool seconds, bool *ok) const; |
102 | QDate readDate(const QString &str, bool shortFormat, bool *ok) const; | 102 | QDate readDate(const QString &str, bool shortFormat, bool *ok) const; |
103 | KCalendarSystem *mCalendarSystem; | 103 | KCalendarSystem *mCalendarSystem; |
104 | bool mWeekStartsMonday; | 104 | bool mWeekStartsMonday; |
105 | bool mHourF24Format; | 105 | bool mHourF24Format; |
106 | IntDateFormat mIntDateFormat; | 106 | IntDateFormat mIntDateFormat; |
107 | IntDateFormat mIntTimeFormat; | 107 | IntDateFormat mIntTimeFormat; |
108 | int mLanguage; | 108 | int mLanguage; |
109 | QString mDateFormat; | 109 | QString mDateFormat; |
110 | QString mDateFormatShort; | 110 | QString mDateFormatShort; |
111 | QStringList mTimeZoneList; | 111 | QStringList mTimeZoneList; |
112 | bool daylightEnabled; | 112 | bool daylightEnabled; |
113 | int mDaylightTZoffset; | 113 | int mDaylightTZoffset; |
114 | int mNondaylightTZoffset; | 114 | int mNondaylightTZoffset; |
115 | bool mSouthDaylight; | 115 | bool mSouthDaylight; |
116 | int daylightStart, daylightEnd, mTimeZoneOffset; | 116 | int daylightStart, daylightEnd, mTimeZoneOffset; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | #endif | 119 | #endif |