-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 6 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 7 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 34 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 2 |
5 files changed, 41 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index be78057..e0380fa 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1896 +1,1898 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | mBlockShowDates = false; | 236 | mBlockShowDates = false; |
237 | beamDialog = new KOBeamPrefs(); | 237 | beamDialog = new KOBeamPrefs(); |
238 | mDatePickerMode = 0; | 238 | mDatePickerMode = 0; |
239 | mCurrentSyncDevice = ""; | 239 | mCurrentSyncDevice = ""; |
240 | writeLocale(); | 240 | writeLocale(); |
241 | mViewManager = new KOViewManager( this ); | 241 | mViewManager = new KOViewManager( this ); |
242 | mDialogManager = new KODialogManager( this ); | 242 | mDialogManager = new KODialogManager( this ); |
243 | mEventViewerDialog = 0; | 243 | mEventViewerDialog = 0; |
244 | mModified = false; | 244 | mModified = false; |
245 | mReadOnly = false; | 245 | mReadOnly = false; |
246 | mSelectedIncidence = 0; | 246 | mSelectedIncidence = 0; |
247 | mCalPrinter = 0; | 247 | mCalPrinter = 0; |
248 | mFilters.setAutoDelete(true); | 248 | mFilters.setAutoDelete(true); |
249 | 249 | ||
250 | mCalendar->registerObserver( this ); | 250 | mCalendar->registerObserver( this ); |
251 | // TODO: Make sure that view is updated, when calendar is changed. | 251 | // TODO: Make sure that view is updated, when calendar is changed. |
252 | 252 | ||
253 | mStorage = new FileStorage( mCalendar ); | 253 | mStorage = new FileStorage( mCalendar ); |
254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
255 | 255 | ||
256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
257 | #ifndef KORG_NOSPLITTER | 257 | #ifndef KORG_NOSPLITTER |
258 | // create the main layout frames. | 258 | // create the main layout frames. |
259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
260 | topLayout->addWidget(mPanner); | 260 | topLayout->addWidget(mPanner); |
261 | 261 | ||
262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
263 | "CalendarView::LeftFrame"); | 263 | "CalendarView::LeftFrame"); |
264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
265 | 265 | ||
266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
267 | "CalendarView::DateNavigator", QDate::currentDate() ); | 267 | "CalendarView::DateNavigator", QDate::currentDate() ); |
268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
270 | mTodoList->setNavigator( mNavigator ); | 270 | mTodoList->setNavigator( mNavigator ); |
271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
272 | 272 | ||
273 | #ifdef KORG_NORESOURCEVIEW | 273 | #ifdef KORG_NORESOURCEVIEW |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | #else | 275 | #else |
276 | if ( mResourceManager ) { | 276 | if ( mResourceManager ) { |
277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
278 | mResourceView->updateView(); | 278 | mResourceView->updateView(); |
279 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 279 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
280 | SLOT( updateView() ) ); | 280 | SLOT( updateView() ) ); |
281 | } else { | 281 | } else { |
282 | mResourceView = 0; | 282 | mResourceView = 0; |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | QWidget *rightBox = new QWidget( mPanner ); | 285 | QWidget *rightBox = new QWidget( mPanner ); |
286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
287 | 287 | ||
288 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 288 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
289 | rightLayout->addWidget( mNavigatorBar ); | 289 | rightLayout->addWidget( mNavigatorBar ); |
290 | 290 | ||
291 | mRightFrame = new QWidgetStack( rightBox ); | 291 | mRightFrame = new QWidgetStack( rightBox ); |
292 | rightLayout->addWidget( mRightFrame, 1 ); | 292 | rightLayout->addWidget( mRightFrame, 1 ); |
293 | 293 | ||
294 | mLeftFrame = mLeftSplitter; | 294 | mLeftFrame = mLeftSplitter; |
295 | #else | 295 | #else |
296 | QWidget *mainBox = new QWidget( this ); | 296 | QWidget *mainBox = new QWidget( this ); |
297 | QWidget *leftFrame = new QWidget( mainBox ); | 297 | QWidget *leftFrame = new QWidget( mainBox ); |
298 | 298 | ||
299 | QBoxLayout * mainBoxLayout; | 299 | QBoxLayout * mainBoxLayout; |
300 | QBoxLayout * leftFrameLayout; | 300 | QBoxLayout * leftFrameLayout; |
301 | if ( KOPrefs::instance()->mVerticalScreen ) { | 301 | if ( KOPrefs::instance()->mVerticalScreen ) { |
302 | mainBoxLayout = new QVBoxLayout(mainBox); | 302 | mainBoxLayout = new QVBoxLayout(mainBox); |
303 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 303 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
304 | } else { | 304 | } else { |
305 | mainBoxLayout = new QHBoxLayout(mainBox); | 305 | mainBoxLayout = new QHBoxLayout(mainBox); |
306 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 306 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
307 | } | 307 | } |
308 | topLayout->addWidget( mainBox ); | 308 | topLayout->addWidget( mainBox ); |
309 | mainBoxLayout->addWidget (leftFrame); | 309 | mainBoxLayout->addWidget (leftFrame); |
310 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 310 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
311 | "CalendarView::DateNavigator", QDate::currentDate()); | 311 | "CalendarView::DateNavigator", QDate::currentDate()); |
312 | // mDateNavigator->blockSignals( true ); | 312 | // mDateNavigator->blockSignals( true ); |
313 | leftFrameLayout->addWidget( mDateNavigator ); | 313 | leftFrameLayout->addWidget( mDateNavigator ); |
314 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 314 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
315 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 315 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
316 | mTodoList->setNavigator( mNavigator ); | 316 | mTodoList->setNavigator( mNavigator ); |
317 | 317 | ||
318 | if ( QApplication::desktop()->width() < 480 ) { | 318 | if ( QApplication::desktop()->width() < 480 ) { |
319 | leftFrameLayout->addWidget(mFilterView); | 319 | leftFrameLayout->addWidget(mFilterView); |
320 | leftFrameLayout->addWidget(mTodoList, 2 ); | 320 | leftFrameLayout->addWidget(mTodoList, 2 ); |
321 | 321 | ||
322 | } else { | 322 | } else { |
323 | leftFrameLayout->addWidget(mTodoList,2 ); | 323 | leftFrameLayout->addWidget(mTodoList,2 ); |
324 | leftFrameLayout->addWidget(mFilterView ); | 324 | leftFrameLayout->addWidget(mFilterView ); |
325 | } | 325 | } |
326 | mFilterView->hide(); | 326 | mFilterView->hide(); |
327 | QWidget *rightBox = new QWidget( mainBox ); | 327 | QWidget *rightBox = new QWidget( mainBox ); |
328 | mainBoxLayout->addWidget ( rightBox, 10 ); | 328 | mainBoxLayout->addWidget ( rightBox, 10 ); |
329 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 329 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
330 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 330 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
331 | mRightFrame = new QWidgetStack( rightBox ); | 331 | mRightFrame = new QWidgetStack( rightBox ); |
332 | rightLayout->addWidget( mNavigatorBar ); | 332 | rightLayout->addWidget( mNavigatorBar ); |
333 | rightLayout->addWidget( mRightFrame, 10 ); | 333 | rightLayout->addWidget( mRightFrame, 10 ); |
334 | 334 | ||
335 | mLeftFrame = leftFrame; | 335 | mLeftFrame = leftFrame; |
336 | if ( KOPrefs::instance()->mVerticalScreen ) { | 336 | if ( KOPrefs::instance()->mVerticalScreen ) { |
337 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 338 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
339 | } else { | 339 | } else { |
340 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 341 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
342 | } | 342 | } |
343 | if ( !KOPrefs::instance()->mShowDateNavigator) | 343 | if ( !KOPrefs::instance()->mShowDateNavigator) |
344 | mDateNavigator->hide(); | 344 | mDateNavigator->hide(); |
345 | //qDebug("Calendarview Size %d %d ", width(), height()); | 345 | //qDebug("Calendarview Size %d %d ", width(), height()); |
346 | #endif | 346 | #endif |
347 | 347 | ||
348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
349 | SLOT( showDates( const KCal::DateList & ) ) ); | 349 | SLOT( showDates( const KCal::DateList & ) ) ); |
350 | 350 | ||
351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
352 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 352 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
354 | mNavigator, SLOT( selectPreviousYear() ) ); | 354 | mNavigator, SLOT( selectPreviousYear() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
356 | mNavigator, SLOT( selectNextYear() ) ); | 356 | mNavigator, SLOT( selectNextYear() ) ); |
357 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 357 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
358 | mNavigator, SLOT( selectPreviousMonth() ) ); | 358 | mNavigator, SLOT( selectPreviousMonth() ) ); |
359 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 359 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
360 | mNavigator, SLOT( selectNextMonth() ) ); | 360 | mNavigator, SLOT( selectNextMonth() ) ); |
361 | connect( mNavigatorBar, SIGNAL( selectWeek( int ) ), | ||
362 | mNavigator, SLOT( selectWeek( int ) ) ); | ||
361 | 363 | ||
362 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
363 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 365 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
364 | 366 | ||
365 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 367 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
366 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 368 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
367 | 369 | ||
368 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 370 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
369 | mNavigator, SLOT( selectPreviousYear() ) ); | 371 | mNavigator, SLOT( selectPreviousYear() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 372 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
371 | mNavigator, SLOT( selectNextYear() ) ); | 373 | mNavigator, SLOT( selectNextYear() ) ); |
372 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 374 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
373 | mNavigator, SLOT( selectPreviousMonth() ) ); | 375 | mNavigator, SLOT( selectPreviousMonth() ) ); |
374 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 376 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
375 | mNavigator, SLOT( selectNextMonth() ) ); | 377 | mNavigator, SLOT( selectNextMonth() ) ); |
376 | 378 | ||
377 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 379 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
378 | mNavigator, SLOT( selectPrevious() ) ); | 380 | mNavigator, SLOT( selectPrevious() ) ); |
379 | connect( mDateNavigator, SIGNAL( goNext() ), | 381 | connect( mDateNavigator, SIGNAL( goNext() ), |
380 | mNavigator, SLOT( selectNext() ) ); | 382 | mNavigator, SLOT( selectNext() ) ); |
381 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 383 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 384 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
383 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 385 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
384 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 386 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
385 | 387 | ||
386 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 388 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
387 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 389 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
388 | 390 | ||
389 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 391 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
390 | SLOT( eventAdded( Event *) ) ); | 392 | SLOT( eventAdded( Event *) ) ); |
391 | 393 | ||
392 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 394 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
393 | 395 | ||
394 | connect( this, SIGNAL( configChanged() ), | 396 | connect( this, SIGNAL( configChanged() ), |
395 | mDateNavigator, SLOT( updateConfig() ) ); | 397 | mDateNavigator, SLOT( updateConfig() ) ); |
396 | 398 | ||
397 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 399 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
398 | SLOT( newTodo() ) ); | 400 | SLOT( newTodo() ) ); |
399 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
400 | SLOT( newSubTodo( Todo * ) ) ); | 402 | SLOT( newSubTodo( Todo * ) ) ); |
401 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 403 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
402 | SLOT( editTodo( Todo * ) ) ); | 404 | SLOT( editTodo( Todo * ) ) ); |
403 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 405 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
404 | SLOT( showTodo( Todo *) ) ); | 406 | SLOT( showTodo( Todo *) ) ); |
405 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 407 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
406 | SLOT( deleteTodo( Todo *) ) ); | 408 | SLOT( deleteTodo( Todo *) ) ); |
407 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 409 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
408 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 410 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
409 | SLOT( purgeCompleted() ) ); | 411 | SLOT( purgeCompleted() ) ); |
410 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 412 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
411 | SIGNAL( todoModified( Todo *, int ) ) ); | 413 | SIGNAL( todoModified( Todo *, int ) ) ); |
412 | 414 | ||
413 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 415 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
414 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 416 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
415 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 417 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
416 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 418 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
417 | 419 | ||
418 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 420 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
419 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 421 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
420 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 422 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
421 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 423 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
422 | 424 | ||
423 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 425 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
424 | this, SLOT ( todo_unsub( Todo * ) ) ); | 426 | this, SLOT ( todo_unsub( Todo * ) ) ); |
425 | 427 | ||
426 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 428 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
427 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 429 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
428 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 430 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
429 | SLOT( updateTodo( Todo *, int ) ) ); | 431 | SLOT( updateTodo( Todo *, int ) ) ); |
430 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 432 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
431 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 433 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
432 | 434 | ||
433 | 435 | ||
434 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 436 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
435 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 437 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
436 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 438 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
437 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 439 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
438 | 440 | ||
439 | 441 | ||
440 | 442 | ||
441 | 443 | ||
442 | 444 | ||
443 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 445 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
444 | SLOT(checkClipboard())); | 446 | SLOT(checkClipboard())); |
445 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 447 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
446 | SLOT( processTodoListSelection( Incidence * ) ) ); | 448 | SLOT( processTodoListSelection( Incidence * ) ) ); |
447 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 449 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
448 | 450 | ||
449 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 451 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
450 | 452 | ||
451 | mDateFrame = new QVBox(0,0,WType_Popup); | 453 | mDateFrame = new QVBox(0,0,WType_Popup); |
452 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 454 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
453 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 455 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
454 | mDateFrame->setLineWidth(3); | 456 | mDateFrame->setLineWidth(3); |
455 | mDateFrame->hide(); | 457 | mDateFrame->hide(); |
456 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 458 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
457 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 459 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
458 | 460 | ||
459 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 461 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
460 | 462 | ||
461 | mEventEditor = mDialogManager->getEventEditor(); | 463 | mEventEditor = mDialogManager->getEventEditor(); |
462 | mTodoEditor = mDialogManager->getTodoEditor(); | 464 | mTodoEditor = mDialogManager->getTodoEditor(); |
463 | 465 | ||
464 | mFlagEditDescription = false; | 466 | mFlagEditDescription = false; |
465 | 467 | ||
466 | mSuspendTimer = new QTimer( this ); | 468 | mSuspendTimer = new QTimer( this ); |
467 | mAlarmTimer = new QTimer( this ); | 469 | mAlarmTimer = new QTimer( this ); |
468 | mRecheckAlarmTimer = new QTimer( this ); | 470 | mRecheckAlarmTimer = new QTimer( this ); |
469 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 471 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
470 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 472 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
471 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 473 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
472 | mAlarmDialog = new AlarmDialog( this ); | 474 | mAlarmDialog = new AlarmDialog( this ); |
473 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 475 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
474 | mAlarmDialog->setServerNotification( false ); | 476 | mAlarmDialog->setServerNotification( false ); |
475 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 477 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
476 | 478 | ||
477 | 479 | ||
478 | #ifndef DESKTOP_VERSION | 480 | #ifndef DESKTOP_VERSION |
479 | //US listen for arriving address resultsets | 481 | //US listen for arriving address resultsets |
480 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 482 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
481 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 483 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
482 | #endif | 484 | #endif |
483 | 485 | ||
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | CalendarView::~CalendarView() | 489 | CalendarView::~CalendarView() |
488 | { | 490 | { |
489 | // kdDebug() << "~CalendarView()" << endl; | 491 | // kdDebug() << "~CalendarView()" << endl; |
490 | //qDebug("CalendarView::~CalendarView() "); | 492 | //qDebug("CalendarView::~CalendarView() "); |
491 | delete mDialogManager; | 493 | delete mDialogManager; |
492 | delete mViewManager; | 494 | delete mViewManager; |
493 | delete mStorage; | 495 | delete mStorage; |
494 | delete mDateFrame ; | 496 | delete mDateFrame ; |
495 | delete beamDialog; | 497 | delete beamDialog; |
496 | //kdDebug() << "~CalendarView() done" << endl; | 498 | //kdDebug() << "~CalendarView() done" << endl; |
497 | } | 499 | } |
498 | 500 | ||
499 | void CalendarView::showDay( QDate d ) | 501 | void CalendarView::showDay( QDate d ) |
500 | { | 502 | { |
501 | dateNavigator()->blockSignals( true ); | 503 | dateNavigator()->blockSignals( true ); |
502 | dateNavigator()->selectDate( d ); | 504 | dateNavigator()->selectDate( d ); |
503 | dateNavigator()->blockSignals( false ); | 505 | dateNavigator()->blockSignals( false ); |
504 | mViewManager->showDayView(); | 506 | mViewManager->showDayView(); |
505 | //dateNavigator()->selectDate( d ); | 507 | //dateNavigator()->selectDate( d ); |
506 | } | 508 | } |
507 | void CalendarView::timerAlarm() | 509 | void CalendarView::timerAlarm() |
508 | { | 510 | { |
509 | //qDebug("CalendarView::timerAlarm() "); | 511 | //qDebug("CalendarView::timerAlarm() "); |
510 | computeAlarm(mAlarmNotification ); | 512 | computeAlarm(mAlarmNotification ); |
511 | } | 513 | } |
512 | 514 | ||
513 | void CalendarView::suspendAlarm() | 515 | void CalendarView::suspendAlarm() |
514 | { | 516 | { |
515 | //qDebug(" CalendarView::suspendAlarm() "); | 517 | //qDebug(" CalendarView::suspendAlarm() "); |
516 | computeAlarm(mSuspendAlarmNotification ); | 518 | computeAlarm(mSuspendAlarmNotification ); |
517 | 519 | ||
518 | } | 520 | } |
519 | 521 | ||
520 | void CalendarView::startAlarm( QString mess , QString filename) | 522 | void CalendarView::startAlarm( QString mess , QString filename) |
521 | { | 523 | { |
522 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
523 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
524 | 526 | ||
525 | } | 527 | } |
526 | 528 | ||
527 | void CalendarView::checkNextTimerAlarm() | 529 | void CalendarView::checkNextTimerAlarm() |
528 | { | 530 | { |
529 | mCalendar->checkAlarmForIncidence( 0, true ); | 531 | mCalendar->checkAlarmForIncidence( 0, true ); |
530 | } | 532 | } |
531 | 533 | ||
532 | void CalendarView::computeAlarm( QString msg ) | 534 | void CalendarView::computeAlarm( QString msg ) |
533 | { | 535 | { |
534 | 536 | ||
535 | QString mess = msg; | 537 | QString mess = msg; |
536 | QString mAlarmMessage = mess.mid( 9 ); | 538 | QString mAlarmMessage = mess.mid( 9 ); |
537 | QString filename = MainWindow::resourcePath(); | 539 | QString filename = MainWindow::resourcePath(); |
538 | filename += "koalarm.wav"; | 540 | filename += "koalarm.wav"; |
539 | QString tempfilename; | 541 | QString tempfilename; |
540 | if ( mess.left( 13 ) == "suspend_alarm") { | 542 | if ( mess.left( 13 ) == "suspend_alarm") { |
541 | bool error = false; | 543 | bool error = false; |
542 | int len = mess.mid( 13 ).find("+++"); | 544 | int len = mess.mid( 13 ).find("+++"); |
543 | if ( len < 2 ) | 545 | if ( len < 2 ) |
544 | error = true; | 546 | error = true; |
545 | else { | 547 | else { |
546 | tempfilename = mess.mid( 13, len ); | 548 | tempfilename = mess.mid( 13, len ); |
547 | if ( !QFile::exists( tempfilename ) ) | 549 | if ( !QFile::exists( tempfilename ) ) |
548 | error = true; | 550 | error = true; |
549 | } | 551 | } |
550 | if ( ! error ) { | 552 | if ( ! error ) { |
551 | filename = tempfilename; | 553 | filename = tempfilename; |
552 | } | 554 | } |
553 | mAlarmMessage = mess.mid( 13+len+3 ); | 555 | mAlarmMessage = mess.mid( 13+len+3 ); |
554 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 556 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
555 | startAlarm( mAlarmMessage, filename); | 557 | startAlarm( mAlarmMessage, filename); |
556 | return; | 558 | return; |
557 | } | 559 | } |
558 | if ( mess.left( 11 ) == "timer_alarm") { | 560 | if ( mess.left( 11 ) == "timer_alarm") { |
559 | //mTimerTime = 0; | 561 | //mTimerTime = 0; |
560 | startAlarm( mess.mid( 11 ), filename ); | 562 | startAlarm( mess.mid( 11 ), filename ); |
561 | return; | 563 | return; |
562 | } | 564 | } |
563 | if ( mess.left( 10 ) == "proc_alarm") { | 565 | if ( mess.left( 10 ) == "proc_alarm") { |
564 | bool error = false; | 566 | bool error = false; |
565 | int len = mess.mid( 10 ).find("+++"); | 567 | int len = mess.mid( 10 ).find("+++"); |
566 | if ( len < 2 ) | 568 | if ( len < 2 ) |
567 | error = true; | 569 | error = true; |
568 | else { | 570 | else { |
569 | tempfilename = mess.mid( 10, len ); | 571 | tempfilename = mess.mid( 10, len ); |
570 | if ( !QFile::exists( tempfilename ) ) | 572 | if ( !QFile::exists( tempfilename ) ) |
571 | error = true; | 573 | error = true; |
572 | } | 574 | } |
573 | if ( error ) { | 575 | if ( error ) { |
574 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
575 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 577 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
576 | } else { | 578 | } else { |
577 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
578 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 580 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
579 | #ifndef _WIN32_ | 581 | #ifndef _WIN32_ |
580 | if ( vfork () == 0 ) { | 582 | if ( vfork () == 0 ) { |
581 | execl ( tempfilename.latin1(), 0 ); | 583 | execl ( tempfilename.latin1(), 0 ); |
582 | return; | 584 | return; |
583 | } | 585 | } |
584 | #else | 586 | #else |
585 | QProcess* p = new QProcess(); | 587 | QProcess* p = new QProcess(); |
586 | p->addArgument( tempfilename.latin1() ); | 588 | p->addArgument( tempfilename.latin1() ); |
587 | p->start(); | 589 | p->start(); |
588 | return; | 590 | return; |
589 | #endif | 591 | #endif |
590 | 592 | ||
591 | return; | 593 | return; |
592 | } | 594 | } |
593 | 595 | ||
594 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
595 | } | 597 | } |
596 | if ( mess.left( 11 ) == "audio_alarm") { | 598 | if ( mess.left( 11 ) == "audio_alarm") { |
597 | bool error = false; | 599 | bool error = false; |
598 | int len = mess.mid( 11 ).find("+++"); | 600 | int len = mess.mid( 11 ).find("+++"); |
599 | if ( len < 2 ) | 601 | if ( len < 2 ) |
600 | error = true; | 602 | error = true; |
601 | else { | 603 | else { |
602 | tempfilename = mess.mid( 11, len ); | 604 | tempfilename = mess.mid( 11, len ); |
603 | if ( !QFile::exists( tempfilename ) ) | 605 | if ( !QFile::exists( tempfilename ) ) |
604 | error = true; | 606 | error = true; |
605 | } | 607 | } |
606 | if ( ! error ) { | 608 | if ( ! error ) { |
607 | filename = tempfilename; | 609 | filename = tempfilename; |
608 | } | 610 | } |
609 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 611 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
610 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 612 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
611 | } | 613 | } |
612 | if ( mess.left( 9 ) == "cal_alarm") { | 614 | if ( mess.left( 9 ) == "cal_alarm") { |
613 | mAlarmMessage = mess.mid( 9 ) ; | 615 | mAlarmMessage = mess.mid( 9 ) ; |
614 | } | 616 | } |
615 | 617 | ||
616 | startAlarm( mAlarmMessage, filename ); | 618 | startAlarm( mAlarmMessage, filename ); |
617 | 619 | ||
618 | 620 | ||
619 | } | 621 | } |
620 | 622 | ||
621 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
622 | { | 624 | { |
623 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
624 | 626 | ||
625 | mSuspendAlarmNotification = noti; | 627 | mSuspendAlarmNotification = noti; |
626 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
627 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
628 | mSuspendTimer->start( ms , true ); | 630 | mSuspendTimer->start( ms , true ); |
629 | 631 | ||
630 | } | 632 | } |
631 | 633 | ||
632 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
633 | { | 635 | { |
634 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
635 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
636 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
637 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
638 | #endif | 640 | #endif |
639 | return; | 641 | return; |
640 | } | 642 | } |
641 | int maxSec; | 643 | int maxSec; |
642 | //maxSec = 5; //testing only | 644 | //maxSec = 5; //testing only |
643 | maxSec = 86400+3600; // one day+1hour | 645 | maxSec = 86400+3600; // one day+1hour |
644 | mAlarmNotification = noti; | 646 | mAlarmNotification = noti; |
645 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
646 | if ( sec > maxSec ) { | 648 | if ( sec > maxSec ) { |
647 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 649 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
648 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
649 | return; | 651 | return; |
650 | } else { | 652 | } else { |
651 | mRecheckAlarmTimer->stop(); | 653 | mRecheckAlarmTimer->stop(); |
652 | } | 654 | } |
653 | //qDebug("Alarm timer started with secs: %d ", sec); | 655 | //qDebug("Alarm timer started with secs: %d ", sec); |
654 | mAlarmTimer->start( sec *1000 , true ); | 656 | mAlarmTimer->start( sec *1000 , true ); |
655 | 657 | ||
656 | } | 658 | } |
657 | // called by mRecheckAlarmTimer to get next alarm | 659 | // called by mRecheckAlarmTimer to get next alarm |
658 | // we need this, because a QTimer has only a max range of 25 days | 660 | // we need this, because a QTimer has only a max range of 25 days |
659 | void CalendarView::recheckTimerAlarm() | 661 | void CalendarView::recheckTimerAlarm() |
660 | { | 662 | { |
661 | mAlarmTimer->stop(); | 663 | mAlarmTimer->stop(); |
662 | mRecheckAlarmTimer->stop(); | 664 | mRecheckAlarmTimer->stop(); |
663 | mCalendar->checkAlarmForIncidence( 0, true ); | 665 | mCalendar->checkAlarmForIncidence( 0, true ); |
664 | } | 666 | } |
665 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
666 | { | 668 | { |
667 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
668 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
669 | #ifndef DESKTOP_VERSION | 671 | #ifndef DESKTOP_VERSION |
670 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
671 | #endif | 673 | #endif |
672 | return; | 674 | return; |
673 | } | 675 | } |
674 | mAlarmTimer->stop(); | 676 | mAlarmTimer->stop(); |
675 | } | 677 | } |
676 | void CalendarView::selectWeekNum ( int num ) | 678 | void CalendarView::selectWeekNum ( int num ) |
677 | { | 679 | { |
678 | dateNavigator()->blockSignals( true ); | 680 | dateNavigator()->blockSignals( true ); |
679 | dateNavigator()->selectWeek( num ); | 681 | dateNavigator()->selectWeek( num ); |
680 | dateNavigator()->blockSignals( false ); | 682 | dateNavigator()->blockSignals( false ); |
681 | mViewManager->showWeekView(); | 683 | mViewManager->showWeekView(); |
682 | } | 684 | } |
683 | KOViewManager *CalendarView::viewManager() | 685 | KOViewManager *CalendarView::viewManager() |
684 | { | 686 | { |
685 | return mViewManager; | 687 | return mViewManager; |
686 | } | 688 | } |
687 | 689 | ||
688 | KODialogManager *CalendarView::dialogManager() | 690 | KODialogManager *CalendarView::dialogManager() |
689 | { | 691 | { |
690 | return mDialogManager; | 692 | return mDialogManager; |
691 | } | 693 | } |
692 | 694 | ||
693 | QDate CalendarView::startDate() | 695 | QDate CalendarView::startDate() |
694 | { | 696 | { |
695 | DateList dates = mNavigator->selectedDates(); | 697 | DateList dates = mNavigator->selectedDates(); |
696 | 698 | ||
697 | return dates.first(); | 699 | return dates.first(); |
698 | } | 700 | } |
699 | 701 | ||
700 | QDate CalendarView::endDate() | 702 | QDate CalendarView::endDate() |
701 | { | 703 | { |
702 | DateList dates = mNavigator->selectedDates(); | 704 | DateList dates = mNavigator->selectedDates(); |
703 | 705 | ||
704 | return dates.last(); | 706 | return dates.last(); |
705 | } | 707 | } |
706 | 708 | ||
707 | 709 | ||
708 | void CalendarView::createPrinter() | 710 | void CalendarView::createPrinter() |
709 | { | 711 | { |
710 | #ifndef KORG_NOPRINTER | 712 | #ifndef KORG_NOPRINTER |
711 | if (!mCalPrinter) { | 713 | if (!mCalPrinter) { |
712 | mCalPrinter = new CalPrinter(this, mCalendar); | 714 | mCalPrinter = new CalPrinter(this, mCalendar); |
713 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
714 | } | 716 | } |
715 | #endif | 717 | #endif |
716 | } | 718 | } |
717 | 719 | ||
718 | 720 | ||
719 | //KOPrefs::instance()->mWriteBackFile | 721 | //KOPrefs::instance()->mWriteBackFile |
720 | //KOPrefs::instance()->mWriteBackExistingOnly | 722 | //KOPrefs::instance()->mWriteBackExistingOnly |
721 | 723 | ||
722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
728 | 730 | ||
729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
730 | { | 732 | { |
731 | 733 | ||
732 | // 0 equal | 734 | // 0 equal |
733 | // 1 take local | 735 | // 1 take local |
734 | // 2 take remote | 736 | // 2 take remote |
735 | // 3 cancel | 737 | // 3 cancel |
736 | QDateTime lastSync = mLastCalendarSync; | 738 | QDateTime lastSync = mLastCalendarSync; |
737 | QDateTime localMod = local->lastModified(); | 739 | QDateTime localMod = local->lastModified(); |
738 | QDateTime remoteMod = remote->lastModified(); | 740 | QDateTime remoteMod = remote->lastModified(); |
739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
740 | bool remCh, locCh; | 742 | bool remCh, locCh; |
741 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
742 | //if ( remCh ) | 744 | //if ( remCh ) |
743 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
744 | locCh = ( localMod > mLastCalendarSync ); | 746 | locCh = ( localMod > mLastCalendarSync ); |
745 | if ( !remCh && ! locCh ) { | 747 | if ( !remCh && ! locCh ) { |
746 | //qDebug("both not changed "); | 748 | //qDebug("both not changed "); |
747 | lastSync = localMod.addDays(1); | 749 | lastSync = localMod.addDays(1); |
748 | if ( mode <= SYNC_PREF_ASK ) | 750 | if ( mode <= SYNC_PREF_ASK ) |
749 | return 0; | 751 | return 0; |
750 | } else { | 752 | } else { |
751 | if ( locCh ) { | 753 | if ( locCh ) { |
752 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
753 | lastSync = localMod.addDays( -1 ); | 755 | lastSync = localMod.addDays( -1 ); |
754 | if ( !remCh ) | 756 | if ( !remCh ) |
755 | remoteMod = ( lastSync.addDays( -1 ) ); | 757 | remoteMod = ( lastSync.addDays( -1 ) ); |
756 | } else { | 758 | } else { |
757 | //qDebug(" not loc changed "); | 759 | //qDebug(" not loc changed "); |
758 | lastSync = localMod.addDays( 1 ); | 760 | lastSync = localMod.addDays( 1 ); |
759 | if ( remCh ) | 761 | if ( remCh ) |
760 | remoteMod =( lastSync.addDays( 1 ) ); | 762 | remoteMod =( lastSync.addDays( 1 ) ); |
761 | 763 | ||
762 | } | 764 | } |
763 | } | 765 | } |
764 | full = true; | 766 | full = true; |
765 | if ( mode < SYNC_PREF_ASK ) | 767 | if ( mode < SYNC_PREF_ASK ) |
766 | mode = SYNC_PREF_ASK; | 768 | mode = SYNC_PREF_ASK; |
767 | } else { | 769 | } else { |
768 | if ( localMod == remoteMod ) | 770 | if ( localMod == remoteMod ) |
769 | // if ( local->revision() == remote->revision() ) | 771 | // if ( local->revision() == remote->revision() ) |
770 | return 0; | 772 | return 0; |
771 | 773 | ||
772 | } | 774 | } |
773 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
774 | 776 | ||
775 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
776 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
777 | //full = true; //debug only | 779 | //full = true; //debug only |
778 | if ( full ) { | 780 | if ( full ) { |
779 | bool equ = false; | 781 | bool equ = false; |
780 | if ( local->type() == "Event" ) { | 782 | if ( local->type() == "Event" ) { |
781 | equ = (*((Event*) local) == *((Event*) remote)); | 783 | equ = (*((Event*) local) == *((Event*) remote)); |
782 | } | 784 | } |
783 | else if ( local->type() =="Todo" ) | 785 | else if ( local->type() =="Todo" ) |
784 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 786 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
785 | else if ( local->type() =="Journal" ) | 787 | else if ( local->type() =="Journal" ) |
786 | equ = (*((Journal*) local) == *((Journal*) remote)); | 788 | equ = (*((Journal*) local) == *((Journal*) remote)); |
787 | if ( equ ) { | 789 | if ( equ ) { |
788 | //qDebug("equal "); | 790 | //qDebug("equal "); |
789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
791 | } | 793 | } |
792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
793 | return 0; | 795 | return 0; |
794 | 796 | ||
795 | }//else //debug only | 797 | }//else //debug only |
796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
797 | } | 799 | } |
798 | int result; | 800 | int result; |
799 | bool localIsNew; | 801 | bool localIsNew; |
800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 802 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
801 | 803 | ||
802 | if ( full && mode < SYNC_PREF_NEWEST ) | 804 | if ( full && mode < SYNC_PREF_NEWEST ) |
803 | mode = SYNC_PREF_ASK; | 805 | mode = SYNC_PREF_ASK; |
804 | 806 | ||
805 | switch( mode ) { | 807 | switch( mode ) { |
806 | case SYNC_PREF_LOCAL: | 808 | case SYNC_PREF_LOCAL: |
807 | if ( lastSync > remoteMod ) | 809 | if ( lastSync > remoteMod ) |
808 | return 1; | 810 | return 1; |
809 | if ( lastSync > localMod ) | 811 | if ( lastSync > localMod ) |
810 | return 2; | 812 | return 2; |
811 | return 1; | 813 | return 1; |
812 | break; | 814 | break; |
813 | case SYNC_PREF_REMOTE: | 815 | case SYNC_PREF_REMOTE: |
814 | if ( lastSync > remoteMod ) | 816 | if ( lastSync > remoteMod ) |
815 | return 1; | 817 | return 1; |
816 | if ( lastSync > localMod ) | 818 | if ( lastSync > localMod ) |
817 | return 2; | 819 | return 2; |
818 | return 2; | 820 | return 2; |
819 | break; | 821 | break; |
820 | case SYNC_PREF_NEWEST: | 822 | case SYNC_PREF_NEWEST: |
821 | if ( localMod > remoteMod ) | 823 | if ( localMod > remoteMod ) |
822 | return 1; | 824 | return 1; |
823 | else | 825 | else |
824 | return 2; | 826 | return 2; |
825 | break; | 827 | break; |
826 | case SYNC_PREF_ASK: | 828 | case SYNC_PREF_ASK: |
827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
828 | if ( lastSync > remoteMod ) | 830 | if ( lastSync > remoteMod ) |
829 | return 1; | 831 | return 1; |
830 | if ( lastSync > localMod ) | 832 | if ( lastSync > localMod ) |
831 | return 2; | 833 | return 2; |
832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
833 | localIsNew = localMod >= remoteMod; | 835 | localIsNew = localMod >= remoteMod; |
834 | if ( localIsNew ) | 836 | if ( localIsNew ) |
835 | getEventViewerDialog()->setColorMode( 1 ); | 837 | getEventViewerDialog()->setColorMode( 1 ); |
836 | else | 838 | else |
837 | getEventViewerDialog()->setColorMode( 2 ); | 839 | getEventViewerDialog()->setColorMode( 2 ); |
838 | getEventViewerDialog()->setIncidence(local); | 840 | getEventViewerDialog()->setIncidence(local); |
839 | if ( localIsNew ) | 841 | if ( localIsNew ) |
840 | getEventViewerDialog()->setColorMode( 2 ); | 842 | getEventViewerDialog()->setColorMode( 2 ); |
841 | else | 843 | else |
842 | getEventViewerDialog()->setColorMode( 1 ); | 844 | getEventViewerDialog()->setColorMode( 1 ); |
843 | getEventViewerDialog()->addIncidence(remote); | 845 | getEventViewerDialog()->addIncidence(remote); |
844 | getEventViewerDialog()->setColorMode( 0 ); | 846 | getEventViewerDialog()->setColorMode( 0 ); |
845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
847 | getEventViewerDialog()->showMe(); | 849 | getEventViewerDialog()->showMe(); |
848 | result = getEventViewerDialog()->executeS( localIsNew ); | 850 | result = getEventViewerDialog()->executeS( localIsNew ); |
849 | return result; | 851 | return result; |
850 | 852 | ||
851 | break; | 853 | break; |
852 | case SYNC_PREF_FORCE_LOCAL: | 854 | case SYNC_PREF_FORCE_LOCAL: |
853 | return 1; | 855 | return 1; |
854 | break; | 856 | break; |
855 | case SYNC_PREF_FORCE_REMOTE: | 857 | case SYNC_PREF_FORCE_REMOTE: |
856 | return 2; | 858 | return 2; |
857 | break; | 859 | break; |
858 | 860 | ||
859 | default: | 861 | default: |
860 | // SYNC_PREF_TAKE_BOTH not implemented | 862 | // SYNC_PREF_TAKE_BOTH not implemented |
861 | break; | 863 | break; |
862 | } | 864 | } |
863 | return 0; | 865 | return 0; |
864 | } | 866 | } |
865 | Event* CalendarView::getLastSyncEvent() | 867 | Event* CalendarView::getLastSyncEvent() |
866 | { | 868 | { |
867 | Event* lse; | 869 | Event* lse; |
868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
870 | if (!lse) { | 872 | if (!lse) { |
871 | lse = new Event(); | 873 | lse = new Event(); |
872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
873 | QString sum = ""; | 875 | QString sum = ""; |
874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
875 | sum = "E: "; | 877 | sum = "E: "; |
876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
877 | lse->setDtStart( mLastCalendarSync ); | 879 | lse->setDtStart( mLastCalendarSync ); |
878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
879 | lse->setCategories( i18n("SyncEvent") ); | 881 | lse->setCategories( i18n("SyncEvent") ); |
880 | lse->setReadOnly( true ); | 882 | lse->setReadOnly( true ); |
881 | mCalendar->addEvent( lse ); | 883 | mCalendar->addEvent( lse ); |
882 | } | 884 | } |
883 | 885 | ||
884 | return lse; | 886 | return lse; |
885 | 887 | ||
886 | } | 888 | } |
887 | 889 | ||
888 | // we check, if the to delete event has a id for a profile | 890 | // we check, if the to delete event has a id for a profile |
889 | // if yes, we set this id in the profile to delete | 891 | // if yes, we set this id in the profile to delete |
890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
891 | { | 893 | { |
892 | if ( lastSync.count() == 0 ) { | 894 | if ( lastSync.count() == 0 ) { |
893 | //qDebug(" lastSync.count() == 0"); | 895 | //qDebug(" lastSync.count() == 0"); |
894 | return; | 896 | return; |
895 | } | 897 | } |
896 | if ( toDelete->type() == "Journal" ) | 898 | if ( toDelete->type() == "Journal" ) |
897 | return; | 899 | return; |
898 | 900 | ||
899 | Event* eve = lastSync.first(); | 901 | Event* eve = lastSync.first(); |
900 | 902 | ||
901 | while ( eve ) { | 903 | while ( eve ) { |
902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
903 | if ( !id.isEmpty() ) { | 905 | if ( !id.isEmpty() ) { |
904 | QString des = eve->description(); | 906 | QString des = eve->description(); |
905 | QString pref = "e"; | 907 | QString pref = "e"; |
906 | if ( toDelete->type() == "Todo" ) | 908 | if ( toDelete->type() == "Todo" ) |
907 | pref = "t"; | 909 | pref = "t"; |
908 | des += pref+ id + ","; | 910 | des += pref+ id + ","; |
909 | eve->setReadOnly( false ); | 911 | eve->setReadOnly( false ); |
910 | eve->setDescription( des ); | 912 | eve->setDescription( des ); |
911 | //qDebug("setdes %s ", des.latin1()); | 913 | //qDebug("setdes %s ", des.latin1()); |
912 | eve->setReadOnly( true ); | 914 | eve->setReadOnly( true ); |
913 | } | 915 | } |
914 | eve = lastSync.next(); | 916 | eve = lastSync.next(); |
915 | } | 917 | } |
916 | 918 | ||
917 | } | 919 | } |
918 | void CalendarView::checkExternalId( Incidence * inc ) | 920 | void CalendarView::checkExternalId( Incidence * inc ) |
919 | { | 921 | { |
920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
921 | checkExternSyncEvent( lastSync, inc ); | 923 | checkExternSyncEvent( lastSync, inc ); |
922 | 924 | ||
923 | } | 925 | } |
924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
925 | { | 927 | { |
926 | bool syncOK = true; | 928 | bool syncOK = true; |
927 | int addedEvent = 0; | 929 | int addedEvent = 0; |
928 | int addedEventR = 0; | 930 | int addedEventR = 0; |
929 | int deletedEventR = 0; | 931 | int deletedEventR = 0; |
930 | int deletedEventL = 0; | 932 | int deletedEventL = 0; |
931 | int changedLocal = 0; | 933 | int changedLocal = 0; |
932 | int changedRemote = 0; | 934 | int changedRemote = 0; |
933 | int filteredIN = 0; | 935 | int filteredIN = 0; |
934 | int filteredOUT = 0; | 936 | int filteredOUT = 0; |
935 | //QPtrList<Event> el = local->rawEvents(); | 937 | //QPtrList<Event> el = local->rawEvents(); |
936 | Event* eventR; | 938 | Event* eventR; |
937 | QString uid; | 939 | QString uid; |
938 | int take; | 940 | int take; |
939 | Event* eventL; | 941 | Event* eventL; |
940 | Event* eventRSync; | 942 | Event* eventRSync; |
941 | Event* eventLSync; | 943 | Event* eventLSync; |
942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
944 | bool fullDateRange = false; | 946 | bool fullDateRange = false; |
945 | local->resetTempSyncStat(); | 947 | local->resetTempSyncStat(); |
946 | mLastCalendarSync = QDateTime::currentDateTime(); | 948 | mLastCalendarSync = QDateTime::currentDateTime(); |
947 | if ( mSyncManager->syncWithDesktop() ) { | 949 | if ( mSyncManager->syncWithDesktop() ) { |
948 | remote->resetPilotStat(1); | 950 | remote->resetPilotStat(1); |
949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
952 | } else { | 954 | } else { |
953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
954 | } | 956 | } |
955 | } | 957 | } |
956 | QDateTime modifiedCalendar = mLastCalendarSync; | 958 | QDateTime modifiedCalendar = mLastCalendarSync; |
957 | eventLSync = getLastSyncEvent(); | 959 | eventLSync = getLastSyncEvent(); |
958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
959 | if ( eventR ) { | 961 | if ( eventR ) { |
960 | eventRSync = (Event*) eventR->clone(); | 962 | eventRSync = (Event*) eventR->clone(); |
961 | remote->deleteEvent(eventR ); | 963 | remote->deleteEvent(eventR ); |
962 | 964 | ||
963 | } else { | 965 | } else { |
964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
965 | eventRSync = (Event*)eventLSync->clone(); | 967 | eventRSync = (Event*)eventLSync->clone(); |
966 | } else { | 968 | } else { |
967 | fullDateRange = true; | 969 | fullDateRange = true; |
968 | eventRSync = new Event(); | 970 | eventRSync = new Event(); |
969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
971 | eventRSync->setDtStart( mLastCalendarSync ); | 973 | eventRSync->setDtStart( mLastCalendarSync ); |
972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
973 | eventRSync->setCategories( i18n("SyncEvent") ); | 975 | eventRSync->setCategories( i18n("SyncEvent") ); |
974 | } | 976 | } |
975 | } | 977 | } |
976 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 978 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
977 | fullDateRange = true; | 979 | fullDateRange = true; |
978 | 980 | ||
979 | if ( ! fullDateRange ) { | 981 | if ( ! fullDateRange ) { |
980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
981 | 983 | ||
982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
984 | fullDateRange = true; | 986 | fullDateRange = true; |
985 | } | 987 | } |
986 | } | 988 | } |
987 | if ( mSyncManager->syncWithDesktop() ) { | 989 | if ( mSyncManager->syncWithDesktop() ) { |
988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
989 | } | 991 | } |
990 | if ( fullDateRange ) | 992 | if ( fullDateRange ) |
991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
992 | else | 994 | else |
993 | mLastCalendarSync = eventLSync->dtStart(); | 995 | mLastCalendarSync = eventLSync->dtStart(); |
994 | // for resyncing if own file has changed | 996 | // for resyncing if own file has changed |
995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
996 | mLastCalendarSync = loadedFileVersion; | 998 | mLastCalendarSync = loadedFileVersion; |
997 | //qDebug("setting mLastCalendarSync "); | 999 | //qDebug("setting mLastCalendarSync "); |
998 | } | 1000 | } |
999 | //qDebug("*************************** "); | 1001 | //qDebug("*************************** "); |
1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1001 | QPtrList<Incidence> er = remote->rawIncidences(); | 1003 | QPtrList<Incidence> er = remote->rawIncidences(); |
1002 | Incidence* inR = er.first(); | 1004 | Incidence* inR = er.first(); |
1003 | Incidence* inL; | 1005 | Incidence* inL; |
1004 | QProgressBar bar( er.count(),0 ); | 1006 | QProgressBar bar( er.count(),0 ); |
1005 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1007 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1006 | 1008 | ||
1007 | // ************** setting up filter ************* | 1009 | // ************** setting up filter ************* |
1008 | CalFilter *filterIN = 0; | 1010 | CalFilter *filterIN = 0; |
1009 | CalFilter *filterOUT = 0; | 1011 | CalFilter *filterOUT = 0; |
1010 | CalFilter *filter = mFilters.first(); | 1012 | CalFilter *filter = mFilters.first(); |
1011 | while(filter) { | 1013 | while(filter) { |
1012 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1013 | filterIN = filter; | 1015 | filterIN = filter; |
1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1015 | filterOUT = filter; | 1017 | filterOUT = filter; |
1016 | filter = mFilters.next(); | 1018 | filter = mFilters.next(); |
1017 | } | 1019 | } |
1018 | int w = 300; | 1020 | int w = 300; |
1019 | if ( QApplication::desktop()->width() < 320 ) | 1021 | if ( QApplication::desktop()->width() < 320 ) |
1020 | w = 220; | 1022 | w = 220; |
1021 | int h = bar.sizeHint().height() ; | 1023 | int h = bar.sizeHint().height() ; |
1022 | int dw = QApplication::desktop()->width(); | 1024 | int dw = QApplication::desktop()->width(); |
1023 | int dh = QApplication::desktop()->height(); | 1025 | int dh = QApplication::desktop()->height(); |
1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1025 | bar.show(); | 1027 | bar.show(); |
1026 | int modulo = (er.count()/10)+1; | 1028 | int modulo = (er.count()/10)+1; |
1027 | int incCounter = 0; | 1029 | int incCounter = 0; |
1028 | while ( inR ) { | 1030 | while ( inR ) { |
1029 | if ( ! bar.isVisible() ) | 1031 | if ( ! bar.isVisible() ) |
1030 | return false; | 1032 | return false; |
1031 | if ( incCounter % modulo == 0 ) | 1033 | if ( incCounter % modulo == 0 ) |
1032 | bar.setProgress( incCounter ); | 1034 | bar.setProgress( incCounter ); |
1033 | ++incCounter; | 1035 | ++incCounter; |
1034 | uid = inR->uid(); | 1036 | uid = inR->uid(); |
1035 | bool skipIncidence = false; | 1037 | bool skipIncidence = false; |
1036 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1038 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1037 | skipIncidence = true; | 1039 | skipIncidence = true; |
1038 | QString idS; | 1040 | QString idS; |
1039 | qApp->processEvents(); | 1041 | qApp->processEvents(); |
1040 | if ( !skipIncidence ) { | 1042 | if ( !skipIncidence ) { |
1041 | inL = local->incidence( uid ); | 1043 | inL = local->incidence( uid ); |
1042 | if ( inL ) { // maybe conflict - same uid in both calendars | 1044 | if ( inL ) { // maybe conflict - same uid in both calendars |
1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1045 | if ( take == 3 ) | 1047 | if ( take == 3 ) |
1046 | return false; | 1048 | return false; |
1047 | if ( take == 1 ) {// take local ********************** | 1049 | if ( take == 1 ) {// take local ********************** |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1050 | else | 1052 | else |
1051 | idS = inR->IDStr(); | 1053 | idS = inR->IDStr(); |
1052 | remote->deleteIncidence( inR ); | 1054 | remote->deleteIncidence( inR ); |
1053 | inR = inL->clone(); | 1055 | inR = inL->clone(); |
1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1056 | inR->setIDStr( idS ); | 1058 | inR->setIDStr( idS ); |
1057 | remote->addIncidence( inR ); | 1059 | remote->addIncidence( inR ); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1060 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inR->setPilotId( 2 ); | 1061 | inR->setPilotId( 2 ); |
1060 | ++changedRemote; | 1062 | ++changedRemote; |
1061 | } else {// take remote ********************** | 1063 | } else {// take remote ********************** |
1062 | idS = inL->IDStr(); | 1064 | idS = inL->IDStr(); |
1063 | int pid = inL->pilotId(); | 1065 | int pid = inL->pilotId(); |
1064 | local->deleteIncidence( inL ); | 1066 | local->deleteIncidence( inL ); |
1065 | inL = inR->clone(); | 1067 | inL = inR->clone(); |
1066 | if ( mSyncManager->syncWithDesktop() ) | 1068 | if ( mSyncManager->syncWithDesktop() ) |
1067 | inL->setPilotId( pid ); | 1069 | inL->setPilotId( pid ); |
1068 | inL->setIDStr( idS ); | 1070 | inL->setIDStr( idS ); |
1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1072 | } | 1074 | } |
1073 | local->addIncidence( inL ); | 1075 | local->addIncidence( inL ); |
1074 | ++changedLocal; | 1076 | ++changedLocal; |
1075 | } | 1077 | } |
1076 | } | 1078 | } |
1077 | } else { // no conflict ********** add or delete remote | 1079 | } else { // no conflict ********** add or delete remote |
1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1080 | QString des = eventLSync->description(); | 1082 | QString des = eventLSync->description(); |
1081 | QString pref = "e"; | 1083 | QString pref = "e"; |
1082 | if ( inR->type() == "Todo" ) | 1084 | if ( inR->type() == "Todo" ) |
1083 | pref = "t"; | 1085 | pref = "t"; |
1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1086 | //remote->deleteIncidence( inR ); | 1088 | //remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1089 | ++deletedEventR; |
1088 | } else { | 1090 | } else { |
1089 | inR->setLastModified( modifiedCalendar ); | 1091 | inR->setLastModified( modifiedCalendar ); |
1090 | inL = inR->clone(); | 1092 | inL = inR->clone(); |
1091 | inL->setIDStr( ":" ); | 1093 | inL->setIDStr( ":" ); |
1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1094 | local->addIncidence( inL ); | 1096 | local->addIncidence( inL ); |
1095 | ++addedEvent; | 1097 | ++addedEvent; |
1096 | 1098 | ||
1097 | } | 1099 | } |
1098 | } else { | 1100 | } else { |
1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1100 | inR->setLastModified( modifiedCalendar ); | 1102 | inR->setLastModified( modifiedCalendar ); |
1101 | inL = inR->clone(); | 1103 | inL = inR->clone(); |
1102 | inL->setIDStr( ":" ); | 1104 | inL->setIDStr( ":" ); |
1103 | local->addIncidence( inL ); | 1105 | local->addIncidence( inL ); |
1104 | ++addedEvent; | 1106 | ++addedEvent; |
1105 | 1107 | ||
1106 | } else { | 1108 | } else { |
1107 | checkExternSyncEvent(eventRSyncSharp, inR); | 1109 | checkExternSyncEvent(eventRSyncSharp, inR); |
1108 | remote->deleteIncidence( inR ); | 1110 | remote->deleteIncidence( inR ); |
1109 | ++deletedEventR; | 1111 | ++deletedEventR; |
1110 | } | 1112 | } |
1111 | } | 1113 | } |
1112 | } else { | 1114 | } else { |
1113 | ++filteredIN; | 1115 | ++filteredIN; |
1114 | } | 1116 | } |
1115 | } | 1117 | } |
1116 | } | 1118 | } |
1117 | inR = er.next(); | 1119 | inR = er.next(); |
1118 | } | 1120 | } |
1119 | QPtrList<Incidence> el = local->rawIncidences(); | 1121 | QPtrList<Incidence> el = local->rawIncidences(); |
1120 | inL = el.first(); | 1122 | inL = el.first(); |
1121 | modulo = (el.count()/10)+1; | 1123 | modulo = (el.count()/10)+1; |
1122 | bar.setCaption (i18n("Add / remove events") ); | 1124 | bar.setCaption (i18n("Add / remove events") ); |
1123 | bar.setTotalSteps ( el.count() ) ; | 1125 | bar.setTotalSteps ( el.count() ) ; |
1124 | bar.show(); | 1126 | bar.show(); |
1125 | incCounter = 0; | 1127 | incCounter = 0; |
1126 | 1128 | ||
1127 | while ( inL ) { | 1129 | while ( inL ) { |
1128 | 1130 | ||
1129 | qApp->processEvents(); | 1131 | qApp->processEvents(); |
1130 | if ( ! bar.isVisible() ) | 1132 | if ( ! bar.isVisible() ) |
1131 | return false; | 1133 | return false; |
1132 | if ( incCounter % modulo == 0 ) | 1134 | if ( incCounter % modulo == 0 ) |
1133 | bar.setProgress( incCounter ); | 1135 | bar.setProgress( incCounter ); |
1134 | ++incCounter; | 1136 | ++incCounter; |
1135 | uid = inL->uid(); | 1137 | uid = inL->uid(); |
1136 | bool skipIncidence = false; | 1138 | bool skipIncidence = false; |
1137 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1139 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1138 | skipIncidence = true; | 1140 | skipIncidence = true; |
1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1140 | skipIncidence = true; | 1142 | skipIncidence = true; |
1141 | if ( !skipIncidence ) { | 1143 | if ( !skipIncidence ) { |
1142 | inR = remote->incidence( uid ); | 1144 | inR = remote->incidence( uid ); |
1143 | if ( ! inR ) { | 1145 | if ( ! inR ) { |
1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1145 | // no conflict ********** add or delete local | 1147 | // no conflict ********** add or delete local |
1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1150 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1151 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1152 | ++deletedEventL; |
1151 | } else { | 1153 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | inL->removeID(mCurrentSyncDevice ); | 1155 | inL->removeID(mCurrentSyncDevice ); |
1154 | ++addedEventR; | 1156 | ++addedEventR; |
1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1156 | inL->setLastModified( modifiedCalendar ); | 1158 | inL->setLastModified( modifiedCalendar ); |
1157 | inR = inL->clone(); | 1159 | inR = inL->clone(); |
1158 | inR->setIDStr( ":" ); | 1160 | inR->setIDStr( ":" ); |
1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1160 | remote->addIncidence( inR ); | 1162 | remote->addIncidence( inR ); |
1161 | } | 1163 | } |
1162 | } | 1164 | } |
1163 | } else { | 1165 | } else { |
1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1165 | checkExternSyncEvent(eventLSyncSharp, inL); | 1167 | checkExternSyncEvent(eventLSyncSharp, inL); |
1166 | local->deleteIncidence( inL ); | 1168 | local->deleteIncidence( inL ); |
1167 | ++deletedEventL; | 1169 | ++deletedEventL; |
1168 | } else { | 1170 | } else { |
1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1170 | ++addedEventR; | 1172 | ++addedEventR; |
1171 | inL->setLastModified( modifiedCalendar ); | 1173 | inL->setLastModified( modifiedCalendar ); |
1172 | inR = inL->clone(); | 1174 | inR = inL->clone(); |
1173 | inR->setIDStr( ":" ); | 1175 | inR->setIDStr( ":" ); |
1174 | remote->addIncidence( inR ); | 1176 | remote->addIncidence( inR ); |
1175 | } | 1177 | } |
1176 | } | 1178 | } |
1177 | } | 1179 | } |
1178 | } else { | 1180 | } else { |
1179 | ++filteredOUT; | 1181 | ++filteredOUT; |
1180 | } | 1182 | } |
1181 | } | 1183 | } |
1182 | } | 1184 | } |
1183 | inL = el.next(); | 1185 | inL = el.next(); |
1184 | } | 1186 | } |
1185 | int delFut = 0; | 1187 | int delFut = 0; |
1186 | int remRem = 0; | 1188 | int remRem = 0; |
1187 | if ( mSyncManager->mWriteBackInFuture ) { | 1189 | if ( mSyncManager->mWriteBackInFuture ) { |
1188 | er = remote->rawIncidences(); | 1190 | er = remote->rawIncidences(); |
1189 | remRem = er.count(); | 1191 | remRem = er.count(); |
1190 | inR = er.first(); | 1192 | inR = er.first(); |
1191 | QDateTime dt; | 1193 | QDateTime dt; |
1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1194 | while ( inR ) { | 1196 | while ( inR ) { |
1195 | if ( inR->type() == "Todo" ) { | 1197 | if ( inR->type() == "Todo" ) { |
1196 | Todo * t = (Todo*)inR; | 1198 | Todo * t = (Todo*)inR; |
1197 | if ( t->hasDueDate() ) | 1199 | if ( t->hasDueDate() ) |
1198 | dt = t->dtDue(); | 1200 | dt = t->dtDue(); |
1199 | else | 1201 | else |
1200 | dt = cur.addSecs( 62 ); | 1202 | dt = cur.addSecs( 62 ); |
1201 | } | 1203 | } |
1202 | else if (inR->type() == "Event" ) { | 1204 | else if (inR->type() == "Event" ) { |
1203 | bool ok; | 1205 | bool ok; |
1204 | dt = inR->getNextOccurence( cur, &ok ); | 1206 | dt = inR->getNextOccurence( cur, &ok ); |
1205 | if ( !ok ) | 1207 | if ( !ok ) |
1206 | dt = cur.addSecs( -62 ); | 1208 | dt = cur.addSecs( -62 ); |
1207 | } | 1209 | } |
1208 | else | 1210 | else |
1209 | dt = inR->dtStart(); | 1211 | dt = inR->dtStart(); |
1210 | if ( dt < cur || dt > end ) { | 1212 | if ( dt < cur || dt > end ) { |
1211 | remote->deleteIncidence( inR ); | 1213 | remote->deleteIncidence( inR ); |
1212 | ++delFut; | 1214 | ++delFut; |
1213 | } | 1215 | } |
1214 | inR = er.next(); | 1216 | inR = er.next(); |
1215 | } | 1217 | } |
1216 | } | 1218 | } |
1217 | bar.hide(); | 1219 | bar.hide(); |
1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1219 | eventLSync->setReadOnly( false ); | 1221 | eventLSync->setReadOnly( false ); |
1220 | eventLSync->setDtStart( mLastCalendarSync ); | 1222 | eventLSync->setDtStart( mLastCalendarSync ); |
1221 | eventRSync->setDtStart( mLastCalendarSync ); | 1223 | eventRSync->setDtStart( mLastCalendarSync ); |
1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1226 | eventLSync->setReadOnly( true ); | 1228 | eventLSync->setReadOnly( true ); |
1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1229 | remote->addEvent( eventRSync ); | 1231 | remote->addEvent( eventRSync ); |
1230 | else | 1232 | else |
1231 | delete eventRSync; | 1233 | delete eventRSync; |
1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1233 | QString mes; | 1235 | QString mes; |
1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1236 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1235 | QString delmess; | 1237 | QString delmess; |
1236 | if ( delFut ) { | 1238 | if ( delFut ) { |
1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1238 | mes += delmess; | 1240 | mes += delmess; |
1239 | } | 1241 | } |
1240 | mes = i18n("Local calendar changed!\n") +mes; | 1242 | mes = i18n("Local calendar changed!\n") +mes; |
1241 | mCalendar->checkAlarmForIncidence( 0, true ); | 1243 | mCalendar->checkAlarmForIncidence( 0, true ); |
1242 | qDebug( mes ); | 1244 | qDebug( mes ); |
1243 | if ( mSyncManager->mShowSyncSummary ) { | 1245 | if ( mSyncManager->mShowSyncSummary ) { |
1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1246 | qDebug("KO: WB cancelled "); | 1248 | qDebug("KO: WB cancelled "); |
1247 | return false; | 1249 | return false; |
1248 | } | 1250 | } |
1249 | } | 1251 | } |
1250 | return syncOK; | 1252 | return syncOK; |
1251 | } | 1253 | } |
1252 | 1254 | ||
1253 | void CalendarView::setSyncDevice( QString s ) | 1255 | void CalendarView::setSyncDevice( QString s ) |
1254 | { | 1256 | { |
1255 | mCurrentSyncDevice= s; | 1257 | mCurrentSyncDevice= s; |
1256 | } | 1258 | } |
1257 | void CalendarView::setSyncName( QString s ) | 1259 | void CalendarView::setSyncName( QString s ) |
1258 | { | 1260 | { |
1259 | mCurrentSyncName= s; | 1261 | mCurrentSyncName= s; |
1260 | } | 1262 | } |
1261 | bool CalendarView::syncCalendar(QString filename, int mode) | 1263 | bool CalendarView::syncCalendar(QString filename, int mode) |
1262 | { | 1264 | { |
1263 | //qDebug("syncCalendar %s ", filename.latin1()); | 1265 | //qDebug("syncCalendar %s ", filename.latin1()); |
1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1266 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1265 | CalendarLocal* calendar = new CalendarLocal(); | 1267 | CalendarLocal* calendar = new CalendarLocal(); |
1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1267 | FileStorage* storage = new FileStorage( calendar ); | 1269 | FileStorage* storage = new FileStorage( calendar ); |
1268 | bool syncOK = false; | 1270 | bool syncOK = false; |
1269 | storage->setFileName( filename ); | 1271 | storage->setFileName( filename ); |
1270 | // qDebug("loading ... "); | 1272 | // qDebug("loading ... "); |
1271 | if ( storage->load() ) { | 1273 | if ( storage->load() ) { |
1272 | getEventViewerDialog()->setSyncMode( true ); | 1274 | getEventViewerDialog()->setSyncMode( true ); |
1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1274 | getEventViewerDialog()->setSyncMode( false ); | 1276 | getEventViewerDialog()->setSyncMode( false ); |
1275 | if ( syncOK ) { | 1277 | if ( syncOK ) { |
1276 | if ( mSyncManager->mWriteBackFile ) | 1278 | if ( mSyncManager->mWriteBackFile ) |
1277 | { | 1279 | { |
1278 | storage->setSaveFormat( new ICalFormat() ); | 1280 | storage->setSaveFormat( new ICalFormat() ); |
1279 | storage->save(); | 1281 | storage->save(); |
1280 | } | 1282 | } |
1281 | } | 1283 | } |
1282 | setModified( true ); | 1284 | setModified( true ); |
1283 | } | 1285 | } |
1284 | delete storage; | 1286 | delete storage; |
1285 | delete calendar; | 1287 | delete calendar; |
1286 | if ( syncOK ) | 1288 | if ( syncOK ) |
1287 | updateView(); | 1289 | updateView(); |
1288 | return syncOK; | 1290 | return syncOK; |
1289 | } | 1291 | } |
1290 | 1292 | ||
1291 | void CalendarView::syncExternal( int mode ) | 1293 | void CalendarView::syncExternal( int mode ) |
1292 | { | 1294 | { |
1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1295 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1294 | 1296 | ||
1295 | qApp->processEvents(); | 1297 | qApp->processEvents(); |
1296 | CalendarLocal* calendar = new CalendarLocal(); | 1298 | CalendarLocal* calendar = new CalendarLocal(); |
1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1299 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1298 | bool syncOK = false; | 1300 | bool syncOK = false; |
1299 | bool loadSuccess = false; | 1301 | bool loadSuccess = false; |
1300 | PhoneFormat* phoneFormat = 0; | 1302 | PhoneFormat* phoneFormat = 0; |
1301 | emit tempDisableBR(true); | 1303 | emit tempDisableBR(true); |
1302 | #ifndef DESKTOP_VERSION | 1304 | #ifndef DESKTOP_VERSION |
1303 | SharpFormat* sharpFormat = 0; | 1305 | SharpFormat* sharpFormat = 0; |
1304 | if ( mode == 0 ) { // sharp | 1306 | if ( mode == 0 ) { // sharp |
1305 | sharpFormat = new SharpFormat () ; | 1307 | sharpFormat = new SharpFormat () ; |
1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1308 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1307 | 1309 | ||
1308 | } else | 1310 | } else |
1309 | #endif | 1311 | #endif |
1310 | if ( mode == 1 ) { // phone | 1312 | if ( mode == 1 ) { // phone |
1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1313 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1312 | mSyncManager->mPhoneDevice, | 1314 | mSyncManager->mPhoneDevice, |
1313 | mSyncManager->mPhoneConnection, | 1315 | mSyncManager->mPhoneConnection, |
1314 | mSyncManager->mPhoneModel); | 1316 | mSyncManager->mPhoneModel); |
1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1317 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1316 | 1318 | ||
1317 | } else { | 1319 | } else { |
1318 | emit tempDisableBR(false); | 1320 | emit tempDisableBR(false); |
1319 | return; | 1321 | return; |
1320 | } | 1322 | } |
1321 | if ( loadSuccess ) { | 1323 | if ( loadSuccess ) { |
1322 | getEventViewerDialog()->setSyncMode( true ); | 1324 | getEventViewerDialog()->setSyncMode( true ); |
1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1325 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1324 | getEventViewerDialog()->setSyncMode( false ); | 1326 | getEventViewerDialog()->setSyncMode( false ); |
1325 | qApp->processEvents(); | 1327 | qApp->processEvents(); |
1326 | if ( syncOK ) { | 1328 | if ( syncOK ) { |
1327 | if ( mSyncManager->mWriteBackFile ) | 1329 | if ( mSyncManager->mWriteBackFile ) |
1328 | { | 1330 | { |
1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1331 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1330 | Incidence* inc = iL.first(); | 1332 | Incidence* inc = iL.first(); |
1331 | if ( phoneFormat ) { | 1333 | if ( phoneFormat ) { |
1332 | while ( inc ) { | 1334 | while ( inc ) { |
1333 | inc->removeID(mCurrentSyncDevice); | 1335 | inc->removeID(mCurrentSyncDevice); |
1334 | inc = iL.next(); | 1336 | inc = iL.next(); |
1335 | } | 1337 | } |
1336 | } | 1338 | } |
1337 | #ifndef DESKTOP_VERSION | 1339 | #ifndef DESKTOP_VERSION |
1338 | if ( sharpFormat ) | 1340 | if ( sharpFormat ) |
1339 | sharpFormat->save(calendar); | 1341 | sharpFormat->save(calendar); |
1340 | #endif | 1342 | #endif |
1341 | if ( phoneFormat ) | 1343 | if ( phoneFormat ) |
1342 | phoneFormat->save(calendar); | 1344 | phoneFormat->save(calendar); |
1343 | iL = calendar->rawIncidences(); | 1345 | iL = calendar->rawIncidences(); |
1344 | inc = iL.first(); | 1346 | inc = iL.first(); |
1345 | Incidence* loc; | 1347 | Incidence* loc; |
1346 | while ( inc ) { | 1348 | while ( inc ) { |
1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1349 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1348 | loc = mCalendar->incidence(inc->uid() ); | 1350 | loc = mCalendar->incidence(inc->uid() ); |
1349 | if ( loc ) { | 1351 | if ( loc ) { |
1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1352 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1353 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1352 | } | 1354 | } |
1353 | } | 1355 | } |
1354 | inc = iL.next(); | 1356 | inc = iL.next(); |
1355 | } | 1357 | } |
1356 | Incidence* lse = getLastSyncEvent(); | 1358 | Incidence* lse = getLastSyncEvent(); |
1357 | if ( lse ) { | 1359 | if ( lse ) { |
1358 | lse->setReadOnly( false ); | 1360 | lse->setReadOnly( false ); |
1359 | lse->setDescription( "" ); | 1361 | lse->setDescription( "" ); |
1360 | lse->setReadOnly( true ); | 1362 | lse->setReadOnly( true ); |
1361 | } | 1363 | } |
1362 | } | 1364 | } |
1363 | } else { | 1365 | } else { |
1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1366 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1365 | } | 1367 | } |
1366 | setModified( true ); | 1368 | setModified( true ); |
1367 | } else { | 1369 | } else { |
1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1370 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1371 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1370 | question, i18n("Ok")) ; | 1372 | question, i18n("Ok")) ; |
1371 | 1373 | ||
1372 | } | 1374 | } |
1373 | delete calendar; | 1375 | delete calendar; |
1374 | updateView(); | 1376 | updateView(); |
1375 | emit tempDisableBR(false); | 1377 | emit tempDisableBR(false); |
1376 | return ;//syncOK; | 1378 | return ;//syncOK; |
1377 | 1379 | ||
1378 | } | 1380 | } |
1379 | 1381 | ||
1380 | bool CalendarView::importBday() | 1382 | bool CalendarView::importBday() |
1381 | { | 1383 | { |
1382 | #ifndef KORG_NOKABC | 1384 | #ifndef KORG_NOKABC |
1383 | 1385 | ||
1384 | #ifdef DESKTOP_VERSION | 1386 | #ifdef DESKTOP_VERSION |
1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1387 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1386 | KABC::AddressBook::Iterator it; | 1388 | KABC::AddressBook::Iterator it; |
1387 | int count = 0; | 1389 | int count = 0; |
1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1390 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1389 | ++count; | 1391 | ++count; |
1390 | } | 1392 | } |
1391 | QProgressBar bar(count,0 ); | 1393 | QProgressBar bar(count,0 ); |
1392 | int w = 300; | 1394 | int w = 300; |
1393 | if ( QApplication::desktop()->width() < 320 ) | 1395 | if ( QApplication::desktop()->width() < 320 ) |
1394 | w = 220; | 1396 | w = 220; |
1395 | int h = bar.sizeHint().height() ; | 1397 | int h = bar.sizeHint().height() ; |
1396 | int dw = QApplication::desktop()->width(); | 1398 | int dw = QApplication::desktop()->width(); |
1397 | int dh = QApplication::desktop()->height(); | 1399 | int dh = QApplication::desktop()->height(); |
1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1400 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1399 | bar.show(); | 1401 | bar.show(); |
1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1402 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1401 | qApp->processEvents(); | 1403 | qApp->processEvents(); |
1402 | count = 0; | 1404 | count = 0; |
1403 | int addCount = 0; | 1405 | int addCount = 0; |
1404 | KCal::Attendee* a = 0; | 1406 | KCal::Attendee* a = 0; |
1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1407 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1406 | if ( ! bar.isVisible() ) | 1408 | if ( ! bar.isVisible() ) |
1407 | return false; | 1409 | return false; |
1408 | bar.setProgress( count++ ); | 1410 | bar.setProgress( count++ ); |
1409 | qApp->processEvents(); | 1411 | qApp->processEvents(); |
1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1412 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1411 | if ( (*it).birthday().date().isValid() ){ | 1413 | if ( (*it).birthday().date().isValid() ){ |
1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1414 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1415 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1414 | ++addCount; | 1416 | ++addCount; |
1415 | } | 1417 | } |
1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1418 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1417 | if ( anni.isValid() ){ | 1419 | if ( anni.isValid() ){ |
1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1420 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1421 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1420 | ++addCount; | 1422 | ++addCount; |
1421 | } | 1423 | } |
1422 | } | 1424 | } |
1423 | updateView(); | 1425 | updateView(); |
1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1426 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1425 | #else //DESKTOP_VERSION | 1427 | #else //DESKTOP_VERSION |
1426 | 1428 | ||
1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1429 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1428 | // the result should now arrive through method insertBirthdays | 1430 | // the result should now arrive through method insertBirthdays |
1429 | 1431 | ||
1430 | #endif //DESKTOP_VERSION | 1432 | #endif //DESKTOP_VERSION |
1431 | 1433 | ||
1432 | #endif //KORG_NOKABC | 1434 | #endif //KORG_NOKABC |
1433 | 1435 | ||
1434 | 1436 | ||
1435 | return true; | 1437 | return true; |
1436 | } | 1438 | } |
1437 | 1439 | ||
1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1440 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1441 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1440 | const QStringList& anniversaryList, const QStringList& realNameList, | 1442 | const QStringList& anniversaryList, const QStringList& realNameList, |
1441 | const QStringList& emailList, const QStringList& assembledNameList, | 1443 | const QStringList& emailList, const QStringList& assembledNameList, |
1442 | const QStringList& uidList) | 1444 | const QStringList& uidList) |
1443 | { | 1445 | { |
1444 | //qDebug("KO::CalendarView::insertBirthdays"); | 1446 | //qDebug("KO::CalendarView::insertBirthdays"); |
1445 | if (uid == this->name()) | 1447 | if (uid == this->name()) |
1446 | { | 1448 | { |
1447 | int count = birthdayList.count(); | 1449 | int count = birthdayList.count(); |
1448 | int addCount = 0; | 1450 | int addCount = 0; |
1449 | KCal::Attendee* a = 0; | 1451 | KCal::Attendee* a = 0; |
1450 | 1452 | ||
1451 | //qDebug("CalView 1 %i", count); | 1453 | //qDebug("CalView 1 %i", count); |
1452 | 1454 | ||
1453 | QProgressBar bar(count,0 ); | 1455 | QProgressBar bar(count,0 ); |
1454 | int w = 300; | 1456 | int w = 300; |
1455 | if ( QApplication::desktop()->width() < 320 ) | 1457 | if ( QApplication::desktop()->width() < 320 ) |
1456 | w = 220; | 1458 | w = 220; |
1457 | int h = bar.sizeHint().height() ; | 1459 | int h = bar.sizeHint().height() ; |
1458 | int dw = QApplication::desktop()->width(); | 1460 | int dw = QApplication::desktop()->width(); |
1459 | int dh = QApplication::desktop()->height(); | 1461 | int dh = QApplication::desktop()->height(); |
1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1462 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1461 | bar.show(); | 1463 | bar.show(); |
1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1464 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1463 | qApp->processEvents(); | 1465 | qApp->processEvents(); |
1464 | 1466 | ||
1465 | QDate birthday; | 1467 | QDate birthday; |
1466 | QDate anniversary; | 1468 | QDate anniversary; |
1467 | QString realName; | 1469 | QString realName; |
1468 | QString email; | 1470 | QString email; |
1469 | QString assembledName; | 1471 | QString assembledName; |
1470 | QString uid; | 1472 | QString uid; |
1471 | bool ok = true; | 1473 | bool ok = true; |
1472 | for ( int i = 0; i < count; i++) | 1474 | for ( int i = 0; i < count; i++) |
1473 | { | 1475 | { |
1474 | if ( ! bar.isVisible() ) | 1476 | if ( ! bar.isVisible() ) |
1475 | return; | 1477 | return; |
1476 | bar.setProgress( i ); | 1478 | bar.setProgress( i ); |
1477 | qApp->processEvents(); | 1479 | qApp->processEvents(); |
1478 | 1480 | ||
1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1481 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1480 | if (!ok) { | 1482 | if (!ok) { |
1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1483 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1482 | } | 1484 | } |
1483 | 1485 | ||
1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1486 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1485 | if (!ok) { | 1487 | if (!ok) { |
1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1488 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1487 | } | 1489 | } |
1488 | realName = realNameList[i]; | 1490 | realName = realNameList[i]; |
1489 | email = emailList[i]; | 1491 | email = emailList[i]; |
1490 | assembledName = assembledNameList[i]; | 1492 | assembledName = assembledNameList[i]; |
1491 | uid = uidList[i]; | 1493 | uid = uidList[i]; |
1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1494 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1493 | 1495 | ||
1494 | if ( birthday.isValid() ){ | 1496 | if ( birthday.isValid() ){ |
1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1497 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1496 | KCal::Attendee::ReqParticipant,uid) ; | 1498 | KCal::Attendee::ReqParticipant,uid) ; |
1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1499 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1498 | ++addCount; | 1500 | ++addCount; |
1499 | } | 1501 | } |
1500 | 1502 | ||
1501 | if ( anniversary.isValid() ){ | 1503 | if ( anniversary.isValid() ){ |
1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1504 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1503 | KCal::Attendee::ReqParticipant,uid) ; | 1505 | KCal::Attendee::ReqParticipant,uid) ; |
1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1506 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1505 | ++addCount; | 1507 | ++addCount; |
1506 | } | 1508 | } |
1507 | } | 1509 | } |
1508 | 1510 | ||
1509 | updateView(); | 1511 | updateView(); |
1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1512 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1511 | 1513 | ||
1512 | } | 1514 | } |
1513 | 1515 | ||
1514 | } | 1516 | } |
1515 | 1517 | ||
1516 | 1518 | ||
1517 | 1519 | ||
1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1520 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1519 | { | 1521 | { |
1520 | //qDebug("addAnni "); | 1522 | //qDebug("addAnni "); |
1521 | Event * ev = new Event(); | 1523 | Event * ev = new Event(); |
1522 | ev->setOrganizer(KOPrefs::instance()->email()); | 1524 | ev->setOrganizer(KOPrefs::instance()->email()); |
1523 | if ( a ) { | 1525 | if ( a ) { |
1524 | ev->addAttendee( a ); | 1526 | ev->addAttendee( a ); |
1525 | } | 1527 | } |
1526 | QString kind; | 1528 | QString kind; |
1527 | if ( birthday ) { | 1529 | if ( birthday ) { |
1528 | kind = i18n( "Birthday" ); | 1530 | kind = i18n( "Birthday" ); |
1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1531 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1530 | } | 1532 | } |
1531 | else { | 1533 | else { |
1532 | kind = i18n( "Anniversary" ); | 1534 | kind = i18n( "Anniversary" ); |
1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1535 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1534 | } | 1536 | } |
1535 | ev->setCategories( kind ); | 1537 | ev->setCategories( kind ); |
1536 | ev->setDtStart( QDateTime(date) ); | 1538 | ev->setDtStart( QDateTime(date) ); |
1537 | ev->setDtEnd( QDateTime(date) ); | 1539 | ev->setDtEnd( QDateTime(date) ); |
1538 | ev->setFloats( true ); | 1540 | ev->setFloats( true ); |
1539 | Recurrence * rec = ev->recurrence(); | 1541 | Recurrence * rec = ev->recurrence(); |
1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1542 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1541 | rec->addYearlyNum( date.month() ); | 1543 | rec->addYearlyNum( date.month() ); |
1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1544 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1543 | delete ev; | 1545 | delete ev; |
1544 | return false; | 1546 | return false; |
1545 | } | 1547 | } |
1546 | return true; | 1548 | return true; |
1547 | 1549 | ||
1548 | } | 1550 | } |
1549 | bool CalendarView::importQtopia( const QString &categories, | 1551 | bool CalendarView::importQtopia( const QString &categories, |
1550 | const QString &datebook, | 1552 | const QString &datebook, |
1551 | const QString &todolist ) | 1553 | const QString &todolist ) |
1552 | { | 1554 | { |
1553 | 1555 | ||
1554 | QtopiaFormat qtopiaFormat; | 1556 | QtopiaFormat qtopiaFormat; |
1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1558 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1559 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1560 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1559 | 1561 | ||
1560 | updateView(); | 1562 | updateView(); |
1561 | return true; | 1563 | return true; |
1562 | 1564 | ||
1563 | #if 0 | 1565 | #if 0 |
1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1566 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1565 | mCurrentSyncDevice = "qtopia-XML"; | 1567 | mCurrentSyncDevice = "qtopia-XML"; |
1566 | if ( mSyncManager->mAskForPreferences ) | 1568 | if ( mSyncManager->mAskForPreferences ) |
1567 | edit_sync_options(); | 1569 | edit_sync_options(); |
1568 | qApp->processEvents(); | 1570 | qApp->processEvents(); |
1569 | CalendarLocal* calendar = new CalendarLocal(); | 1571 | CalendarLocal* calendar = new CalendarLocal(); |
1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1572 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1571 | bool syncOK = false; | 1573 | bool syncOK = false; |
1572 | QtopiaFormat qtopiaFormat; | 1574 | QtopiaFormat qtopiaFormat; |
1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1575 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1574 | bool loadOk = true; | 1576 | bool loadOk = true; |
1575 | if ( !categories.isEmpty() ) | 1577 | if ( !categories.isEmpty() ) |
1576 | loadOk = qtopiaFormat.load( calendar, categories ); | 1578 | loadOk = qtopiaFormat.load( calendar, categories ); |
1577 | if ( loadOk && !datebook.isEmpty() ) | 1579 | if ( loadOk && !datebook.isEmpty() ) |
1578 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1580 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1579 | if ( loadOk && !todolist.isEmpty() ) | 1581 | if ( loadOk && !todolist.isEmpty() ) |
1580 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1582 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1581 | 1583 | ||
1582 | if ( loadOk ) { | 1584 | if ( loadOk ) { |
1583 | getEventViewerDialog()->setSyncMode( true ); | 1585 | getEventViewerDialog()->setSyncMode( true ); |
1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1586 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1585 | getEventViewerDialog()->setSyncMode( false ); | 1587 | getEventViewerDialog()->setSyncMode( false ); |
1586 | qApp->processEvents(); | 1588 | qApp->processEvents(); |
1587 | if ( syncOK ) { | 1589 | if ( syncOK ) { |
1588 | if ( mSyncManager->mWriteBackFile ) | 1590 | if ( mSyncManager->mWriteBackFile ) |
1589 | { | 1591 | { |
1590 | // write back XML file | 1592 | // write back XML file |
1591 | 1593 | ||
1592 | } | 1594 | } |
1593 | setModified( true ); | 1595 | setModified( true ); |
1594 | } | 1596 | } |
1595 | } else { | 1597 | } else { |
1596 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1598 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1599 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1598 | question, i18n("Ok")) ; | 1600 | question, i18n("Ok")) ; |
1599 | } | 1601 | } |
1600 | delete calendar; | 1602 | delete calendar; |
1601 | updateView(); | 1603 | updateView(); |
1602 | return syncOK; | 1604 | return syncOK; |
1603 | 1605 | ||
1604 | 1606 | ||
1605 | #endif | 1607 | #endif |
1606 | 1608 | ||
1607 | } | 1609 | } |
1608 | 1610 | ||
1609 | void CalendarView::setSyncEventsReadOnly() | 1611 | void CalendarView::setSyncEventsReadOnly() |
1610 | { | 1612 | { |
1611 | Event * ev; | 1613 | Event * ev; |
1612 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1614 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1613 | ev = eL.first(); | 1615 | ev = eL.first(); |
1614 | while ( ev ) { | 1616 | while ( ev ) { |
1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1617 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1616 | ev->setReadOnly( true ); | 1618 | ev->setReadOnly( true ); |
1617 | ev = eL.next(); | 1619 | ev = eL.next(); |
1618 | } | 1620 | } |
1619 | } | 1621 | } |
1620 | bool CalendarView::openCalendar(QString filename, bool merge) | 1622 | bool CalendarView::openCalendar(QString filename, bool merge) |
1621 | { | 1623 | { |
1622 | 1624 | ||
1623 | if (filename.isEmpty()) { | 1625 | if (filename.isEmpty()) { |
1624 | return false; | 1626 | return false; |
1625 | } | 1627 | } |
1626 | 1628 | ||
1627 | if (!QFile::exists(filename)) { | 1629 | if (!QFile::exists(filename)) { |
1628 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1630 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1629 | return false; | 1631 | return false; |
1630 | } | 1632 | } |
1631 | 1633 | ||
1632 | globalFlagBlockAgenda = 1; | 1634 | globalFlagBlockAgenda = 1; |
1633 | if (!merge) mCalendar->close(); | 1635 | if (!merge) mCalendar->close(); |
1634 | 1636 | ||
1635 | mStorage->setFileName( filename ); | 1637 | mStorage->setFileName( filename ); |
1636 | 1638 | ||
1637 | if ( mStorage->load() ) { | 1639 | if ( mStorage->load() ) { |
1638 | if ( merge ) ;//setModified( true ); | 1640 | if ( merge ) ;//setModified( true ); |
1639 | else { | 1641 | else { |
1640 | //setModified( true ); | 1642 | //setModified( true ); |
1641 | mViewManager->setDocumentId( filename ); | 1643 | mViewManager->setDocumentId( filename ); |
1642 | mDialogManager->setDocumentId( filename ); | 1644 | mDialogManager->setDocumentId( filename ); |
1643 | mTodoList->setDocumentId( filename ); | 1645 | mTodoList->setDocumentId( filename ); |
1644 | } | 1646 | } |
1645 | globalFlagBlockAgenda = 2; | 1647 | globalFlagBlockAgenda = 2; |
1646 | // if ( getLastSyncEvent() ) | 1648 | // if ( getLastSyncEvent() ) |
1647 | // getLastSyncEvent()->setReadOnly( true ); | 1649 | // getLastSyncEvent()->setReadOnly( true ); |
1648 | mCalendar->reInitAlarmSettings(); | 1650 | mCalendar->reInitAlarmSettings(); |
1649 | setSyncEventsReadOnly(); | 1651 | setSyncEventsReadOnly(); |
1650 | updateUnmanagedViews(); | 1652 | updateUnmanagedViews(); |
1651 | updateView(); | 1653 | updateView(); |
1652 | if ( filename != MainWindow::defaultFileName() ) { | 1654 | if ( filename != MainWindow::defaultFileName() ) { |
1653 | saveCalendar( MainWindow::defaultFileName() ); | 1655 | saveCalendar( MainWindow::defaultFileName() ); |
1654 | } else { | 1656 | } else { |
1655 | QFileInfo finf ( MainWindow::defaultFileName()); | 1657 | QFileInfo finf ( MainWindow::defaultFileName()); |
1656 | if ( finf.exists() ) { | 1658 | if ( finf.exists() ) { |
1657 | setLoadedFileVersion( finf.lastModified () ); | 1659 | setLoadedFileVersion( finf.lastModified () ); |
1658 | } | 1660 | } |
1659 | } | 1661 | } |
1660 | return true; | 1662 | return true; |
1661 | } else { | 1663 | } else { |
1662 | // while failing to load, the calendar object could | 1664 | // while failing to load, the calendar object could |
1663 | // have become partially populated. Clear it out. | 1665 | // have become partially populated. Clear it out. |
1664 | if ( !merge ) { | 1666 | if ( !merge ) { |
1665 | mCalendar->close(); | 1667 | mCalendar->close(); |
1666 | mViewManager->setDocumentId( filename ); | 1668 | mViewManager->setDocumentId( filename ); |
1667 | mDialogManager->setDocumentId( filename ); | 1669 | mDialogManager->setDocumentId( filename ); |
1668 | mTodoList->setDocumentId( filename ); | 1670 | mTodoList->setDocumentId( filename ); |
1669 | } | 1671 | } |
1670 | 1672 | ||
1671 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1673 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1672 | 1674 | ||
1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1675 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1674 | globalFlagBlockAgenda = 2; | 1676 | globalFlagBlockAgenda = 2; |
1675 | mCalendar->reInitAlarmSettings(); | 1677 | mCalendar->reInitAlarmSettings(); |
1676 | setSyncEventsReadOnly(); | 1678 | setSyncEventsReadOnly(); |
1677 | updateUnmanagedViews(); | 1679 | updateUnmanagedViews(); |
1678 | updateView(); | 1680 | updateView(); |
1679 | } | 1681 | } |
1680 | return false; | 1682 | return false; |
1681 | } | 1683 | } |
1682 | void CalendarView::showOpenError() | 1684 | void CalendarView::showOpenError() |
1683 | { | 1685 | { |
1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1686 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1685 | } | 1687 | } |
1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1688 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1687 | { | 1689 | { |
1688 | loadedFileVersion = dt; | 1690 | loadedFileVersion = dt; |
1689 | } | 1691 | } |
1690 | bool CalendarView::checkFileChanged(QString fn) | 1692 | bool CalendarView::checkFileChanged(QString fn) |
1691 | { | 1693 | { |
1692 | QFileInfo finf ( fn ); | 1694 | QFileInfo finf ( fn ); |
1693 | if ( !finf.exists() ) | 1695 | if ( !finf.exists() ) |
1694 | return true; | 1696 | return true; |
1695 | QDateTime dt = finf.lastModified (); | 1697 | QDateTime dt = finf.lastModified (); |
1696 | if ( dt <= loadedFileVersion ) | 1698 | if ( dt <= loadedFileVersion ) |
1697 | return false; | 1699 | return false; |
1698 | return true; | 1700 | return true; |
1699 | 1701 | ||
1700 | } | 1702 | } |
1701 | void CalendarView::watchSavedFile() | 1703 | void CalendarView::watchSavedFile() |
1702 | { | 1704 | { |
1703 | QFileInfo finf ( MainWindow::defaultFileName()); | 1705 | QFileInfo finf ( MainWindow::defaultFileName()); |
1704 | if ( !finf.exists() ) | 1706 | if ( !finf.exists() ) |
1705 | return; | 1707 | return; |
1706 | QDateTime dt = finf.lastModified (); | 1708 | QDateTime dt = finf.lastModified (); |
1707 | if ( dt < loadedFileVersion ) { | 1709 | if ( dt < loadedFileVersion ) { |
1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1710 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1711 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1710 | return; | 1712 | return; |
1711 | } | 1713 | } |
1712 | loadedFileVersion = dt; | 1714 | loadedFileVersion = dt; |
1713 | } | 1715 | } |
1714 | 1716 | ||
1715 | bool CalendarView::checkFileVersion(QString fn) | 1717 | bool CalendarView::checkFileVersion(QString fn) |
1716 | { | 1718 | { |
1717 | QFileInfo finf ( fn ); | 1719 | QFileInfo finf ( fn ); |
1718 | if ( !finf.exists() ) | 1720 | if ( !finf.exists() ) |
1719 | return true; | 1721 | return true; |
1720 | QDateTime dt = finf.lastModified (); | 1722 | QDateTime dt = finf.lastModified (); |
1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1723 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1722 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1724 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1723 | if ( dt <= loadedFileVersion ) | 1725 | if ( dt <= loadedFileVersion ) |
1724 | return true; | 1726 | return true; |
1725 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1727 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1728 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1727 | i18n("Sync+save")); | 1729 | i18n("Sync+save")); |
1728 | 1730 | ||
1729 | if ( km == KMessageBox::Cancel ) | 1731 | if ( km == KMessageBox::Cancel ) |
1730 | return false; | 1732 | return false; |
1731 | if ( km == KMessageBox::Yes ) | 1733 | if ( km == KMessageBox::Yes ) |
1732 | return true; | 1734 | return true; |
1733 | 1735 | ||
1734 | setSyncDevice("deleteaftersync" ); | 1736 | setSyncDevice("deleteaftersync" ); |
1735 | mSyncManager->mAskForPreferences = true; | 1737 | mSyncManager->mAskForPreferences = true; |
1736 | mSyncManager->mSyncAlgoPrefs = 3; | 1738 | mSyncManager->mSyncAlgoPrefs = 3; |
1737 | mSyncManager->mWriteBackFile = false; | 1739 | mSyncManager->mWriteBackFile = false; |
1738 | mSyncManager->mWriteBackExistingOnly = false; | 1740 | mSyncManager->mWriteBackExistingOnly = false; |
1739 | mSyncManager->mShowSyncSummary = false; | 1741 | mSyncManager->mShowSyncSummary = false; |
1740 | syncCalendar( fn, 3 ); | 1742 | syncCalendar( fn, 3 ); |
1741 | Event * e = getLastSyncEvent(); | 1743 | Event * e = getLastSyncEvent(); |
1742 | mCalendar->deleteEvent ( e ); | 1744 | mCalendar->deleteEvent ( e ); |
1743 | updateView(); | 1745 | updateView(); |
1744 | return true; | 1746 | return true; |
1745 | } | 1747 | } |
1746 | 1748 | ||
1747 | bool CalendarView::saveCalendar( QString filename ) | 1749 | bool CalendarView::saveCalendar( QString filename ) |
1748 | { | 1750 | { |
1749 | 1751 | ||
1750 | // Store back all unsaved data into calendar object | 1752 | // Store back all unsaved data into calendar object |
1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1753 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1752 | if ( mViewManager->currentView() ) | 1754 | if ( mViewManager->currentView() ) |
1753 | mViewManager->currentView()->flushView(); | 1755 | mViewManager->currentView()->flushView(); |
1754 | 1756 | ||
1755 | 1757 | ||
1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1758 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1757 | mStorage->setSaveFormat( new ICalFormat() ); | 1759 | mStorage->setSaveFormat( new ICalFormat() ); |
1758 | mStorage->setFileName( filename ); | 1760 | mStorage->setFileName( filename ); |
1759 | bool success; | 1761 | bool success; |
1760 | success = mStorage->save(); | 1762 | success = mStorage->save(); |
1761 | if ( !success ) { | 1763 | if ( !success ) { |
1762 | return false; | 1764 | return false; |
1763 | } | 1765 | } |
1764 | if ( filename == MainWindow::defaultFileName() ) { | 1766 | if ( filename == MainWindow::defaultFileName() ) { |
1765 | setLoadedFileVersion( lfv ); | 1767 | setLoadedFileVersion( lfv ); |
1766 | watchSavedFile(); | 1768 | watchSavedFile(); |
1767 | } | 1769 | } |
1768 | return true; | 1770 | return true; |
1769 | } | 1771 | } |
1770 | 1772 | ||
1771 | void CalendarView::closeCalendar() | 1773 | void CalendarView::closeCalendar() |
1772 | { | 1774 | { |
1773 | 1775 | ||
1774 | // child windows no longer valid | 1776 | // child windows no longer valid |
1775 | emit closingDown(); | 1777 | emit closingDown(); |
1776 | 1778 | ||
1777 | mCalendar->close(); | 1779 | mCalendar->close(); |
1778 | setModified(false); | 1780 | setModified(false); |
1779 | updateView(); | 1781 | updateView(); |
1780 | } | 1782 | } |
1781 | 1783 | ||
1782 | void CalendarView::archiveCalendar() | 1784 | void CalendarView::archiveCalendar() |
1783 | { | 1785 | { |
1784 | mDialogManager->showArchiveDialog(); | 1786 | mDialogManager->showArchiveDialog(); |
1785 | } | 1787 | } |
1786 | 1788 | ||
1787 | 1789 | ||
1788 | void CalendarView::readSettings() | 1790 | void CalendarView::readSettings() |
1789 | { | 1791 | { |
1790 | 1792 | ||
1791 | 1793 | ||
1792 | // mViewManager->showAgendaView(); | 1794 | // mViewManager->showAgendaView(); |
1793 | QString str; | 1795 | QString str; |
1794 | //qDebug("CalendarView::readSettings() "); | 1796 | //qDebug("CalendarView::readSettings() "); |
1795 | // read settings from the KConfig, supplying reasonable | 1797 | // read settings from the KConfig, supplying reasonable |
1796 | // defaults where none are to be found | 1798 | // defaults where none are to be found |
1797 | KConfig *config = KOGlobals::config(); | 1799 | KConfig *config = KOGlobals::config(); |
1798 | #ifndef KORG_NOSPLITTER | 1800 | #ifndef KORG_NOSPLITTER |
1799 | config->setGroup("KOrganizer Geometry"); | 1801 | config->setGroup("KOrganizer Geometry"); |
1800 | 1802 | ||
1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1803 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1802 | if (sizes.count() != 2) { | 1804 | if (sizes.count() != 2) { |
1803 | sizes << mDateNavigator->minimumSizeHint().width(); | 1805 | sizes << mDateNavigator->minimumSizeHint().width(); |
1804 | sizes << 300; | 1806 | sizes << 300; |
1805 | } | 1807 | } |
1806 | mPanner->setSizes(sizes); | 1808 | mPanner->setSizes(sizes); |
1807 | 1809 | ||
1808 | sizes = config->readIntListEntry("Separator2"); | 1810 | sizes = config->readIntListEntry("Separator2"); |
1809 | if ( ( mResourceView && sizes.count() == 4 ) || | 1811 | if ( ( mResourceView && sizes.count() == 4 ) || |
1810 | ( !mResourceView && sizes.count() == 3 ) ) { | 1812 | ( !mResourceView && sizes.count() == 3 ) ) { |
1811 | mLeftSplitter->setSizes(sizes); | 1813 | mLeftSplitter->setSizes(sizes); |
1812 | } | 1814 | } |
1813 | #endif | 1815 | #endif |
1814 | globalFlagBlockAgenda = 1; | 1816 | globalFlagBlockAgenda = 1; |
1815 | mViewManager->showAgendaView(); | 1817 | mViewManager->showAgendaView(); |
1816 | //mViewManager->readSettings( config ); | 1818 | //mViewManager->readSettings( config ); |
1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1819 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1818 | readFilterSettings(config); | 1820 | readFilterSettings(config); |
1819 | config->setGroup( "Views" ); | 1821 | config->setGroup( "Views" ); |
1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1822 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1823 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1824 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1823 | else mNavigator->selectDates( dateCount ); | 1825 | else mNavigator->selectDates( dateCount ); |
1824 | // mViewManager->readSettings( config ); | 1826 | // mViewManager->readSettings( config ); |
1825 | updateConfig(); | 1827 | updateConfig(); |
1826 | globalFlagBlockAgenda = 2; | 1828 | globalFlagBlockAgenda = 2; |
1827 | mViewManager->readSettings( config ); | 1829 | mViewManager->readSettings( config ); |
1828 | #ifdef DESKTOP_VERSION | 1830 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1831 | config->setGroup("WidgetLayout"); |
1830 | QStringList list; | 1832 | QStringList list; |
1831 | list = config->readListEntry("MainLayout"); | 1833 | list = config->readListEntry("MainLayout"); |
1832 | int x,y,w,h; | 1834 | int x,y,w,h; |
1833 | if ( ! list.isEmpty() ) { | 1835 | if ( ! list.isEmpty() ) { |
1834 | x = list[0].toInt(); | 1836 | x = list[0].toInt(); |
1835 | y = list[1].toInt(); | 1837 | y = list[1].toInt(); |
1836 | w = list[2].toInt(); | 1838 | w = list[2].toInt(); |
1837 | h = list[3].toInt(); | 1839 | h = list[3].toInt(); |
1838 | topLevelWidget()->setGeometry(x,y,w,h); | 1840 | topLevelWidget()->setGeometry(x,y,w,h); |
1839 | 1841 | ||
1840 | } else { | 1842 | } else { |
1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1843 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1842 | } | 1844 | } |
1843 | list = config->readListEntry("EditEventLayout"); | 1845 | list = config->readListEntry("EditEventLayout"); |
1844 | if ( ! list.isEmpty() ) { | 1846 | if ( ! list.isEmpty() ) { |
1845 | x = list[0].toInt(); | 1847 | x = list[0].toInt(); |
1846 | y = list[1].toInt(); | 1848 | y = list[1].toInt(); |
1847 | w = list[2].toInt(); | 1849 | w = list[2].toInt(); |
1848 | h = list[3].toInt(); | 1850 | h = list[3].toInt(); |
1849 | mEventEditor->setGeometry(x,y,w,h); | 1851 | mEventEditor->setGeometry(x,y,w,h); |
1850 | 1852 | ||
1851 | } | 1853 | } |
1852 | list = config->readListEntry("EditTodoLayout"); | 1854 | list = config->readListEntry("EditTodoLayout"); |
1853 | if ( ! list.isEmpty() ) { | 1855 | if ( ! list.isEmpty() ) { |
1854 | x = list[0].toInt(); | 1856 | x = list[0].toInt(); |
1855 | y = list[1].toInt(); | 1857 | y = list[1].toInt(); |
1856 | w = list[2].toInt(); | 1858 | w = list[2].toInt(); |
1857 | h = list[3].toInt(); | 1859 | h = list[3].toInt(); |
1858 | mTodoEditor->setGeometry(x,y,w,h); | 1860 | mTodoEditor->setGeometry(x,y,w,h); |
1859 | 1861 | ||
1860 | } | 1862 | } |
1861 | list = config->readListEntry("ViewerLayout"); | 1863 | list = config->readListEntry("ViewerLayout"); |
1862 | if ( ! list.isEmpty() ) { | 1864 | if ( ! list.isEmpty() ) { |
1863 | x = list[0].toInt(); | 1865 | x = list[0].toInt(); |
1864 | y = list[1].toInt(); | 1866 | y = list[1].toInt(); |
1865 | w = list[2].toInt(); | 1867 | w = list[2].toInt(); |
1866 | h = list[3].toInt(); | 1868 | h = list[3].toInt(); |
1867 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1869 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1868 | } | 1870 | } |
1869 | #endif | 1871 | #endif |
1870 | 1872 | ||
1871 | } | 1873 | } |
1872 | 1874 | ||
1873 | 1875 | ||
1874 | void CalendarView::writeSettings() | 1876 | void CalendarView::writeSettings() |
1875 | { | 1877 | { |
1876 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1878 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1877 | 1879 | ||
1878 | KConfig *config = KOGlobals::config(); | 1880 | KConfig *config = KOGlobals::config(); |
1879 | 1881 | ||
1880 | #ifndef KORG_NOSPLITTER | 1882 | #ifndef KORG_NOSPLITTER |
1881 | config->setGroup("KOrganizer Geometry"); | 1883 | config->setGroup("KOrganizer Geometry"); |
1882 | 1884 | ||
1883 | QValueList<int> list = mPanner->sizes(); | 1885 | QValueList<int> list = mPanner->sizes(); |
1884 | config->writeEntry("Separator1",list); | 1886 | config->writeEntry("Separator1",list); |
1885 | 1887 | ||
1886 | list = mLeftSplitter->sizes(); | 1888 | list = mLeftSplitter->sizes(); |
1887 | config->writeEntry("Separator2",list); | 1889 | config->writeEntry("Separator2",list); |
1888 | #endif | 1890 | #endif |
1889 | 1891 | ||
1890 | mViewManager->writeSettings( config ); | 1892 | mViewManager->writeSettings( config ); |
1891 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1893 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1892 | mDialogManager->writeSettings( config ); | 1894 | mDialogManager->writeSettings( config ); |
1893 | //KOPrefs::instance()->usrWriteConfig(); | 1895 | //KOPrefs::instance()->usrWriteConfig(); |
1894 | KOPrefs::instance()->writeConfig(); | 1896 | KOPrefs::instance()->writeConfig(); |
1895 | 1897 | ||
1896 | writeFilterSettings(config); | 1898 | writeFilterSettings(config); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index aed9bae..c018dc7 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1593 +1,1597 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | QString fullTime; | 128 | QString fullTime; |
129 | int tW = fm.width("24:00i"); | 129 | int tW = fm.width("24:00i"); |
130 | 130 | ||
131 | while (y < cy + ch) { | 131 | while (y < cy + ch) { |
132 | p->drawLine(cx,y,cx+tW,y); | 132 | p->drawLine(cx,y,cx+tW,y); |
133 | hour.setNum(cell); | 133 | hour.setNum(cell); |
134 | suffix = "am"; | 134 | suffix = "am"; |
135 | 135 | ||
136 | // handle 24h and am/pm time formats | 136 | // handle 24h and am/pm time formats |
137 | if (KGlobal::locale()->use12Clock()) { | 137 | if (KGlobal::locale()->use12Clock()) { |
138 | if (cell > 11) suffix = "pm"; | 138 | if (cell > 11) suffix = "pm"; |
139 | if (cell == 0) hour.setNum(12); | 139 | if (cell == 0) hour.setNum(12); |
140 | if (cell > 12) hour.setNum(cell - 12); | 140 | if (cell > 12) hour.setNum(cell - 12); |
141 | } else { | 141 | } else { |
142 | suffix = ":00"; | 142 | suffix = ":00"; |
143 | } | 143 | } |
144 | 144 | ||
145 | // create string in format of "XX:XX" or "XXpm/am" | 145 | // create string in format of "XX:XX" or "XXpm/am" |
146 | fullTime = hour + suffix; | 146 | fullTime = hour + suffix; |
147 | 147 | ||
148 | // center and draw the time label | 148 | // center and draw the time label |
149 | int timeWidth = fm.width(fullTime+"i"); | 149 | int timeWidth = fm.width(fullTime+"i"); |
150 | int offset = this->width() - timeWidth; | 150 | int offset = this->width() - timeWidth; |
151 | int borderWidth = 5; | 151 | int borderWidth = 5; |
152 | int timeHeight = fm.height(); | 152 | int timeHeight = fm.height(); |
153 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); | 153 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); |
154 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); | 154 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); |
155 | 155 | ||
156 | // increment indices | 156 | // increment indices |
157 | y += mCellHeight; | 157 | y += mCellHeight; |
158 | cell++; | 158 | cell++; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Calculates the minimum width. | 163 | Calculates the minimum width. |
164 | */ | 164 | */ |
165 | int TimeLabels::minimumWidth() const | 165 | int TimeLabels::minimumWidth() const |
166 | { | 166 | { |
167 | QFontMetrics fm = fontMetrics(); | 167 | QFontMetrics fm = fontMetrics(); |
168 | 168 | ||
169 | //TODO: calculate this value | 169 | //TODO: calculate this value |
170 | int borderWidth = 4; | 170 | int borderWidth = 4; |
171 | 171 | ||
172 | // the maximum width possible | 172 | // the maximum width possible |
173 | int width = fm.width("88:88x") + borderWidth; | 173 | int width = fm.width("88:88x") + borderWidth; |
174 | 174 | ||
175 | return width; | 175 | return width; |
176 | } | 176 | } |
177 | 177 | ||
178 | /** updates widget's internal state */ | 178 | /** updates widget's internal state */ |
179 | void TimeLabels::updateConfig() | 179 | void TimeLabels::updateConfig() |
180 | { | 180 | { |
181 | // set the font | 181 | // set the font |
182 | // config->setGroup("Fonts"); | 182 | // config->setGroup("Fonts"); |
183 | // QFont font = config->readFontEntry("TimeBar Font"); | 183 | // QFont font = config->readFontEntry("TimeBar Font"); |
184 | setFont(KOPrefs::instance()->mTimeBarFont); | 184 | setFont(KOPrefs::instance()->mTimeBarFont); |
185 | 185 | ||
186 | // update geometry restrictions based on new settings | 186 | // update geometry restrictions based on new settings |
187 | setFixedWidth(minimumWidth()); | 187 | setFixedWidth(minimumWidth()); |
188 | 188 | ||
189 | // update HourSize | 189 | // update HourSize |
190 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 190 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
191 | resizeContents(50,mRows * mCellHeight); | 191 | resizeContents(50,mRows * mCellHeight); |
192 | } | 192 | } |
193 | 193 | ||
194 | /** update time label positions */ | 194 | /** update time label positions */ |
195 | void TimeLabels::positionChanged() | 195 | void TimeLabels::positionChanged() |
196 | { | 196 | { |
197 | int adjustment = mAgenda->contentsY(); | 197 | int adjustment = mAgenda->contentsY(); |
198 | setContentsPos(0, adjustment); | 198 | setContentsPos(0, adjustment); |
199 | } | 199 | } |
200 | 200 | ||
201 | /** */ | 201 | /** */ |
202 | void TimeLabels::setAgenda(KOAgenda* agenda) | 202 | void TimeLabels::setAgenda(KOAgenda* agenda) |
203 | { | 203 | { |
204 | mAgenda = agenda; | 204 | mAgenda = agenda; |
205 | } | 205 | } |
206 | 206 | ||
207 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 207 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
208 | { | 208 | { |
209 | mMouseDownY = e->pos().y(); | 209 | mMouseDownY = e->pos().y(); |
210 | mOrgCap = topLevelWidget()->caption(); | 210 | mOrgCap = topLevelWidget()->caption(); |
211 | } | 211 | } |
212 | 212 | ||
213 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 213 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
214 | { | 214 | { |
215 | int diff = mMouseDownY - e->pos().y(); | 215 | int diff = mMouseDownY - e->pos().y(); |
216 | if ( diff < 10 && diff > -10 ) | 216 | if ( diff < 10 && diff > -10 ) |
217 | return; | 217 | return; |
218 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 218 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
219 | if ( tSize < 4 ) | 219 | if ( tSize < 4 ) |
220 | tSize = 4; | 220 | tSize = 4; |
221 | if ( tSize > 22 ) | 221 | if ( tSize > 22 ) |
222 | tSize = 22; | 222 | tSize = 22; |
223 | tSize = (tSize-2)/2; | 223 | tSize = (tSize-2)/2; |
224 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 224 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
225 | 225 | ||
226 | } | 226 | } |
227 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 227 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
228 | { | 228 | { |
229 | topLevelWidget()->setCaption( mOrgCap ); | 229 | topLevelWidget()->setCaption( mOrgCap ); |
230 | int diff = mMouseDownY - e->pos().y(); | 230 | int diff = mMouseDownY - e->pos().y(); |
231 | if ( diff < 10 && diff > -10 ) | 231 | if ( diff < 10 && diff > -10 ) |
232 | return; | 232 | return; |
233 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 233 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
234 | if ( tSize < 4 ) | 234 | if ( tSize < 4 ) |
235 | tSize = 4; | 235 | tSize = 4; |
236 | if ( tSize > 22 ) | 236 | if ( tSize > 22 ) |
237 | tSize = 22; | 237 | tSize = 22; |
238 | tSize = (tSize/2)*2; | 238 | tSize = (tSize/2)*2; |
239 | if ( tSize == KOPrefs::instance()->mHourSize ) | 239 | if ( tSize == KOPrefs::instance()->mHourSize ) |
240 | return; | 240 | return; |
241 | KOPrefs::instance()->mHourSize = tSize; | 241 | KOPrefs::instance()->mHourSize = tSize; |
242 | emit scaleChanged(); | 242 | emit scaleChanged(); |
243 | } | 243 | } |
244 | 244 | ||
245 | /** This is called in response to repaint() */ | 245 | /** This is called in response to repaint() */ |
246 | void TimeLabels::paintEvent(QPaintEvent*) | 246 | void TimeLabels::paintEvent(QPaintEvent*) |
247 | { | 247 | { |
248 | 248 | ||
249 | // kdDebug() << "paintevent..." << endl; | 249 | // kdDebug() << "paintevent..." << endl; |
250 | // this is another hack! | 250 | // this is another hack! |
251 | // QPainter painter(this); | 251 | // QPainter painter(this); |
252 | //QString c | 252 | //QString c |
253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
254 | } | 254 | } |
255 | 255 | ||
256 | //////////////////////////////////////////////////////////////////////////// | 256 | //////////////////////////////////////////////////////////////////////////// |
257 | 257 | ||
258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
259 | : QFrame(parent,name) | 259 | : QFrame(parent,name) |
260 | { | 260 | { |
261 | mColumns = 1; | 261 | mColumns = 1; |
262 | mTopBox = 0; | 262 | mTopBox = 0; |
263 | mLocation = loc; | 263 | mLocation = loc; |
264 | mTopLayout = 0; | 264 | mTopLayout = 0; |
265 | mPaintWidget = 0; | 265 | mPaintWidget = 0; |
266 | mXOffset = 0; | 266 | mXOffset = 0; |
267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
268 | else mPixmap = SmallIcon("1downarrow"); | 268 | else mPixmap = SmallIcon("1downarrow"); |
269 | mEnabled.resize(mColumns); | 269 | mEnabled.resize(mColumns); |
270 | if (mLocation == Top) | 270 | if (mLocation == Top) |
271 | setMaximumHeight(0); | 271 | setMaximumHeight(0); |
272 | else | 272 | else |
273 | setMinimumHeight(mPixmap.height()); | 273 | setMinimumHeight(mPixmap.height()); |
274 | } | 274 | } |
275 | 275 | ||
276 | EventIndicator::~EventIndicator() | 276 | EventIndicator::~EventIndicator() |
277 | { | 277 | { |
278 | } | 278 | } |
279 | 279 | ||
280 | void EventIndicator::drawContents(QPainter *p) | 280 | void EventIndicator::drawContents(QPainter *p) |
281 | { | 281 | { |
282 | 282 | ||
283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
284 | KDGanttSplitterHandle* han = 0; | 284 | KDGanttSplitterHandle* han = 0; |
285 | if ( mPaintWidget ) | 285 | if ( mPaintWidget ) |
286 | han = mPaintWidget->firstHandle(); | 286 | han = mPaintWidget->firstHandle(); |
287 | if ( ! han ) { | 287 | if ( ! han ) { |
288 | int i; | 288 | int i; |
289 | for(i=0;i<mColumns;++i) { | 289 | for(i=0;i<mColumns;++i) { |
290 | if (mEnabled[i]) { | 290 | if (mEnabled[i]) { |
291 | int cellWidth = contentsRect().right()/mColumns; | 291 | int cellWidth = contentsRect().right()/mColumns; |
292 | int xOffset = KOGlobals::self()->reverseLayout() ? | 292 | int xOffset = KOGlobals::self()->reverseLayout() ? |
293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); | 295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } else { | 298 | } else { |
299 | han->repaint(); | 299 | han->repaint(); |
300 | //mPaintWidget->setBackgroundColor( red ); | 300 | //mPaintWidget->setBackgroundColor( red ); |
301 | 301 | ||
302 | QPainter pa( han ); | 302 | QPainter pa( han ); |
303 | int i; | 303 | int i; |
304 | bool setColor = false; | 304 | bool setColor = false; |
305 | for(i=0;i<mColumns;++i) { | 305 | for(i=0;i<mColumns;++i) { |
306 | if (mEnabled[i]) { | 306 | if (mEnabled[i]) { |
307 | setColor = true; | 307 | setColor = true; |
308 | 308 | ||
309 | int cellWidth = contentsRect().right()/mColumns; | 309 | int cellWidth = contentsRect().right()/mColumns; |
310 | int xOffset = KOGlobals::self()->reverseLayout() ? | 310 | int xOffset = KOGlobals::self()->reverseLayout() ? |
311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
314 | //qDebug("222draw pix %d ",xOffset ); | 314 | //qDebug("222draw pix %d ",xOffset ); |
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | } | 318 | } |
319 | pa.end(); | 319 | pa.end(); |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void EventIndicator::setXOffset( int x ) | 324 | void EventIndicator::setXOffset( int x ) |
325 | { | 325 | { |
326 | mXOffset = x; | 326 | mXOffset = x; |
327 | } | 327 | } |
328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
329 | { | 329 | { |
330 | mPaintWidget = w; | 330 | mPaintWidget = w; |
331 | } | 331 | } |
332 | void EventIndicator::changeColumns(int columns) | 332 | void EventIndicator::changeColumns(int columns) |
333 | { | 333 | { |
334 | mColumns = columns; | 334 | mColumns = columns; |
335 | mEnabled.resize(mColumns); | 335 | mEnabled.resize(mColumns); |
336 | 336 | ||
337 | update(); | 337 | update(); |
338 | } | 338 | } |
339 | 339 | ||
340 | void EventIndicator::enableColumn(int column, bool enable) | 340 | void EventIndicator::enableColumn(int column, bool enable) |
341 | { | 341 | { |
342 | mEnabled[column] = enable; | 342 | mEnabled[column] = enable; |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | //////////////////////////////////////////////////////////////////////////// | 346 | //////////////////////////////////////////////////////////////////////////// |
347 | //////////////////////////////////////////////////////////////////////////// | 347 | //////////////////////////////////////////////////////////////////////////// |
348 | //////////////////////////////////////////////////////////////////////////// | 348 | //////////////////////////////////////////////////////////////////////////// |
349 | 349 | ||
350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
351 | KOEventView (cal,parent,name) | 351 | KOEventView (cal,parent,name) |
352 | { | 352 | { |
353 | mBlockUpdating = true; | 353 | mBlockUpdating = true; |
354 | mStartHour = 8; | 354 | mStartHour = 8; |
355 | mSelectedDates.append(QDate::currentDate()); | 355 | mSelectedDates.append(QDate::currentDate()); |
356 | 356 | ||
357 | mLayoutDayLabels = 0; | 357 | mLayoutDayLabels = 0; |
358 | mDayLabelsFrame = 0; | 358 | mDayLabelsFrame = 0; |
359 | mDayLabels = 0; | 359 | mDayLabels = 0; |
360 | bool isRTL = KOGlobals::self()->reverseLayout(); | 360 | bool isRTL = KOGlobals::self()->reverseLayout(); |
361 | 361 | ||
362 | if ( KOPrefs::instance()->mVerticalScreen ) { | 362 | if ( KOPrefs::instance()->mVerticalScreen ) { |
363 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 363 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
365 | } else { | 365 | } else { |
366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
368 | } | 368 | } |
369 | 369 | ||
370 | QBoxLayout *topLayout = new QVBoxLayout(this); | 370 | QBoxLayout *topLayout = new QVBoxLayout(this); |
371 | 371 | ||
372 | // Create day name labels for agenda columns | 372 | // Create day name labels for agenda columns |
373 | mDayLabelsFrame = new QHBox(this); | 373 | mDayLabelsFrame = new QHBox(this); |
374 | topLayout->addWidget(mDayLabelsFrame); | 374 | topLayout->addWidget(mDayLabelsFrame); |
375 | mDayLabels = new QFrame (mDayLabelsFrame); | 375 | mDayLabels = new QFrame (mDayLabelsFrame); |
376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
377 | // Create agenda splitter | 377 | // Create agenda splitter |
378 | #ifndef KORG_NOSPLITTER | 378 | #ifndef KORG_NOSPLITTER |
379 | mSplitterAgenda = new QSplitter(Vertical,this); | 379 | mSplitterAgenda = new QSplitter(Vertical,this); |
380 | topLayout->addWidget(mSplitterAgenda); | 380 | topLayout->addWidget(mSplitterAgenda); |
381 | mSplitterAgenda->setOpaqueResize(); | 381 | mSplitterAgenda->setOpaqueResize(); |
382 | 382 | ||
383 | mAllDayFrame = new QHBox(mSplitterAgenda); | 383 | mAllDayFrame = new QHBox(mSplitterAgenda); |
384 | 384 | ||
385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
386 | #else | 386 | #else |
387 | #if 0 | 387 | #if 0 |
388 | QWidget *mainBox = new QWidget( this ); | 388 | QWidget *mainBox = new QWidget( this ); |
389 | topLayout->addWidget( mainBox ); | 389 | topLayout->addWidget( mainBox ); |
390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
391 | mAllDayFrame = new QHBox(mainBox); | 391 | mAllDayFrame = new QHBox(mainBox); |
392 | mainLayout->addWidget(mAllDayFrame); | 392 | mainLayout->addWidget(mAllDayFrame); |
393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
394 | mAllDayFrame->setFocusPolicy(NoFocus); | 394 | mAllDayFrame->setFocusPolicy(NoFocus); |
395 | QWidget *agendaFrame = new QWidget(mainBox); | 395 | QWidget *agendaFrame = new QWidget(mainBox); |
396 | mainLayout->addWidget(agendaFrame); | 396 | mainLayout->addWidget(agendaFrame); |
397 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 397 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
398 | 398 | ||
399 | agendaFrame->setFocusPolicy(NoFocus); | 399 | agendaFrame->setFocusPolicy(NoFocus); |
400 | #endif | 400 | #endif |
401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
403 | topLayout->addWidget( mSplitterAgenda ); | 403 | topLayout->addWidget( mSplitterAgenda ); |
404 | mAllDayFrame = new QHBox(mSplitterAgenda); | 404 | mAllDayFrame = new QHBox(mSplitterAgenda); |
405 | mAllDayFrame->setFocusPolicy(NoFocus); | 405 | mAllDayFrame->setFocusPolicy(NoFocus); |
406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
407 | agendaFrame->setFocusPolicy(NoFocus); | 407 | agendaFrame->setFocusPolicy(NoFocus); |
408 | 408 | ||
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | // Create all-day agenda widget | 411 | // Create all-day agenda widget |
412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
413 | 413 | ||
414 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 414 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
415 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 415 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
416 | int widebut = mExpandButton->sizeHint().width(); | 416 | int widebut = mExpandButton->sizeHint().width(); |
417 | if ( QApplication::desktop()->width() < 480 ) | 417 | if ( QApplication::desktop()->width() < 480 ) |
418 | widebut = widebut*2; | 418 | widebut = widebut*2; |
419 | else | 419 | else |
420 | widebut = (widebut*3) / 2; | 420 | widebut = (widebut*3) / 2; |
421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
422 | // QSizePolicy::Fixed ) ); | 422 | // QSizePolicy::Fixed ) ); |
423 | mExpandButton->setFixedSize( widebut, widebut); | 423 | mExpandButton->setFixedSize( widebut, widebut); |
424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
425 | mExpandButton->setFocusPolicy(NoFocus); | 425 | mExpandButton->setFocusPolicy(NoFocus); |
426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
427 | mAllDayAgenda->setFocusPolicy(NoFocus); | 427 | mAllDayAgenda->setFocusPolicy(NoFocus); |
428 | QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); | 428 | QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); |
429 | 429 | ||
430 | QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); | 430 | QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); |
431 | QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight ); | 431 | QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight ); |
432 | 432 | ||
433 | dummyAllDayRightB->setFlat( true ); | 433 | dummyAllDayRightB->setFlat( true ); |
434 | dummyAllDayRightB->setFocusPolicy(NoFocus); | 434 | dummyAllDayRightB->setFocusPolicy(NoFocus); |
435 | // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); | 435 | // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); |
436 | //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 ); | 436 | //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 ); |
437 | QPopupMenu * wpo = new QPopupMenu (this); | 437 | QPopupMenu * wpo = new QPopupMenu (this); |
438 | wpo->insertItem( i18n("W#"), 0 ); | 438 | wpo->insertItem( i18n("W#"), 0 ); |
439 | int i; | 439 | int i; |
440 | for ( i = 1; i < 54; i++ ) | 440 | for ( i = 1; i < 53; i++ ) |
441 | wpo->insertItem( QString::number( i ),i ); | 441 | wpo->insertItem( QString::number( i ),i ); |
442 | //Qt bug - we must add some empty fields... | ||
443 | for ( i = 53; i < 54; ++i ) { | ||
444 | wpo->insertItem( "", 52 ); | ||
445 | } | ||
442 | dummyAllDayRightB->setPopup( wpo ); | 446 | dummyAllDayRightB->setPopup( wpo ); |
443 | 447 | ||
444 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); | 448 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); |
445 | 449 | ||
446 | // Create event context menu for all day agenda | 450 | // Create event context menu for all day agenda |
447 | mAllDayAgendaPopup = eventPopup(); | 451 | mAllDayAgendaPopup = eventPopup(); |
448 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 452 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
449 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 453 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
450 | 454 | ||
451 | // Create agenda frame | 455 | // Create agenda frame |
452 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 456 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
453 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 457 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
454 | 458 | ||
455 | // create event indicator bars | 459 | // create event indicator bars |
456 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 460 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
457 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 461 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
458 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 462 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
459 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 463 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
460 | agendaFrame); | 464 | agendaFrame); |
461 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 465 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
462 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 466 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
463 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 467 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
464 | 468 | ||
465 | // Create time labels | 469 | // Create time labels |
466 | mTimeLabels = new TimeLabels(24,agendaFrame); | 470 | mTimeLabels = new TimeLabels(24,agendaFrame); |
467 | agendaLayout->addWidget(mTimeLabels,1,0); | 471 | agendaLayout->addWidget(mTimeLabels,1,0); |
468 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 472 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
469 | this,SLOT(updateConfig())); | 473 | this,SLOT(updateConfig())); |
470 | 474 | ||
471 | // Create agenda | 475 | // Create agenda |
472 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 476 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
473 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 477 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
474 | agendaLayout->setColStretch(1,1); | 478 | agendaLayout->setColStretch(1,1); |
475 | mAgenda->setFocusPolicy(NoFocus); | 479 | mAgenda->setFocusPolicy(NoFocus); |
476 | // Create event context menu for agenda | 480 | // Create event context menu for agenda |
477 | mAgendaPopup = eventPopup(); | 481 | mAgendaPopup = eventPopup(); |
478 | 482 | ||
479 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 483 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
480 | i18n("Toggle Alarm"),mAgenda, | 484 | i18n("Toggle Alarm"),mAgenda, |
481 | SLOT(popupAlarm()),true); | 485 | SLOT(popupAlarm()),true); |
482 | 486 | ||
483 | 487 | ||
484 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 488 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
485 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 489 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
486 | 490 | ||
487 | // make connections between dependent widgets | 491 | // make connections between dependent widgets |
488 | mTimeLabels->setAgenda(mAgenda); | 492 | mTimeLabels->setAgenda(mAgenda); |
489 | 493 | ||
490 | // Update widgets to reflect user preferences | 494 | // Update widgets to reflect user preferences |
491 | // updateConfig(); | 495 | // updateConfig(); |
492 | 496 | ||
493 | // createDayLabels(); | 497 | // createDayLabels(); |
494 | 498 | ||
495 | // these blank widgets make the All Day Event box line up with the agenda | 499 | // these blank widgets make the All Day Event box line up with the agenda |
496 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 500 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
497 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 501 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
498 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 502 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
499 | 503 | ||
500 | // Scrolling | 504 | // Scrolling |
501 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 505 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
502 | mTimeLabels, SLOT(positionChanged())); | 506 | mTimeLabels, SLOT(positionChanged())); |
503 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 507 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
504 | SLOT(setContentsPos(int))); | 508 | SLOT(setContentsPos(int))); |
505 | 509 | ||
506 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 510 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
507 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 511 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
508 | 512 | ||
509 | // Create/Show/Edit/Delete Event | 513 | // Create/Show/Edit/Delete Event |
510 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 514 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
511 | SLOT(newEvent(int,int))); | 515 | SLOT(newEvent(int,int))); |
512 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 516 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
513 | SLOT(newTodo(int,int))); | 517 | SLOT(newTodo(int,int))); |
514 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 518 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
515 | SLOT(newEvent(int,int,int,int))); | 519 | SLOT(newEvent(int,int,int,int))); |
516 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 520 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
517 | SLOT(newEventAllDay(int,int))); | 521 | SLOT(newEventAllDay(int,int))); |
518 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 522 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
519 | SLOT(newTodoAllDay(int,int))); | 523 | SLOT(newTodoAllDay(int,int))); |
520 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 524 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
521 | SLOT(newEventAllDay(int,int))); | 525 | SLOT(newEventAllDay(int,int))); |
522 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 526 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
523 | SLOT(newTimeSpanSelected(int,int,int,int))); | 527 | SLOT(newTimeSpanSelected(int,int,int,int))); |
524 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 528 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
525 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 529 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
526 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 530 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
527 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 531 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
528 | 532 | ||
529 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 533 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
530 | SIGNAL(editIncidenceSignal(Incidence *))); | 534 | SIGNAL(editIncidenceSignal(Incidence *))); |
531 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 535 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
532 | SIGNAL(editIncidenceSignal(Incidence *))); | 536 | SIGNAL(editIncidenceSignal(Incidence *))); |
533 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 537 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
534 | SIGNAL(showIncidenceSignal(Incidence *))); | 538 | SIGNAL(showIncidenceSignal(Incidence *))); |
535 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 539 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
536 | SIGNAL(showIncidenceSignal(Incidence *))); | 540 | SIGNAL(showIncidenceSignal(Incidence *))); |
537 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 541 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
538 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 542 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
539 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 543 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
540 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 544 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
541 | 545 | ||
542 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 546 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
543 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 547 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
544 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 548 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
545 | SLOT(updateEventDates(KOAgendaItem *, int))); | 549 | SLOT(updateEventDates(KOAgendaItem *, int))); |
546 | 550 | ||
547 | // event indicator update | 551 | // event indicator update |
548 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 552 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
549 | SLOT(updateEventIndicatorTop(int))); | 553 | SLOT(updateEventIndicatorTop(int))); |
550 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 554 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
551 | SLOT(updateEventIndicatorBottom(int))); | 555 | SLOT(updateEventIndicatorBottom(int))); |
552 | // drag signals | 556 | // drag signals |
553 | /* | 557 | /* |
554 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 558 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
555 | SLOT(startDrag(Event *))); | 559 | SLOT(startDrag(Event *))); |
556 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 560 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
557 | SLOT(startDrag(Event *))); | 561 | SLOT(startDrag(Event *))); |
558 | */ | 562 | */ |
559 | // synchronize selections | 563 | // synchronize selections |
560 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 564 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
561 | mAllDayAgenda, SLOT( deselectItem() ) ); | 565 | mAllDayAgenda, SLOT( deselectItem() ) ); |
562 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 566 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
563 | mAgenda, SLOT( deselectItem() ) ); | 567 | mAgenda, SLOT( deselectItem() ) ); |
564 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 568 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
565 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 569 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
566 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 570 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
567 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 571 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
568 | connect( mAgenda, SIGNAL( resizedSignal() ), | 572 | connect( mAgenda, SIGNAL( resizedSignal() ), |
569 | SLOT( updateConfig( ) ) ); | 573 | SLOT( updateConfig( ) ) ); |
570 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 574 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
571 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 575 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
572 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 576 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
573 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 577 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
574 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 578 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
575 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 579 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
576 | 580 | ||
577 | 581 | ||
578 | } | 582 | } |
579 | 583 | ||
580 | void KOAgendaView::toggleAllDay() | 584 | void KOAgendaView::toggleAllDay() |
581 | { | 585 | { |
582 | if ( mSplitterAgenda->firstHandle() ) | 586 | if ( mSplitterAgenda->firstHandle() ) |
583 | mSplitterAgenda->firstHandle()->toggle(); | 587 | mSplitterAgenda->firstHandle()->toggle(); |
584 | } | 588 | } |
585 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 589 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
586 | { | 590 | { |
587 | calendar()->addIncidence( inc ); | 591 | calendar()->addIncidence( inc ); |
588 | 592 | ||
589 | if ( incOld ) { | 593 | if ( incOld ) { |
590 | if ( incOld->type() == "Todo" ) | 594 | if ( incOld->type() == "Todo" ) |
591 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 595 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
592 | else | 596 | else |
593 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 597 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
594 | } | 598 | } |
595 | 599 | ||
596 | } | 600 | } |
597 | 601 | ||
598 | KOAgendaView::~KOAgendaView() | 602 | KOAgendaView::~KOAgendaView() |
599 | { | 603 | { |
600 | delete mAgendaPopup; | 604 | delete mAgendaPopup; |
601 | delete mAllDayAgendaPopup; | 605 | delete mAllDayAgendaPopup; |
602 | delete KOAgendaItem::paintPix(); | 606 | delete KOAgendaItem::paintPix(); |
603 | delete KOAgendaItem::paintPixSel(); | 607 | delete KOAgendaItem::paintPixSel(); |
604 | } | 608 | } |
605 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 609 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
606 | { | 610 | { |
607 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 611 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
608 | bool uc = false; | 612 | bool uc = false; |
609 | int ow = e->oldSize().width(); | 613 | int ow = e->oldSize().width(); |
610 | int oh = e->oldSize().height(); | 614 | int oh = e->oldSize().height(); |
611 | int w = e->size().width(); | 615 | int w = e->size().width(); |
612 | int h = e->size().height(); | 616 | int h = e->size().height(); |
613 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 617 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
614 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 618 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
615 | uc = true; | 619 | uc = true; |
616 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 620 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
617 | } | 621 | } |
618 | mUpcomingWidth = e->size().width() ; | 622 | mUpcomingWidth = e->size().width() ; |
619 | if ( mBlockUpdating || uc ) { | 623 | if ( mBlockUpdating || uc ) { |
620 | mBlockUpdating = false; | 624 | mBlockUpdating = false; |
621 | //mAgenda->setMinimumSize(800 , 600 ); | 625 | //mAgenda->setMinimumSize(800 , 600 ); |
622 | //qDebug("mAgenda->resize+++++++++++++++ "); | 626 | //qDebug("mAgenda->resize+++++++++++++++ "); |
623 | updateConfig(); | 627 | updateConfig(); |
624 | //qDebug("KOAgendaView::Updating now possible "); | 628 | //qDebug("KOAgendaView::Updating now possible "); |
625 | } else | 629 | } else |
626 | createDayLabels(); | 630 | createDayLabels(); |
627 | //qDebug("resizeEvent end "); | 631 | //qDebug("resizeEvent end "); |
628 | 632 | ||
629 | } | 633 | } |
630 | void KOAgendaView::slotDaylabelClicked( int num ) | 634 | void KOAgendaView::slotDaylabelClicked( int num ) |
631 | { | 635 | { |
632 | 636 | ||
633 | QDate firstDate = mSelectedDates.first(); | 637 | QDate firstDate = mSelectedDates.first(); |
634 | if ( num == -1 ) | 638 | if ( num == -1 ) |
635 | emit showDateView( 6, firstDate ); | 639 | emit showDateView( 6, firstDate ); |
636 | else if (num >= 0 ) { | 640 | else if (num >= 0 ) { |
637 | if ( mSelectedDates.count() == 1) | 641 | if ( mSelectedDates.count() == 1) |
638 | emit showDateView( 9, firstDate.addDays( num ) ); | 642 | emit showDateView( 9, firstDate.addDays( num ) ); |
639 | else | 643 | else |
640 | emit showDateView( 3, firstDate.addDays( num ) ); | 644 | emit showDateView( 3, firstDate.addDays( num ) ); |
641 | } | 645 | } |
642 | else | 646 | else |
643 | showDateView( 10, firstDate.addDays(1) ); | 647 | showDateView( 10, firstDate.addDays(1) ); |
644 | } | 648 | } |
645 | 649 | ||
646 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 650 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
647 | { | 651 | { |
648 | 652 | ||
649 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 653 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
650 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 654 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
651 | mDayLabelsList.append( dayLabel ); | 655 | mDayLabelsList.append( dayLabel ); |
652 | mLayoutDayLabels->addWidget(dayLabel); | 656 | mLayoutDayLabels->addWidget(dayLabel); |
653 | return dayLabel ; | 657 | return dayLabel ; |
654 | } | 658 | } |
655 | 659 | ||
656 | void KOAgendaView::createDayLabels() | 660 | void KOAgendaView::createDayLabels() |
657 | { | 661 | { |
658 | 662 | ||
659 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 663 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
660 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 664 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
661 | return; | 665 | return; |
662 | 666 | ||
663 | } | 667 | } |
664 | int newHight; | 668 | int newHight; |
665 | 669 | ||
666 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 670 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
667 | // It would remove some flickering and gain speed (since this is called by | 671 | // It would remove some flickering and gain speed (since this is called by |
668 | // each updateView() call) | 672 | // each updateView() call) |
669 | 673 | ||
670 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 674 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
671 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 675 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
672 | if ( maxWid < 0 ) | 676 | if ( maxWid < 0 ) |
673 | maxWid = 20; | 677 | maxWid = 20; |
674 | 678 | ||
675 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 679 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
676 | QFontMetrics fm ( dlf ); | 680 | QFontMetrics fm ( dlf ); |
677 | int selCount = mSelectedDates.count(); | 681 | int selCount = mSelectedDates.count(); |
678 | QString dayTest = "Mon 20"; | 682 | QString dayTest = "Mon 20"; |
679 | //QString dayTest = "Mon 20"; | 683 | //QString dayTest = "Mon 20"; |
680 | int wid = fm.width( dayTest ); | 684 | int wid = fm.width( dayTest ); |
681 | //maxWid -= ( selCount * 3 ); //working for QLabels | 685 | //maxWid -= ( selCount * 3 ); //working for QLabels |
682 | maxWid -= ( selCount * 3 ); //working for QPushButton | 686 | maxWid -= ( selCount * 3 ); //working for QPushButton |
683 | if ( maxWid < 0 ) | 687 | if ( maxWid < 0 ) |
684 | maxWid = 20; | 688 | maxWid = 20; |
685 | int needWid = wid * selCount; | 689 | int needWid = wid * selCount; |
686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 690 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
687 | //if ( needWid > maxWid ) | 691 | //if ( needWid > maxWid ) |
688 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 692 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
689 | while ( needWid > maxWid ) { | 693 | while ( needWid > maxWid ) { |
690 | dayTest = dayTest.left( dayTest.length() - 1 ); | 694 | dayTest = dayTest.left( dayTest.length() - 1 ); |
691 | wid = fm.width( dayTest ); | 695 | wid = fm.width( dayTest ); |
692 | needWid = wid * selCount; | 696 | needWid = wid * selCount; |
693 | } | 697 | } |
694 | int maxLen = dayTest.length(); | 698 | int maxLen = dayTest.length(); |
695 | int fontPoint = dlf.pointSize(); | 699 | int fontPoint = dlf.pointSize(); |
696 | if ( maxLen < 2 ) { | 700 | if ( maxLen < 2 ) { |
697 | int fontPoint = dlf.pointSize(); | 701 | int fontPoint = dlf.pointSize(); |
698 | while ( fontPoint > 4 ) { | 702 | while ( fontPoint > 4 ) { |
699 | --fontPoint; | 703 | --fontPoint; |
700 | dlf.setPointSize( fontPoint ); | 704 | dlf.setPointSize( fontPoint ); |
701 | QFontMetrics f( dlf ); | 705 | QFontMetrics f( dlf ); |
702 | wid = f.width( "30" ); | 706 | wid = f.width( "30" ); |
703 | needWid = wid * selCount; | 707 | needWid = wid * selCount; |
704 | if ( needWid < maxWid ) | 708 | if ( needWid < maxWid ) |
705 | break; | 709 | break; |
706 | } | 710 | } |
707 | maxLen = 2; | 711 | maxLen = 2; |
708 | } | 712 | } |
709 | //qDebug("Max len %d ", dayTest.length() ); | 713 | //qDebug("Max len %d ", dayTest.length() ); |
710 | 714 | ||
711 | QFontMetrics tempF( dlf ); | 715 | QFontMetrics tempF( dlf ); |
712 | newHight = tempF.height(); | 716 | newHight = tempF.height(); |
713 | mDayLabels->setFont( dlf ); | 717 | mDayLabels->setFont( dlf ); |
714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 718 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 719 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
716 | //mLayoutDayLabels->addSpacing( 2 ); | 720 | //mLayoutDayLabels->addSpacing( 2 ); |
717 | // QFont lFont = dlf; | 721 | // QFont lFont = dlf; |
718 | bool appendLabels = false; | 722 | bool appendLabels = false; |
719 | KOAgendaButton *dayLabel; | 723 | KOAgendaButton *dayLabel; |
720 | dayLabel = mDayLabelsList.first(); | 724 | dayLabel = mDayLabelsList.first(); |
721 | if ( !dayLabel ) { | 725 | if ( !dayLabel ) { |
722 | appendLabels = true; | 726 | appendLabels = true; |
723 | dayLabel = getNewDaylabel(); | 727 | dayLabel = getNewDaylabel(); |
724 | } | 728 | } |
725 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 729 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
726 | dayLabel->setFont( dlf ); | 730 | dayLabel->setFont( dlf ); |
727 | dayLabel->setNum( -1 ); | 731 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 732 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
730 | dayLabel->show(); | 734 | dayLabel->show(); |
731 | DateList::ConstIterator dit; | 735 | DateList::ConstIterator dit; |
732 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
733 | int counter = -1; | 737 | int counter = -1; |
734 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
735 | ++counter; | 739 | ++counter; |
736 | QDate date = *dit; | 740 | QDate date = *dit; |
737 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
738 | if ( ! appendLabels ) { | 742 | if ( ! appendLabels ) { |
739 | dayLabel = mDayLabelsList.next(); | 743 | dayLabel = mDayLabelsList.next(); |
740 | if ( !dayLabel ) | 744 | if ( !dayLabel ) |
741 | appendLabels = true; | 745 | appendLabels = true; |
742 | } | 746 | } |
743 | if ( appendLabels ) { | 747 | if ( appendLabels ) { |
744 | dayLabel = getNewDaylabel(); | 748 | dayLabel = getNewDaylabel(); |
745 | } | 749 | } |
746 | dayLabel->setMinimumWidth( 1 ); | 750 | dayLabel->setMinimumWidth( 1 ); |
747 | dayLabel->setMaximumWidth( 1024 ); | 751 | dayLabel->setMaximumWidth( 1024 ); |
748 | dayLabel->setFont( dlf ); | 752 | dayLabel->setFont( dlf ); |
749 | dayLabel->show(); | 753 | dayLabel->show(); |
750 | dayLabel->setNum( counter ); | 754 | dayLabel->setNum( counter ); |
751 | QString str; | 755 | QString str; |
752 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 756 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
753 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 757 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
754 | switch ( maxLen ) { | 758 | switch ( maxLen ) { |
755 | case 2: | 759 | case 2: |
756 | str = QString::number( date.day() ); | 760 | str = QString::number( date.day() ); |
757 | break; | 761 | break; |
758 | 762 | ||
759 | case 3: | 763 | case 3: |
760 | str = dayName.left( 1 ) +QString::number( date.day()); | 764 | str = dayName.left( 1 ) +QString::number( date.day()); |
761 | 765 | ||
762 | break; | 766 | break; |
763 | case 4: | 767 | case 4: |
764 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 768 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
765 | 769 | ||
766 | break; | 770 | break; |
767 | case 5: | 771 | case 5: |
768 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 772 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
769 | 773 | ||
770 | break; | 774 | break; |
771 | case 6: | 775 | case 6: |
772 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 776 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
773 | break; | 777 | break; |
774 | 778 | ||
775 | default: | 779 | default: |
776 | break; | 780 | break; |
777 | } | 781 | } |
778 | if ( oneday ) { | 782 | if ( oneday ) { |
779 | QString addString; | 783 | QString addString; |
780 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 784 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
781 | addString = i18n("Today"); | 785 | addString = i18n("Today"); |
782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
783 | addString = i18n("Tomorrow"); | 787 | addString = i18n("Tomorrow"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
785 | addString = i18n("Yesterday"); | 789 | addString = i18n("Yesterday"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
787 | addString = i18n("Day before yesterday"); | 791 | addString = i18n("Day before yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 792 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
789 | addString = i18n("Day after tomorrow"); | 793 | addString = i18n("Day after tomorrow"); |
790 | if ( !addString.isEmpty() ) { | 794 | if ( !addString.isEmpty() ) { |
791 | str = addString+", " + str; | 795 | str = addString+", " + str; |
792 | } | 796 | } |
793 | } | 797 | } |
794 | dayLabel->setText(str); | 798 | dayLabel->setText(str); |
795 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 799 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
796 | if (date == QDate::currentDate()) { | 800 | if (date == QDate::currentDate()) { |
797 | QFont bFont = dlf; | 801 | QFont bFont = dlf; |
798 | bFont.setBold( true ); | 802 | bFont.setBold( true ); |
799 | dayLabel->setFont(bFont); | 803 | dayLabel->setFont(bFont); |
800 | } | 804 | } |
801 | //dayLayout->addWidget(dayLabel); | 805 | //dayLayout->addWidget(dayLabel); |
802 | 806 | ||
803 | #ifndef KORG_NOPLUGINS | 807 | #ifndef KORG_NOPLUGINS |
804 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
805 | CalendarDecoration *it; | 809 | CalendarDecoration *it; |
806 | for(it = cds.first(); it; it = cds.next()) { | 810 | for(it = cds.first(); it; it = cds.next()) { |
807 | QString text = it->shortText( date ); | 811 | QString text = it->shortText( date ); |
808 | if ( !text.isEmpty() ) { | 812 | if ( !text.isEmpty() ) { |
809 | QLabel *label = new QLabel(text,mDayLabels); | 813 | QLabel *label = new QLabel(text,mDayLabels); |
810 | label->setAlignment(AlignCenter); | 814 | label->setAlignment(AlignCenter); |
811 | dayLayout->addWidget(label); | 815 | dayLayout->addWidget(label); |
812 | } | 816 | } |
813 | } | 817 | } |
814 | 818 | ||
815 | for(it = cds.first(); it; it = cds.next()) { | 819 | for(it = cds.first(); it; it = cds.next()) { |
816 | QWidget *wid = it->smallWidget(mDayLabels,date); | 820 | QWidget *wid = it->smallWidget(mDayLabels,date); |
817 | if ( wid ) { | 821 | if ( wid ) { |
818 | // wid->setHeight(20); | 822 | // wid->setHeight(20); |
819 | dayLayout->addWidget(wid); | 823 | dayLayout->addWidget(wid); |
820 | } | 824 | } |
821 | } | 825 | } |
822 | #endif | 826 | #endif |
823 | } | 827 | } |
824 | if ( ! appendLabels ) { | 828 | if ( ! appendLabels ) { |
825 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
826 | if ( !dayLabel ) | 830 | if ( !dayLabel ) |
827 | appendLabels = true; | 831 | appendLabels = true; |
828 | } | 832 | } |
829 | if ( appendLabels ) { | 833 | if ( appendLabels ) { |
830 | dayLabel = getNewDaylabel(); | 834 | dayLabel = getNewDaylabel(); |
831 | } | 835 | } |
832 | //dayLabel->hide();//test only | 836 | //dayLabel->hide();//test only |
833 | 837 | ||
834 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 838 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
835 | if ( offset < 0 ) offset = 0; | 839 | if ( offset < 0 ) offset = 0; |
836 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 840 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
837 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 841 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
838 | dayLabel->setFont( dlf ); | 842 | dayLabel->setFont( dlf ); |
839 | dayLabel->show(); | 843 | dayLabel->show(); |
840 | dayLabel->setNum( -2 ); | 844 | dayLabel->setNum( -2 ); |
841 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 845 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
842 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 846 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
843 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 847 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
844 | if ( !appendLabels ) { | 848 | if ( !appendLabels ) { |
845 | dayLabel = mDayLabelsList.next(); | 849 | dayLabel = mDayLabelsList.next(); |
846 | while ( dayLabel ) { | 850 | while ( dayLabel ) { |
847 | //qDebug("!dayLabel %d",dayLabel ); | 851 | //qDebug("!dayLabel %d",dayLabel ); |
848 | dayLabel->hide(); | 852 | dayLabel->hide(); |
849 | dayLabel = mDayLabelsList.next(); | 853 | dayLabel = mDayLabelsList.next(); |
850 | } | 854 | } |
851 | } | 855 | } |
852 | //mDayLabelsFrame->show(); | 856 | //mDayLabelsFrame->show(); |
853 | //mDayLabels->show(); | 857 | //mDayLabels->show(); |
854 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 858 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
855 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 859 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
856 | mDayLabelsFrame->setFixedHeight( newHight ); | 860 | mDayLabelsFrame->setFixedHeight( newHight ); |
857 | } | 861 | } |
858 | 862 | ||
859 | int KOAgendaView::maxDatesHint() | 863 | int KOAgendaView::maxDatesHint() |
860 | { | 864 | { |
861 | // Not sure about the max number of events, so return 0 for now. | 865 | // Not sure about the max number of events, so return 0 for now. |
862 | return 0; | 866 | return 0; |
863 | } | 867 | } |
864 | 868 | ||
865 | int KOAgendaView::currentDateCount() | 869 | int KOAgendaView::currentDateCount() |
866 | { | 870 | { |
867 | return mSelectedDates.count(); | 871 | return mSelectedDates.count(); |
868 | } | 872 | } |
869 | 873 | ||
870 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 874 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
871 | { | 875 | { |
872 | QPtrList<Incidence> selected; | 876 | QPtrList<Incidence> selected; |
873 | Incidence *incidence; | 877 | Incidence *incidence; |
874 | 878 | ||
875 | incidence = mAgenda->selectedIncidence(); | 879 | incidence = mAgenda->selectedIncidence(); |
876 | if (incidence) selected.append(incidence); | 880 | if (incidence) selected.append(incidence); |
877 | 881 | ||
878 | incidence = mAllDayAgenda->selectedIncidence(); | 882 | incidence = mAllDayAgenda->selectedIncidence(); |
879 | if (incidence) selected.append(incidence); | 883 | if (incidence) selected.append(incidence); |
880 | 884 | ||
881 | return selected; | 885 | return selected; |
882 | } | 886 | } |
883 | 887 | ||
884 | DateList KOAgendaView::selectedDates() | 888 | DateList KOAgendaView::selectedDates() |
885 | { | 889 | { |
886 | DateList selected; | 890 | DateList selected; |
887 | QDate qd; | 891 | QDate qd; |
888 | 892 | ||
889 | qd = mAgenda->selectedIncidenceDate(); | 893 | qd = mAgenda->selectedIncidenceDate(); |
890 | if (qd.isValid()) selected.append(qd); | 894 | if (qd.isValid()) selected.append(qd); |
891 | 895 | ||
892 | qd = mAllDayAgenda->selectedIncidenceDate(); | 896 | qd = mAllDayAgenda->selectedIncidenceDate(); |
893 | if (qd.isValid()) selected.append(qd); | 897 | if (qd.isValid()) selected.append(qd); |
894 | 898 | ||
895 | return selected; | 899 | return selected; |
896 | } | 900 | } |
897 | 901 | ||
898 | 902 | ||
899 | void KOAgendaView::updateView() | 903 | void KOAgendaView::updateView() |
900 | { | 904 | { |
901 | if ( mBlockUpdating ) | 905 | if ( mBlockUpdating ) |
902 | return; | 906 | return; |
903 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 907 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
904 | fillAgenda(); | 908 | fillAgenda(); |
905 | 909 | ||
906 | } | 910 | } |
907 | 911 | ||
908 | 912 | ||
909 | /* | 913 | /* |
910 | Update configuration settings for the agenda view. This method is not | 914 | Update configuration settings for the agenda view. This method is not |
911 | complete. | 915 | complete. |
912 | */ | 916 | */ |
913 | void KOAgendaView::updateConfig() | 917 | void KOAgendaView::updateConfig() |
914 | { | 918 | { |
915 | if ( mBlockUpdating ) | 919 | if ( mBlockUpdating ) |
916 | return; | 920 | return; |
917 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 921 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
918 | 922 | ||
919 | // update config for children | 923 | // update config for children |
920 | mTimeLabels->updateConfig(); | 924 | mTimeLabels->updateConfig(); |
921 | mAgenda->storePosition(); | 925 | mAgenda->storePosition(); |
922 | mAgenda->updateConfig(); | 926 | mAgenda->updateConfig(); |
923 | mAllDayAgenda->updateConfig(); | 927 | mAllDayAgenda->updateConfig(); |
924 | // widget synchronization | 928 | // widget synchronization |
925 | //TODO: find a better way, maybe signal/slot | 929 | //TODO: find a better way, maybe signal/slot |
926 | mTimeLabels->positionChanged(); | 930 | mTimeLabels->positionChanged(); |
927 | 931 | ||
928 | // for some reason, this needs to be called explicitly | 932 | // for some reason, this needs to be called explicitly |
929 | mTimeLabels->repaint(); | 933 | mTimeLabels->repaint(); |
930 | 934 | ||
931 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
932 | 936 | ||
933 | // ToolTips displaying summary of events | 937 | // ToolTips displaying summary of events |
934 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
935 | ->mEnableToolTips); | 939 | ->mEnableToolTips); |
936 | 940 | ||
937 | //setHolidayMasks(); | 941 | //setHolidayMasks(); |
938 | 942 | ||
939 | //createDayLabels(); called by via updateView(); | 943 | //createDayLabels(); called by via updateView(); |
940 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
941 | updateView(); | 945 | updateView(); |
942 | mAgenda->restorePosition(); | 946 | mAgenda->restorePosition(); |
943 | } | 947 | } |
944 | 948 | ||
945 | 949 | ||
946 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
947 | { | 951 | { |
948 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 952 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
949 | //qDebug("KOAgendaView::updateEventDates "); | 953 | //qDebug("KOAgendaView::updateEventDates "); |
950 | QDateTime startDt,endDt; | 954 | QDateTime startDt,endDt; |
951 | QDate startDate; | 955 | QDate startDate; |
952 | int lenInSecs; | 956 | int lenInSecs; |
953 | // if ( type == KOAgenda::RESIZETOP ) | 957 | // if ( type == KOAgenda::RESIZETOP ) |
954 | // qDebug("RESIZETOP "); | 958 | // qDebug("RESIZETOP "); |
955 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 959 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
956 | // qDebug("RESIZEBOTTOM "); | 960 | // qDebug("RESIZEBOTTOM "); |
957 | // if ( type == KOAgenda::MOVE ) | 961 | // if ( type == KOAgenda::MOVE ) |
958 | // qDebug("MOVE "); | 962 | // qDebug("MOVE "); |
959 | if ( item->incidence()->type() == "Event" ) { | 963 | if ( item->incidence()->type() == "Event" ) { |
960 | startDt =item->incidence()->dtStart(); | 964 | startDt =item->incidence()->dtStart(); |
961 | endDt = item->incidence()->dtEnd(); | 965 | endDt = item->incidence()->dtEnd(); |
962 | lenInSecs = startDt.secsTo( endDt ); | 966 | lenInSecs = startDt.secsTo( endDt ); |
963 | } | 967 | } |
964 | 968 | ||
965 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 969 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
966 | 970 | ||
967 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 971 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
968 | startDate = mSelectedDates[item->mLastMoveXPos]; | 972 | startDate = mSelectedDates[item->mLastMoveXPos]; |
969 | } else { | 973 | } else { |
970 | if (item->cellX() < 0) { | 974 | if (item->cellX() < 0) { |
971 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 975 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
972 | } else { | 976 | } else { |
973 | startDate = mSelectedDates[item->cellX()]; | 977 | startDate = mSelectedDates[item->cellX()]; |
974 | } | 978 | } |
975 | } | 979 | } |
976 | startDt.setDate(startDate); | 980 | startDt.setDate(startDate); |
977 | 981 | ||
978 | if (item->incidence()->doesFloat()) { | 982 | if (item->incidence()->doesFloat()) { |
979 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 983 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
980 | } else { | 984 | } else { |
981 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 985 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
982 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 986 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
983 | if ( item->incidence()->type() == "Event" ) { | 987 | if ( item->incidence()->type() == "Event" ) { |
984 | if ( type == KOAgenda::MOVE ) { | 988 | if ( type == KOAgenda::MOVE ) { |
985 | endDt = startDt.addSecs(lenInSecs); | 989 | endDt = startDt.addSecs(lenInSecs); |
986 | 990 | ||
987 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 991 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
988 | if (item->lastMultiItem()) { | 992 | if (item->lastMultiItem()) { |
989 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 993 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
990 | endDt.setDate(startDate. | 994 | endDt.setDate(startDate. |
991 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 995 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
992 | } else { | 996 | } else { |
993 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 997 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
994 | endDt.setDate(startDate); | 998 | endDt.setDate(startDate); |
995 | } | 999 | } |
996 | } | 1000 | } |
997 | } else { | 1001 | } else { |
998 | // todo | 1002 | // todo |
999 | if (item->lastMultiItem()) { | 1003 | if (item->lastMultiItem()) { |
1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1004 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1001 | endDt.setDate(startDate. | 1005 | endDt.setDate(startDate. |
1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1006 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1003 | } else { | 1007 | } else { |
1004 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1008 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1005 | if ( item->cellYBottom() > 0 ) | 1009 | if ( item->cellYBottom() > 0 ) |
1006 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1010 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1007 | else | 1011 | else |
1008 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1012 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1009 | endDt.setDate(startDate); | 1013 | endDt.setDate(startDate); |
1010 | } | 1014 | } |
1011 | } | 1015 | } |
1012 | } | 1016 | } |
1013 | if ( item->incidence()->type() == "Event" ) { | 1017 | if ( item->incidence()->type() == "Event" ) { |
1014 | item->incidence()->setDtStart(startDt); | 1018 | item->incidence()->setDtStart(startDt); |
1015 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1019 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1016 | } else if ( item->incidence()->type() == "Todo" ) { | 1020 | } else if ( item->incidence()->type() == "Todo" ) { |
1017 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1021 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1018 | } | 1022 | } |
1019 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1023 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1020 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1024 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1021 | item->setItemDate(startDt.date()); | 1025 | item->setItemDate(startDt.date()); |
1022 | //item->updateItem(); | 1026 | //item->updateItem(); |
1023 | if ( item->incidence()->type() == "Todo" ) { | 1027 | if ( item->incidence()->type() == "Todo" ) { |
1024 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1028 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1025 | 1029 | ||
1026 | } | 1030 | } |
1027 | else | 1031 | else |
1028 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1032 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1029 | item->updateItem(); | 1033 | item->updateItem(); |
1030 | } | 1034 | } |
1031 | 1035 | ||
1032 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1036 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1033 | { | 1037 | { |
1034 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1038 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1035 | 1039 | ||
1036 | mSelectedDates.clear(); | 1040 | mSelectedDates.clear(); |
1037 | // qDebug("KOAgendaView::showDates "); | 1041 | // qDebug("KOAgendaView::showDates "); |
1038 | QDate d = start; | 1042 | QDate d = start; |
1039 | while (d <= end) { | 1043 | while (d <= end) { |
1040 | mSelectedDates.append(d); | 1044 | mSelectedDates.append(d); |
1041 | d = d.addDays( 1 ); | 1045 | d = d.addDays( 1 ); |
1042 | } | 1046 | } |
1043 | 1047 | ||
1044 | // and update the view | 1048 | // and update the view |
1045 | fillAgenda(); | 1049 | fillAgenda(); |
1046 | } | 1050 | } |
1047 | 1051 | ||
1048 | 1052 | ||
1049 | void KOAgendaView::showEvents(QPtrList<Event>) | 1053 | void KOAgendaView::showEvents(QPtrList<Event>) |
1050 | { | 1054 | { |
1051 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1055 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1052 | } | 1056 | } |
1053 | 1057 | ||
1054 | void KOAgendaView::changeEventDisplay(Event *, int) | 1058 | void KOAgendaView::changeEventDisplay(Event *, int) |
1055 | { | 1059 | { |
1056 | // qDebug("KOAgendaView::changeEventDisplay "); | 1060 | // qDebug("KOAgendaView::changeEventDisplay "); |
1057 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1061 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1058 | // this should be re-written to be MUCH smarter. Right now we | 1062 | // this should be re-written to be MUCH smarter. Right now we |
1059 | // are just playing dumb. | 1063 | // are just playing dumb. |
1060 | fillAgenda(); | 1064 | fillAgenda(); |
1061 | } | 1065 | } |
1062 | 1066 | ||
1063 | void KOAgendaView::fillAgenda(const QDate &) | 1067 | void KOAgendaView::fillAgenda(const QDate &) |
1064 | { | 1068 | { |
1065 | // qDebug("KOAgendaView::fillAgenda "); | 1069 | // qDebug("KOAgendaView::fillAgenda "); |
1066 | fillAgenda(); | 1070 | fillAgenda(); |
1067 | } | 1071 | } |
1068 | 1072 | ||
1069 | void KOAgendaView::fillAgenda() | 1073 | void KOAgendaView::fillAgenda() |
1070 | { | 1074 | { |
1071 | if ( globalFlagBlockStartup ) | 1075 | if ( globalFlagBlockStartup ) |
1072 | return; | 1076 | return; |
1073 | if ( globalFlagBlockAgenda == 1 ) | 1077 | if ( globalFlagBlockAgenda == 1 ) |
1074 | return; | 1078 | return; |
1075 | //if ( globalFlagBlockAgenda == 2 ) | 1079 | //if ( globalFlagBlockAgenda == 2 ) |
1076 | //globalFlagBlockAgenda = 0; | 1080 | //globalFlagBlockAgenda = 0; |
1077 | // globalFlagBlockPainting = false; | 1081 | // globalFlagBlockPainting = false; |
1078 | if ( globalFlagBlockAgenda == 0 ) | 1082 | if ( globalFlagBlockAgenda == 0 ) |
1079 | globalFlagBlockAgenda = 1; | 1083 | globalFlagBlockAgenda = 1; |
1080 | // clearView(); | 1084 | // clearView(); |
1081 | //qDebug("fillAgenda()++++ "); | 1085 | //qDebug("fillAgenda()++++ "); |
1082 | globalFlagBlockAgendaItemPaint = 1; | 1086 | globalFlagBlockAgendaItemPaint = 1; |
1083 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1087 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1084 | mAgenda->changeColumns(mSelectedDates.count()); | 1088 | mAgenda->changeColumns(mSelectedDates.count()); |
1085 | qApp->processEvents(); | 1089 | qApp->processEvents(); |
1086 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1090 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1087 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1091 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1088 | setHolidayMasks(); | 1092 | setHolidayMasks(); |
1089 | 1093 | ||
1090 | //mAgenda->hideUnused(); | 1094 | //mAgenda->hideUnused(); |
1091 | //mAllDayAgenda->hideUnused(); | 1095 | //mAllDayAgenda->hideUnused(); |
1092 | 1096 | ||
1093 | // mAgenda->blockNextRepaint( false ); | 1097 | // mAgenda->blockNextRepaint( false ); |
1094 | // mAgenda->viewport()->repaint(); | 1098 | // mAgenda->viewport()->repaint(); |
1095 | // mAgenda->blockNextRepaint( true ); | 1099 | // mAgenda->blockNextRepaint( true ); |
1096 | mMinY.resize(mSelectedDates.count()); | 1100 | mMinY.resize(mSelectedDates.count()); |
1097 | mMaxY.resize(mSelectedDates.count()); | 1101 | mMaxY.resize(mSelectedDates.count()); |
1098 | 1102 | ||
1099 | QPtrList<Event> dayEvents; | 1103 | QPtrList<Event> dayEvents; |
1100 | 1104 | ||
1101 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1105 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1102 | // Therefore, gtodoset all of them. | 1106 | // Therefore, gtodoset all of them. |
1103 | QPtrList<Todo> todos = calendar()->todos(); | 1107 | QPtrList<Todo> todos = calendar()->todos(); |
1104 | 1108 | ||
1105 | mAgenda->setDateList(mSelectedDates); | 1109 | mAgenda->setDateList(mSelectedDates); |
1106 | 1110 | ||
1107 | QDate today = QDate::currentDate(); | 1111 | QDate today = QDate::currentDate(); |
1108 | 1112 | ||
1109 | DateList::ConstIterator dit; | 1113 | DateList::ConstIterator dit; |
1110 | int curCol = 0; | 1114 | int curCol = 0; |
1111 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1115 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1112 | QDate currentDate = *dit; | 1116 | QDate currentDate = *dit; |
1113 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1117 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1114 | // << endl; | 1118 | // << endl; |
1115 | 1119 | ||
1116 | dayEvents = calendar()->events(currentDate,true); | 1120 | dayEvents = calendar()->events(currentDate,true); |
1117 | 1121 | ||
1118 | // Default values, which can never be reached | 1122 | // Default values, which can never be reached |
1119 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1123 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1120 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1124 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1121 | 1125 | ||
1122 | unsigned int numEvent; | 1126 | unsigned int numEvent; |
1123 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1127 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1124 | Event *event = dayEvents.at(numEvent); | 1128 | Event *event = dayEvents.at(numEvent); |
1125 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1129 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1126 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1130 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1127 | continue; | 1131 | continue; |
1128 | // kdDebug() << " Event: " << event->summary() << endl; | 1132 | // kdDebug() << " Event: " << event->summary() << endl; |
1129 | 1133 | ||
1130 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1134 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1131 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1135 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1132 | 1136 | ||
1133 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1137 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1134 | 1138 | ||
1135 | if (event->doesFloat()) { | 1139 | if (event->doesFloat()) { |
1136 | if (event->recurrence()->doesRecur()) { | 1140 | if (event->recurrence()->doesRecur()) { |
1137 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1141 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1138 | } else { | 1142 | } else { |
1139 | if (beginX <= 0 && curCol == 0) { | 1143 | if (beginX <= 0 && curCol == 0) { |
1140 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1144 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1141 | } else if (beginX == curCol) { | 1145 | } else if (beginX == curCol) { |
1142 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1146 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1143 | } | 1147 | } |
1144 | } | 1148 | } |
1145 | } else if (event->isMultiDay()) { | 1149 | } else if (event->isMultiDay()) { |
1146 | if ( event->doesRecur () ) { | 1150 | if ( event->doesRecur () ) { |
1147 | QDate dateit = currentDate; | 1151 | QDate dateit = currentDate; |
1148 | int count = 0; | 1152 | int count = 0; |
1149 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1153 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1150 | while (! event->recursOn( dateit ) && count <= max ) { | 1154 | while (! event->recursOn( dateit ) && count <= max ) { |
1151 | ++count; | 1155 | ++count; |
1152 | dateit = dateit.addDays( -1 ); | 1156 | dateit = dateit.addDays( -1 ); |
1153 | } | 1157 | } |
1154 | bool ok; | 1158 | bool ok; |
1155 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1159 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1156 | if ( ok ) | 1160 | if ( ok ) |
1157 | { | 1161 | { |
1158 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1162 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1159 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1163 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1160 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1164 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1161 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1165 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1162 | 1166 | ||
1163 | } | 1167 | } |
1164 | } | 1168 | } |
1165 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1169 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1166 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1170 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1167 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1171 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1168 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1172 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1169 | //qDebug("insert!!! "); | 1173 | //qDebug("insert!!! "); |
1170 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1174 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1171 | } | 1175 | } |
1172 | if (beginX == curCol) { | 1176 | if (beginX == curCol) { |
1173 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1177 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1174 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1178 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1175 | } else if (endX == curCol) { | 1179 | } else if (endX == curCol) { |
1176 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1180 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1177 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1181 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1178 | } else { | 1182 | } else { |
1179 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1183 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1180 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1184 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1181 | } | 1185 | } |
1182 | } else { | 1186 | } else { |
1183 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1187 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1184 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1188 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1185 | if (endY < startY) endY = startY; | 1189 | if (endY < startY) endY = startY; |
1186 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1190 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1187 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1191 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1188 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1192 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1189 | } | 1193 | } |
1190 | } | 1194 | } |
1191 | // ---------- [display Todos -------------- | 1195 | // ---------- [display Todos -------------- |
1192 | unsigned int numTodo; | 1196 | unsigned int numTodo; |
1193 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1197 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1194 | Todo *todo = todos.at(numTodo); | 1198 | Todo *todo = todos.at(numTodo); |
1195 | 1199 | ||
1196 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1200 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1197 | 1201 | ||
1198 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1202 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1199 | // Already completed items can be displayed on their original due date | 1203 | // Already completed items can be displayed on their original due date |
1200 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1204 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1201 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1205 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1202 | bool fillIn = false; | 1206 | bool fillIn = false; |
1203 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1207 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1204 | fillIn = true; | 1208 | fillIn = true; |
1205 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1209 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1206 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1210 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1207 | if ( fillIn ) { | 1211 | if ( fillIn ) { |
1208 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1212 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1209 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1213 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1210 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1214 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1211 | } | 1215 | } |
1212 | else { | 1216 | else { |
1213 | QDateTime dt; | 1217 | QDateTime dt; |
1214 | if ( todo->hasCompletedDate() ) | 1218 | if ( todo->hasCompletedDate() ) |
1215 | dt = todo->completed(); | 1219 | dt = todo->completed(); |
1216 | else | 1220 | else |
1217 | dt = todo->dtDue();; | 1221 | dt = todo->dtDue();; |
1218 | 1222 | ||
1219 | 1223 | ||
1220 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1224 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1221 | int hi = (18/KOPrefs::instance()->mHourSize); | 1225 | int hi = (18/KOPrefs::instance()->mHourSize); |
1222 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1226 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1223 | int startY = endY -hi; | 1227 | int startY = endY -hi; |
1224 | 1228 | ||
1225 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1229 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1226 | 1230 | ||
1227 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1231 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1228 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1232 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1229 | } | 1233 | } |
1230 | } | 1234 | } |
1231 | } | 1235 | } |
1232 | // ---------- display Todos] -------------- | 1236 | // ---------- display Todos] -------------- |
1233 | 1237 | ||
1234 | ++curCol; | 1238 | ++curCol; |
1235 | } | 1239 | } |
1236 | mAgenda->hideUnused(); | 1240 | mAgenda->hideUnused(); |
1237 | mAllDayAgenda->hideUnused(); | 1241 | mAllDayAgenda->hideUnused(); |
1238 | mAgenda->checkScrollBoundaries(); | 1242 | mAgenda->checkScrollBoundaries(); |
1239 | 1243 | ||
1240 | deleteSelectedDateTime(); | 1244 | deleteSelectedDateTime(); |
1241 | 1245 | ||
1242 | createDayLabels(); | 1246 | createDayLabels(); |
1243 | emit incidenceSelected( 0 ); | 1247 | emit incidenceSelected( 0 ); |
1244 | 1248 | ||
1245 | if ( globalFlagBlockAgenda == 2 ) { | 1249 | if ( globalFlagBlockAgenda == 2 ) { |
1246 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1250 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1247 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1251 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1248 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1252 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1249 | setStartHour( QTime::currentTime ().hour() ); | 1253 | setStartHour( QTime::currentTime ().hour() ); |
1250 | // qApp->processEvents(); | 1254 | // qApp->processEvents(); |
1251 | } | 1255 | } |
1252 | qApp->processEvents(); | 1256 | qApp->processEvents(); |
1253 | //qDebug("qApp->processEvents(); END "); | 1257 | //qDebug("qApp->processEvents(); END "); |
1254 | globalFlagBlockAgenda = 0; | 1258 | globalFlagBlockAgenda = 0; |
1255 | 1259 | ||
1256 | // mAgenda->hideUnused(); | 1260 | // mAgenda->hideUnused(); |
1257 | //mAllDayAgenda->hideUnused(); | 1261 | //mAllDayAgenda->hideUnused(); |
1258 | mAllDayAgenda->drawContentsToPainter(); | 1262 | mAllDayAgenda->drawContentsToPainter(); |
1259 | mAgenda->drawContentsToPainter(); | 1263 | mAgenda->drawContentsToPainter(); |
1260 | repaintAgenda(); | 1264 | repaintAgenda(); |
1261 | // mAgenda->finishUpdate(); | 1265 | // mAgenda->finishUpdate(); |
1262 | //mAllDayAgenda->finishUpdate(); | 1266 | //mAllDayAgenda->finishUpdate(); |
1263 | 1267 | ||
1264 | // repaintAgenda(); | 1268 | // repaintAgenda(); |
1265 | //qApp->processEvents(); | 1269 | //qApp->processEvents(); |
1266 | // globalFlagBlockAgenda = 0; | 1270 | // globalFlagBlockAgenda = 0; |
1267 | } | 1271 | } |
1268 | void KOAgendaView::repaintAgenda() | 1272 | void KOAgendaView::repaintAgenda() |
1269 | { | 1273 | { |
1270 | // mAllDayAgenda->drawContentsToPainter(); | 1274 | // mAllDayAgenda->drawContentsToPainter(); |
1271 | // mAllDayAgenda->viewport()->repaint( false ); | 1275 | // mAllDayAgenda->viewport()->repaint( false ); |
1272 | // mAgenda->drawContentsToPainter(); | 1276 | // mAgenda->drawContentsToPainter(); |
1273 | // mAgenda->viewport()->repaint( false ); | 1277 | // mAgenda->viewport()->repaint( false ); |
1274 | // qApp->processEvents(); | 1278 | // qApp->processEvents(); |
1275 | 1279 | ||
1276 | //qDebug("KOAgendaView::repaintAgenda() "); | 1280 | //qDebug("KOAgendaView::repaintAgenda() "); |
1277 | //qApp->processEvents(); | 1281 | //qApp->processEvents(); |
1278 | mAgenda->viewport()->repaint( false ); | 1282 | mAgenda->viewport()->repaint( false ); |
1279 | mAllDayAgenda->viewport()->repaint( false ); | 1283 | mAllDayAgenda->viewport()->repaint( false ); |
1280 | mAgenda->finishUpdate(); | 1284 | mAgenda->finishUpdate(); |
1281 | mAllDayAgenda->finishUpdate(); | 1285 | mAllDayAgenda->finishUpdate(); |
1282 | } | 1286 | } |
1283 | 1287 | ||
1284 | 1288 | ||
1285 | void KOAgendaView::clearView() | 1289 | void KOAgendaView::clearView() |
1286 | { | 1290 | { |
1287 | // kdDebug() << "ClearView" << endl; | 1291 | // kdDebug() << "ClearView" << endl; |
1288 | mAllDayAgenda->clear(); | 1292 | mAllDayAgenda->clear(); |
1289 | mAgenda->clear(); | 1293 | mAgenda->clear(); |
1290 | } | 1294 | } |
1291 | 1295 | ||
1292 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1296 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1293 | const QDate &td) | 1297 | const QDate &td) |
1294 | { | 1298 | { |
1295 | #ifndef KORG_NOPRINTER | 1299 | #ifndef KORG_NOPRINTER |
1296 | if (fd == td) | 1300 | if (fd == td) |
1297 | calPrinter->preview(CalPrinter::Day, fd, td); | 1301 | calPrinter->preview(CalPrinter::Day, fd, td); |
1298 | else | 1302 | else |
1299 | calPrinter->preview(CalPrinter::Week, fd, td); | 1303 | calPrinter->preview(CalPrinter::Week, fd, td); |
1300 | #endif | 1304 | #endif |
1301 | } | 1305 | } |
1302 | 1306 | ||
1303 | // void KOAgendaView::updateMovedTodo() | 1307 | // void KOAgendaView::updateMovedTodo() |
1304 | // { | 1308 | // { |
1305 | // // updateConfig(); | 1309 | // // updateConfig(); |
1306 | // // emit updateTodoViews(); | 1310 | // // emit updateTodoViews(); |
1307 | // } | 1311 | // } |
1308 | 1312 | ||
1309 | void KOAgendaView::newEvent(int gx, int gy) | 1313 | void KOAgendaView::newEvent(int gx, int gy) |
1310 | { | 1314 | { |
1311 | if (!mSelectedDates.count()) return; | 1315 | if (!mSelectedDates.count()) return; |
1312 | 1316 | ||
1313 | QDate day = mSelectedDates[gx]; | 1317 | QDate day = mSelectedDates[gx]; |
1314 | 1318 | ||
1315 | QTime time = mAgenda->gyToTime(gy); | 1319 | QTime time = mAgenda->gyToTime(gy); |
1316 | QDateTime dt(day,time); | 1320 | QDateTime dt(day,time); |
1317 | // if ( dt < QDateTime::currentDateTime () ) | 1321 | // if ( dt < QDateTime::currentDateTime () ) |
1318 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1322 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1319 | emit newEventSignal(dt); | 1323 | emit newEventSignal(dt); |
1320 | } | 1324 | } |
1321 | 1325 | ||
1322 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1326 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1323 | { | 1327 | { |
1324 | if (!mSelectedDates.count()) return; | 1328 | if (!mSelectedDates.count()) return; |
1325 | 1329 | ||
1326 | QDate dayStart = mSelectedDates[gxStart]; | 1330 | QDate dayStart = mSelectedDates[gxStart]; |
1327 | QDate dayEnd = mSelectedDates[gxEnd]; | 1331 | QDate dayEnd = mSelectedDates[gxEnd]; |
1328 | 1332 | ||
1329 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1333 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1330 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1334 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1331 | 1335 | ||
1332 | QDateTime dtStart(dayStart,timeStart); | 1336 | QDateTime dtStart(dayStart,timeStart); |
1333 | QDateTime dtEnd(dayEnd,timeEnd); | 1337 | QDateTime dtEnd(dayEnd,timeEnd); |
1334 | 1338 | ||
1335 | emit newEventSignal(dtStart,dtEnd); | 1339 | emit newEventSignal(dtStart,dtEnd); |
1336 | } | 1340 | } |
1337 | 1341 | ||
1338 | void KOAgendaView::newEventAllDay(int gx, int ) | 1342 | void KOAgendaView::newEventAllDay(int gx, int ) |
1339 | { | 1343 | { |
1340 | if (!mSelectedDates.count()) return; | 1344 | if (!mSelectedDates.count()) return; |
1341 | 1345 | ||
1342 | QDate day = mSelectedDates[gx]; | 1346 | QDate day = mSelectedDates[gx]; |
1343 | 1347 | ||
1344 | emit newEventSignal(day); | 1348 | emit newEventSignal(day); |
1345 | } | 1349 | } |
1346 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1350 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1347 | { | 1351 | { |
1348 | if (!mSelectedDates.count()) return; | 1352 | if (!mSelectedDates.count()) return; |
1349 | 1353 | ||
1350 | QDateTime day (mSelectedDates[gx] ); | 1354 | QDateTime day (mSelectedDates[gx] ); |
1351 | emit newTodoSignal(day, true); | 1355 | emit newTodoSignal(day, true); |
1352 | } | 1356 | } |
1353 | void KOAgendaView::newTodo(int gx, int gy ) | 1357 | void KOAgendaView::newTodo(int gx, int gy ) |
1354 | { | 1358 | { |
1355 | if (!mSelectedDates.count()) return; | 1359 | if (!mSelectedDates.count()) return; |
1356 | QDate dayStart = mSelectedDates[gx]; | 1360 | QDate dayStart = mSelectedDates[gx]; |
1357 | QTime timeStart = mAgenda->gyToTime(gy); | 1361 | QTime timeStart = mAgenda->gyToTime(gy); |
1358 | QDateTime dt (dayStart,timeStart); | 1362 | QDateTime dt (dayStart,timeStart); |
1359 | emit newTodoSignal( dt, false ); | 1363 | emit newTodoSignal( dt, false ); |
1360 | } | 1364 | } |
1361 | 1365 | ||
1362 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1366 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1363 | { | 1367 | { |
1364 | uint i; | 1368 | uint i; |
1365 | for(i=0;i<mMinY.size();++i) { | 1369 | for(i=0;i<mMinY.size();++i) { |
1366 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1370 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1367 | else mEventIndicatorTop->enableColumn(i,false); | 1371 | else mEventIndicatorTop->enableColumn(i,false); |
1368 | } | 1372 | } |
1369 | 1373 | ||
1370 | mEventIndicatorTop->update(); | 1374 | mEventIndicatorTop->update(); |
1371 | } | 1375 | } |
1372 | 1376 | ||
1373 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1377 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1374 | { | 1378 | { |
1375 | uint i; | 1379 | uint i; |
1376 | for(i=0;i<mMaxY.size();++i) { | 1380 | for(i=0;i<mMaxY.size();++i) { |
1377 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1381 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1378 | else mEventIndicatorBottom->enableColumn(i,false); | 1382 | else mEventIndicatorBottom->enableColumn(i,false); |
1379 | } | 1383 | } |
1380 | 1384 | ||
1381 | mEventIndicatorBottom->update(); | 1385 | mEventIndicatorBottom->update(); |
1382 | } | 1386 | } |
1383 | 1387 | ||
1384 | void KOAgendaView::startDrag(Event *event) | 1388 | void KOAgendaView::startDrag(Event *event) |
1385 | { | 1389 | { |
1386 | #ifndef KORG_NODND | 1390 | #ifndef KORG_NODND |
1387 | DndFactory factory( calendar() ); | 1391 | DndFactory factory( calendar() ); |
1388 | ICalDrag *vd = factory.createDrag(event,this); | 1392 | ICalDrag *vd = factory.createDrag(event,this); |
1389 | if (vd->drag()) { | 1393 | if (vd->drag()) { |
1390 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1394 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1391 | } | 1395 | } |
1392 | #endif | 1396 | #endif |
1393 | } | 1397 | } |
1394 | 1398 | ||
1395 | void KOAgendaView::readSettings() | 1399 | void KOAgendaView::readSettings() |
1396 | { | 1400 | { |
1397 | readSettings(KOGlobals::config()); | 1401 | readSettings(KOGlobals::config()); |
1398 | } | 1402 | } |
1399 | 1403 | ||
1400 | void KOAgendaView::readSettings(KConfig *config) | 1404 | void KOAgendaView::readSettings(KConfig *config) |
1401 | { | 1405 | { |
1402 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1406 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1403 | 1407 | ||
1404 | config->setGroup("Views"); | 1408 | config->setGroup("Views"); |
1405 | 1409 | ||
1406 | //#ifndef KORG_NOSPLITTER | 1410 | //#ifndef KORG_NOSPLITTER |
1407 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1411 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1408 | if (sizes.count() == 2) { | 1412 | if (sizes.count() == 2) { |
1409 | if ( sizes[0] < 20 ) { | 1413 | if ( sizes[0] < 20 ) { |
1410 | sizes[1] = sizes[1] +20 - sizes[0]; | 1414 | sizes[1] = sizes[1] +20 - sizes[0]; |
1411 | sizes[0] = 20; | 1415 | sizes[0] = 20; |
1412 | } | 1416 | } |
1413 | mSplitterAgenda->setSizes(sizes); | 1417 | mSplitterAgenda->setSizes(sizes); |
1414 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1418 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1415 | } | 1419 | } |
1416 | //#endif | 1420 | //#endif |
1417 | 1421 | ||
1418 | // updateConfig(); | 1422 | // updateConfig(); |
1419 | } | 1423 | } |
1420 | 1424 | ||
1421 | void KOAgendaView::writeSettings(KConfig *config) | 1425 | void KOAgendaView::writeSettings(KConfig *config) |
1422 | { | 1426 | { |
1423 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1427 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1424 | 1428 | ||
1425 | config->setGroup("Views"); | 1429 | config->setGroup("Views"); |
1426 | 1430 | ||
1427 | //#ifndef KORG_NOSPLITTER | 1431 | //#ifndef KORG_NOSPLITTER |
1428 | QValueList<int> list = mSplitterAgenda->sizes(); | 1432 | QValueList<int> list = mSplitterAgenda->sizes(); |
1429 | config->writeEntry("Separator AgendaView",list); | 1433 | config->writeEntry("Separator AgendaView",list); |
1430 | //qDebug("write %d %d ", list[0],list[1] ); | 1434 | //qDebug("write %d %d ", list[0],list[1] ); |
1431 | //#endif | 1435 | //#endif |
1432 | } | 1436 | } |
1433 | 1437 | ||
1434 | void KOAgendaView::setHolidayMasks() | 1438 | void KOAgendaView::setHolidayMasks() |
1435 | { | 1439 | { |
1436 | mHolidayMask.resize(mSelectedDates.count()); | 1440 | mHolidayMask.resize(mSelectedDates.count()); |
1437 | 1441 | ||
1438 | uint i; | 1442 | uint i; |
1439 | for(i=0;i<mSelectedDates.count();++i) { | 1443 | for(i=0;i<mSelectedDates.count();++i) { |
1440 | QDate date = mSelectedDates[i]; | 1444 | QDate date = mSelectedDates[i]; |
1441 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1445 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1442 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1446 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1443 | bool showHoliday = false; | 1447 | bool showHoliday = false; |
1444 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1448 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1445 | QPtrList<Event> events = calendar()->events( date, true ); | 1449 | QPtrList<Event> events = calendar()->events( date, true ); |
1446 | Event *event; | 1450 | Event *event; |
1447 | for( event = events.first(); event; event = events.next() ) { | 1451 | for( event = events.first(); event; event = events.next() ) { |
1448 | if ( event->categories().contains("Holiday") || | 1452 | if ( event->categories().contains("Holiday") || |
1449 | event->categories().contains(i18n("Holiday"))) { | 1453 | event->categories().contains(i18n("Holiday"))) { |
1450 | showHoliday = true; | 1454 | showHoliday = true; |
1451 | break; | 1455 | break; |
1452 | } | 1456 | } |
1453 | } | 1457 | } |
1454 | 1458 | ||
1455 | } | 1459 | } |
1456 | 1460 | ||
1457 | #ifndef KORG_NOPLUGINS | 1461 | #ifndef KORG_NOPLUGINS |
1458 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1462 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1459 | !KOCore::self()->holiday(date).isEmpty(); | 1463 | !KOCore::self()->holiday(date).isEmpty(); |
1460 | #endif | 1464 | #endif |
1461 | bool showDay = showSaturday || showSunday || showHoliday; | 1465 | bool showDay = showSaturday || showSunday || showHoliday; |
1462 | 1466 | ||
1463 | if (showDay) { | 1467 | if (showDay) { |
1464 | mHolidayMask.at(i) = true; | 1468 | mHolidayMask.at(i) = true; |
1465 | } else { | 1469 | } else { |
1466 | mHolidayMask.at(i) = false; | 1470 | mHolidayMask.at(i) = false; |
1467 | } | 1471 | } |
1468 | } | 1472 | } |
1469 | 1473 | ||
1470 | mAgenda->setHolidayMask(&mHolidayMask); | 1474 | mAgenda->setHolidayMask(&mHolidayMask); |
1471 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1475 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1472 | } | 1476 | } |
1473 | 1477 | ||
1474 | void KOAgendaView::setContentsPos(int y) | 1478 | void KOAgendaView::setContentsPos(int y) |
1475 | { | 1479 | { |
1476 | mAgenda->setContentsPos(0,y); | 1480 | mAgenda->setContentsPos(0,y); |
1477 | } | 1481 | } |
1478 | 1482 | ||
1479 | void KOAgendaView::setExpandedButton( bool expanded ) | 1483 | void KOAgendaView::setExpandedButton( bool expanded ) |
1480 | { | 1484 | { |
1481 | if ( expanded ) { | 1485 | if ( expanded ) { |
1482 | mExpandButton->setPixmap( mExpandedPixmap ); | 1486 | mExpandButton->setPixmap( mExpandedPixmap ); |
1483 | } else { | 1487 | } else { |
1484 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1488 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1485 | } | 1489 | } |
1486 | } | 1490 | } |
1487 | 1491 | ||
1488 | void KOAgendaView::clearSelection() | 1492 | void KOAgendaView::clearSelection() |
1489 | { | 1493 | { |
1490 | mAgenda->deselectItem(); | 1494 | mAgenda->deselectItem(); |
1491 | mAllDayAgenda->deselectItem(); | 1495 | mAllDayAgenda->deselectItem(); |
1492 | } | 1496 | } |
1493 | 1497 | ||
1494 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1498 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1495 | int gxEnd, int gyEnd) | 1499 | int gxEnd, int gyEnd) |
1496 | { | 1500 | { |
1497 | mTimeSpanInAllDay = true; | 1501 | mTimeSpanInAllDay = true; |
1498 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1502 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1499 | } | 1503 | } |
1500 | 1504 | ||
1501 | 1505 | ||
1502 | 1506 | ||
1503 | 1507 | ||
1504 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1508 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1505 | int gxEnd, int gyEnd) | 1509 | int gxEnd, int gyEnd) |
1506 | { | 1510 | { |
1507 | if (!mSelectedDates.count()) return; | 1511 | if (!mSelectedDates.count()) return; |
1508 | 1512 | ||
1509 | QDate dayStart = mSelectedDates[gxStart]; | 1513 | QDate dayStart = mSelectedDates[gxStart]; |
1510 | QDate dayEnd = mSelectedDates[gxEnd]; | 1514 | QDate dayEnd = mSelectedDates[gxEnd]; |
1511 | 1515 | ||
1512 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1516 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1513 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1517 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1514 | 1518 | ||
1515 | QDateTime dtStart(dayStart,timeStart); | 1519 | QDateTime dtStart(dayStart,timeStart); |
1516 | QDateTime dtEnd(dayEnd,timeEnd); | 1520 | QDateTime dtEnd(dayEnd,timeEnd); |
1517 | 1521 | ||
1518 | mTimeSpanBegin = dtStart; | 1522 | mTimeSpanBegin = dtStart; |
1519 | mTimeSpanEnd = dtEnd; | 1523 | mTimeSpanEnd = dtEnd; |
1520 | 1524 | ||
1521 | } | 1525 | } |
1522 | 1526 | ||
1523 | void KOAgendaView::deleteSelectedDateTime() | 1527 | void KOAgendaView::deleteSelectedDateTime() |
1524 | { | 1528 | { |
1525 | mTimeSpanBegin.setDate(QDate()); | 1529 | mTimeSpanBegin.setDate(QDate()); |
1526 | mTimeSpanEnd.setDate(QDate()); | 1530 | mTimeSpanEnd.setDate(QDate()); |
1527 | mTimeSpanInAllDay = false; | 1531 | mTimeSpanInAllDay = false; |
1528 | } | 1532 | } |
1529 | 1533 | ||
1530 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1534 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1531 | { | 1535 | { |
1532 | e->ignore(); | 1536 | e->ignore(); |
1533 | } | 1537 | } |
1534 | 1538 | ||
1535 | void KOAgendaView::scrollOneHourUp() | 1539 | void KOAgendaView::scrollOneHourUp() |
1536 | { | 1540 | { |
1537 | 1541 | ||
1538 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1542 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1539 | } | 1543 | } |
1540 | void KOAgendaView::scrollOneHourDown() | 1544 | void KOAgendaView::scrollOneHourDown() |
1541 | { | 1545 | { |
1542 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1546 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1543 | } | 1547 | } |
1544 | 1548 | ||
1545 | void KOAgendaView::setStartHour( int h ) | 1549 | void KOAgendaView::setStartHour( int h ) |
1546 | { | 1550 | { |
1547 | mAgenda->setStartHour( h ); | 1551 | mAgenda->setStartHour( h ); |
1548 | 1552 | ||
1549 | } | 1553 | } |
1550 | 1554 | ||
1551 | void KOAgendaView::updateTodo( Todo * t, int ) | 1555 | void KOAgendaView::updateTodo( Todo * t, int ) |
1552 | { | 1556 | { |
1553 | if ( !isVisible() ) | 1557 | if ( !isVisible() ) |
1554 | return; | 1558 | return; |
1555 | bool remove = false; | 1559 | bool remove = false; |
1556 | bool removeAD = false; | 1560 | bool removeAD = false; |
1557 | QDate da; | 1561 | QDate da; |
1558 | if ( t->hasCompletedDate() ) | 1562 | if ( t->hasCompletedDate() ) |
1559 | da = t->completed().date(); | 1563 | da = t->completed().date(); |
1560 | else | 1564 | else |
1561 | da = t->dtDue().date(); | 1565 | da = t->dtDue().date(); |
1562 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1566 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1563 | remove = true; | 1567 | remove = true; |
1564 | removeAD = true; | 1568 | removeAD = true; |
1565 | } | 1569 | } |
1566 | else { | 1570 | else { |
1567 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1571 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1568 | if ( overdue && | 1572 | if ( overdue && |
1569 | QDate::currentDate() >= mSelectedDates.first() && | 1573 | QDate::currentDate() >= mSelectedDates.first() && |
1570 | QDate::currentDate() <= mSelectedDates.last()) { | 1574 | QDate::currentDate() <= mSelectedDates.last()) { |
1571 | removeAD = false; | 1575 | removeAD = false; |
1572 | remove = true; | 1576 | remove = true; |
1573 | } | 1577 | } |
1574 | else { | 1578 | else { |
1575 | 1579 | ||
1576 | if ( da < mSelectedDates.first() || | 1580 | if ( da < mSelectedDates.first() || |
1577 | da > mSelectedDates.last() ) { | 1581 | da > mSelectedDates.last() ) { |
1578 | remove = true; | 1582 | remove = true; |
1579 | removeAD = true; | 1583 | removeAD = true; |
1580 | } else { | 1584 | } else { |
1581 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1585 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1582 | removeAD = !remove; | 1586 | removeAD = !remove; |
1583 | } | 1587 | } |
1584 | } | 1588 | } |
1585 | } | 1589 | } |
1586 | int days = mSelectedDates.first().daysTo( da ); | 1590 | int days = mSelectedDates.first().daysTo( da ); |
1587 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1591 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1588 | mAgenda->updateTodo( t , days, remove); | 1592 | mAgenda->updateTodo( t , days, remove); |
1589 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1593 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1590 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1594 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1591 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1595 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1592 | 1596 | ||
1593 | } | 1597 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ab96786..9c1e4c3 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1430 +1,1425 @@ | |||
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 <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(count() < 2) { | 118 | if(count() < 2) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | setCurrentItem((currentItem()+count()-1)%count()); | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
123 | if(!itemVisible(currentItem())) { | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | 124 | if((unsigned int) currentItem() == (count()-1)) { |
125 | setTopItem(currentItem()-numItemsVisible()+1); | 125 | setTopItem(currentItem()-numItemsVisible()+1); |
126 | } else { | 126 | } else { |
127 | setTopItem(topItem()-1); | 127 | setTopItem(topItem()-1); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case Key_Down: | 131 | case Key_Down: |
132 | if(count() < 2) { | 132 | if(count() < 2) { |
133 | e->ignore(); | 133 | e->ignore(); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | setCurrentItem((currentItem()+1)%count()); | 136 | setCurrentItem((currentItem()+1)%count()); |
137 | if(!itemVisible(currentItem())) { | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | 138 | if(currentItem() == 0) { |
139 | setTopItem(0); | 139 | setTopItem(0); |
140 | } else { | 140 | } else { |
141 | setTopItem(topItem()+1); | 141 | setTopItem(topItem()+1); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftDown(); | 146 | emit shiftDown(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | switch(e->key()) { | 156 | switch(e->key()) { |
157 | case Key_Shift: | 157 | case Key_Shift: |
158 | emit shiftUp(); | 158 | emit shiftUp(); |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
166 | { | 166 | { |
167 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
168 | 168 | ||
169 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
170 | emit rightClick(); | 170 | emit rightClick(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
175 | : QListBoxItem() | 175 | : QListBoxItem() |
176 | { | 176 | { |
177 | setText( s ); | 177 | setText( s ); |
178 | 178 | ||
179 | mIncidence = incidence; | 179 | mIncidence = incidence; |
180 | mDate = qd; | 180 | mDate = qd; |
181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
182 | mRecur = false; | 182 | mRecur = false; |
183 | mAlarm = false; | 183 | mAlarm = false; |
184 | mReply = false; | 184 | mReply = false; |
185 | mInfo = false; | 185 | mInfo = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
189 | { | 189 | { |
190 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
191 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
192 | #else | 192 | #else |
193 | bool sel = selected(); | 193 | bool sel = selected(); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | 196 | ||
197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
198 | { | 198 | { |
199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
202 | } | 202 | } |
203 | int x = 1; | 203 | int x = 1; |
204 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
205 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
206 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
207 | size = 3; | 207 | size = 3; |
208 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
209 | if ( mInfo ) { | 209 | if ( mInfo ) { |
210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | if ( mRecur ) { | 213 | if ( mRecur ) { |
214 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
215 | x += size + 1; | 215 | x += size + 1; |
216 | } | 216 | } |
217 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
218 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
219 | x += size + 1; | 219 | x += size + 1; |
220 | } | 220 | } |
221 | if ( mReply ) { | 221 | if ( mReply ) { |
222 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
223 | x += size + 1; | 223 | x += size + 1; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void MonthViewCell::startUpdateCell() | 400 | void MonthViewCell::startUpdateCell() |
401 | { | 401 | { |
402 | 402 | ||
403 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
404 | return; | 404 | return; |
405 | /* | 405 | /* |
406 | if ( !isVisible() ){ | 406 | if ( !isVisible() ){ |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | */ | 409 | */ |
410 | // qDebug("MonthViewCell::updateCell() "); | 410 | // qDebug("MonthViewCell::updateCell() "); |
411 | setPrimary( mDate.month()%2 ); | 411 | setPrimary( mDate.month()%2 ); |
412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
413 | if ( mDate == QDate::currentDate() ) { | 413 | if ( mDate == QDate::currentDate() ) { |
414 | mItemList->setLineWidth( 3 ); | 414 | mItemList->setLineWidth( 3 ); |
415 | } else { | 415 | } else { |
416 | mItemList->setLineWidth( 1 ); | 416 | mItemList->setLineWidth( 1 ); |
417 | } | 417 | } |
418 | mItemList->clear(); | 418 | mItemList->clear(); |
419 | 419 | ||
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | QToolTip::remove(this); | 421 | QToolTip::remove(this); |
422 | #endif | 422 | #endif |
423 | mToolTip = ""; | 423 | mToolTip = ""; |
424 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
425 | if ( !mHolidayString.isEmpty() ) { | 425 | if ( !mHolidayString.isEmpty() ) { |
426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
427 | item->setPalette( mHolidayPalette ); | 427 | item->setPalette( mHolidayPalette ); |
428 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
429 | mToolTip += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | 433 | void MonthViewCell::insertEvent(Event *event) |
434 | { | 434 | { |
435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
437 | return; | 437 | return; |
438 | else | 438 | else |
439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | if ( event->categories().contains("Holiday") || | 443 | if ( event->categories().contains("Holiday") || |
444 | event->categories().contains(i18n("Holiday"))) { | 444 | event->categories().contains(i18n("Holiday"))) { |
445 | setHoliday( true ); | 445 | setHoliday( true ); |
446 | if ( mDate.dayOfWeek() == 7 ) | 446 | if ( mDate.dayOfWeek() == 7 ) |
447 | mItemList->setLineWidth( 3 ); | 447 | mItemList->setLineWidth( 3 ); |
448 | } | 448 | } |
449 | QString text; | 449 | QString text; |
450 | if (event->isMultiDay()) { | 450 | if (event->isMultiDay()) { |
451 | QString prefix = "<->"; | 451 | QString prefix = "<->"; |
452 | if ( event->doesRecur() ) { | 452 | if ( event->doesRecur() ) { |
453 | if ( event->recursOn( mDate) ) | 453 | if ( event->recursOn( mDate) ) |
454 | prefix ="->" ; | 454 | prefix ="->" ; |
455 | else { | 455 | else { |
456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
457 | if ( event->recursOn( mDate.addDays( -days)) ) | 457 | if ( event->recursOn( mDate.addDays( -days)) ) |
458 | prefix ="<-" ; | 458 | prefix ="<-" ; |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if (mDate == event->dtStart().date()) { | 462 | if (mDate == event->dtStart().date()) { |
463 | prefix ="->" ; | 463 | prefix ="->" ; |
464 | } else if (mDate == event->dtEnd().date()) { | 464 | } else if (mDate == event->dtEnd().date()) { |
465 | prefix ="<-" ; | 465 | prefix ="<-" ; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | if ( !event->doesFloat() ) { | 468 | if ( !event->doesFloat() ) { |
469 | if ( mDate == event->dtStart().date () ) | 469 | if ( mDate == event->dtStart().date () ) |
470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
471 | else if ( mDate == event->dtEnd().date () ) | 471 | else if ( mDate == event->dtEnd().date () ) |
472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
473 | 473 | ||
474 | } | 474 | } |
475 | text = prefix + event->summary(); | 475 | text = prefix + event->summary(); |
476 | mToolTip += text; | 476 | mToolTip += text; |
477 | } else { | 477 | } else { |
478 | if (event->doesFloat()) { | 478 | if (event->doesFloat()) { |
479 | text = event->summary(); | 479 | text = event->summary(); |
480 | mToolTip += text; | 480 | mToolTip += text; |
481 | } | 481 | } |
482 | else { | 482 | else { |
483 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 483 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
484 | text += " " + event->summary(); | 484 | text += " " + event->summary(); |
485 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 485 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 489 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
490 | QPalette pal; | 490 | QPalette pal; |
491 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 491 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
492 | QStringList categories = event->categories(); | 492 | QStringList categories = event->categories(); |
493 | QString cat = categories.first(); | 493 | QString cat = categories.first(); |
494 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 494 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
495 | pal = getPalette(); | 495 | pal = getPalette(); |
496 | if (cat.isEmpty()) { | 496 | if (cat.isEmpty()) { |
497 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 497 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
498 | } else { | 498 | } else { |
499 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 499 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
500 | } | 500 | } |
501 | 501 | ||
502 | } else { | 502 | } else { |
503 | if (cat.isEmpty()) { | 503 | if (cat.isEmpty()) { |
504 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 504 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
505 | } else { | 505 | } else { |
506 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 506 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | } else { | 510 | } else { |
511 | pal = mStandardPalette ; | 511 | pal = mStandardPalette ; |
512 | } | 512 | } |
513 | item->setPalette( pal ); | 513 | item->setPalette( pal ); |
514 | item->setRecur( event->recurrence()->doesRecur() ); | 514 | item->setRecur( event->recurrence()->doesRecur() ); |
515 | item->setAlarm( event->isAlarmEnabled() ); | 515 | item->setAlarm( event->isAlarmEnabled() ); |
516 | item->setMoreInfo( event->description().length() > 0 ); | 516 | item->setMoreInfo( event->description().length() > 0 ); |
517 | #ifdef DESKTOP_VERSION | 517 | #ifdef DESKTOP_VERSION |
518 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 518 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
519 | KOPrefs::instance()->email()); | 519 | KOPrefs::instance()->email()); |
520 | if ( me != 0 ) { | 520 | if ( me != 0 ) { |
521 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 521 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
522 | item->setReply(true); | 522 | item->setReply(true); |
523 | else | 523 | else |
524 | item->setReply(false); | 524 | item->setReply(false); |
525 | } else | 525 | } else |
526 | item->setReply(false); | 526 | item->setReply(false); |
527 | #endif | 527 | #endif |
528 | mItemList->insertItem( item ); | 528 | mItemList->insertItem( item ); |
529 | mToolTip += "\n"; | 529 | mToolTip += "\n"; |
530 | } | 530 | } |
531 | void MonthViewCell::insertTodo(Todo *todo) | 531 | void MonthViewCell::insertTodo(Todo *todo) |
532 | { | 532 | { |
533 | QString text; | 533 | QString text; |
534 | if (todo->hasDueDate()) { | 534 | if (todo->hasDueDate()) { |
535 | if (!todo->doesFloat()) { | 535 | if (!todo->doesFloat()) { |
536 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 536 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
537 | text += " "; | 537 | text += " "; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | text += i18n("To-Do: %1").arg(todo->summary()); | 540 | text += i18n("To-Do: %1").arg(todo->summary()); |
541 | 541 | ||
542 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 542 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
543 | //item->setPalette( mStandardPalette ); | 543 | //item->setPalette( mStandardPalette ); |
544 | QPalette pal; | 544 | QPalette pal; |
545 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 545 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
546 | QStringList categories = todo->categories(); | 546 | QStringList categories = todo->categories(); |
547 | QString cat = categories.first(); | 547 | QString cat = categories.first(); |
548 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 548 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
549 | pal = getPalette(); | 549 | pal = getPalette(); |
550 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
551 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 551 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
552 | } else { | 552 | } else { |
553 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
554 | } | 554 | } |
555 | 555 | ||
556 | } else { | 556 | } else { |
557 | if (cat.isEmpty()) { | 557 | if (cat.isEmpty()) { |
558 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 558 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
559 | } else { | 559 | } else { |
560 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 560 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | } else { | 564 | } else { |
565 | pal = mStandardPalette ; | 565 | pal = mStandardPalette ; |
566 | } | 566 | } |
567 | item->setPalette( pal ); | 567 | item->setPalette( pal ); |
568 | mItemList->insertItem( item ); | 568 | mItemList->insertItem( item ); |
569 | mToolTip += text+"\n"; | 569 | mToolTip += text+"\n"; |
570 | } | 570 | } |
571 | void MonthViewCell::finishUpdateCell() | 571 | void MonthViewCell::finishUpdateCell() |
572 | { | 572 | { |
573 | #ifdef DESKTOP_VERSION | 573 | #ifdef DESKTOP_VERSION |
574 | if (mToolTip != "") | 574 | if (mToolTip != "") |
575 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 575 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
576 | #endif | 576 | #endif |
577 | mItemList->sort(); | 577 | mItemList->sort(); |
578 | //setMyPalette(); | 578 | //setMyPalette(); |
579 | setMyPalette(); | 579 | setMyPalette(); |
580 | QString text; | 580 | QString text; |
581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
584 | mLabel->resize( mLabelBigSize ); | 584 | mLabel->resize( mLabelBigSize ); |
585 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 585 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
586 | } else { | 586 | } else { |
587 | mLabel->resize( mLabelSize ); | 587 | mLabel->resize( mLabelSize ); |
588 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 588 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
589 | } | 589 | } |
590 | 590 | ||
591 | mLabel->setText( text ); | 591 | mLabel->setText( text ); |
592 | resizeEvent( 0 ); | 592 | resizeEvent( 0 ); |
593 | } | 593 | } |
594 | void MonthViewCell::updateCell() | 594 | void MonthViewCell::updateCell() |
595 | { | 595 | { |
596 | if ( !mMonthView->isUpdatePossible() ) | 596 | if ( !mMonthView->isUpdatePossible() ) |
597 | return; | 597 | return; |
598 | startUpdateCell(); | 598 | startUpdateCell(); |
599 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 599 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
600 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 600 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
601 | Event *event; | 601 | Event *event; |
602 | for( event = events.first(); event; event = events.next() ) { // for event | 602 | for( event = events.first(); event; event = events.next() ) { // for event |
603 | insertEvent(event); | 603 | insertEvent(event); |
604 | } | 604 | } |
605 | // insert due todos | 605 | // insert due todos |
606 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 606 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
607 | Todo *todo; | 607 | Todo *todo; |
608 | for(todo = todos.first(); todo; todo = todos.next()) { | 608 | for(todo = todos.first(); todo; todo = todos.next()) { |
609 | insertTodo( todo ); | 609 | insertTodo( todo ); |
610 | } | 610 | } |
611 | finishUpdateCell(); | 611 | finishUpdateCell(); |
612 | // if ( isVisible()) | 612 | // if ( isVisible()) |
613 | //qApp->processEvents(); | 613 | //qApp->processEvents(); |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::updateConfig() | 616 | void MonthViewCell::updateConfig() |
617 | { | 617 | { |
618 | setFont( KOPrefs::instance()->mMonthViewFont ); | 618 | setFont( KOPrefs::instance()->mMonthViewFont ); |
619 | 619 | ||
620 | QFontMetrics fm( font() ); | 620 | QFontMetrics fm( font() ); |
621 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 621 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
622 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 622 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
623 | mHolidayPalette = mStandardPalette; | 623 | mHolidayPalette = mStandardPalette; |
624 | mPrimaryPalette = mStandardPalette; | 624 | mPrimaryPalette = mStandardPalette; |
625 | mNonPrimaryPalette = mStandardPalette; | 625 | mNonPrimaryPalette = mStandardPalette; |
626 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 626 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
627 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 627 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
628 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 628 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
636 | } | 636 | } |
637 | //updateCell(); | 637 | //updateCell(); |
638 | } | 638 | } |
639 | 639 | ||
640 | void MonthViewCell::enableScrollBars( bool enabled ) | 640 | void MonthViewCell::enableScrollBars( bool enabled ) |
641 | { | 641 | { |
642 | if ( enabled ) { | 642 | if ( enabled ) { |
643 | mItemList->setVScrollBarMode(QScrollView::Auto); | 643 | mItemList->setVScrollBarMode(QScrollView::Auto); |
644 | mItemList->setHScrollBarMode(QScrollView::Auto); | 644 | mItemList->setHScrollBarMode(QScrollView::Auto); |
645 | } else { | 645 | } else { |
646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | 650 | ||
651 | Incidence *MonthViewCell::selectedIncidence() | 651 | Incidence *MonthViewCell::selectedIncidence() |
652 | { | 652 | { |
653 | int index = mItemList->currentItem(); | 653 | int index = mItemList->currentItem(); |
654 | if ( index < 0 ) return 0; | 654 | if ( index < 0 ) return 0; |
655 | 655 | ||
656 | MonthViewItem *item = | 656 | MonthViewItem *item = |
657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
658 | 658 | ||
659 | if ( !item ) return 0; | 659 | if ( !item ) return 0; |
660 | 660 | ||
661 | return item->incidence(); | 661 | return item->incidence(); |
662 | } | 662 | } |
663 | 663 | ||
664 | QDate MonthViewCell::selectedIncidenceDate() | 664 | QDate MonthViewCell::selectedIncidenceDate() |
665 | { | 665 | { |
666 | QDate qd; | 666 | QDate qd; |
667 | int index = mItemList->currentItem(); | 667 | int index = mItemList->currentItem(); |
668 | if ( index < 0 ) return qd; | 668 | if ( index < 0 ) return qd; |
669 | 669 | ||
670 | MonthViewItem *item = | 670 | MonthViewItem *item = |
671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
672 | 672 | ||
673 | if ( !item ) return qd; | 673 | if ( !item ) return qd; |
674 | 674 | ||
675 | return item->incidenceDate(); | 675 | return item->incidenceDate(); |
676 | } | 676 | } |
677 | 677 | ||
678 | void MonthViewCell::deselect() | 678 | void MonthViewCell::deselect() |
679 | { | 679 | { |
680 | mItemList->clearSelection(); | 680 | mItemList->clearSelection(); |
681 | enableScrollBars( false ); | 681 | enableScrollBars( false ); |
682 | // updateCell(); | 682 | // updateCell(); |
683 | } | 683 | } |
684 | void MonthViewCell::select() | 684 | void MonthViewCell::select() |
685 | { | 685 | { |
686 | ;// updateCell(); | 686 | ;// updateCell(); |
687 | } | 687 | } |
688 | 688 | ||
689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
690 | { | 690 | { |
691 | if ( !mMonthView->isUpdatePossible() ) | 691 | if ( !mMonthView->isUpdatePossible() ) |
692 | return; | 692 | return; |
693 | 693 | ||
694 | int size = height() - mLabel->height() - 2; | 694 | int size = height() - mLabel->height() - 2; |
695 | if ( size > 0 ) | 695 | if ( size > 0 ) |
696 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 696 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
697 | size = width() - mLabel->width() -2; | 697 | size = width() - mLabel->width() -2; |
698 | if ( size > 0 ) | 698 | if ( size > 0 ) |
699 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 699 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
700 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 700 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
701 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 701 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
702 | } | 702 | } |
703 | 703 | ||
704 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 704 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
705 | { | 705 | { |
706 | if ( !item ) return; | 706 | if ( !item ) return; |
707 | 707 | ||
708 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 708 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
709 | Incidence *incidence = eventItem->incidence(); | 709 | Incidence *incidence = eventItem->incidence(); |
710 | if ( incidence ) mMonthView->defaultAction( incidence ); | 710 | if ( incidence ) mMonthView->defaultAction( incidence ); |
711 | } | 711 | } |
712 | void MonthViewCell::showDay() | 712 | void MonthViewCell::showDay() |
713 | { | 713 | { |
714 | emit showDaySignal( date() ); | 714 | emit showDaySignal( date() ); |
715 | } | 715 | } |
716 | void MonthViewCell::newEvent() | 716 | void MonthViewCell::newEvent() |
717 | { | 717 | { |
718 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 718 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
719 | emit newEventSignal( dt ); | 719 | emit newEventSignal( dt ); |
720 | } | 720 | } |
721 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 721 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
722 | { | 722 | { |
723 | static QListBoxItem * lastClicked = 0; | 723 | static QListBoxItem * lastClicked = 0; |
724 | if ( item == 0 ) { | 724 | if ( item == 0 ) { |
725 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 725 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
726 | emit newEventSignal( dt ); | 726 | emit newEventSignal( dt ); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | /* | 729 | /* |
730 | if ( lastClicked ) | 730 | if ( lastClicked ) |
731 | if ( ! item ) { | 731 | if ( ! item ) { |
732 | if ( lastClicked->listBox() != item->listBox() ) | 732 | if ( lastClicked->listBox() != item->listBox() ) |
733 | lastClicked->listBox()->clearSelection(); | 733 | lastClicked->listBox()->clearSelection(); |
734 | } | 734 | } |
735 | */ | 735 | */ |
736 | 736 | ||
737 | mMonthView->setSelectedCell( this ); | 737 | mMonthView->setSelectedCell( this ); |
738 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 738 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
739 | select(); | 739 | select(); |
740 | } | 740 | } |
741 | 741 | ||
742 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 742 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
743 | { | 743 | { |
744 | if ( !item ) return; | 744 | if ( !item ) return; |
745 | 745 | ||
746 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 746 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
747 | Incidence *incidence = eventItem->incidence(); | 747 | Incidence *incidence = eventItem->incidence(); |
748 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 748 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
749 | } | 749 | } |
750 | 750 | ||
751 | void MonthViewCell::selection( QListBoxItem *item ) | 751 | void MonthViewCell::selection( QListBoxItem *item ) |
752 | { | 752 | { |
753 | if ( !item ) return; | 753 | if ( !item ) return; |
754 | 754 | ||
755 | mMonthView->setSelectedCell( this ); | 755 | mMonthView->setSelectedCell( this ); |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | // ******************************************************************************* | 759 | // ******************************************************************************* |
760 | // ******************************************************************************* | 760 | // ******************************************************************************* |
761 | // ******************************************************************************* | 761 | // ******************************************************************************* |
762 | 762 | ||
763 | 763 | ||
764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
765 | : KOEventView( calendar, parent, name ), | 765 | : KOEventView( calendar, parent, name ), |
766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
768 | { | 768 | { |
769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
771 | if ( mShowWeekView ) | 771 | if ( mShowWeekView ) |
772 | mWeekStartsMonday = true; | 772 | mWeekStartsMonday = true; |
773 | updatePossible = false; | 773 | updatePossible = false; |
774 | mCells.setAutoDelete( true ); | 774 | mCells.setAutoDelete( true ); |
775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
776 | // mDayLayout = new QGridLayout( this ); | 776 | // mDayLayout = new QGridLayout( this ); |
777 | // create the day of the week labels (Sun, Mon, etc) and add them to | 777 | // create the day of the week labels (Sun, Mon, etc) and add them to |
778 | // the layout. | 778 | // the layout. |
779 | mDayLabels.resize( mDaysPerWeek ); | 779 | mDayLabels.resize( mDaysPerWeek ); |
780 | QFont bfont = font(); | 780 | QFont bfont = font(); |
781 | if ( QApplication::desktop()->width() < 650 ) { | 781 | if ( QApplication::desktop()->width() < 650 ) { |
782 | bfont.setPointSize( bfont.pointSize() - 2 ); | 782 | bfont.setPointSize( bfont.pointSize() - 2 ); |
783 | } | 783 | } |
784 | bfont.setBold( true ); | 784 | bfont.setBold( true ); |
785 | int i; | 785 | int i; |
786 | 786 | ||
787 | for( i = 0; i < mDaysPerWeek; i++ ) { | 787 | for( i = 0; i < mDaysPerWeek; i++ ) { |
788 | QLabel *label = new QLabel( this ); | 788 | QLabel *label = new QLabel( this ); |
789 | label->setFont(bfont); | 789 | label->setFont(bfont); |
790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
791 | label->setLineWidth(1); | 791 | label->setLineWidth(1); |
792 | label->setAlignment(AlignCenter); | 792 | label->setAlignment(AlignCenter); |
793 | mDayLabels.insert( i, label ); | 793 | mDayLabels.insert( i, label ); |
794 | } | 794 | } |
795 | 795 | ||
796 | bfont.setBold( false ); | 796 | bfont.setBold( false ); |
797 | mWeekLabels.resize( mNumWeeks+1 ); | 797 | mWeekLabels.resize( mNumWeeks+1 ); |
798 | for( i = 0; i < mNumWeeks+1; i++ ) { | 798 | for( i = 0; i < mNumWeeks+1; i++ ) { |
799 | KOWeekButton *label = new KOWeekButton( this ); | 799 | KOWeekButton *label = new KOWeekButton( this ); |
800 | label->setFont(bfont); | 800 | label->setFont(bfont); |
801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
802 | label->setFlat(true); | 802 | label->setFlat(true); |
803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
805 | //label->setLineWidth(1); | 805 | //label->setLineWidth(1); |
806 | //label->setAlignment(AlignCenter); | 806 | //label->setAlignment(AlignCenter); |
807 | mWeekLabels.insert( i, label ); | 807 | mWeekLabels.insert( i, label ); |
808 | } | 808 | } |
809 | mWeekLabels[mNumWeeks]->setText( i18n("")); | 809 | mWeekLabels[mNumWeeks]->setText( i18n("")); |
810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
811 | int row, col; | 811 | int row, col; |
812 | QPopupMenu * wpo = new QPopupMenu (this); | ||
813 | wpo->insertItem( i18n("W#"), 0 ); | ||
814 | for ( i = 1; i < 54; i++ ) | ||
815 | wpo->insertItem( i18n("%1").arg(i), i ); | ||
816 | mWeekLabels[mNumWeeks]->setPopup( wpo ); | ||
817 | mCells.resize( mNumCells ); | 812 | mCells.resize( mNumCells ); |
818 | for( row = 0; row < mNumWeeks; ++row ) { | 813 | for( row = 0; row < mNumWeeks; ++row ) { |
819 | for( col = 0; col < mDaysPerWeek; ++col ) { | 814 | for( col = 0; col < mDaysPerWeek; ++col ) { |
820 | MonthViewCell *cell = new MonthViewCell( this ); | 815 | MonthViewCell *cell = new MonthViewCell( this ); |
821 | mCells.insert( row * mDaysPerWeek + col, cell ); | 816 | mCells.insert( row * mDaysPerWeek + col, cell ); |
822 | 817 | ||
823 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 818 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
824 | SLOT( defaultAction( Incidence * ) ) ); | 819 | SLOT( defaultAction( Incidence * ) ) ); |
825 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 820 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
826 | SIGNAL( newEventSignal( QDateTime ) ) ); | 821 | SIGNAL( newEventSignal( QDateTime ) ) ); |
827 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 822 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
828 | SIGNAL( showDaySignal( QDate ) ) ); | 823 | SIGNAL( showDaySignal( QDate ) ) ); |
829 | } | 824 | } |
830 | } | 825 | } |
831 | 826 | ||
832 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 827 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
833 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); | ||
834 | mContextMenu = eventPopup(); | 828 | mContextMenu = eventPopup(); |
835 | // updateConfig(); //useless here | 829 | // updateConfig(); //useless here |
836 | 830 | ||
831 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
837 | emit incidenceSelected( 0 ); | 832 | emit incidenceSelected( 0 ); |
838 | } | 833 | } |
839 | 834 | ||
840 | KOMonthView::~KOMonthView() | 835 | KOMonthView::~KOMonthView() |
841 | { | 836 | { |
842 | delete mContextMenu; | 837 | delete mContextMenu; |
843 | } | 838 | } |
844 | void KOMonthView::selectDateWeekNum ( int ) | 839 | void KOMonthView::selectDateWeekNum ( int ) |
845 | { | 840 | { |
846 | 841 | ||
847 | } | 842 | } |
848 | void KOMonthView::selectInternalWeekNum ( int n ) | 843 | void KOMonthView::selectInternalWeekNum ( int n ) |
849 | { | 844 | { |
850 | emit selectWeekNum ( n ); | 845 | emit selectWeekNum ( n ); |
851 | switchView(); | 846 | switchView(); |
852 | } | 847 | } |
853 | 848 | ||
854 | void KOMonthView::switchView() | 849 | void KOMonthView::switchView() |
855 | { | 850 | { |
856 | if ( selectedCell( ) ) | 851 | if ( selectedCell( ) ) |
857 | selectedCell()->deselect(); | 852 | selectedCell()->deselect(); |
858 | mShowWeekView = !mShowWeekView; | 853 | mShowWeekView = !mShowWeekView; |
859 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 854 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
860 | //emit showNavigator( !mShowWeekView ); | 855 | //emit showNavigator( !mShowWeekView ); |
861 | computeLayout(); | 856 | computeLayout(); |
862 | updateConfig(); | 857 | updateConfig(); |
863 | } | 858 | } |
864 | 859 | ||
865 | int KOMonthView::maxDatesHint() | 860 | int KOMonthView::maxDatesHint() |
866 | { | 861 | { |
867 | return mNumCells; | 862 | return mNumCells; |
868 | } | 863 | } |
869 | 864 | ||
870 | int KOMonthView::currentDateCount() | 865 | int KOMonthView::currentDateCount() |
871 | { | 866 | { |
872 | return mNumCells; | 867 | return mNumCells; |
873 | } | 868 | } |
874 | 869 | ||
875 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 870 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
876 | { | 871 | { |
877 | QPtrList<Incidence> selected; | 872 | QPtrList<Incidence> selected; |
878 | 873 | ||
879 | if ( mSelectedCell ) { | 874 | if ( mSelectedCell ) { |
880 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 875 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
881 | if ( incidence ) selected.append( incidence ); | 876 | if ( incidence ) selected.append( incidence ); |
882 | } | 877 | } |
883 | 878 | ||
884 | return selected; | 879 | return selected; |
885 | } | 880 | } |
886 | 881 | ||
887 | DateList KOMonthView::selectedDates() | 882 | DateList KOMonthView::selectedDates() |
888 | { | 883 | { |
889 | DateList selected; | 884 | DateList selected; |
890 | 885 | ||
891 | if ( mSelectedCell ) { | 886 | if ( mSelectedCell ) { |
892 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 887 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
893 | if ( qd.isValid() ) selected.append( qd ); | 888 | if ( qd.isValid() ) selected.append( qd ); |
894 | } | 889 | } |
895 | 890 | ||
896 | return selected; | 891 | return selected; |
897 | } | 892 | } |
898 | 893 | ||
899 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 894 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
900 | const QDate &td) | 895 | const QDate &td) |
901 | { | 896 | { |
902 | #ifndef KORG_NOPRINTER | 897 | #ifndef KORG_NOPRINTER |
903 | calPrinter->preview(CalPrinter::Month, fd, td); | 898 | calPrinter->preview(CalPrinter::Month, fd, td); |
904 | #endif | 899 | #endif |
905 | } | 900 | } |
906 | 901 | ||
907 | void KOMonthView::updateConfig() | 902 | void KOMonthView::updateConfig() |
908 | { | 903 | { |
909 | 904 | ||
910 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 905 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
911 | 906 | ||
912 | if ( mShowWeekView ) { | 907 | if ( mShowWeekView ) { |
913 | mWeekStartsMonday = true; | 908 | mWeekStartsMonday = true; |
914 | } | 909 | } |
915 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 910 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
916 | mWidthLongDayLabel = 0; | 911 | mWidthLongDayLabel = 0; |
917 | 912 | ||
918 | for (int i = 0; i < 7; i++) { | 913 | for (int i = 0; i < 7; i++) { |
919 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 914 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
920 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 915 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
921 | } | 916 | } |
922 | bool temp = mShowSatSunComp ; | 917 | bool temp = mShowSatSunComp ; |
923 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 918 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
924 | if ( ! mShowWeekView ) { | 919 | if ( ! mShowWeekView ) { |
925 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 920 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
926 | computeLayout(); | 921 | computeLayout(); |
927 | } | 922 | } |
928 | updateDayLabels(); | 923 | updateDayLabels(); |
929 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 924 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
930 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 925 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
931 | //resizeEvent( 0 ); | 926 | //resizeEvent( 0 ); |
932 | for (uint i = 0; i < mCells.count(); ++i) { | 927 | for (uint i = 0; i < mCells.count(); ++i) { |
933 | mCells[i]->updateConfig(); | 928 | mCells[i]->updateConfig(); |
934 | } | 929 | } |
935 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
936 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 931 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
937 | #endif | 932 | #endif |
938 | updateView(); | 933 | updateView(); |
939 | } | 934 | } |
940 | 935 | ||
941 | void KOMonthView::updateDayLabels() | 936 | void KOMonthView::updateDayLabels() |
942 | { | 937 | { |
943 | 938 | ||
944 | for (int i = 0; i < 7; i++) { | 939 | for (int i = 0; i < 7; i++) { |
945 | if (mWeekStartsMonday) { | 940 | if (mWeekStartsMonday) { |
946 | bool show = mShortDayLabels; | 941 | bool show = mShortDayLabels; |
947 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 942 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
948 | show = true; | 943 | show = true; |
949 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 944 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
950 | } else { | 945 | } else { |
951 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 946 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
952 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 947 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
953 | 948 | ||
954 | } | 949 | } |
955 | } | 950 | } |
956 | } | 951 | } |
957 | 952 | ||
958 | void KOMonthView::showDates(const QDate &start, const QDate &) | 953 | void KOMonthView::showDates(const QDate &start, const QDate &) |
959 | { | 954 | { |
960 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 955 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
961 | 956 | ||
962 | 957 | ||
963 | mStartDate = start; | 958 | mStartDate = start; |
964 | 959 | ||
965 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 960 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
966 | 961 | ||
967 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 962 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
968 | mStartDate = mStartDate.addDays( -1 ); | 963 | mStartDate = mStartDate.addDays( -1 ); |
969 | } | 964 | } |
970 | 965 | ||
971 | bool primary = false; | 966 | bool primary = false; |
972 | uint i; | 967 | uint i; |
973 | for( i = 0; i < mCells.size(); ++i ) { | 968 | for( i = 0; i < mCells.size(); ++i ) { |
974 | QDate date = mStartDate.addDays( i ); | 969 | QDate date = mStartDate.addDays( i ); |
975 | mCells[i]->setDate( date ); | 970 | mCells[i]->setDate( date ); |
976 | 971 | ||
977 | #ifndef KORG_NOPLUGINS | 972 | #ifndef KORG_NOPLUGINS |
978 | // add holiday, if present | 973 | // add holiday, if present |
979 | QString hstring(KOCore::self()->holiday(date)); | 974 | QString hstring(KOCore::self()->holiday(date)); |
980 | mCells[i]->setHoliday( hstring ); | 975 | mCells[i]->setHoliday( hstring ); |
981 | #endif | 976 | #endif |
982 | 977 | ||
983 | } | 978 | } |
984 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 979 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
985 | for( i = 0; i < 6; ++i ) { | 980 | for( i = 0; i < 6; ++i ) { |
986 | int wno; | 981 | int wno; |
987 | // remember, according to ISO 8601, the first week of the year is the | 982 | // remember, according to ISO 8601, the first week of the year is the |
988 | // first week that contains a thursday. Thus we must subtract off 4, | 983 | // first week that contains a thursday. Thus we must subtract off 4, |
989 | // not just 1. | 984 | // not just 1. |
990 | int dayOfYear = date.dayOfYear(); | 985 | int dayOfYear = date.dayOfYear(); |
991 | if (dayOfYear % 7 != 0) | 986 | if (dayOfYear % 7 != 0) |
992 | wno = dayOfYear / 7 + 1; | 987 | wno = dayOfYear / 7 + 1; |
993 | else | 988 | else |
994 | wno =dayOfYear / 7; | 989 | wno =dayOfYear / 7; |
995 | mWeekLabels[i]->setWeekNum( wno ); | 990 | mWeekLabels[i]->setWeekNum( wno ); |
996 | date = date.addDays( 7 ); | 991 | date = date.addDays( 7 ); |
997 | } | 992 | } |
998 | updateView(); | 993 | updateView(); |
999 | } | 994 | } |
1000 | 995 | ||
1001 | void KOMonthView::showEvents(QPtrList<Event>) | 996 | void KOMonthView::showEvents(QPtrList<Event>) |
1002 | { | 997 | { |
1003 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 998 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1004 | } | 999 | } |
1005 | 1000 | ||
1006 | void KOMonthView::changeEventDisplay(Event *, int) | 1001 | void KOMonthView::changeEventDisplay(Event *, int) |
1007 | { | 1002 | { |
1008 | // this should be re-written to be much more efficient, but this | 1003 | // this should be re-written to be much more efficient, but this |
1009 | // quick-and-dirty-hack gets the job done for right now. | 1004 | // quick-and-dirty-hack gets the job done for right now. |
1010 | updateView(); | 1005 | updateView(); |
1011 | } | 1006 | } |
1012 | 1007 | ||
1013 | void KOMonthView::updateView() | 1008 | void KOMonthView::updateView() |
1014 | { | 1009 | { |
1015 | 1010 | ||
1016 | if ( !updatePossible ) | 1011 | if ( !updatePossible ) |
1017 | return; | 1012 | return; |
1018 | //QTime ti; | 1013 | //QTime ti; |
1019 | //ti.start(); | 1014 | //ti.start(); |
1020 | #if 1 | 1015 | #if 1 |
1021 | int i; | 1016 | int i; |
1022 | int timeSpan = mCells.size()-1; | 1017 | int timeSpan = mCells.size()-1; |
1023 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1018 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1024 | timeSpan = 6; | 1019 | timeSpan = 6; |
1025 | for( i = 0; i < timeSpan + 1; ++i ) { | 1020 | for( i = 0; i < timeSpan + 1; ++i ) { |
1026 | mCells[i]->startUpdateCell(); | 1021 | mCells[i]->startUpdateCell(); |
1027 | } | 1022 | } |
1028 | 1023 | ||
1029 | QPtrList<Event> events = calendar()->events(); | 1024 | QPtrList<Event> events = calendar()->events(); |
1030 | Event *event; | 1025 | Event *event; |
1031 | QDateTime dt; | 1026 | QDateTime dt; |
1032 | bool ok; | 1027 | bool ok; |
1033 | QDate endDate = mStartDate.addDays( timeSpan ); | 1028 | QDate endDate = mStartDate.addDays( timeSpan ); |
1034 | for( event = events.first(); event; event = events.next() ) { // for event | 1029 | for( event = events.first(); event; event = events.next() ) { // for event |
1035 | if ( event->doesRecur() ) { | 1030 | if ( event->doesRecur() ) { |
1036 | bool last; | 1031 | bool last; |
1037 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1032 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1038 | QDateTime incidenceEnd; | 1033 | QDateTime incidenceEnd; |
1039 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1034 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1040 | bool invalid = false; | 1035 | bool invalid = false; |
1041 | while( true ) { | 1036 | while( true ) { |
1042 | if ( incidenceStart.isValid() ) { | 1037 | if ( incidenceStart.isValid() ) { |
1043 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1038 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1044 | int st = incidenceStart.date().daysTo( endDate ); | 1039 | int st = incidenceStart.date().daysTo( endDate ); |
1045 | if ( st >= 0 ) { // start before timeend | 1040 | if ( st >= 0 ) { // start before timeend |
1046 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1041 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1047 | if ( end >= 0 ) { // end after timestart --- got one! | 1042 | if ( end >= 0 ) { // end after timestart --- got one! |
1048 | //normalize | 1043 | //normalize |
1049 | st = timeSpan - st; | 1044 | st = timeSpan - st; |
1050 | if ( st < 0 ) st = 0; | 1045 | if ( st < 0 ) st = 0; |
1051 | if ( end > timeSpan ) end = timeSpan; | 1046 | if ( end > timeSpan ) end = timeSpan; |
1052 | int iii; | 1047 | int iii; |
1053 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1048 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1054 | for ( iii = st;iii<= end;++iii) | 1049 | for ( iii = st;iii<= end;++iii) |
1055 | mCells[iii]->insertEvent( event ); | 1050 | mCells[iii]->insertEvent( event ); |
1056 | } | 1051 | } |
1057 | } | 1052 | } |
1058 | } else { | 1053 | } else { |
1059 | if ( invalid ) | 1054 | if ( invalid ) |
1060 | break; | 1055 | break; |
1061 | invalid = true; | 1056 | invalid = true; |
1062 | //qDebug("invalid %s", event->summary().latin1()); | 1057 | //qDebug("invalid %s", event->summary().latin1()); |
1063 | incidenceStart = QDateTime( mStartDate ); | 1058 | incidenceStart = QDateTime( mStartDate ); |
1064 | } | 1059 | } |
1065 | if ( last ) | 1060 | if ( last ) |
1066 | break; | 1061 | break; |
1067 | bool ok; | 1062 | bool ok; |
1068 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1063 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1069 | if ( ! ok ) | 1064 | if ( ! ok ) |
1070 | break; | 1065 | break; |
1071 | if ( incidenceStart.date() > endDate ) | 1066 | if ( incidenceStart.date() > endDate ) |
1072 | break; | 1067 | break; |
1073 | } | 1068 | } |
1074 | } else { // no recur | 1069 | } else { // no recur |
1075 | int st = event->dtStart().date().daysTo( endDate ); | 1070 | int st = event->dtStart().date().daysTo( endDate ); |
1076 | if ( st >= 0 ) { // start before timeend | 1071 | if ( st >= 0 ) { // start before timeend |
1077 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1072 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1078 | if ( end >= 0 ) { // end after timestart --- got one! | 1073 | if ( end >= 0 ) { // end after timestart --- got one! |
1079 | //normalize | 1074 | //normalize |
1080 | st = timeSpan - st; | 1075 | st = timeSpan - st; |
1081 | if ( st < 0 ) st = 0; | 1076 | if ( st < 0 ) st = 0; |
1082 | if ( end > timeSpan ) end = timeSpan; | 1077 | if ( end > timeSpan ) end = timeSpan; |
1083 | int iii; | 1078 | int iii; |
1084 | for ( iii = st;iii<= end;++iii) | 1079 | for ( iii = st;iii<= end;++iii) |
1085 | mCells[iii]->insertEvent( event ); | 1080 | mCells[iii]->insertEvent( event ); |
1086 | } | 1081 | } |
1087 | } | 1082 | } |
1088 | } | 1083 | } |
1089 | } | 1084 | } |
1090 | // insert due todos | 1085 | // insert due todos |
1091 | QPtrList<Todo> todos = calendar()->todos( ); | 1086 | QPtrList<Todo> todos = calendar()->todos( ); |
1092 | Todo *todo; | 1087 | Todo *todo; |
1093 | for(todo = todos.first(); todo; todo = todos.next()) { | 1088 | for(todo = todos.first(); todo; todo = todos.next()) { |
1094 | //insertTodo( todo ); | 1089 | //insertTodo( todo ); |
1095 | if ( todo->hasDueDate() ) { | 1090 | if ( todo->hasDueDate() ) { |
1096 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1091 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1097 | if ( day >= 0 && day < timeSpan + 1) { | 1092 | if ( day >= 0 && day < timeSpan + 1) { |
1098 | mCells[day]->insertTodo( todo ); | 1093 | mCells[day]->insertTodo( todo ); |
1099 | } | 1094 | } |
1100 | } | 1095 | } |
1101 | } | 1096 | } |
1102 | 1097 | ||
1103 | for( i = 0; i < timeSpan+1; ++i ) { | 1098 | for( i = 0; i < timeSpan+1; ++i ) { |
1104 | mCells[i]->finishUpdateCell(); | 1099 | mCells[i]->finishUpdateCell(); |
1105 | } | 1100 | } |
1106 | processSelectionChange(); | 1101 | processSelectionChange(); |
1107 | mCells[0]->setFocus(); | 1102 | mCells[0]->setFocus(); |
1108 | 1103 | ||
1109 | 1104 | ||
1110 | #else | 1105 | #else |
1111 | // old code | 1106 | // old code |
1112 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1107 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1113 | int i; | 1108 | int i; |
1114 | for( i = 0; i < mCells.count(); ++i ) { | 1109 | for( i = 0; i < mCells.count(); ++i ) { |
1115 | mCells[i]->updateCell(); | 1110 | mCells[i]->updateCell(); |
1116 | } | 1111 | } |
1117 | 1112 | ||
1118 | //qDebug("KOMonthView::updateView() "); | 1113 | //qDebug("KOMonthView::updateView() "); |
1119 | processSelectionChange(); | 1114 | processSelectionChange(); |
1120 | // qDebug("---------------------------------------------------------------------+ "); | 1115 | // qDebug("---------------------------------------------------------------------+ "); |
1121 | mCells[0]->setFocus(); | 1116 | mCells[0]->setFocus(); |
1122 | #endif | 1117 | #endif |
1123 | 1118 | ||
1124 | //qDebug("update time %d ", ti.elapsed()); | 1119 | //qDebug("update time %d ", ti.elapsed()); |
1125 | } | 1120 | } |
1126 | 1121 | ||
1127 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1122 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1128 | { | 1123 | { |
1129 | computeLayout(); | 1124 | computeLayout(); |
1130 | mCells[0]->setFocus(); | 1125 | mCells[0]->setFocus(); |
1131 | } | 1126 | } |
1132 | void KOMonthView::computeLayoutWeek() | 1127 | void KOMonthView::computeLayoutWeek() |
1133 | { | 1128 | { |
1134 | 1129 | ||
1135 | int daysToShow; | 1130 | int daysToShow; |
1136 | bool combinedSatSun = false; | 1131 | bool combinedSatSun = false; |
1137 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1132 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1138 | daysToShow = 6; | 1133 | daysToShow = 6; |
1139 | combinedSatSun = true; | 1134 | combinedSatSun = true; |
1140 | } | 1135 | } |
1141 | int tWid = topLevelWidget()->size().width(); | 1136 | int tWid = topLevelWidget()->size().width(); |
1142 | int tHei = topLevelWidget()->size().height(); | 1137 | int tHei = topLevelWidget()->size().height(); |
1143 | 1138 | ||
1144 | int wid = size().width();//e | 1139 | int wid = size().width();//e |
1145 | int hei = size().height()-1; | 1140 | int hei = size().height()-1; |
1146 | 1141 | ||
1147 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1142 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1148 | return; | 1143 | return; |
1149 | 1144 | ||
1150 | if ( wid < hei ) | 1145 | if ( wid < hei ) |
1151 | daysToShow = 2; | 1146 | daysToShow = 2; |
1152 | else | 1147 | else |
1153 | daysToShow = 3; | 1148 | daysToShow = 3; |
1154 | mShowSatSunComp = true; | 1149 | mShowSatSunComp = true; |
1155 | combinedSatSun = true; | 1150 | combinedSatSun = true; |
1156 | 1151 | ||
1157 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1152 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1158 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1153 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1159 | int weeklabelwid = fm.width( "888" ); | 1154 | int weeklabelwid = fm.width( "888" ); |
1160 | wid -= weeklabelwid; | 1155 | wid -= weeklabelwid; |
1161 | 1156 | ||
1162 | int colWid = wid / daysToShow; | 1157 | int colWid = wid / daysToShow; |
1163 | int lastCol = wid - ( colWid*6 ); | 1158 | int lastCol = wid - ( colWid*6 ); |
1164 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1159 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1165 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1160 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1166 | int colModulo = wid % daysToShow; | 1161 | int colModulo = wid % daysToShow; |
1167 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1162 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1168 | //qDebug("rowmod %d ", rowModulo); | 1163 | //qDebug("rowmod %d ", rowModulo); |
1169 | int i; | 1164 | int i; |
1170 | int x,y,w,h; | 1165 | int x,y,w,h; |
1171 | x= 0; | 1166 | x= 0; |
1172 | y= 0; | 1167 | y= 0; |
1173 | w = colWid; | 1168 | w = colWid; |
1174 | h = dayLabelHei ; | 1169 | h = dayLabelHei ; |
1175 | for ( i = 0; i < 7; i++) { | 1170 | for ( i = 0; i < 7; i++) { |
1176 | if ( i && !( i % daysToShow) && i < 6) { | 1171 | if ( i && !( i % daysToShow) && i < 6) { |
1177 | y += hei/(5-daysToShow); | 1172 | y += hei/(5-daysToShow); |
1178 | x = 0; | 1173 | x = 0; |
1179 | w = colWid; | 1174 | w = colWid; |
1180 | } | 1175 | } |
1181 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1176 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1182 | ++w; | 1177 | ++w; |
1183 | } | 1178 | } |
1184 | if ( i >= 5 ) { | 1179 | if ( i >= 5 ) { |
1185 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1180 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1186 | x -= (w/2 ); | 1181 | x -= (w/2 ); |
1187 | } | 1182 | } |
1188 | else | 1183 | else |
1189 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1184 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1190 | x += w; | 1185 | x += w; |
1191 | } | 1186 | } |
1192 | x= 0; | 1187 | x= 0; |
1193 | y= dayLabelHei; | 1188 | y= dayLabelHei; |
1194 | w = colWid; | 1189 | w = colWid; |
1195 | h = cellHei; | 1190 | h = cellHei; |
1196 | for ( i = 0; i < mCells.count(); ++i) { | 1191 | for ( i = 0; i < mCells.count(); ++i) { |
1197 | if ( i > 6 ) { | 1192 | if ( i > 6 ) { |
1198 | mCells[i]->hide(); | 1193 | mCells[i]->hide(); |
1199 | continue; | 1194 | continue; |
1200 | } | 1195 | } |
1201 | 1196 | ||
1202 | w = colWid; | 1197 | w = colWid; |
1203 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1198 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1204 | ++w; | 1199 | ++w; |
1205 | } | 1200 | } |
1206 | if ( i == (daysToShow-1-rowModulo)*7) | 1201 | if ( i == (daysToShow-1-rowModulo)*7) |
1207 | ++h; | 1202 | ++h; |
1208 | 1203 | ||
1209 | if ( i >= 5 ) { | 1204 | if ( i >= 5 ) { |
1210 | if ( i ==5 ) { | 1205 | if ( i ==5 ) { |
1211 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1206 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1212 | x -= w ;y += h/2; | 1207 | x -= w ;y += h/2; |
1213 | } else { | 1208 | } else { |
1214 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1209 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1215 | ++w; | 1210 | ++w; |
1216 | } | 1211 | } |
1217 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1212 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1218 | y -= h/2; | 1213 | y -= h/2; |
1219 | } | 1214 | } |
1220 | } else | 1215 | } else |
1221 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1216 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1222 | 1217 | ||
1223 | 1218 | ||
1224 | x += w; | 1219 | x += w; |
1225 | if ( x + w/2 > wid ) { | 1220 | if ( x + w/2 > wid ) { |
1226 | x = 0; | 1221 | x = 0; |
1227 | y += h+dayLabelHei ; | 1222 | y += h+dayLabelHei ; |
1228 | } | 1223 | } |
1229 | } | 1224 | } |
1230 | y= dayLabelHei; | 1225 | y= dayLabelHei; |
1231 | h = cellHei ; | 1226 | h = cellHei ; |
1232 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1227 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1233 | for ( i = 1; i < 6; i++) { | 1228 | for ( i = 1; i < 6; i++) { |
1234 | mWeekLabels[i]->hide(); | 1229 | mWeekLabels[i]->hide(); |
1235 | } | 1230 | } |
1236 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1231 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1237 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1232 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1238 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1233 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1239 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1234 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1240 | updateDayLabels(); | 1235 | updateDayLabels(); |
1241 | bool forceUpdate = !updatePossible; | 1236 | bool forceUpdate = !updatePossible; |
1242 | updatePossible = true; | 1237 | updatePossible = true; |
1243 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1238 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1244 | if ( forceUpdate ) | 1239 | if ( forceUpdate ) |
1245 | updateView(); | 1240 | updateView(); |
1246 | } | 1241 | } |
1247 | void KOMonthView::computeLayout() | 1242 | void KOMonthView::computeLayout() |
1248 | { | 1243 | { |
1249 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1244 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1250 | // note this only changes the text if the requested size crosses the | 1245 | // note this only changes the text if the requested size crosses the |
1251 | // threshold between big enough to support the full name and not big | 1246 | // threshold between big enough to support the full name and not big |
1252 | // enough. | 1247 | // enough. |
1253 | if ( mShowWeekView ){ | 1248 | if ( mShowWeekView ){ |
1254 | computeLayoutWeek(); | 1249 | computeLayoutWeek(); |
1255 | return; | 1250 | return; |
1256 | } | 1251 | } |
1257 | int daysToShow = 7; | 1252 | int daysToShow = 7; |
1258 | bool combinedSatSun = false; | 1253 | bool combinedSatSun = false; |
1259 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1254 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1260 | daysToShow = 6; | 1255 | daysToShow = 6; |
1261 | combinedSatSun = true; | 1256 | combinedSatSun = true; |
1262 | } | 1257 | } |
1263 | int tWid = topLevelWidget()->size().width(); | 1258 | int tWid = topLevelWidget()->size().width(); |
1264 | int tHei = topLevelWidget()->size().height(); | 1259 | int tHei = topLevelWidget()->size().height(); |
1265 | 1260 | ||
1266 | int wid = size().width();//e | 1261 | int wid = size().width();//e |
1267 | int hei = size().height()-1; | 1262 | int hei = size().height()-1; |
1268 | 1263 | ||
1269 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1264 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1270 | return; | 1265 | return; |
1271 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1266 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1272 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1267 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1273 | int weeklabelwid = fm.width( "888" ); | 1268 | int weeklabelwid = fm.width( "888" ); |
1274 | wid -= weeklabelwid; | 1269 | wid -= weeklabelwid; |
1275 | 1270 | ||
1276 | int colWid = wid / daysToShow; | 1271 | int colWid = wid / daysToShow; |
1277 | int lastCol = wid - ( colWid*6 ); | 1272 | int lastCol = wid - ( colWid*6 ); |
1278 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1273 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1279 | int cellHei = (hei - dayLabelHei) /6; | 1274 | int cellHei = (hei - dayLabelHei) /6; |
1280 | int colModulo = wid % daysToShow; | 1275 | int colModulo = wid % daysToShow; |
1281 | int rowModulo = (hei- dayLabelHei) % 6; | 1276 | int rowModulo = (hei- dayLabelHei) % 6; |
1282 | //qDebug("rowmod %d ", rowModulo); | 1277 | //qDebug("rowmod %d ", rowModulo); |
1283 | int i; | 1278 | int i; |
1284 | int x,y,w,h; | 1279 | int x,y,w,h; |
1285 | x= 0; | 1280 | x= 0; |
1286 | y= 0; | 1281 | y= 0; |
1287 | w = colWid; | 1282 | w = colWid; |
1288 | h = dayLabelHei ; | 1283 | h = dayLabelHei ; |
1289 | for ( i = 0; i < 7; i++) { | 1284 | for ( i = 0; i < 7; i++) { |
1290 | if ( i == daysToShow-colModulo ) | 1285 | if ( i == daysToShow-colModulo ) |
1291 | ++w; | 1286 | ++w; |
1292 | if ( combinedSatSun ) { | 1287 | if ( combinedSatSun ) { |
1293 | if ( i >= daysToShow-1 ) { | 1288 | if ( i >= daysToShow-1 ) { |
1294 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1289 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1295 | x -= w/2 ; | 1290 | x -= w/2 ; |
1296 | } | 1291 | } |
1297 | else | 1292 | else |
1298 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1293 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1299 | } else | 1294 | } else |
1300 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1295 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1301 | x += w; | 1296 | x += w; |
1302 | } | 1297 | } |
1303 | x= 0; | 1298 | x= 0; |
1304 | y= dayLabelHei; | 1299 | y= dayLabelHei; |
1305 | w = colWid; | 1300 | w = colWid; |
1306 | h = cellHei ; | 1301 | h = cellHei ; |
1307 | for ( i = 0; i < mCells.count(); ++i) { | 1302 | for ( i = 0; i < mCells.count(); ++i) { |
1308 | mCells[i]->show(); | 1303 | mCells[i]->show(); |
1309 | w = colWid; | 1304 | w = colWid; |
1310 | if ( ((i) % 7) >= 7-colModulo ) { | 1305 | if ( ((i) % 7) >= 7-colModulo ) { |
1311 | ++w; | 1306 | ++w; |
1312 | } | 1307 | } |
1313 | if ( i == (6-rowModulo)*7) | 1308 | if ( i == (6-rowModulo)*7) |
1314 | ++h; | 1309 | ++h; |
1315 | if ( combinedSatSun ) { | 1310 | if ( combinedSatSun ) { |
1316 | if ( (i)%7 >= daysToShow-1 ) { | 1311 | if ( (i)%7 >= daysToShow-1 ) { |
1317 | if ( (i)%7 == daysToShow-1 ) { | 1312 | if ( (i)%7 == daysToShow-1 ) { |
1318 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1313 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1319 | x -= w ;y += h/2; | 1314 | x -= w ;y += h/2; |
1320 | } else { | 1315 | } else { |
1321 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1316 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1322 | y -= h/2; | 1317 | y -= h/2; |
1323 | } | 1318 | } |
1324 | } else | 1319 | } else |
1325 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1320 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1326 | 1321 | ||
1327 | } | 1322 | } |
1328 | else | 1323 | else |
1329 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1324 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1330 | x += w; | 1325 | x += w; |
1331 | if ( x + w/2 > wid ) { | 1326 | if ( x + w/2 > wid ) { |
1332 | x = 0; | 1327 | x = 0; |
1333 | y += h; | 1328 | y += h; |
1334 | } | 1329 | } |
1335 | } | 1330 | } |
1336 | y= dayLabelHei; | 1331 | y= dayLabelHei; |
1337 | h = cellHei ; | 1332 | h = cellHei ; |
1338 | for ( i = 0; i < 6; i++) { | 1333 | for ( i = 0; i < 6; i++) { |
1339 | mWeekLabels[i]->show(); | 1334 | mWeekLabels[i]->show(); |
1340 | if ( i == (6-rowModulo)) | 1335 | if ( i == (6-rowModulo)) |
1341 | ++h; | 1336 | ++h; |
1342 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1337 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1343 | y += h; | 1338 | y += h; |
1344 | } | 1339 | } |
1345 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1340 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1346 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1341 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1347 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1342 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1348 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1343 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1349 | updateDayLabels(); | 1344 | updateDayLabels(); |
1350 | bool forceUpdate = !updatePossible; | 1345 | bool forceUpdate = !updatePossible; |
1351 | updatePossible = true; | 1346 | updatePossible = true; |
1352 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1347 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1353 | if ( forceUpdate ) | 1348 | if ( forceUpdate ) |
1354 | updateView(); | 1349 | updateView(); |
1355 | } | 1350 | } |
1356 | 1351 | ||
1357 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1352 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1358 | { | 1353 | { |
1359 | mContextMenu->showIncidencePopup(incidence); | 1354 | mContextMenu->showIncidencePopup(incidence); |
1360 | /* | 1355 | /* |
1361 | if( incidence && incidence->type() == "Event" ) { | 1356 | if( incidence && incidence->type() == "Event" ) { |
1362 | Event *event = static_cast<Event *>(incidence); | 1357 | Event *event = static_cast<Event *>(incidence); |
1363 | mContextMenu->showEventPopup(event); | 1358 | mContextMenu->showEventPopup(event); |
1364 | } else { | 1359 | } else { |
1365 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1360 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1366 | } | 1361 | } |
1367 | */ | 1362 | */ |
1368 | } | 1363 | } |
1369 | MonthViewCell * KOMonthView::selectedCell( ) | 1364 | MonthViewCell * KOMonthView::selectedCell( ) |
1370 | { | 1365 | { |
1371 | return mSelectedCell; | 1366 | return mSelectedCell; |
1372 | } | 1367 | } |
1373 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1368 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1374 | { | 1369 | { |
1375 | // qDebug("KOMonthView::setSelectedCell "); | 1370 | // qDebug("KOMonthView::setSelectedCell "); |
1376 | if ( mSelectedCell && mSelectedCell != cell ) { | 1371 | if ( mSelectedCell && mSelectedCell != cell ) { |
1377 | MonthViewCell * mvc = mSelectedCell; | 1372 | MonthViewCell * mvc = mSelectedCell; |
1378 | mSelectedCell = cell; | 1373 | mSelectedCell = cell; |
1379 | mvc->deselect(); | 1374 | mvc->deselect(); |
1380 | } else | 1375 | } else |
1381 | mSelectedCell = cell; | 1376 | mSelectedCell = cell; |
1382 | // if ( mSelectedCell ) | 1377 | // if ( mSelectedCell ) |
1383 | // mSelectedCell->select(); | 1378 | // mSelectedCell->select(); |
1384 | if ( !mSelectedCell ) | 1379 | if ( !mSelectedCell ) |
1385 | emit incidenceSelected( 0 ); | 1380 | emit incidenceSelected( 0 ); |
1386 | else | 1381 | else |
1387 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1382 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1388 | } | 1383 | } |
1389 | 1384 | ||
1390 | void KOMonthView::processSelectionChange() | 1385 | void KOMonthView::processSelectionChange() |
1391 | { | 1386 | { |
1392 | QPtrList<Incidence> incidences = selectedIncidences(); | 1387 | QPtrList<Incidence> incidences = selectedIncidences(); |
1393 | if (incidences.count() > 0) { | 1388 | if (incidences.count() > 0) { |
1394 | emit incidenceSelected( incidences.first() ); | 1389 | emit incidenceSelected( incidences.first() ); |
1395 | } else { | 1390 | } else { |
1396 | emit incidenceSelected( 0 ); | 1391 | emit incidenceSelected( 0 ); |
1397 | } | 1392 | } |
1398 | } | 1393 | } |
1399 | 1394 | ||
1400 | void KOMonthView::clearSelection() | 1395 | void KOMonthView::clearSelection() |
1401 | { | 1396 | { |
1402 | if ( mSelectedCell ) { | 1397 | if ( mSelectedCell ) { |
1403 | mSelectedCell->deselect(); | 1398 | mSelectedCell->deselect(); |
1404 | mSelectedCell = 0; | 1399 | mSelectedCell = 0; |
1405 | } | 1400 | } |
1406 | } | 1401 | } |
1407 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1402 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1408 | { | 1403 | { |
1409 | //qDebug("KOMonthView::keyPressEvent "); | 1404 | //qDebug("KOMonthView::keyPressEvent "); |
1410 | switch(e->key()) { | 1405 | switch(e->key()) { |
1411 | case Key_Up: | 1406 | case Key_Up: |
1412 | { | 1407 | { |
1413 | emit prevMonth(); | 1408 | emit prevMonth(); |
1414 | mCells[0]->setFocus(); | 1409 | mCells[0]->setFocus(); |
1415 | } | 1410 | } |
1416 | e->accept(); | 1411 | e->accept(); |
1417 | break; | 1412 | break; |
1418 | case Key_Down: | 1413 | case Key_Down: |
1419 | { | 1414 | { |
1420 | emit nextMonth(); | 1415 | emit nextMonth(); |
1421 | mCells[0]->setFocus(); | 1416 | mCells[0]->setFocus(); |
1422 | 1417 | ||
1423 | } | 1418 | } |
1424 | e->accept(); | 1419 | e->accept(); |
1425 | break; | 1420 | break; |
1426 | default: | 1421 | default: |
1427 | e->ignore(); | 1422 | e->ignore(); |
1428 | break; | 1423 | break; |
1429 | } | 1424 | } |
1430 | } | 1425 | } |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index f339c67..2406bb5 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,198 +1,228 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | ||
31 | #include <qapplication.h> | 32 | #include <qapplication.h> |
32 | 33 | ||
33 | #include <kdebug.h> | 34 | #include <kdebug.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | #include <kglobal.h> | 36 | #include <kglobal.h> |
36 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
37 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
38 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
39 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
40 | 41 | ||
41 | #include "koglobals.h" | 42 | #include "koglobals.h" |
42 | #include "koprefs.h" | 43 | #include "koprefs.h" |
43 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 45 | #include "kocore.h" |
45 | #endif | 46 | #endif |
46 | 47 | ||
47 | #include <kcalendarsystem.h> | 48 | #include <kcalendarsystem.h> |
48 | 49 | ||
49 | #include "navigatorbar.h" | 50 | #include "navigatorbar.h" |
50 | 51 | ||
51 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 52 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
52 | : QWidget( parent, name ) | 53 | : QWidget( parent, name ) |
53 | { | 54 | { |
54 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 55 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
55 | 56 | ||
56 | // Set up the control buttons and date label | 57 | // Set up the control buttons and date label |
57 | mCtrlFrame = new QFrame( this ); | 58 | mCtrlFrame = new QFrame( this ); |
58 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 59 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
59 | mCtrlFrame->setLineWidth(1); | 60 | mCtrlFrame->setLineWidth(1); |
60 | 61 | ||
61 | topLayout->addWidget( mCtrlFrame ); | 62 | topLayout->addWidget( mCtrlFrame ); |
62 | 63 | ||
63 | QFont tfont = font(); | 64 | QFont tfont = font(); |
64 | if ( QApplication::desktop()->width() >= 480 ) | 65 | if ( QApplication::desktop()->width() >= 480 ) |
65 | tfont.setPointSize(tfont.pointSize()+2); | 66 | tfont.setPointSize(tfont.pointSize()+2); |
66 | tfont.setBold(true); | 67 | tfont.setBold(true); |
67 | 68 | ||
68 | bool isRTL = KOGlobals::self()->reverseLayout(); | 69 | bool isRTL = KOGlobals::self()->reverseLayout(); |
69 | #ifndef DESKTOP_VERSION | 70 | #ifndef DESKTOP_VERSION |
70 | bool isDesktop = false; | 71 | bool isDesktop = false; |
71 | #else | 72 | #else |
72 | bool isDesktop = true; | 73 | bool isDesktop = true; |
73 | #endif | 74 | #endif |
74 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 75 | bool insertWeek = (QString ( name ) == QString("useBigPixmaps")) ; |
76 | if ( insertWeek && QApplication::desktop()->width() > 320 ) | ||
75 | isDesktop = true; | 77 | isDesktop = true; |
76 | // Create backward navigation buttons | 78 | // Create backward navigation buttons |
77 | mPrevYear = new QPushButton( mCtrlFrame ); | 79 | mPrevYear = new QPushButton( mCtrlFrame ); |
78 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
79 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
80 | 82 | ||
81 | mPrevMonth = new QPushButton( mCtrlFrame ); | 83 | mPrevMonth = new QPushButton( mCtrlFrame ); |
82 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
83 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
84 | 86 | ||
85 | // Create forward navigation buttons | 87 | // Create forward navigation buttons |
86 | mNextMonth = new QPushButton( mCtrlFrame ); | 88 | mNextMonth = new QPushButton( mCtrlFrame ); |
87 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
88 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 90 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
89 | 91 | ||
92 | QPushButton * selWeek = 0; | ||
93 | if ( insertWeek ) { | ||
94 | selWeek = new QPushButton( mCtrlFrame ); | ||
95 | QToolTip::add( selWeek, i18n("Select Week") ); | ||
96 | selWeek->setFocusPolicy(NoFocus); | ||
97 | } | ||
98 | |||
90 | mNextYear = new QPushButton( mCtrlFrame ); | 99 | mNextYear = new QPushButton( mCtrlFrame ); |
91 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 100 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
92 | QToolTip::add( mNextYear, i18n("Next Year") ); | 101 | QToolTip::add( mNextYear, i18n("Next Year") ); |
93 | mSelectMonth = new QPushButton( mCtrlFrame ); | 102 | mSelectMonth = new QPushButton( mCtrlFrame ); |
94 | // Create month name label | 103 | // Create month name label |
95 | //selectMonth->setFont( tfont ); | 104 | //selectMonth->setFont( tfont ); |
96 | // selectMonth->setAlignment( AlignCenter ); | 105 | // selectMonth->setAlignment( AlignCenter ); |
97 | //mDateLabel = new QLabel( selectMonth ); | 106 | //mDateLabel = new QLabel( selectMonth ); |
98 | //mDateLabel->setFont( tfont ); | 107 | //mDateLabel->setFont( tfont ); |
99 | //mDateLabel->setAlignment( AlignCenter ); | 108 | //mDateLabel->setAlignment( AlignCenter ); |
100 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 109 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
101 | mNextMonth->setFlat( true); | 110 | mNextMonth->setFlat( true); |
102 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
103 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
104 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
105 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
115 | if ( insertWeek ) | ||
116 | selWeek->setFlat( true); | ||
106 | } | 117 | } |
107 | mSelectMonth->setFont( tfont ); | 118 | mSelectMonth->setFont( tfont ); |
108 | // Set minimum width to width of widest month name label | 119 | // Set minimum width to width of widest month name label |
109 | int i; | 120 | int i; |
110 | int maxwidth = 0; | 121 | int maxwidth = 0; |
111 | QFontMetrics fm ( mSelectMonth->font() ); | 122 | QFontMetrics fm ( mSelectMonth->font() ); |
112 | int width = fm.width("September '00" ); | 123 | int width = fm.width("September '00" ); |
113 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | 124 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); |
114 | // ++i ) { | 125 | // ++i ) { |
115 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | 126 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, |
116 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | 127 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); |
117 | // int width = fm.width("September 2000" ); | 128 | // int width = fm.width("September 2000" ); |
118 | // if ( width > maxwidth ) maxwidth = width; | 129 | // if ( width > maxwidth ) maxwidth = width; |
119 | // } | 130 | // } |
120 | maxwidth = width+2; | 131 | maxwidth = width+2; |
121 | int size = fm.height()+2; | 132 | int size = fm.height()+2; |
122 | if ( QApplication::desktop()->width() >= 480 ) { | 133 | if ( QApplication::desktop()->width() >= 480 ) { |
123 | size += 6; | 134 | size += 6; |
124 | maxwidth+= 6; | 135 | maxwidth+= 6; |
125 | } | 136 | } |
137 | |||
138 | if ( insertWeek ) { | ||
139 | //shit : bug in Qt. after inserting 53 item, only 51 are shown... | ||
140 | QPopupMenu * wpo = new QPopupMenu (this); | ||
141 | wpo->insertItem( i18n("W#"), 0 ); | ||
142 | for ( i = 1; i < 53; ++i ) { | ||
143 | wpo->insertItem( QString::number(i), i ); | ||
144 | } | ||
145 | for ( i = 53; i < 54; ++i ) { | ||
146 | wpo->insertItem( "", 52 ); | ||
147 | } | ||
148 | selWeek->setPopup( wpo ); | ||
149 | selWeek->setFixedWidth( (size/4)*3 ); | ||
150 | selWeek->setFixedHeight( size ); | ||
151 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); | ||
152 | } | ||
126 | mSelectMonth->setFixedWidth( maxwidth ); | 153 | mSelectMonth->setFixedWidth( maxwidth ); |
127 | mSelectMonth->setFixedHeight( size ); | 154 | mSelectMonth->setFixedHeight( size ); |
128 | mPrevYear->setFixedHeight( size ); | 155 | mPrevYear->setFixedHeight( size ); |
129 | mPrevMonth->setFixedHeight( size ); | 156 | mPrevMonth->setFixedHeight( size ); |
130 | mNextMonth->setFixedHeight( size ); | 157 | mNextMonth->setFixedHeight( size ); |
131 | mNextYear->setFixedHeight ( size ); | 158 | mNextYear->setFixedHeight ( size ); |
132 | // set up control frame layout | 159 | // set up control frame layout |
133 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 160 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
134 | ctrlLayout->addWidget( mPrevYear, 3 ); | 161 | ctrlLayout->addWidget( mPrevYear, 3 ); |
135 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 162 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
136 | //ctrlLayout->addStretch( 1 ); | 163 | //ctrlLayout->addStretch( 1 ); |
137 | // ctrlLayout->addSpacing( 1 ); | 164 | // ctrlLayout->addSpacing( 1 ); |
138 | // ctrlLayout->addWidget( mDateLabel ); | 165 | // ctrlLayout->addWidget( mDateLabel ); |
139 | ctrlLayout->addWidget( mSelectMonth ); | 166 | ctrlLayout->addWidget( mSelectMonth ); |
140 | // ctrlLayout->addSpacing( 1 ); | 167 | // ctrlLayout->addSpacing( 1 ); |
141 | // ctrlLayout->addStretch( 1 ); | 168 | // ctrlLayout->addStretch( 1 ); |
142 | ctrlLayout->addWidget( mNextMonth, 3 ); | 169 | ctrlLayout->addWidget( mNextMonth, 3 ); |
143 | ctrlLayout->addWidget( mNextYear, 3 ); | 170 | ctrlLayout->addWidget( mNextYear, 3 ); |
171 | if ( insertWeek ) | ||
172 | ctrlLayout->addWidget( selWeek ); | ||
144 | 173 | ||
145 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 174 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
146 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 175 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
147 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 176 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
148 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 177 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
149 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 178 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
150 | mPrevYear->setFocusPolicy(NoFocus); | 179 | mPrevYear->setFocusPolicy(NoFocus); |
151 | mPrevMonth->setFocusPolicy(NoFocus); | 180 | mPrevMonth->setFocusPolicy(NoFocus); |
152 | mNextMonth->setFocusPolicy(NoFocus); | 181 | mNextMonth->setFocusPolicy(NoFocus); |
153 | mNextYear->setFocusPolicy(NoFocus); | 182 | mNextYear->setFocusPolicy(NoFocus); |
154 | mSelectMonth->setFocusPolicy(NoFocus); | 183 | mSelectMonth->setFocusPolicy(NoFocus); |
184 | |||
155 | } | 185 | } |
156 | 186 | ||
157 | NavigatorBar::~NavigatorBar() | 187 | NavigatorBar::~NavigatorBar() |
158 | { | 188 | { |
159 | } | 189 | } |
160 | 190 | ||
161 | void NavigatorBar::selectMonth() | 191 | void NavigatorBar::selectMonth() |
162 | { | 192 | { |
163 | 193 | ||
164 | int month; | 194 | int month; |
165 | KPopupFrame* popup = new KPopupFrame(this); | 195 | KPopupFrame* popup = new KPopupFrame(this); |
166 | int size = 12; | 196 | int size = 12; |
167 | if ( QApplication::desktop()->width() >= 480 ) | 197 | if ( QApplication::desktop()->width() >= 480 ) |
168 | size = 18; | 198 | size = 18; |
169 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); | 199 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); |
170 | // ----- | 200 | // ----- |
171 | picker->resize(picker->sizeHint()); | 201 | picker->resize(picker->sizeHint()); |
172 | popup->setMainWidget(picker); | 202 | popup->setMainWidget(picker); |
173 | picker->setFocus(); | 203 | picker->setFocus(); |
174 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 204 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
175 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 205 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
176 | { | 206 | { |
177 | month = picker->getResult(); | 207 | month = picker->getResult(); |
178 | emit monthSelected ( month ); | 208 | emit monthSelected ( month ); |
179 | } else { | 209 | } else { |
180 | KNotifyClient::beep(); | 210 | KNotifyClient::beep(); |
181 | } | 211 | } |
182 | delete popup; | 212 | delete popup; |
183 | } | 213 | } |
184 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 214 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
185 | { | 215 | { |
186 | if (dateList.count() > 0) { | 216 | if (dateList.count() > 0) { |
187 | QDate date = dateList.first(); | 217 | QDate date = dateList.first(); |
188 | 218 | ||
189 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 219 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
190 | 220 | ||
191 | // compute the label at the top of the navigator | 221 | // compute the label at the top of the navigator |
192 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 222 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
193 | QString::number( calSys->year( date ) ).right(2); | 223 | QString::number( calSys->year( date ) ).right(2); |
194 | 224 | ||
195 | mSelectMonth->setText( dtstr ); | 225 | mSelectMonth->setText( dtstr ); |
196 | } | 226 | } |
197 | } | 227 | } |
198 | 228 | ||
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 9c5c0cf..ee4c06d 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef NAVIGATORBAR_H | 24 | #ifndef NAVIGATORBAR_H |
25 | #define NAVIGATORBAR_H | 25 | #define NAVIGATORBAR_H |
26 | 26 | ||
27 | #include <libkcal/incidencebase.h> | 27 | #include <libkcal/incidencebase.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | 30 | ||
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QFrame; | 32 | class QFrame; |
33 | class QLabel; | 33 | class QLabel; |
34 | 34 | ||
35 | class NavigatorBar: public QWidget | 35 | class NavigatorBar: public QWidget |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); | 39 | NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); |
40 | ~NavigatorBar(); | 40 | ~NavigatorBar(); |
41 | 41 | ||
42 | public slots: | 42 | public slots: |
43 | void selectDates( const KCal::DateList & ); | 43 | void selectDates( const KCal::DateList & ); |
44 | void selectMonth(); | 44 | void selectMonth(); |
45 | 45 | ||
46 | signals: | 46 | signals: |
47 | void goNextMonth(); | 47 | void goNextMonth(); |
48 | void goPrevMonth(); | 48 | void goPrevMonth(); |
49 | void goNextYear(); | 49 | void goNextYear(); |
50 | void goPrevYear(); | 50 | void goPrevYear(); |
51 | void monthSelected( int ); | 51 | void monthSelected( int ); |
52 | 52 | void selectWeek( int ); | |
53 | 53 | ||
54 | private: | 54 | private: |
55 | QFrame *mCtrlFrame; | 55 | QFrame *mCtrlFrame; |
56 | 56 | ||
57 | QPushButton *mPrevYear; | 57 | QPushButton *mPrevYear; |
58 | QPushButton *mPrevMonth; | 58 | QPushButton *mPrevMonth; |
59 | QPushButton *mNextMonth; | 59 | QPushButton *mNextMonth; |
60 | QPushButton *mNextYear; | 60 | QPushButton *mNextYear; |
61 | QPushButton *mSelectMonth; | 61 | QPushButton *mSelectMonth; |
62 | 62 | ||
63 | //QLabel *mDateLabel; | 63 | //QLabel *mDateLabel; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | #endif | 66 | #endif |