-rw-r--r-- | korganizer/calendarview.cpp | 72 | ||||
-rw-r--r-- | korganizer/calendarview.h | 6 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 218 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.h | 90 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 38 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 8 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 49 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 8 | ||||
-rw-r--r-- | korganizer/korganizerE.pro | 4 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 22 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 1 |
11 files changed, 464 insertions, 52 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6eaac1c..00285a5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,726 +1,740 @@ | |||
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 "datenavigatorcontainer.h" | ||
110 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 115 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
118 | 119 | ||
119 | #include "calendarview.h" | 120 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
122 | #endif | 123 | #endif |
123 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 125 | #include <stdlib.h> |
125 | #include <stdio.h> | 126 | #include <stdio.h> |
126 | #include <unistd.h> | 127 | #include <unistd.h> |
127 | #else | 128 | #else |
128 | #include <qprocess.h> | 129 | #include <qprocess.h> |
129 | #endif | 130 | #endif |
130 | 131 | ||
131 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
133 | #endif | 134 | #endif |
134 | using namespace KOrg; | 135 | using namespace KOrg; |
135 | using namespace KCal; | 136 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
138 | 139 | ||
139 | 140 | ||
140 | 141 | ||
141 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
142 | { | 143 | { |
143 | public: | 144 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
146 | { | 147 | { |
147 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
169 | } | 170 | } |
170 | 171 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 174 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 176 | }; |
176 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
177 | { | 178 | { |
178 | public: | 179 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
181 | { | 182 | { |
182 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 186 | 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 ); | 187 | 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 ); | 188 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
201 | } | 202 | } |
202 | 203 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 205 | private: |
205 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
206 | }; | 207 | }; |
207 | 208 | ||
208 | 209 | ||
209 | 210 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
215 | { | 216 | { |
216 | 217 | ||
217 | mEventEditor = 0; | 218 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
219 | 220 | ||
220 | init(); | 221 | init(); |
221 | } | 222 | } |
222 | 223 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
228 | { | 229 | { |
229 | 230 | ||
230 | mEventEditor = 0; | 231 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
232 | init(); | 233 | init(); |
233 | } | 234 | } |
234 | 235 | ||
235 | void CalendarView::init() | 236 | void CalendarView::init() |
236 | { | 237 | { |
237 | 238 | ||
238 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
239 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
240 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
241 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
242 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
243 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
244 | writeLocale(); | 245 | writeLocale(); |
245 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
246 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
247 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
248 | mModified = false; | 249 | mModified = false; |
249 | mReadOnly = false; | 250 | mReadOnly = false; |
250 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
251 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
252 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
253 | 254 | ||
254 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
255 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
256 | 257 | ||
257 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
258 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
259 | 260 | ||
260 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
261 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
262 | // create the main layout frames. | 263 | // create the main layout frames. |
263 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
264 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
265 | 266 | ||
266 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
267 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
268 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
269 | 270 | ||
270 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
271 | "CalendarView::DateNavigator", QDate::currentDate() ); | 272 | "CalendarView::DateNavigator" ); |
273 | |||
272 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
273 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
274 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
275 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
276 | 278 | ||
277 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
278 | mResourceView = 0; | 280 | mResourceView = 0; |
279 | #else | 281 | #else |
280 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
281 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
282 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
283 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
284 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
285 | } else { | 287 | } else { |
286 | mResourceView = 0; | 288 | mResourceView = 0; |
287 | } | 289 | } |
288 | #endif | 290 | #endif |
289 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
290 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
291 | 293 | ||
292 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
293 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
294 | 296 | ||
295 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
296 | #else | 298 | #else |
297 | QWidget *mainBox = new QWidget( this ); | 299 | QWidget *mainBox = new QWidget( this ); |
298 | QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
299 | |||
300 | QBoxLayout * mainBoxLayout; | 301 | QBoxLayout * mainBoxLayout; |
301 | QBoxLayout * leftFrameLayout; | ||
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | mainBoxLayout = new QVBoxLayout(mainBox); | 303 | mainBoxLayout = new QVBoxLayout(mainBox); |
304 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; | ||
306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | ||
305 | } else { | 307 | } else { |
306 | mainBoxLayout = new QHBoxLayout(mainBox); | 308 | mainBoxLayout = new QHBoxLayout(mainBox); |
307 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; | ||
311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | ||
308 | } | 312 | } |
313 | //QBoxLayout * leftFrameLayout; | ||
309 | topLayout->addWidget( mainBox ); | 314 | topLayout->addWidget( mainBox ); |
310 | mainBoxLayout->addWidget (leftFrame); | 315 | mainBoxLayout->addWidget (mLeftFrame); |
311 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
317 | "CalendarView::DateNavigator" ); | ||
318 | #if 0 | ||
319 | // FIXME | ||
320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | ||
312 | "CalendarView::DateNavigator", QDate::currentDate()); | 321 | "CalendarView::DateNavigator", QDate::currentDate()); |
322 | #endif | ||
313 | // mDateNavigator->blockSignals( true ); | 323 | // mDateNavigator->blockSignals( true ); |
314 | leftFrameLayout->addWidget( mDateNavigator ); | 324 | //leftFrameLayout->addWidget( mDateNavigator ); |
315 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
316 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
317 | mTodoList->setNavigator( mNavigator ); | 327 | mTodoList->setNavigator( mNavigator ); |
318 | 328 | #if 0 | |
319 | if ( QApplication::desktop()->width() < 480 ) { | 329 | if ( QApplication::desktop()->width() < 480 ) { |
320 | leftFrameLayout->addWidget(mFilterView); | 330 | leftFrameLayout->addWidget(mFilterView); |
321 | leftFrameLayout->addWidget(mTodoList, 2 ); | 331 | leftFrameLayout->addWidget(mTodoList, 2 ); |
322 | 332 | ||
323 | } else { | 333 | } else { |
324 | leftFrameLayout->addWidget(mTodoList,2 ); | 334 | leftFrameLayout->addWidget(mTodoList,2 ); |
325 | leftFrameLayout->addWidget(mFilterView ); | 335 | leftFrameLayout->addWidget(mFilterView ); |
326 | } | 336 | } |
337 | #endif | ||
327 | mFilterView->hide(); | 338 | mFilterView->hide(); |
328 | QWidget *rightBox = new QWidget( mainBox ); | 339 | QWidget *rightBox = new QWidget( mainBox ); |
329 | mainBoxLayout->addWidget ( rightBox, 10 ); | 340 | mainBoxLayout->addWidget ( rightBox, 10 ); |
330 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
331 | mRightFrame = new QWidgetStack( rightBox ); | 342 | mRightFrame = new QWidgetStack( rightBox ); |
332 | rightLayout->addWidget( mRightFrame, 10 ); | 343 | rightLayout->addWidget( mRightFrame, 10 ); |
333 | 344 | ||
334 | mLeftFrame = leftFrame; | 345 | //mLeftFrame = (QWidget *)leftFrame; |
335 | if ( KOPrefs::instance()->mVerticalScreen ) { | 346 | if ( KOPrefs::instance()->mVerticalScreen ) { |
336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
349 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | ||
350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | ||
338 | } else { | 351 | } else { |
339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 353 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | ||
341 | } | 355 | } |
342 | if ( !KOPrefs::instance()->mShowDateNavigator) | 356 | if ( !KOPrefs::instance()->mShowDateNavigator) |
343 | mDateNavigator->hide(); | 357 | mLeftFrame->toggle(); |
344 | //qDebug("Calendarview Size %d %d ", width(), height()); | 358 | //qDebug("Calendarview Size %d %d ", width(), height()); |
345 | #endif | 359 | #endif |
346 | 360 | ||
347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
348 | SLOT( showDates( const KCal::DateList & ) ) ); | 362 | SLOT( showDates( const KCal::DateList & ) ) ); |
349 | 363 | ||
350 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
351 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
352 | 366 | ||
353 | 367 | ||
354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
356 | 370 | ||
357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
358 | mNavigator, SLOT( selectPreviousYear() ) ); | 372 | mNavigator, SLOT( selectPreviousYear() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 373 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
360 | mNavigator, SLOT( selectNextYear() ) ); | 374 | mNavigator, SLOT( selectNextYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
362 | mNavigator, SLOT( selectPreviousMonth() ) ); | 376 | mNavigator, SLOT( selectPreviousMonth() ) ); |
363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
364 | mNavigator, SLOT( selectNextMonth() ) ); | 378 | mNavigator, SLOT( selectNextMonth() ) ); |
365 | 379 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 380 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
367 | mNavigator, SLOT( selectPrevious() ) ); | 381 | mNavigator, SLOT( selectPrevious() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNext() ), | 382 | connect( mDateNavigator, SIGNAL( goNext() ), |
369 | mNavigator, SLOT( selectNext() ) ); | 383 | mNavigator, SLOT( selectNext() ) ); |
370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
372 | 386 | ||
373 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
374 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
375 | 389 | #if 0 | |
376 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
377 | SLOT( eventAdded( Event *) ) ); | 391 | SLOT( incidenceAdded( Incidence *) ) ); |
378 | 392 | #endif | |
379 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
380 | 394 | ||
381 | connect( this, SIGNAL( configChanged() ), | 395 | connect( this, SIGNAL( configChanged() ), |
382 | mDateNavigator, SLOT( updateConfig() ) ); | 396 | mDateNavigator, SLOT( updateConfig() ) ); |
383 | 397 | ||
384 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 398 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
385 | SLOT( newTodo() ) ); | 399 | SLOT( newTodo() ) ); |
386 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
387 | SLOT( newSubTodo( Todo * ) ) ); | 401 | SLOT( newSubTodo( Todo * ) ) ); |
388 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
389 | SLOT( editTodo( Todo * ) ) ); | 403 | SLOT( editTodo( Todo * ) ) ); |
390 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
391 | SLOT( showTodo( Todo *) ) ); | 405 | SLOT( showTodo( Todo *) ) ); |
392 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
393 | SLOT( deleteTodo( Todo *) ) ); | 407 | SLOT( deleteTodo( Todo *) ) ); |
394 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
395 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
396 | SLOT( purgeCompleted() ) ); | 410 | SLOT( purgeCompleted() ) ); |
397 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
398 | SIGNAL( todoModified( Todo *, int ) ) ); | 412 | SIGNAL( todoModified( Todo *, int ) ) ); |
399 | 413 | ||
400 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
401 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
402 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
403 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 417 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
404 | 418 | ||
405 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
406 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 420 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
407 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
408 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 422 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
409 | 423 | ||
410 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
411 | this, SLOT ( todo_unsub( Todo * ) ) ); | 425 | this, SLOT ( todo_unsub( Todo * ) ) ); |
412 | 426 | ||
413 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
414 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
416 | SLOT( updateTodo( Todo *, int ) ) ); | 430 | SLOT( updateTodo( Todo *, int ) ) ); |
417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
419 | 433 | ||
420 | 434 | ||
421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
425 | 439 | ||
426 | 440 | ||
427 | 441 | ||
428 | 442 | ||
429 | 443 | ||
430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
431 | SLOT(checkClipboard())); | 445 | SLOT(checkClipboard())); |
432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
433 | SLOT( processTodoListSelection( Incidence * ) ) ); | 447 | SLOT( processTodoListSelection( Incidence * ) ) ); |
434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
435 | 449 | ||
436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
437 | 451 | ||
438 | mDateFrame = new QVBox(0,0,WType_Popup); | 452 | mDateFrame = new QVBox(0,0,WType_Popup); |
439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
441 | mDateFrame->setLineWidth(3); | 455 | mDateFrame->setLineWidth(3); |
442 | mDateFrame->hide(); | 456 | mDateFrame->hide(); |
443 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 457 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
445 | 459 | ||
446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
447 | 461 | ||
448 | mEventEditor = mDialogManager->getEventEditor(); | 462 | mEventEditor = mDialogManager->getEventEditor(); |
449 | mTodoEditor = mDialogManager->getTodoEditor(); | 463 | mTodoEditor = mDialogManager->getTodoEditor(); |
450 | 464 | ||
451 | mFlagEditDescription = false; | 465 | mFlagEditDescription = false; |
452 | 466 | ||
453 | mSuspendTimer = new QTimer( this ); | 467 | mSuspendTimer = new QTimer( this ); |
454 | mAlarmTimer = new QTimer( this ); | 468 | mAlarmTimer = new QTimer( this ); |
455 | mRecheckAlarmTimer = new QTimer( this ); | 469 | mRecheckAlarmTimer = new QTimer( this ); |
456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
459 | mAlarmDialog = new AlarmDialog( this ); | 473 | mAlarmDialog = new AlarmDialog( this ); |
460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
461 | mAlarmDialog->setServerNotification( false ); | 475 | mAlarmDialog->setServerNotification( false ); |
462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
463 | 477 | ||
464 | 478 | ||
465 | #ifndef DESKTOP_VERSION | 479 | #ifndef DESKTOP_VERSION |
466 | //US listen for arriving address resultsets | 480 | //US listen for arriving address resultsets |
467 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
468 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
469 | #endif | 483 | #endif |
470 | 484 | mDateNavigator->setCalendar( mCalendar ); | |
471 | } | 485 | } |
472 | 486 | ||
473 | 487 | ||
474 | CalendarView::~CalendarView() | 488 | CalendarView::~CalendarView() |
475 | { | 489 | { |
476 | // kdDebug() << "~CalendarView()" << endl; | 490 | // kdDebug() << "~CalendarView()" << endl; |
477 | //qDebug("CalendarView::~CalendarView() "); | 491 | //qDebug("CalendarView::~CalendarView() "); |
478 | delete mDialogManager; | 492 | delete mDialogManager; |
479 | delete mViewManager; | 493 | delete mViewManager; |
480 | delete mStorage; | 494 | delete mStorage; |
481 | delete mDateFrame ; | 495 | delete mDateFrame ; |
482 | delete beamDialog; | 496 | delete beamDialog; |
483 | delete mEventViewerDialog; | 497 | delete mEventViewerDialog; |
484 | //kdDebug() << "~CalendarView() done" << endl; | 498 | //kdDebug() << "~CalendarView() done" << endl; |
485 | } | 499 | } |
486 | 500 | ||
487 | void CalendarView::showDay( QDate d ) | 501 | void CalendarView::showDay( QDate d ) |
488 | { | 502 | { |
489 | dateNavigator()->blockSignals( true ); | 503 | dateNavigator()->blockSignals( true ); |
490 | dateNavigator()->selectDate( d ); | 504 | dateNavigator()->selectDate( d ); |
491 | dateNavigator()->blockSignals( false ); | 505 | dateNavigator()->blockSignals( false ); |
492 | mViewManager->showDayView(); | 506 | mViewManager->showDayView(); |
493 | //dateNavigator()->selectDate( d ); | 507 | //dateNavigator()->selectDate( d ); |
494 | } | 508 | } |
495 | void CalendarView::timerAlarm() | 509 | void CalendarView::timerAlarm() |
496 | { | 510 | { |
497 | //qDebug("CalendarView::timerAlarm() "); | 511 | //qDebug("CalendarView::timerAlarm() "); |
498 | computeAlarm(mAlarmNotification ); | 512 | computeAlarm(mAlarmNotification ); |
499 | } | 513 | } |
500 | 514 | ||
501 | void CalendarView::suspendAlarm() | 515 | void CalendarView::suspendAlarm() |
502 | { | 516 | { |
503 | //qDebug(" CalendarView::suspendAlarm() "); | 517 | //qDebug(" CalendarView::suspendAlarm() "); |
504 | computeAlarm(mSuspendAlarmNotification ); | 518 | computeAlarm(mSuspendAlarmNotification ); |
505 | 519 | ||
506 | } | 520 | } |
507 | 521 | ||
508 | void CalendarView::startAlarm( QString mess , QString filename) | 522 | void CalendarView::startAlarm( QString mess , QString filename) |
509 | { | 523 | { |
510 | 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 ); |
511 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
512 | 526 | ||
513 | } | 527 | } |
514 | 528 | ||
515 | void CalendarView::checkNextTimerAlarm() | 529 | void CalendarView::checkNextTimerAlarm() |
516 | { | 530 | { |
517 | mCalendar->checkAlarmForIncidence( 0, true ); | 531 | mCalendar->checkAlarmForIncidence( 0, true ); |
518 | } | 532 | } |
519 | 533 | ||
520 | void CalendarView::computeAlarm( QString msg ) | 534 | void CalendarView::computeAlarm( QString msg ) |
521 | { | 535 | { |
522 | 536 | ||
523 | QString mess = msg; | 537 | QString mess = msg; |
524 | QString mAlarmMessage = mess.mid( 9 ); | 538 | QString mAlarmMessage = mess.mid( 9 ); |
525 | QString filename = MainWindow::resourcePath(); | 539 | QString filename = MainWindow::resourcePath(); |
526 | filename += "koalarm.wav"; | 540 | filename += "koalarm.wav"; |
527 | QString tempfilename; | 541 | QString tempfilename; |
528 | if ( mess.left( 13 ) == "suspend_alarm") { | 542 | if ( mess.left( 13 ) == "suspend_alarm") { |
529 | bool error = false; | 543 | bool error = false; |
530 | int len = mess.mid( 13 ).find("+++"); | 544 | int len = mess.mid( 13 ).find("+++"); |
531 | if ( len < 2 ) | 545 | if ( len < 2 ) |
532 | error = true; | 546 | error = true; |
533 | else { | 547 | else { |
534 | tempfilename = mess.mid( 13, len ); | 548 | tempfilename = mess.mid( 13, len ); |
535 | if ( !QFile::exists( tempfilename ) ) | 549 | if ( !QFile::exists( tempfilename ) ) |
536 | error = true; | 550 | error = true; |
537 | } | 551 | } |
538 | if ( ! error ) { | 552 | if ( ! error ) { |
539 | filename = tempfilename; | 553 | filename = tempfilename; |
540 | } | 554 | } |
541 | mAlarmMessage = mess.mid( 13+len+3 ); | 555 | mAlarmMessage = mess.mid( 13+len+3 ); |
542 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 556 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
543 | startAlarm( mAlarmMessage, filename); | 557 | startAlarm( mAlarmMessage, filename); |
544 | return; | 558 | return; |
545 | } | 559 | } |
546 | if ( mess.left( 11 ) == "timer_alarm") { | 560 | if ( mess.left( 11 ) == "timer_alarm") { |
547 | //mTimerTime = 0; | 561 | //mTimerTime = 0; |
548 | startAlarm( mess.mid( 11 ), filename ); | 562 | startAlarm( mess.mid( 11 ), filename ); |
549 | return; | 563 | return; |
550 | } | 564 | } |
551 | if ( mess.left( 10 ) == "proc_alarm") { | 565 | if ( mess.left( 10 ) == "proc_alarm") { |
552 | bool error = false; | 566 | bool error = false; |
553 | int len = mess.mid( 10 ).find("+++"); | 567 | int len = mess.mid( 10 ).find("+++"); |
554 | if ( len < 2 ) | 568 | if ( len < 2 ) |
555 | error = true; | 569 | error = true; |
556 | else { | 570 | else { |
557 | tempfilename = mess.mid( 10, len ); | 571 | tempfilename = mess.mid( 10, len ); |
558 | if ( !QFile::exists( tempfilename ) ) | 572 | if ( !QFile::exists( tempfilename ) ) |
559 | error = true; | 573 | error = true; |
560 | } | 574 | } |
561 | if ( error ) { | 575 | if ( error ) { |
562 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
563 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 577 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
564 | } else { | 578 | } else { |
565 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
566 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 580 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
567 | #ifndef _WIN32_ | 581 | #ifndef _WIN32_ |
568 | if ( vfork () == 0 ) { | 582 | if ( vfork () == 0 ) { |
569 | execl ( tempfilename.latin1(), 0 ); | 583 | execl ( tempfilename.latin1(), 0 ); |
570 | return; | 584 | return; |
571 | } | 585 | } |
572 | #else | 586 | #else |
573 | QProcess* p = new QProcess(); | 587 | QProcess* p = new QProcess(); |
574 | p->addArgument( tempfilename.latin1() ); | 588 | p->addArgument( tempfilename.latin1() ); |
575 | p->start(); | 589 | p->start(); |
576 | return; | 590 | return; |
577 | #endif | 591 | #endif |
578 | 592 | ||
579 | return; | 593 | return; |
580 | } | 594 | } |
581 | 595 | ||
582 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
583 | } | 597 | } |
584 | if ( mess.left( 11 ) == "audio_alarm") { | 598 | if ( mess.left( 11 ) == "audio_alarm") { |
585 | bool error = false; | 599 | bool error = false; |
586 | int len = mess.mid( 11 ).find("+++"); | 600 | int len = mess.mid( 11 ).find("+++"); |
587 | if ( len < 2 ) | 601 | if ( len < 2 ) |
588 | error = true; | 602 | error = true; |
589 | else { | 603 | else { |
590 | tempfilename = mess.mid( 11, len ); | 604 | tempfilename = mess.mid( 11, len ); |
591 | if ( !QFile::exists( tempfilename ) ) | 605 | if ( !QFile::exists( tempfilename ) ) |
592 | error = true; | 606 | error = true; |
593 | } | 607 | } |
594 | if ( ! error ) { | 608 | if ( ! error ) { |
595 | filename = tempfilename; | 609 | filename = tempfilename; |
596 | } | 610 | } |
597 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 611 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
598 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 612 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
599 | } | 613 | } |
600 | if ( mess.left( 9 ) == "cal_alarm") { | 614 | if ( mess.left( 9 ) == "cal_alarm") { |
601 | mAlarmMessage = mess.mid( 9 ) ; | 615 | mAlarmMessage = mess.mid( 9 ) ; |
602 | } | 616 | } |
603 | 617 | ||
604 | startAlarm( mAlarmMessage, filename ); | 618 | startAlarm( mAlarmMessage, filename ); |
605 | 619 | ||
606 | 620 | ||
607 | } | 621 | } |
608 | 622 | ||
609 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
610 | { | 624 | { |
611 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
612 | 626 | ||
613 | mSuspendAlarmNotification = noti; | 627 | mSuspendAlarmNotification = noti; |
614 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
615 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
616 | mSuspendTimer->start( ms , true ); | 630 | mSuspendTimer->start( ms , true ); |
617 | 631 | ||
618 | } | 632 | } |
619 | 633 | ||
620 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
621 | { | 635 | { |
622 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
623 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
624 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
625 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
626 | #endif | 640 | #endif |
627 | return; | 641 | return; |
628 | } | 642 | } |
629 | int maxSec; | 643 | int maxSec; |
630 | //maxSec = 5; //testing only | 644 | //maxSec = 5; //testing only |
631 | maxSec = 86400+3600; // one day+1hour | 645 | maxSec = 86400+3600; // one day+1hour |
632 | mAlarmNotification = noti; | 646 | mAlarmNotification = noti; |
633 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
634 | if ( sec > maxSec ) { | 648 | if ( sec > maxSec ) { |
635 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 649 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
636 | // 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 ); |
637 | return; | 651 | return; |
638 | } else { | 652 | } else { |
639 | mRecheckAlarmTimer->stop(); | 653 | mRecheckAlarmTimer->stop(); |
640 | } | 654 | } |
641 | //qDebug("Alarm timer started with secs: %d ", sec); | 655 | //qDebug("Alarm timer started with secs: %d ", sec); |
642 | mAlarmTimer->start( sec *1000 , true ); | 656 | mAlarmTimer->start( sec *1000 , true ); |
643 | 657 | ||
644 | } | 658 | } |
645 | // called by mRecheckAlarmTimer to get next alarm | 659 | // called by mRecheckAlarmTimer to get next alarm |
646 | // 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 |
647 | void CalendarView::recheckTimerAlarm() | 661 | void CalendarView::recheckTimerAlarm() |
648 | { | 662 | { |
649 | mAlarmTimer->stop(); | 663 | mAlarmTimer->stop(); |
650 | mRecheckAlarmTimer->stop(); | 664 | mRecheckAlarmTimer->stop(); |
651 | mCalendar->checkAlarmForIncidence( 0, true ); | 665 | mCalendar->checkAlarmForIncidence( 0, true ); |
652 | } | 666 | } |
653 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
654 | { | 668 | { |
655 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
656 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
657 | #ifndef DESKTOP_VERSION | 671 | #ifndef DESKTOP_VERSION |
658 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
659 | #endif | 673 | #endif |
660 | return; | 674 | return; |
661 | } | 675 | } |
662 | mAlarmTimer->stop(); | 676 | mAlarmTimer->stop(); |
663 | } | 677 | } |
664 | void CalendarView::selectWeekNum ( int num ) | 678 | void CalendarView::selectWeekNum ( int num ) |
665 | { | 679 | { |
666 | dateNavigator()->blockSignals( true ); | 680 | dateNavigator()->blockSignals( true ); |
667 | dateNavigator()->selectWeek( num ); | 681 | dateNavigator()->selectWeek( num ); |
668 | dateNavigator()->blockSignals( false ); | 682 | dateNavigator()->blockSignals( false ); |
669 | mViewManager->showWeekView(); | 683 | mViewManager->showWeekView(); |
670 | } | 684 | } |
671 | KOViewManager *CalendarView::viewManager() | 685 | KOViewManager *CalendarView::viewManager() |
672 | { | 686 | { |
673 | return mViewManager; | 687 | return mViewManager; |
674 | } | 688 | } |
675 | 689 | ||
676 | KODialogManager *CalendarView::dialogManager() | 690 | KODialogManager *CalendarView::dialogManager() |
677 | { | 691 | { |
678 | return mDialogManager; | 692 | return mDialogManager; |
679 | } | 693 | } |
680 | 694 | ||
681 | QDate CalendarView::startDate() | 695 | QDate CalendarView::startDate() |
682 | { | 696 | { |
683 | DateList dates = mNavigator->selectedDates(); | 697 | DateList dates = mNavigator->selectedDates(); |
684 | 698 | ||
685 | return dates.first(); | 699 | return dates.first(); |
686 | } | 700 | } |
687 | 701 | ||
688 | QDate CalendarView::endDate() | 702 | QDate CalendarView::endDate() |
689 | { | 703 | { |
690 | DateList dates = mNavigator->selectedDates(); | 704 | DateList dates = mNavigator->selectedDates(); |
691 | 705 | ||
692 | return dates.last(); | 706 | return dates.last(); |
693 | } | 707 | } |
694 | 708 | ||
695 | 709 | ||
696 | void CalendarView::createPrinter() | 710 | void CalendarView::createPrinter() |
697 | { | 711 | { |
698 | #ifndef KORG_NOPRINTER | 712 | #ifndef KORG_NOPRINTER |
699 | if (!mCalPrinter) { | 713 | if (!mCalPrinter) { |
700 | mCalPrinter = new CalPrinter(this, mCalendar); | 714 | mCalPrinter = new CalPrinter(this, mCalendar); |
701 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
702 | } | 716 | } |
703 | #endif | 717 | #endif |
704 | } | 718 | } |
705 | 719 | ||
706 | 720 | ||
707 | //KOPrefs::instance()->mWriteBackFile | 721 | //KOPrefs::instance()->mWriteBackFile |
708 | //KOPrefs::instance()->mWriteBackExistingOnly | 722 | //KOPrefs::instance()->mWriteBackExistingOnly |
709 | 723 | ||
710 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
711 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
712 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
713 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
714 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
715 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
716 | 730 | ||
717 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
718 | { | 732 | { |
719 | 733 | ||
720 | // 0 equal | 734 | // 0 equal |
721 | // 1 take local | 735 | // 1 take local |
722 | // 2 take remote | 736 | // 2 take remote |
723 | // 3 cancel | 737 | // 3 cancel |
724 | QDateTime lastSync = mLastCalendarSync; | 738 | QDateTime lastSync = mLastCalendarSync; |
725 | QDateTime localMod = local->lastModified(); | 739 | QDateTime localMod = local->lastModified(); |
726 | QDateTime remoteMod = remote->lastModified(); | 740 | QDateTime remoteMod = remote->lastModified(); |
@@ -3432,531 +3446,535 @@ void CalendarView::eventUpdated(Incidence *) | |||
3432 | // event is responsible for updating the view. | 3446 | // event is responsible for updating the view. |
3433 | // updateView(); | 3447 | // updateView(); |
3434 | } | 3448 | } |
3435 | 3449 | ||
3436 | void CalendarView::adaptNavigationUnits() | 3450 | void CalendarView::adaptNavigationUnits() |
3437 | { | 3451 | { |
3438 | if (mViewManager->currentView()->isEventView()) { | 3452 | if (mViewManager->currentView()->isEventView()) { |
3439 | int days = mViewManager->currentView()->currentDateCount(); | 3453 | int days = mViewManager->currentView()->currentDateCount(); |
3440 | if (days == 1) { | 3454 | if (days == 1) { |
3441 | emit changeNavStringPrev(i18n("&Previous Day")); | 3455 | emit changeNavStringPrev(i18n("&Previous Day")); |
3442 | emit changeNavStringNext(i18n("&Next Day")); | 3456 | emit changeNavStringNext(i18n("&Next Day")); |
3443 | } else { | 3457 | } else { |
3444 | emit changeNavStringPrev(i18n("&Previous Week")); | 3458 | emit changeNavStringPrev(i18n("&Previous Week")); |
3445 | emit changeNavStringNext(i18n("&Next Week")); | 3459 | emit changeNavStringNext(i18n("&Next Week")); |
3446 | } | 3460 | } |
3447 | } | 3461 | } |
3448 | } | 3462 | } |
3449 | 3463 | ||
3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3464 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3451 | { | 3465 | { |
3452 | if ( incidence ) mTodoList->clearSelection(); | 3466 | if ( incidence ) mTodoList->clearSelection(); |
3453 | processIncidenceSelection( incidence ); | 3467 | processIncidenceSelection( incidence ); |
3454 | } | 3468 | } |
3455 | 3469 | ||
3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3470 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3457 | { | 3471 | { |
3458 | if ( incidence && mViewManager->currentView() ) { | 3472 | if ( incidence && mViewManager->currentView() ) { |
3459 | mViewManager->currentView()->clearSelection(); | 3473 | mViewManager->currentView()->clearSelection(); |
3460 | } | 3474 | } |
3461 | processIncidenceSelection( incidence ); | 3475 | processIncidenceSelection( incidence ); |
3462 | } | 3476 | } |
3463 | 3477 | ||
3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3478 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3465 | { | 3479 | { |
3466 | if ( incidence == mSelectedIncidence ) return; | 3480 | if ( incidence == mSelectedIncidence ) return; |
3467 | 3481 | ||
3468 | mSelectedIncidence = incidence; | 3482 | mSelectedIncidence = incidence; |
3469 | 3483 | ||
3470 | emit incidenceSelected( mSelectedIncidence ); | 3484 | emit incidenceSelected( mSelectedIncidence ); |
3471 | 3485 | ||
3472 | if ( incidence && incidence->type() == "Event" ) { | 3486 | if ( incidence && incidence->type() == "Event" ) { |
3473 | Event *event = static_cast<Event *>( incidence ); | 3487 | Event *event = static_cast<Event *>( incidence ); |
3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3488 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3475 | emit organizerEventsSelected( true ); | 3489 | emit organizerEventsSelected( true ); |
3476 | } else { | 3490 | } else { |
3477 | emit organizerEventsSelected(false); | 3491 | emit organizerEventsSelected(false); |
3478 | } | 3492 | } |
3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3493 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3480 | KOPrefs::instance()->email() ) ) { | 3494 | KOPrefs::instance()->email() ) ) { |
3481 | emit groupEventsSelected( true ); | 3495 | emit groupEventsSelected( true ); |
3482 | } else { | 3496 | } else { |
3483 | emit groupEventsSelected(false); | 3497 | emit groupEventsSelected(false); |
3484 | } | 3498 | } |
3485 | return; | 3499 | return; |
3486 | } else { | 3500 | } else { |
3487 | if ( incidence && incidence->type() == "Todo" ) { | 3501 | if ( incidence && incidence->type() == "Todo" ) { |
3488 | emit todoSelected( true ); | 3502 | emit todoSelected( true ); |
3489 | Todo *event = static_cast<Todo *>( incidence ); | 3503 | Todo *event = static_cast<Todo *>( incidence ); |
3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3504 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3491 | emit organizerEventsSelected( true ); | 3505 | emit organizerEventsSelected( true ); |
3492 | } else { | 3506 | } else { |
3493 | emit organizerEventsSelected(false); | 3507 | emit organizerEventsSelected(false); |
3494 | } | 3508 | } |
3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3509 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3496 | KOPrefs::instance()->email() ) ) { | 3510 | KOPrefs::instance()->email() ) ) { |
3497 | emit groupEventsSelected( true ); | 3511 | emit groupEventsSelected( true ); |
3498 | } else { | 3512 | } else { |
3499 | emit groupEventsSelected(false); | 3513 | emit groupEventsSelected(false); |
3500 | } | 3514 | } |
3501 | return; | 3515 | return; |
3502 | } else { | 3516 | } else { |
3503 | emit todoSelected( false ); | 3517 | emit todoSelected( false ); |
3504 | emit organizerEventsSelected(false); | 3518 | emit organizerEventsSelected(false); |
3505 | emit groupEventsSelected(false); | 3519 | emit groupEventsSelected(false); |
3506 | } | 3520 | } |
3507 | return; | 3521 | return; |
3508 | } | 3522 | } |
3509 | 3523 | ||
3510 | /* if ( incidence && incidence->type() == "Todo" ) { | 3524 | /* if ( incidence && incidence->type() == "Todo" ) { |
3511 | emit todoSelected( true ); | 3525 | emit todoSelected( true ); |
3512 | } else { | 3526 | } else { |
3513 | emit todoSelected( false ); | 3527 | emit todoSelected( false ); |
3514 | }*/ | 3528 | }*/ |
3515 | } | 3529 | } |
3516 | 3530 | ||
3517 | 3531 | ||
3518 | void CalendarView::checkClipboard() | 3532 | void CalendarView::checkClipboard() |
3519 | { | 3533 | { |
3520 | #ifndef KORG_NODND | 3534 | #ifndef KORG_NODND |
3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3535 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3522 | emit pasteEnabled(true); | 3536 | emit pasteEnabled(true); |
3523 | } else { | 3537 | } else { |
3524 | emit pasteEnabled(false); | 3538 | emit pasteEnabled(false); |
3525 | } | 3539 | } |
3526 | #endif | 3540 | #endif |
3527 | } | 3541 | } |
3528 | 3542 | ||
3529 | void CalendarView::showDates(const DateList &selectedDates) | 3543 | void CalendarView::showDates(const DateList &selectedDates) |
3530 | { | 3544 | { |
3531 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3545 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3532 | 3546 | ||
3533 | 3547 | ||
3534 | if ( !mBlockShowDates ) { | 3548 | if ( !mBlockShowDates ) { |
3535 | if ( mViewManager->currentView() ) { | 3549 | if ( mViewManager->currentView() ) { |
3536 | updateView( selectedDates.first(), selectedDates.last() ); | 3550 | updateView( selectedDates.first(), selectedDates.last() ); |
3537 | } else { | 3551 | } else { |
3538 | mViewManager->showAgendaView(); | 3552 | mViewManager->showAgendaView(); |
3539 | } | 3553 | } |
3540 | } | 3554 | } |
3541 | 3555 | ||
3542 | QString selDates; | 3556 | QString selDates; |
3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3557 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3544 | if (selectedDates.first() < selectedDates.last() ) | 3558 | if (selectedDates.first() < selectedDates.last() ) |
3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3559 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3546 | else { | 3560 | else { |
3547 | QString addString; | 3561 | QString addString; |
3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3562 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3549 | addString = i18n("Today"); | 3563 | addString = i18n("Today"); |
3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3564 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3551 | addString = i18n("Tomorrow"); | 3565 | addString = i18n("Tomorrow"); |
3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3566 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3553 | addString = i18n("Yesterday"); | 3567 | addString = i18n("Yesterday"); |
3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3568 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3555 | addString = i18n("Day before yesterday"); | 3569 | addString = i18n("Day before yesterday"); |
3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3570 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3557 | addString = i18n("Day after tomorrow"); | 3571 | addString = i18n("Day after tomorrow"); |
3558 | if ( !addString.isEmpty() ) { | 3572 | if ( !addString.isEmpty() ) { |
3559 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3573 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3560 | return; | 3574 | return; |
3561 | } | 3575 | } |
3562 | } | 3576 | } |
3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3577 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3564 | 3578 | ||
3565 | } | 3579 | } |
3566 | 3580 | ||
3567 | QPtrList<CalFilter> CalendarView::filters() | 3581 | QPtrList<CalFilter> CalendarView::filters() |
3568 | { | 3582 | { |
3569 | return mFilters; | 3583 | return mFilters; |
3570 | 3584 | ||
3571 | } | 3585 | } |
3572 | void CalendarView::editFilters() | 3586 | void CalendarView::editFilters() |
3573 | { | 3587 | { |
3574 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3588 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3575 | 3589 | ||
3576 | CalFilter *filter = mFilters.first(); | 3590 | CalFilter *filter = mFilters.first(); |
3577 | while(filter) { | 3591 | while(filter) { |
3578 | kdDebug() << " Filter: " << filter->name() << endl; | 3592 | kdDebug() << " Filter: " << filter->name() << endl; |
3579 | filter = mFilters.next(); | 3593 | filter = mFilters.next(); |
3580 | } | 3594 | } |
3581 | 3595 | ||
3582 | mDialogManager->showFilterEditDialog(&mFilters); | 3596 | mDialogManager->showFilterEditDialog(&mFilters); |
3583 | } | 3597 | } |
3584 | void CalendarView::toggleFilter() | 3598 | void CalendarView::toggleFilter() |
3585 | { | 3599 | { |
3586 | showFilter(! mFilterView->isVisible()); | 3600 | showFilter(! mFilterView->isVisible()); |
3587 | } | 3601 | } |
3588 | 3602 | ||
3589 | KOFilterView *CalendarView::filterView() | 3603 | KOFilterView *CalendarView::filterView() |
3590 | { | 3604 | { |
3591 | return mFilterView; | 3605 | return mFilterView; |
3592 | } | 3606 | } |
3593 | void CalendarView::selectFilter( int fil ) | 3607 | void CalendarView::selectFilter( int fil ) |
3594 | { | 3608 | { |
3595 | mFilterView->setSelectedFilter( fil ); | 3609 | mFilterView->setSelectedFilter( fil ); |
3596 | } | 3610 | } |
3597 | void CalendarView::showFilter(bool visible) | 3611 | void CalendarView::showFilter(bool visible) |
3598 | { | 3612 | { |
3599 | if (visible) mFilterView->show(); | 3613 | if (visible) mFilterView->show(); |
3600 | else mFilterView->hide(); | 3614 | else mFilterView->hide(); |
3601 | } | 3615 | } |
3602 | void CalendarView::toggleFilerEnabled( ) | 3616 | void CalendarView::toggleFilerEnabled( ) |
3603 | { | 3617 | { |
3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3618 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3605 | if ( !mFilterView->filtersEnabled() ) | 3619 | if ( !mFilterView->filtersEnabled() ) |
3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3620 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3607 | 3621 | ||
3608 | } | 3622 | } |
3609 | void CalendarView::updateFilter() | 3623 | void CalendarView::updateFilter() |
3610 | { | 3624 | { |
3611 | CalFilter *filter = mFilterView->selectedFilter(); | 3625 | CalFilter *filter = mFilterView->selectedFilter(); |
3612 | if (filter) { | 3626 | if (filter) { |
3613 | QString mess; | 3627 | QString mess; |
3614 | if (mFilterView->filtersEnabled()) { | 3628 | if (mFilterView->filtersEnabled()) { |
3615 | mess = i18n("Filter selected: ")+filter->name(); | 3629 | mess = i18n("Filter selected: ")+filter->name(); |
3616 | filter->setEnabled(true); | 3630 | filter->setEnabled(true); |
3617 | } | 3631 | } |
3618 | else filter->setEnabled(false); | 3632 | else filter->setEnabled(false); |
3619 | mCalendar->setFilter(filter); | 3633 | mCalendar->setFilter(filter); |
3620 | updateView(); | 3634 | updateView(); |
3621 | if ( !mess.isEmpty() ) | 3635 | if ( !mess.isEmpty() ) |
3622 | topLevelWidget()->setCaption( mess ); | 3636 | topLevelWidget()->setCaption( mess ); |
3623 | 3637 | ||
3624 | } | 3638 | } |
3625 | } | 3639 | } |
3626 | 3640 | ||
3627 | void CalendarView::filterEdited() | 3641 | void CalendarView::filterEdited() |
3628 | { | 3642 | { |
3629 | mFilterView->updateFilters(); | 3643 | mFilterView->updateFilters(); |
3630 | updateFilter(); | 3644 | updateFilter(); |
3631 | writeSettings(); | 3645 | writeSettings(); |
3632 | } | 3646 | } |
3633 | 3647 | ||
3634 | 3648 | ||
3635 | void CalendarView::takeOverEvent() | 3649 | void CalendarView::takeOverEvent() |
3636 | { | 3650 | { |
3637 | Incidence *incidence = currentSelection(); | 3651 | Incidence *incidence = currentSelection(); |
3638 | 3652 | ||
3639 | if (!incidence) return; | 3653 | if (!incidence) return; |
3640 | 3654 | ||
3641 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3655 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3642 | incidence->recreate(); | 3656 | incidence->recreate(); |
3643 | incidence->setReadOnly(false); | 3657 | incidence->setReadOnly(false); |
3644 | 3658 | ||
3645 | updateView(); | 3659 | updateView(); |
3646 | } | 3660 | } |
3647 | 3661 | ||
3648 | void CalendarView::takeOverCalendar() | 3662 | void CalendarView::takeOverCalendar() |
3649 | { | 3663 | { |
3650 | // TODO: Create Calendar::allIncidences() function and use it here | 3664 | // TODO: Create Calendar::allIncidences() function and use it here |
3651 | 3665 | ||
3652 | QPtrList<Event> events = mCalendar->events(); | 3666 | QPtrList<Event> events = mCalendar->events(); |
3653 | for(uint i=0; i<events.count(); ++i) { | 3667 | for(uint i=0; i<events.count(); ++i) { |
3654 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3668 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3655 | events.at(i)->recreate(); | 3669 | events.at(i)->recreate(); |
3656 | events.at(i)->setReadOnly(false); | 3670 | events.at(i)->setReadOnly(false); |
3657 | } | 3671 | } |
3658 | 3672 | ||
3659 | QPtrList<Todo> todos = mCalendar->todos(); | 3673 | QPtrList<Todo> todos = mCalendar->todos(); |
3660 | for(uint i=0; i<todos.count(); ++i) { | 3674 | for(uint i=0; i<todos.count(); ++i) { |
3661 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3675 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3662 | todos.at(i)->recreate(); | 3676 | todos.at(i)->recreate(); |
3663 | todos.at(i)->setReadOnly(false); | 3677 | todos.at(i)->setReadOnly(false); |
3664 | } | 3678 | } |
3665 | 3679 | ||
3666 | QPtrList<Journal> journals = mCalendar->journals(); | 3680 | QPtrList<Journal> journals = mCalendar->journals(); |
3667 | for(uint i=0; i<journals.count(); ++i) { | 3681 | for(uint i=0; i<journals.count(); ++i) { |
3668 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3682 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3669 | journals.at(i)->recreate(); | 3683 | journals.at(i)->recreate(); |
3670 | journals.at(i)->setReadOnly(false); | 3684 | journals.at(i)->setReadOnly(false); |
3671 | } | 3685 | } |
3672 | 3686 | ||
3673 | updateView(); | 3687 | updateView(); |
3674 | } | 3688 | } |
3675 | 3689 | ||
3676 | void CalendarView::showIntro() | 3690 | void CalendarView::showIntro() |
3677 | { | 3691 | { |
3678 | kdDebug() << "To be implemented." << endl; | 3692 | kdDebug() << "To be implemented." << endl; |
3679 | } | 3693 | } |
3680 | 3694 | ||
3681 | QWidgetStack *CalendarView::viewStack() | 3695 | QWidgetStack *CalendarView::viewStack() |
3682 | { | 3696 | { |
3683 | return mRightFrame; | 3697 | return mRightFrame; |
3684 | } | 3698 | } |
3685 | 3699 | ||
3686 | QWidget *CalendarView::leftFrame() | 3700 | QWidget *CalendarView::leftFrame() |
3687 | { | 3701 | { |
3688 | return mLeftFrame; | 3702 | return ( QWidget *)mLeftFrame; |
3689 | } | 3703 | } |
3690 | 3704 | ||
3691 | DateNavigator *CalendarView::dateNavigator() | 3705 | DateNavigator *CalendarView::dateNavigator() |
3692 | { | 3706 | { |
3693 | return mNavigator; | 3707 | return mNavigator; |
3694 | } | 3708 | } |
3695 | 3709 | ||
3696 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3710 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3697 | { | 3711 | { |
3698 | return mDateNavigator; | 3712 | return mDateNavigator->navigatorView(); |
3699 | } | 3713 | } |
3700 | void CalendarView::toggleDateNavigatorWidget() | 3714 | void CalendarView::toggleDateNavigatorWidget() |
3701 | { | 3715 | { |
3702 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3716 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3717 | mLeftFrame->toggle(); | ||
3718 | // FIXME mShowDateNavigator is not the toggle state of mLeftFrame | ||
3719 | #if 0 | ||
3703 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3720 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3704 | mDateNavigator->hide(); | 3721 | mDateNavigator->hide(); |
3705 | else | 3722 | else |
3706 | mDateNavigator->show(); | 3723 | mDateNavigator->show(); |
3724 | #endif | ||
3707 | } | 3725 | } |
3708 | void CalendarView::addView(KOrg::BaseView *view) | 3726 | void CalendarView::addView(KOrg::BaseView *view) |
3709 | { | 3727 | { |
3710 | mViewManager->addView(view); | 3728 | mViewManager->addView(view); |
3711 | } | 3729 | } |
3712 | 3730 | ||
3713 | void CalendarView::showView(KOrg::BaseView *view) | 3731 | void CalendarView::showView(KOrg::BaseView *view) |
3714 | { | 3732 | { |
3715 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3733 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3716 | } | 3734 | } |
3717 | 3735 | ||
3718 | Incidence *CalendarView::currentSelection() | 3736 | Incidence *CalendarView::currentSelection() |
3719 | { | 3737 | { |
3720 | return mViewManager->currentSelection(); | 3738 | return mViewManager->currentSelection(); |
3721 | } | 3739 | } |
3722 | void CalendarView::toggleAllDaySize() | 3740 | void CalendarView::toggleAllDaySize() |
3723 | { | 3741 | { |
3724 | /* | 3742 | /* |
3725 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3743 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3726 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3744 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3727 | else | 3745 | else |
3728 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3746 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3729 | */ | 3747 | */ |
3730 | viewManager()->agendaView()->toggleAllDay(); | 3748 | viewManager()->agendaView()->toggleAllDay(); |
3731 | } | 3749 | } |
3732 | void CalendarView::toggleExpand() | 3750 | void CalendarView::toggleExpand() |
3733 | { | 3751 | { |
3734 | // if ( mLeftFrame->isHidden() ) { | 3752 | // if ( mLeftFrame->isHidden() ) { |
3735 | // mLeftFrame->show(); | 3753 | // mLeftFrame->show(); |
3736 | // emit calendarViewExpanded( false ); | 3754 | // emit calendarViewExpanded( false ); |
3737 | // } else { | 3755 | // } else { |
3738 | // mLeftFrame->hide(); | 3756 | // mLeftFrame->hide(); |
3739 | // emit calendarViewExpanded( true ); | 3757 | // emit calendarViewExpanded( true ); |
3740 | // } | 3758 | // } |
3741 | //qDebug(" CalendarView::toggleExpand()"); | 3759 | //qDebug(" CalendarView::toggleExpand()"); |
3742 | globalFlagBlockAgenda = 1; | 3760 | globalFlagBlockAgenda = 1; |
3743 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3761 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3744 | globalFlagBlockAgenda = 5; | 3762 | globalFlagBlockAgenda = 5; |
3745 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3763 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3746 | //mViewManager->showView( 0, true ); | 3764 | //mViewManager->showView( 0, true ); |
3747 | } | 3765 | } |
3748 | 3766 | ||
3749 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3767 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3750 | { | 3768 | { |
3751 | setModified( modified ); | 3769 | setModified( modified ); |
3752 | } | 3770 | } |
3753 | 3771 | ||
3754 | Todo *CalendarView::selectedTodo() | 3772 | Todo *CalendarView::selectedTodo() |
3755 | { | 3773 | { |
3756 | Incidence *incidence = currentSelection(); | 3774 | Incidence *incidence = currentSelection(); |
3757 | if ( incidence && incidence->type() == "Todo" ) { | 3775 | if ( incidence && incidence->type() == "Todo" ) { |
3758 | return static_cast<Todo *>( incidence ); | 3776 | return static_cast<Todo *>( incidence ); |
3759 | } | 3777 | } |
3760 | 3778 | ||
3761 | incidence = mTodoList->selectedIncidences().first(); | 3779 | incidence = mTodoList->selectedIncidences().first(); |
3762 | if ( incidence && incidence->type() == "Todo" ) { | 3780 | if ( incidence && incidence->type() == "Todo" ) { |
3763 | return static_cast<Todo *>( incidence ); | 3781 | return static_cast<Todo *>( incidence ); |
3764 | } | 3782 | } |
3765 | 3783 | ||
3766 | return 0; | 3784 | return 0; |
3767 | } | 3785 | } |
3768 | 3786 | ||
3769 | void CalendarView::dialogClosing(Incidence *in) | 3787 | void CalendarView::dialogClosing(Incidence *in) |
3770 | { | 3788 | { |
3771 | // mDialogList.remove(in); | 3789 | // mDialogList.remove(in); |
3772 | } | 3790 | } |
3773 | 3791 | ||
3774 | void CalendarView::showIncidence() | 3792 | void CalendarView::showIncidence() |
3775 | { | 3793 | { |
3776 | mViewerCallerIsSearchDialog = false; | 3794 | mViewerCallerIsSearchDialog = false; |
3777 | Incidence *incidence = currentSelection(); | 3795 | Incidence *incidence = currentSelection(); |
3778 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3796 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3779 | if ( incidence ) { | 3797 | if ( incidence ) { |
3780 | ShowIncidenceVisitor v; | 3798 | ShowIncidenceVisitor v; |
3781 | v.act( incidence, this ); | 3799 | v.act( incidence, this ); |
3782 | } | 3800 | } |
3783 | } | 3801 | } |
3784 | void CalendarView::editIncidenceDescription() | 3802 | void CalendarView::editIncidenceDescription() |
3785 | { | 3803 | { |
3786 | mFlagEditDescription = true; | 3804 | mFlagEditDescription = true; |
3787 | editIncidence(); | 3805 | editIncidence(); |
3788 | mFlagEditDescription = false; | 3806 | mFlagEditDescription = false; |
3789 | } | 3807 | } |
3790 | void CalendarView::editIncidence() | 3808 | void CalendarView::editIncidence() |
3791 | { | 3809 | { |
3792 | // qDebug("editIncidence() "); | 3810 | // qDebug("editIncidence() "); |
3793 | Incidence *incidence = currentSelection(); | 3811 | Incidence *incidence = currentSelection(); |
3794 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3812 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3795 | if ( incidence ) { | 3813 | if ( incidence ) { |
3796 | EditIncidenceVisitor v; | 3814 | EditIncidenceVisitor v; |
3797 | v.act( incidence, this ); | 3815 | v.act( incidence, this ); |
3798 | } | 3816 | } |
3799 | } | 3817 | } |
3800 | 3818 | ||
3801 | void CalendarView::deleteIncidence() | 3819 | void CalendarView::deleteIncidence() |
3802 | { | 3820 | { |
3803 | Incidence *incidence = currentSelection(); | 3821 | Incidence *incidence = currentSelection(); |
3804 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3822 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3805 | if ( incidence ) { | 3823 | if ( incidence ) { |
3806 | deleteIncidence(incidence); | 3824 | deleteIncidence(incidence); |
3807 | } | 3825 | } |
3808 | } | 3826 | } |
3809 | 3827 | ||
3810 | void CalendarView::showIncidence(Incidence *incidence) | 3828 | void CalendarView::showIncidence(Incidence *incidence) |
3811 | { | 3829 | { |
3812 | mViewerCallerIsSearchDialog = false; | 3830 | mViewerCallerIsSearchDialog = false; |
3813 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3831 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3814 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3832 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3815 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3833 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3816 | mViewerCallerIsSearchDialog = true; | 3834 | mViewerCallerIsSearchDialog = true; |
3817 | } | 3835 | } |
3818 | } | 3836 | } |
3819 | if ( incidence ) { | 3837 | if ( incidence ) { |
3820 | ShowIncidenceVisitor v; | 3838 | ShowIncidenceVisitor v; |
3821 | v.act( incidence, this ); | 3839 | v.act( incidence, this ); |
3822 | } | 3840 | } |
3823 | } | 3841 | } |
3824 | 3842 | ||
3825 | void CalendarView::editIncidence(Incidence *incidence) | 3843 | void CalendarView::editIncidence(Incidence *incidence) |
3826 | { | 3844 | { |
3827 | if ( incidence ) { | 3845 | if ( incidence ) { |
3828 | 3846 | ||
3829 | EditIncidenceVisitor v; | 3847 | EditIncidenceVisitor v; |
3830 | v.act( incidence, this ); | 3848 | v.act( incidence, this ); |
3831 | 3849 | ||
3832 | } | 3850 | } |
3833 | } | 3851 | } |
3834 | 3852 | ||
3835 | void CalendarView::deleteIncidence(Incidence *incidence) | 3853 | void CalendarView::deleteIncidence(Incidence *incidence) |
3836 | { | 3854 | { |
3837 | //qDebug(" CalendarView::deleteIncidence "); | 3855 | //qDebug(" CalendarView::deleteIncidence "); |
3838 | if ( incidence ) { | 3856 | if ( incidence ) { |
3839 | DeleteIncidenceVisitor v; | 3857 | DeleteIncidenceVisitor v; |
3840 | v.act( incidence, this ); | 3858 | v.act( incidence, this ); |
3841 | } | 3859 | } |
3842 | } | 3860 | } |
3843 | 3861 | ||
3844 | 3862 | ||
3845 | void CalendarView::lookForOutgoingMessages() | 3863 | void CalendarView::lookForOutgoingMessages() |
3846 | { | 3864 | { |
3847 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3865 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3848 | ogd->loadMessages(); | 3866 | ogd->loadMessages(); |
3849 | } | 3867 | } |
3850 | 3868 | ||
3851 | void CalendarView::lookForIncomingMessages() | 3869 | void CalendarView::lookForIncomingMessages() |
3852 | { | 3870 | { |
3853 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3871 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3854 | icd->retrieve(); | 3872 | icd->retrieve(); |
3855 | } | 3873 | } |
3856 | 3874 | ||
3857 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3875 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3858 | { | 3876 | { |
3859 | bool deleteTodo = true; | 3877 | bool deleteTodo = true; |
3860 | QPtrList<Incidence> subTodos; | 3878 | QPtrList<Incidence> subTodos; |
3861 | Incidence *aTodo; | 3879 | Incidence *aTodo; |
3862 | subTodos = t->relations(); | 3880 | subTodos = t->relations(); |
3863 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3881 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3864 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3882 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3865 | deleteTodo = false; | 3883 | deleteTodo = false; |
3866 | } | 3884 | } |
3867 | if ( deleteTodo ) { | 3885 | if ( deleteTodo ) { |
3868 | if ( t->isCompleted() && !t->doesRecur()) { | 3886 | if ( t->isCompleted() && !t->doesRecur()) { |
3869 | checkExternalId( t ); | 3887 | checkExternalId( t ); |
3870 | mCalendar->deleteTodo( t ); | 3888 | mCalendar->deleteTodo( t ); |
3871 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3889 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3872 | } | 3890 | } |
3873 | else | 3891 | else |
3874 | deleteTodo = false; | 3892 | deleteTodo = false; |
3875 | } | 3893 | } |
3876 | return deleteTodo; | 3894 | return deleteTodo; |
3877 | 3895 | ||
3878 | } | 3896 | } |
3879 | void CalendarView::purgeCompleted() | 3897 | void CalendarView::purgeCompleted() |
3880 | { | 3898 | { |
3881 | int result = KMessageBox::warningContinueCancel(this, | 3899 | int result = KMessageBox::warningContinueCancel(this, |
3882 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3900 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3883 | 3901 | ||
3884 | if (result == KMessageBox::Continue) { | 3902 | if (result == KMessageBox::Continue) { |
3885 | 3903 | ||
3886 | QPtrList<Todo> todoCal; | 3904 | QPtrList<Todo> todoCal; |
3887 | QPtrList<Todo> rootTodos; | 3905 | QPtrList<Todo> rootTodos; |
3888 | //QPtrList<Incidence> rel; | 3906 | //QPtrList<Incidence> rel; |
3889 | Todo *aTodo;//, *rTodo; | 3907 | Todo *aTodo;//, *rTodo; |
3890 | Incidence *rIncidence; | 3908 | Incidence *rIncidence; |
3891 | bool childDelete = false; | 3909 | bool childDelete = false; |
3892 | bool deletedOne = true; | 3910 | bool deletedOne = true; |
3893 | todoCal = calendar()->todos(); | 3911 | todoCal = calendar()->todos(); |
3894 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3912 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3895 | if ( !aTodo->relatedTo() ) | 3913 | if ( !aTodo->relatedTo() ) |
3896 | rootTodos.append( aTodo ); | 3914 | rootTodos.append( aTodo ); |
3897 | } | 3915 | } |
3898 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3916 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3899 | removeCompletedSubTodos( aTodo ); | 3917 | removeCompletedSubTodos( aTodo ); |
3900 | } | 3918 | } |
3901 | 3919 | ||
3902 | updateView(); | 3920 | updateView(); |
3903 | } | 3921 | } |
3904 | } | 3922 | } |
3905 | 3923 | ||
3906 | void CalendarView::slotCalendarChanged() | 3924 | void CalendarView::slotCalendarChanged() |
3907 | { | 3925 | { |
3908 | ; | 3926 | ; |
3909 | } | 3927 | } |
3910 | 3928 | ||
3911 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3929 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3912 | { | 3930 | { |
3913 | //qDebug(" alendarView::keyPressEvent "); | 3931 | //qDebug(" alendarView::keyPressEvent "); |
3914 | e->ignore(); | 3932 | e->ignore(); |
3915 | } | 3933 | } |
3916 | 3934 | ||
3917 | 3935 | ||
3918 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3936 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3919 | { | 3937 | { |
3920 | // mSyncManager = manager; | 3938 | // mSyncManager = manager; |
3921 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3939 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3922 | qDebug("KO: SyncKDE request detected!"); | 3940 | qDebug("KO: SyncKDE request detected!"); |
3923 | } | 3941 | } |
3924 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3942 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3925 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3943 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3926 | return syncCalendar( filename, mode ); | 3944 | return syncCalendar( filename, mode ); |
3927 | } | 3945 | } |
3928 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3946 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3929 | { | 3947 | { |
3930 | //mSyncManager = manager; | 3948 | //mSyncManager = manager; |
3931 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3949 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3932 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3950 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3933 | if ( resource == "sharp" ) | 3951 | if ( resource == "sharp" ) |
3934 | syncExternal( 0 ); | 3952 | syncExternal( 0 ); |
3935 | if ( resource == "phone" ) | 3953 | if ( resource == "phone" ) |
3936 | syncExternal( 1 ); | 3954 | syncExternal( 1 ); |
3937 | // pending setmodified | 3955 | // pending setmodified |
3938 | return true; | 3956 | return true; |
3939 | } | 3957 | } |
3940 | void CalendarView::setSyncManager(KSyncManager* manager) | 3958 | void CalendarView::setSyncManager(KSyncManager* manager) |
3941 | { | 3959 | { |
3942 | mSyncManager = manager; | 3960 | mSyncManager = manager; |
3943 | } | 3961 | } |
3944 | 3962 | ||
3945 | void CalendarView::removeSyncInfo( QString syncProfile) | 3963 | void CalendarView::removeSyncInfo( QString syncProfile) |
3946 | { | 3964 | { |
3947 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3965 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3948 | mCalendar->removeSyncInfo( syncProfile ); | 3966 | mCalendar->removeSyncInfo( syncProfile ); |
3949 | 3967 | ||
3950 | } | 3968 | } |
3951 | 3969 | ||
3952 | void CalendarView::undo_delete() | 3970 | void CalendarView::undo_delete() |
3953 | { | 3971 | { |
3954 | //qDebug("undo_delete() "); | 3972 | //qDebug("undo_delete() "); |
3955 | Incidence* undo = mCalendar->undoIncidence(); | 3973 | Incidence* undo = mCalendar->undoIncidence(); |
3956 | if ( !undo ) { | 3974 | if ( !undo ) { |
3957 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3975 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3958 | i18n("KO/Pi")); | 3976 | i18n("KO/Pi")); |
3959 | return; | 3977 | return; |
3960 | } | 3978 | } |
3961 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3979 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3962 | i18n("\nAre you sure you want\nto restore this?"), | 3980 | i18n("\nAre you sure you want\nto restore this?"), |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 664d700..fac9a9e 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,615 +1,617 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | 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 CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <KDGanttMinimizeSplitter.h> | ||
42 | 43 | ||
43 | #include <korganizer/calendarviewbase.h> | 44 | #include <korganizer/calendarviewbase.h> |
44 | 45 | ||
45 | #include <ksyncmanager.h> | 46 | #include <ksyncmanager.h> |
46 | 47 | ||
47 | class QWidgetStack; | 48 | class QWidgetStack; |
48 | class QSplitter; | 49 | class QSplitter; |
49 | 50 | ||
50 | class CalPrinter; | 51 | class CalPrinter; |
51 | class KOFilterView; | 52 | class KOFilterView; |
52 | class KOViewManager; | 53 | class KOViewManager; |
53 | class KODialogManager; | 54 | class KODialogManager; |
54 | class KOTodoView; | 55 | class KOTodoView; |
55 | class KDateNavigator; | 56 | class KDateNavigator; |
57 | class DateNavigatorContainer; | ||
56 | class DateNavigator; | 58 | class DateNavigator; |
57 | class KOIncidenceEditor; | 59 | class KOIncidenceEditor; |
58 | class KDatePicker; | 60 | class KDatePicker; |
59 | class ResourceView; | 61 | class ResourceView; |
60 | class KOEventEditor; | 62 | class KOEventEditor; |
61 | class KOTodoEditor ; | 63 | class KOTodoEditor ; |
62 | class KOEventViewerDialog; | 64 | class KOEventViewerDialog; |
63 | class KOBeamPrefs; | 65 | class KOBeamPrefs; |
64 | class KSyncProfile; | 66 | class KSyncProfile; |
65 | class AlarmDialog; | 67 | class AlarmDialog; |
66 | class KCal::Attendee; | 68 | class KCal::Attendee; |
67 | 69 | ||
68 | namespace KCal { class FileStorage; } | 70 | namespace KCal { class FileStorage; } |
69 | 71 | ||
70 | using namespace KCal; | 72 | using namespace KCal; |
71 | 73 | ||
72 | /** | 74 | /** |
73 | This is the main calendar widget. It provides the different vies on t he | 75 | This is the main calendar widget. It provides the different vies on t he |
74 | calendar data as well as the date navigator. It also handles synchronisation | 76 | calendar data as well as the date navigator. It also handles synchronisation |
75 | of the different views and controls the different dialogs like preferences, | 77 | of the different views and controls the different dialogs like preferences, |
76 | event editor, search dialog etc. | 78 | event editor, search dialog etc. |
77 | 79 | ||
78 | @short main calendar view widget | 80 | @short main calendar view widget |
79 | @author Cornelius Schumacher | 81 | @author Cornelius Schumacher |
80 | */ | 82 | */ |
81 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 83 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
82 | { | 84 | { |
83 | Q_OBJECT | 85 | Q_OBJECT |
84 | public: | 86 | public: |
85 | /** | 87 | /** |
86 | Constructs a new calendar view widget. | 88 | Constructs a new calendar view widget. |
87 | 89 | ||
88 | @param calendar calendar document | 90 | @param calendar calendar document |
89 | @param parent parent window | 91 | @param parent parent window |
90 | @param name Qt internal widget object name | 92 | @param name Qt internal widget object name |
91 | */ | 93 | */ |
92 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 94 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
93 | const char *name = 0 ); | 95 | const char *name = 0 ); |
94 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 96 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
95 | const char *name = 0 ); | 97 | const char *name = 0 ); |
96 | virtual ~CalendarView(); | 98 | virtual ~CalendarView(); |
97 | 99 | ||
98 | Calendar *calendar() { return mCalendar; } | 100 | Calendar *calendar() { return mCalendar; } |
99 | 101 | ||
100 | KOViewManager *viewManager(); | 102 | KOViewManager *viewManager(); |
101 | KODialogManager *dialogManager(); | 103 | KODialogManager *dialogManager(); |
102 | 104 | ||
103 | QDate startDate(); | 105 | QDate startDate(); |
104 | QDate endDate(); | 106 | QDate endDate(); |
105 | 107 | ||
106 | QWidgetStack *viewStack(); | 108 | QWidgetStack *viewStack(); |
107 | QWidget *leftFrame(); | 109 | QWidget *leftFrame(); |
108 | 110 | ||
109 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
111 | 113 | ||
112 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
116 | 118 | ||
117 | signals: | 119 | signals: |
118 | void save (); | 120 | void save (); |
119 | void saveStopTimer (); | 121 | void saveStopTimer (); |
120 | void tempDisableBR(bool); | 122 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 123 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 124 | void todoModified(Todo *, int); |
123 | 125 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 126 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 127 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 128 | * for notification to update their settings. */ |
127 | void configChanged(); | 129 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 130 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 131 | child windows can also close. */ |
130 | void closingDown(); | 132 | void closingDown(); |
131 | /** emitted right before we die */ | 133 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 134 | void closed(QWidget *); |
133 | 135 | ||
134 | /** Emitted when state of modified flag changes */ | 136 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 137 | void modifiedChanged(bool); |
136 | void signalmodified(); | 138 | void signalmodified(); |
137 | 139 | ||
138 | /** Emitted when state of read-only flag changes */ | 140 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 141 | void readOnlyChanged(bool); |
140 | 142 | ||
141 | /** Emitted when the unit of navigation changes */ | 143 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 144 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 145 | void changeNavStringNext(const QString &); |
144 | 146 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 147 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 148 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 149 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 150 | void groupEventsSelected(bool); |
149 | /** | 151 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 152 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 153 | signal is emitted with 0 as argument. |
152 | */ | 154 | */ |
153 | void incidenceSelected( Incidence * ); | 155 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 156 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 157 | void todoSelected( bool ); |
156 | 158 | ||
157 | /** | 159 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 160 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 161 | is possible or not. |
160 | */ | 162 | */ |
161 | void pasteEnabled(bool); | 163 | void pasteEnabled(bool); |
162 | 164 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 165 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 166 | void numIncomingChanged(int); |
165 | 167 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 168 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 169 | void numOutgoingChanged(int); |
168 | 170 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 171 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 172 | void statusMessage(const QString &); |
171 | 173 | ||
172 | void calendarViewExpanded( bool ); | 174 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 175 | void updateSearchDialog(); |
174 | 176 | ||
175 | 177 | ||
176 | public slots: | 178 | public slots: |
177 | void showOpenError(); | 179 | void showOpenError(); |
178 | void watchSavedFile(); | 180 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 181 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 182 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 184 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 185 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 186 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 187 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 188 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 189 | void updateConfig(); |
188 | 190 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 191 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 192 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 193 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 194 | const QStringList& uidList); |
193 | 195 | ||
194 | /** | 196 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 197 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 198 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 199 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 200 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 201 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 202 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 203 | ||
202 | /** | 204 | /** |
203 | Save calendar data to file. Return true if calendar could be | 205 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 206 | successfully saved. |
205 | */ | 207 | */ |
206 | bool saveCalendar(QString filename); | 208 | bool saveCalendar(QString filename); |
207 | 209 | ||
208 | /** | 210 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 211 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 212 | calendar. |
211 | */ | 213 | */ |
212 | void closeCalendar(); | 214 | void closeCalendar(); |
213 | 215 | ||
214 | /** Archive old events of calendar */ | 216 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 217 | void archiveCalendar(); |
216 | 218 | ||
217 | void showIncidence(); | 219 | void showIncidence(); |
218 | void editIncidence(); | 220 | void editIncidence(); |
219 | void editIncidenceDescription(); | 221 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 222 | void deleteIncidence(); |
221 | void cloneIncidence(); | 223 | void cloneIncidence(); |
222 | void moveIncidence(); | 224 | void moveIncidence(); |
223 | void beamIncidence(); | 225 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 226 | void toggleCancelIncidence(); |
225 | 227 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 228 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 229 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay ); | 230 | void newEvent(QDateTime, QDateTime, bool allDay ); |
229 | void newEvent(QDateTime, QDateTime); | 231 | void newEvent(QDateTime, QDateTime); |
230 | void newEvent(QDateTime fh); | 232 | void newEvent(QDateTime fh); |
231 | void newEvent(QDate dt); | 233 | void newEvent(QDate dt); |
232 | /** create new event without having a date hint. Takes current date as | 234 | /** create new event without having a date hint. Takes current date as |
233 | default hint. */ | 235 | default hint. */ |
234 | void newEvent(); | 236 | void newEvent(); |
235 | void newFloatingEvent(); | 237 | void newFloatingEvent(); |
236 | 238 | ||
237 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 239 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
238 | void showIncidence(Incidence *); | 240 | void showIncidence(Incidence *); |
239 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 241 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
240 | void editIncidence(Incidence *); | 242 | void editIncidence(Incidence *); |
241 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 243 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
242 | void deleteIncidence(Incidence *); | 244 | void deleteIncidence(Incidence *); |
243 | void cloneIncidence(Incidence *); | 245 | void cloneIncidence(Incidence *); |
244 | void cancelIncidence(Incidence *); | 246 | void cancelIncidence(Incidence *); |
245 | /** Create an editor for the supplied event. */ | 247 | /** Create an editor for the supplied event. */ |
246 | void editEvent(Event *); | 248 | void editEvent(Event *); |
247 | /** Delete the supplied event. */ | 249 | /** Delete the supplied event. */ |
248 | void deleteEvent(Event *); | 250 | void deleteEvent(Event *); |
249 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 251 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
250 | found. */ | 252 | found. */ |
251 | bool deleteEvent(const QString &uid); | 253 | bool deleteEvent(const QString &uid); |
252 | /** Create a read-only viewer dialog for the supplied event. */ | 254 | /** Create a read-only viewer dialog for the supplied event. */ |
253 | void showEvent(Event *); | 255 | void showEvent(Event *); |
254 | 256 | ||
255 | void editJournal(Journal *); | 257 | void editJournal(Journal *); |
256 | void showJournal(Journal *); | 258 | void showJournal(Journal *); |
257 | void deleteJournal(Journal *); | 259 | void deleteJournal(Journal *); |
258 | /** Create an editor dialog for a todo */ | 260 | /** Create an editor dialog for a todo */ |
259 | void editTodo(Todo *); | 261 | void editTodo(Todo *); |
260 | /** Create a read-only viewer dialog for the supplied todo */ | 262 | /** Create a read-only viewer dialog for the supplied todo */ |
261 | void showTodo(Todo *); | 263 | void showTodo(Todo *); |
262 | /** create new todo */ | 264 | /** create new todo */ |
263 | void newTodo(); | 265 | void newTodo(); |
264 | void newTodoDateTime(QDateTime, bool allday); | 266 | void newTodoDateTime(QDateTime, bool allday); |
265 | /** create new todo with a parent todo */ | 267 | /** create new todo with a parent todo */ |
266 | void newSubTodo(); | 268 | void newSubTodo(); |
267 | /** create new todo with a parent todo */ | 269 | /** create new todo with a parent todo */ |
268 | void newSubTodo(Todo *); | 270 | void newSubTodo(Todo *); |
269 | /** Delete todo */ | 271 | /** Delete todo */ |
270 | void deleteTodo(Todo *); | 272 | void deleteTodo(Todo *); |
271 | 273 | ||
272 | 274 | ||
273 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 275 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
274 | * emitted as result. */ | 276 | * emitted as result. */ |
275 | void checkClipboard(); | 277 | void checkClipboard(); |
276 | 278 | ||
277 | /** using the KConfig associated with the kapp variable, read in the | 279 | /** using the KConfig associated with the kapp variable, read in the |
278 | * settings from the config file. | 280 | * settings from the config file. |
279 | */ | 281 | */ |
280 | void readSettings(); | 282 | void readSettings(); |
281 | 283 | ||
282 | /** write current state to config file. */ | 284 | /** write current state to config file. */ |
283 | void writeSettings(); | 285 | void writeSettings(); |
284 | 286 | ||
285 | /** read settings for calendar filters */ | 287 | /** read settings for calendar filters */ |
286 | void readFilterSettings(KConfig *config); | 288 | void readFilterSettings(KConfig *config); |
287 | 289 | ||
288 | /** write settings for calendar filters */ | 290 | /** write settings for calendar filters */ |
289 | void writeFilterSettings(KConfig *config); | 291 | void writeFilterSettings(KConfig *config); |
290 | 292 | ||
291 | /** passes on the message that an event has changed to the currently | 293 | /** passes on the message that an event has changed to the currently |
292 | * activated view so that it can make appropriate display changes. */ | 294 | * activated view so that it can make appropriate display changes. */ |
293 | void changeEventDisplay(Event *, int); | 295 | void changeEventDisplay(Event *, int); |
294 | void changeIncidenceDisplay(Incidence *, int); | 296 | void changeIncidenceDisplay(Incidence *, int); |
295 | void changeTodoDisplay(Todo *, int); | 297 | void changeTodoDisplay(Todo *, int); |
296 | 298 | ||
297 | void eventAdded(Event *); | 299 | void eventAdded(Event *); |
298 | void eventChanged(Event *); | 300 | void eventChanged(Event *); |
299 | void eventToBeDeleted(Event *); | 301 | void eventToBeDeleted(Event *); |
300 | void eventDeleted(); | 302 | void eventDeleted(); |
301 | 303 | ||
302 | void todoAdded(Todo *); | 304 | void todoAdded(Todo *); |
303 | void todoChanged(Todo *); | 305 | void todoChanged(Todo *); |
304 | void todoToBeDeleted(Todo *); | 306 | void todoToBeDeleted(Todo *); |
305 | void todoDeleted(); | 307 | void todoDeleted(); |
306 | 308 | ||
307 | void updateView(const QDate &start, const QDate &end); | 309 | void updateView(const QDate &start, const QDate &end); |
308 | void updateView(); | 310 | void updateView(); |
309 | 311 | ||
310 | /** Full update of visible todo views */ | 312 | /** Full update of visible todo views */ |
311 | void updateTodoViews(); | 313 | void updateTodoViews(); |
312 | 314 | ||
313 | void updateUnmanagedViews(); | 315 | void updateUnmanagedViews(); |
314 | 316 | ||
315 | /** cut the current appointment to the clipboard */ | 317 | /** cut the current appointment to the clipboard */ |
316 | void edit_cut(); | 318 | void edit_cut(); |
317 | 319 | ||
318 | /** copy the current appointment(s) to the clipboard */ | 320 | /** copy the current appointment(s) to the clipboard */ |
319 | void edit_copy(); | 321 | void edit_copy(); |
320 | 322 | ||
321 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 323 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
322 | void edit_paste(); | 324 | void edit_paste(); |
323 | 325 | ||
324 | /** edit viewing and configuration options. */ | 326 | /** edit viewing and configuration options. */ |
325 | void edit_options(); | 327 | void edit_options(); |
326 | /** | 328 | /** |
327 | Functions for printing, previewing a print, and setting up printing | 329 | Functions for printing, previewing a print, and setting up printing |
328 | parameters. | 330 | parameters. |
329 | */ | 331 | */ |
330 | void print(); | 332 | void print(); |
331 | void printSetup(); | 333 | void printSetup(); |
332 | void printPreview(); | 334 | void printPreview(); |
333 | 335 | ||
334 | /** Export as iCalendar file */ | 336 | /** Export as iCalendar file */ |
335 | void exportICalendar(); | 337 | void exportICalendar(); |
336 | 338 | ||
337 | /** Export as vCalendar file */ | 339 | /** Export as vCalendar file */ |
338 | bool exportVCalendar( QString fn); | 340 | bool exportVCalendar( QString fn); |
339 | 341 | ||
340 | /** pop up a dialog to show an existing appointment. */ | 342 | /** pop up a dialog to show an existing appointment. */ |
341 | void appointment_show(); | 343 | void appointment_show(); |
342 | /** | 344 | /** |
343 | * pop up an Appointment Dialog to edit an existing appointment.Get | 345 | * pop up an Appointment Dialog to edit an existing appointment.Get |
344 | * information on the appointment from the list of unique IDs that is | 346 | * information on the appointment from the list of unique IDs that is |
345 | * currently in the View, called currIds. | 347 | * currently in the View, called currIds. |
346 | */ | 348 | */ |
347 | void appointment_edit(); | 349 | void appointment_edit(); |
348 | /** | 350 | /** |
349 | * pop up dialog confirming deletion of currently selected event in the | 351 | * pop up dialog confirming deletion of currently selected event in the |
350 | * View. | 352 | * View. |
351 | */ | 353 | */ |
352 | void appointment_delete(); | 354 | void appointment_delete(); |
353 | 355 | ||
354 | /** mails the currently selected event to a particular user as a vCalendar | 356 | /** mails the currently selected event to a particular user as a vCalendar |
355 | attachment. */ | 357 | attachment. */ |
356 | void action_mail(); | 358 | void action_mail(); |
357 | 359 | ||
358 | /* frees a subtodo from it's relation */ | 360 | /* frees a subtodo from it's relation */ |
359 | void todo_unsub( Todo * ); | 361 | void todo_unsub( Todo * ); |
360 | void todo_resub( Todo * parent, Todo * sub ); | 362 | void todo_resub( Todo * parent, Todo * sub ); |
361 | 363 | ||
362 | /** Take ownership of selected event. */ | 364 | /** Take ownership of selected event. */ |
363 | void takeOverEvent(); | 365 | void takeOverEvent(); |
364 | 366 | ||
365 | /** Take ownership of all events in calendar. */ | 367 | /** Take ownership of all events in calendar. */ |
366 | void takeOverCalendar(); | 368 | void takeOverCalendar(); |
367 | 369 | ||
368 | /** query whether or not the calendar is "dirty". */ | 370 | /** query whether or not the calendar is "dirty". */ |
369 | bool isModified(); | 371 | bool isModified(); |
370 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 372 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
371 | void setModified(bool modified=true); | 373 | void setModified(bool modified=true); |
372 | 374 | ||
373 | /** query if the calendar is read-only. */ | 375 | /** query if the calendar is read-only. */ |
374 | bool isReadOnly(); | 376 | bool isReadOnly(); |
375 | /** set state of calendar to read-only */ | 377 | /** set state of calendar to read-only */ |
376 | void setReadOnly(bool readOnly=true); | 378 | void setReadOnly(bool readOnly=true); |
377 | 379 | ||
378 | void eventUpdated(Incidence *); | 380 | void eventUpdated(Incidence *); |
379 | 381 | ||
380 | /* iTIP scheduling actions */ | 382 | /* iTIP scheduling actions */ |
381 | void schedule_publish(Incidence *incidence = 0); | 383 | void schedule_publish(Incidence *incidence = 0); |
382 | void schedule_request(Incidence *incidence = 0); | 384 | void schedule_request(Incidence *incidence = 0); |
383 | void schedule_refresh(Incidence *incidence = 0); | 385 | void schedule_refresh(Incidence *incidence = 0); |
384 | void schedule_cancel(Incidence *incidence = 0); | 386 | void schedule_cancel(Incidence *incidence = 0); |
385 | void schedule_add(Incidence *incidence = 0); | 387 | void schedule_add(Incidence *incidence = 0); |
386 | void schedule_reply(Incidence *incidence = 0); | 388 | void schedule_reply(Incidence *incidence = 0); |
387 | void schedule_counter(Incidence *incidence = 0); | 389 | void schedule_counter(Incidence *incidence = 0); |
388 | void schedule_declinecounter(Incidence *incidence = 0); | 390 | void schedule_declinecounter(Incidence *incidence = 0); |
389 | void schedule_publish_freebusy(int daysToPublish = 30); | 391 | void schedule_publish_freebusy(int daysToPublish = 30); |
390 | 392 | ||
391 | void openAddressbook(); | 393 | void openAddressbook(); |
392 | 394 | ||
393 | void editFilters(); | 395 | void editFilters(); |
394 | void toggleFilerEnabled(); | 396 | void toggleFilerEnabled(); |
395 | QPtrList<CalFilter> filters(); | 397 | QPtrList<CalFilter> filters(); |
396 | void toggleFilter(); | 398 | void toggleFilter(); |
397 | void showFilter(bool visible); | 399 | void showFilter(bool visible); |
398 | void updateFilter(); | 400 | void updateFilter(); |
399 | void filterEdited(); | 401 | void filterEdited(); |
400 | void selectFilter( int ); | 402 | void selectFilter( int ); |
401 | KOFilterView *filterView(); | 403 | KOFilterView *filterView(); |
402 | 404 | ||
403 | void showIntro(); | 405 | void showIntro(); |
404 | 406 | ||
405 | /** Move the curdatepient view date to today */ | 407 | /** Move the curdatepient view date to today */ |
406 | void goToday(); | 408 | void goToday(); |
407 | 409 | ||
408 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
409 | void goNext(); | 411 | void goNext(); |
410 | 412 | ||
411 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
412 | void goPrevious(); | 414 | void goPrevious(); |
413 | /** Move to the next date(s) in the current view */ | 415 | /** Move to the next date(s) in the current view */ |
414 | void goNextMonth(); | 416 | void goNextMonth(); |
415 | 417 | ||
416 | /** Move to the previous date(s) in the current view */ | 418 | /** Move to the previous date(s) in the current view */ |
417 | void goPreviousMonth(); | 419 | void goPreviousMonth(); |
418 | 420 | ||
419 | void toggleExpand(); | 421 | void toggleExpand(); |
420 | void toggleDateNavigatorWidget(); | 422 | void toggleDateNavigatorWidget(); |
421 | void toggleAllDaySize(); | 423 | void toggleAllDaySize(); |
422 | void dialogClosing(Incidence *); | 424 | void dialogClosing(Incidence *); |
423 | 425 | ||
424 | /** Look for new messages in the inbox */ | 426 | /** Look for new messages in the inbox */ |
425 | void lookForIncomingMessages(); | 427 | void lookForIncomingMessages(); |
426 | /** Look for new messages in the outbox */ | 428 | /** Look for new messages in the outbox */ |
427 | void lookForOutgoingMessages(); | 429 | void lookForOutgoingMessages(); |
428 | 430 | ||
429 | void processMainViewSelection( Incidence * ); | 431 | void processMainViewSelection( Incidence * ); |
430 | void processTodoListSelection( Incidence * ); | 432 | void processTodoListSelection( Incidence * ); |
431 | 433 | ||
432 | void processIncidenceSelection( Incidence * ); | 434 | void processIncidenceSelection( Incidence * ); |
433 | 435 | ||
434 | void purgeCompleted(); | 436 | void purgeCompleted(); |
435 | bool removeCompletedSubTodos( Todo* ); | 437 | bool removeCompletedSubTodos( Todo* ); |
436 | void slotCalendarChanged(); | 438 | void slotCalendarChanged(); |
437 | bool importBday(); | 439 | bool importBday(); |
438 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 440 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
439 | bool importQtopia( const QString &categoriesFile, | 441 | bool importQtopia( const QString &categoriesFile, |
440 | const QString &datebookFile, | 442 | const QString &datebookFile, |
441 | const QString &tasklistFile ); | 443 | const QString &tasklistFile ); |
442 | void syncExternal( int mode ); | 444 | void syncExternal( int mode ); |
443 | void slotSelectPickerDate( QDate ) ; | 445 | void slotSelectPickerDate( QDate ) ; |
444 | void showDatePicker() ; | 446 | void showDatePicker() ; |
445 | void showDatePickerPopup() ; | 447 | void showDatePickerPopup() ; |
446 | void moveIncidence(Incidence *) ; | 448 | void moveIncidence(Incidence *) ; |
447 | void beamIncidence(Incidence *) ; | 449 | void beamIncidence(Incidence *) ; |
448 | void beamCalendar() ; | 450 | void beamCalendar() ; |
449 | void beamFilteredCalendar() ; | 451 | void beamFilteredCalendar() ; |
450 | void beamIncidenceList(QPtrList<Incidence>) ; | 452 | void beamIncidenceList(QPtrList<Incidence>) ; |
451 | void manageCategories(); | 453 | void manageCategories(); |
452 | int addCategories(); | 454 | int addCategories(); |
453 | void removeCategories(); | 455 | void removeCategories(); |
454 | void setSyncDevice( QString ); | 456 | void setSyncDevice( QString ); |
455 | void setSyncName( QString ); | 457 | void setSyncName( QString ); |
456 | void showDay( QDate ); | 458 | void showDay( QDate ); |
457 | void undo_delete(); | 459 | void undo_delete(); |
458 | protected slots: | 460 | protected slots: |
459 | void resetFocus(); | 461 | void resetFocus(); |
460 | void slotViewerClosed(); | 462 | void slotViewerClosed(); |
461 | void timerAlarm(); | 463 | void timerAlarm(); |
462 | void suspendAlarm(); | 464 | void suspendAlarm(); |
463 | void beamDone( Ir *ir ); | 465 | void beamDone( Ir *ir ); |
464 | /** Select a view or adapt the current view to display the specified dates. */ | 466 | /** Select a view or adapt the current view to display the specified dates. */ |
465 | void showDates( const KCal::DateList & ); | 467 | void showDates( const KCal::DateList & ); |
466 | void selectWeekNum ( int ); | 468 | void selectWeekNum ( int ); |
467 | 469 | ||
468 | public: | 470 | public: |
469 | // show a standard warning | 471 | // show a standard warning |
470 | // returns KMsgBox::yesNoCancel() | 472 | // returns KMsgBox::yesNoCancel() |
471 | int msgCalModified(); | 473 | int msgCalModified(); |
472 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 474 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
473 | 475 | ||
474 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 476 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
475 | virtual void removeSyncInfo( QString syncProfile); | 477 | virtual void removeSyncInfo( QString syncProfile); |
476 | void setSyncManager(KSyncManager* manager); | 478 | void setSyncManager(KSyncManager* manager); |
477 | void setLoadedFileVersion(QDateTime); | 479 | void setLoadedFileVersion(QDateTime); |
478 | bool checkFileVersion(QString fn); | 480 | bool checkFileVersion(QString fn); |
479 | bool checkFileChanged(QString fn); | 481 | bool checkFileChanged(QString fn); |
480 | Event* getLastSyncEvent(); | 482 | Event* getLastSyncEvent(); |
481 | /** Adapt navigation units correpsonding to step size of navigation of the | 483 | /** Adapt navigation units correpsonding to step size of navigation of the |
482 | * current view. | 484 | * current view. |
483 | */ | 485 | */ |
484 | void adaptNavigationUnits(); | 486 | void adaptNavigationUnits(); |
485 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 487 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
486 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 488 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
487 | //Attendee* getYourAttendee(Event *event); | 489 | //Attendee* getYourAttendee(Event *event); |
488 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 490 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
489 | protected: | 491 | protected: |
490 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 492 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
491 | 493 | ||
492 | // returns KMsgBox::OKCandel() | 494 | // returns KMsgBox::OKCandel() |
493 | int msgItemDelete(const QString name); | 495 | int msgItemDelete(const QString name); |
494 | void showEventEditor(); | 496 | void showEventEditor(); |
495 | void showTodoEditor(); | 497 | void showTodoEditor(); |
496 | void writeLocale(); | 498 | void writeLocale(); |
497 | Todo *selectedTodo(); | 499 | Todo *selectedTodo(); |
498 | 500 | ||
499 | private: | 501 | private: |
500 | bool mViewerCallerIsSearchDialog; | 502 | bool mViewerCallerIsSearchDialog; |
501 | bool mBlockShowDates; | 503 | bool mBlockShowDates; |
502 | KSyncManager* mSyncManager; | 504 | KSyncManager* mSyncManager; |
503 | AlarmDialog * mAlarmDialog; | 505 | AlarmDialog * mAlarmDialog; |
504 | QString mAlarmNotification; | 506 | QString mAlarmNotification; |
505 | QString mSuspendAlarmNotification; | 507 | QString mSuspendAlarmNotification; |
506 | QTimer* mSuspendTimer; | 508 | QTimer* mSuspendTimer; |
507 | QTimer* mAlarmTimer; | 509 | QTimer* mAlarmTimer; |
508 | QTimer* mRecheckAlarmTimer; | 510 | QTimer* mRecheckAlarmTimer; |
509 | void computeAlarm( QString ); | 511 | void computeAlarm( QString ); |
510 | void startAlarm( QString, QString ); | 512 | void startAlarm( QString, QString ); |
511 | void setSyncEventsReadOnly(); | 513 | void setSyncEventsReadOnly(); |
512 | 514 | ||
513 | QDateTime loadedFileVersion; | 515 | QDateTime loadedFileVersion; |
514 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 516 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
515 | void checkExternalId( Incidence * inc ); | 517 | void checkExternalId( Incidence * inc ); |
516 | int mGlobalSyncMode; | 518 | int mGlobalSyncMode; |
517 | QString mCurrentSyncDevice; | 519 | QString mCurrentSyncDevice; |
518 | QString mCurrentSyncName; | 520 | QString mCurrentSyncName; |
519 | KOBeamPrefs* beamDialog; | 521 | KOBeamPrefs* beamDialog; |
520 | void init(); | 522 | void init(); |
521 | int mDatePickerMode; | 523 | int mDatePickerMode; |
522 | bool mFlagEditDescription; | 524 | bool mFlagEditDescription; |
523 | QDateTime mLastCalendarSync; | 525 | QDateTime mLastCalendarSync; |
524 | void createPrinter(); | 526 | void createPrinter(); |
525 | 527 | ||
526 | void calendarModified( bool, Calendar * ); | 528 | void calendarModified( bool, Calendar * ); |
527 | 529 | ||
528 | CalPrinter *mCalPrinter; | 530 | CalPrinter *mCalPrinter; |
529 | 531 | ||
530 | QSplitter *mPanner; | 532 | QSplitter *mPanner; |
531 | QSplitter *mLeftSplitter; | 533 | QSplitter *mLeftSplitter; |
532 | QWidget *mLeftFrame; | 534 | KDGanttMinimizeSplitter *mLeftFrame; |
533 | QWidgetStack *mRightFrame; | 535 | QWidgetStack *mRightFrame; |
534 | 536 | ||
535 | KDatePicker* mDatePicker; | 537 | KDatePicker* mDatePicker; |
536 | QVBox* mDateFrame; | 538 | QVBox* mDateFrame; |
537 | 539 | ||
538 | KDateNavigator *mDateNavigator; // widget showing small month view. | 540 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
539 | 541 | ||
540 | KOFilterView *mFilterView; | 542 | KOFilterView *mFilterView; |
541 | 543 | ||
542 | ResourceView *mResourceView; | 544 | ResourceView *mResourceView; |
543 | 545 | ||
544 | // calendar object for this viewing instance | 546 | // calendar object for this viewing instance |
545 | Calendar *mCalendar; | 547 | Calendar *mCalendar; |
546 | 548 | ||
547 | CalendarResourceManager *mResourceManager; | 549 | CalendarResourceManager *mResourceManager; |
548 | 550 | ||
549 | FileStorage *mStorage; | 551 | FileStorage *mStorage; |
550 | 552 | ||
551 | DateNavigator *mNavigator; | 553 | DateNavigator *mNavigator; |
552 | 554 | ||
553 | KOViewManager *mViewManager; | 555 | KOViewManager *mViewManager; |
554 | KODialogManager *mDialogManager; | 556 | KODialogManager *mDialogManager; |
555 | 557 | ||
556 | // Calendar filters | 558 | // Calendar filters |
557 | QPtrList<CalFilter> mFilters; | 559 | QPtrList<CalFilter> mFilters; |
558 | 560 | ||
559 | // various housekeeping variables. | 561 | // various housekeeping variables. |
560 | bool mModified; // flag indicating if calendar is modified | 562 | bool mModified; // flag indicating if calendar is modified |
561 | bool mReadOnly; // flag indicating if calendar is read-only | 563 | bool mReadOnly; // flag indicating if calendar is read-only |
562 | QDate mSaveSingleDate; | 564 | QDate mSaveSingleDate; |
563 | 565 | ||
564 | Incidence *mSelectedIncidence; | 566 | Incidence *mSelectedIncidence; |
565 | Incidence *mMoveIncidence; | 567 | Incidence *mMoveIncidence; |
566 | QDate mMoveIncidenceOldDate; | 568 | QDate mMoveIncidenceOldDate; |
567 | KOTodoView *mTodoList; | 569 | KOTodoView *mTodoList; |
568 | KOEventEditor * mEventEditor; | 570 | KOEventEditor * mEventEditor; |
569 | KOTodoEditor * mTodoEditor; | 571 | KOTodoEditor * mTodoEditor; |
570 | KOEventViewerDialog * mEventViewerDialog; | 572 | KOEventViewerDialog * mEventViewerDialog; |
571 | void keyPressEvent ( QKeyEvent *e) ; | 573 | void keyPressEvent ( QKeyEvent *e) ; |
572 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 574 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
573 | }; | 575 | }; |
574 | 576 | ||
575 | 577 | ||
576 | class CalendarViewVisitor : public Incidence::Visitor | 578 | class CalendarViewVisitor : public Incidence::Visitor |
577 | { | 579 | { |
578 | public: | 580 | public: |
579 | CalendarViewVisitor() : mView( 0 ) {} | 581 | CalendarViewVisitor() : mView( 0 ) {} |
580 | 582 | ||
581 | bool act( Incidence *incidence, CalendarView *view ) | 583 | bool act( Incidence *incidence, CalendarView *view ) |
582 | { | 584 | { |
583 | mView = view; | 585 | mView = view; |
584 | return incidence->accept( *this ); | 586 | return incidence->accept( *this ); |
585 | } | 587 | } |
586 | 588 | ||
587 | protected: | 589 | protected: |
588 | CalendarView *mView; | 590 | CalendarView *mView; |
589 | }; | 591 | }; |
590 | 592 | ||
591 | class ShowIncidenceVisitor : public CalendarViewVisitor | 593 | class ShowIncidenceVisitor : public CalendarViewVisitor |
592 | { | 594 | { |
593 | protected: | 595 | protected: |
594 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 596 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
595 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 597 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
596 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 598 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
597 | }; | 599 | }; |
598 | 600 | ||
599 | class EditIncidenceVisitor : public CalendarViewVisitor | 601 | class EditIncidenceVisitor : public CalendarViewVisitor |
600 | { | 602 | { |
601 | protected: | 603 | protected: |
602 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 604 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
603 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 605 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
604 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 606 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
605 | }; | 607 | }; |
606 | 608 | ||
607 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 609 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
608 | { | 610 | { |
609 | protected: | 611 | protected: |
610 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 612 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
611 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 613 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
612 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 614 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
613 | }; | 615 | }; |
614 | 616 | ||
615 | #endif | 617 | #endif |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp new file mode 100644 index 0000000..cbfc5b2 --- a/dev/null +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -0,0 +1,218 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | |||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | ||
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | |||
21 | As a special exception, permission is given to link this program | ||
22 | with any edition of Qt, and distribute the resulting executable, | ||
23 | without including the source code for Qt in the source distribution. | ||
24 | */ | ||
25 | |||
26 | #include <kdebug.h> | ||
27 | #include <klocale.h> | ||
28 | |||
29 | //#include "koglobals.h" | ||
30 | #include "navigatorbar.h" | ||
31 | #include "kdatenavigator.h" | ||
32 | |||
33 | #include <kcalendarsystem.h> | ||
34 | |||
35 | #include "datenavigatorcontainer.h" | ||
36 | |||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | ||
38 | const char *name ) | ||
39 | : QWidget( parent, name ), mCalendar( 0 ), | ||
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | ||
41 | { | ||
42 | mExtraViews.setAutoDelete( true ); | ||
43 | |||
44 | mNavigatorView = new KDateNavigator( this, name ); | ||
45 | |||
46 | connectNavigatorView( mNavigatorView ); | ||
47 | } | ||
48 | |||
49 | DateNavigatorContainer::~DateNavigatorContainer() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | ||
54 | { | ||
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | ||
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | ||
57 | #if 0 | ||
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | ||
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | ||
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | ||
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | ||
62 | #endif | ||
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | ||
64 | SIGNAL( weekClicked( const QDate & ) ) ); | ||
65 | |||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | ||
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | ||
68 | |||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | ||
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | ||
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | ||
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | ||
73 | |||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | ||
75 | } | ||
76 | |||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | ||
78 | { | ||
79 | mCalendar = cal; | ||
80 | mNavigatorView->setCalendar( cal ); | ||
81 | KDateNavigator *n; | ||
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
83 | n->setCalendar( cal ); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void DateNavigatorContainer::updateDayMatrix() | ||
88 | { | ||
89 | mNavigatorView->updateDayMatrix(); | ||
90 | KDateNavigator *n; | ||
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
92 | n->updateDayMatrix(); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void DateNavigatorContainer::updateToday() | ||
97 | { | ||
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | ||
99 | #if 0 | ||
100 | mNavigatorView->updateToday(); | ||
101 | KDateNavigator *n; | ||
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
103 | n->updateToday(); | ||
104 | } | ||
105 | #endif | ||
106 | } | ||
107 | |||
108 | void DateNavigatorContainer::updateView() | ||
109 | { | ||
110 | mNavigatorView->updateView(); | ||
111 | KDateNavigator *n; | ||
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
113 | n->updateView(); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | void DateNavigatorContainer::updateConfig() | ||
118 | { | ||
119 | mNavigatorView->updateConfig(); | ||
120 | KDateNavigator *n; | ||
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
122 | n->updateConfig(); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | ||
127 | { | ||
128 | mNavigatorView->selectDates( dateList ); | ||
129 | setBaseDates(); | ||
130 | } | ||
131 | |||
132 | void DateNavigatorContainer::setBaseDates() | ||
133 | { | ||
134 | KCal::DateList dateList = mNavigatorView->selectedDates(); | ||
135 | if ( dateList.isEmpty() ) { | ||
136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | ||
137 | } | ||
138 | QDate baseDate = dateList.first(); | ||
139 | KDateNavigator *n; | ||
140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | ||
141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); | ||
142 | n->setBaseDate( baseDate ); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | ||
147 | { | ||
148 | #if 0 | ||
149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | ||
150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | ||
151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | ||
152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | ||
153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | ||
154 | #endif | ||
155 | |||
156 | QSize minSize = mNavigatorView->minimumSizeHint(); | ||
157 | |||
158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | ||
159 | |||
160 | int verticalCount = size().height() / minSize.height(); | ||
161 | int horizontalCount = size().width() / minSize.width(); | ||
162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | ||
163 | if ( horizontalCount != mHorizontalCount || | ||
164 | verticalCount != mVerticalCount ) { | ||
165 | uint count = horizontalCount * verticalCount; | ||
166 | if ( count == 0 ) return; | ||
167 | |||
168 | while ( count > ( mExtraViews.count() + 1 ) ) { | ||
169 | KDateNavigator *n = new KDateNavigator( this ); | ||
170 | mExtraViews.append( n ); | ||
171 | n->setCalendar( mCalendar ); | ||
172 | setBaseDates(); | ||
173 | connectNavigatorView( n ); | ||
174 | n->show(); | ||
175 | } | ||
176 | |||
177 | while ( count < ( mExtraViews.count() + 1 ) ) { | ||
178 | mExtraViews.removeLast(); | ||
179 | } | ||
180 | |||
181 | mHorizontalCount = horizontalCount; | ||
182 | mVerticalCount = verticalCount; | ||
183 | } | ||
184 | |||
185 | int height = size().height() / verticalCount; | ||
186 | int width = size().width() / horizontalCount; | ||
187 | |||
188 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | ||
189 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | ||
190 | else bar->showButtons( true, true ); | ||
191 | |||
192 | mNavigatorView->setGeometry(0, | ||
193 | 0, width, height ); | ||
194 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | ||
195 | int x = ( i + 1 ) % horizontalCount; | ||
196 | int y = ( i + 1 ) / horizontalCount; | ||
197 | |||
198 | KDateNavigator *view = mExtraViews.at( i ); | ||
199 | bar = view->navigatorBar(); | ||
200 | if ( y > 0 ) bar->showButtons( false, false ); | ||
201 | else { | ||
202 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | ||
203 | else bar->showButtons( false, false ); | ||
204 | } | ||
205 | view->setGeometry( x * width, | ||
206 | y * height, width, height ); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | QSize DateNavigatorContainer::minimumSizeHint() const | ||
211 | { | ||
212 | return mNavigatorView->minimumSizeHint(); | ||
213 | } | ||
214 | |||
215 | QSize DateNavigatorContainer::sizeHint() const | ||
216 | { | ||
217 | return mNavigatorView->sizeHint(); | ||
218 | } | ||
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h new file mode 100644 index 0000000..affa8e1 --- a/dev/null +++ b/korganizer/datenavigatorcontainer.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | |||
4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> | ||
5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | |||
21 | As a special exception, permission is given to link this program | ||
22 | with any edition of Qt, and distribute the resulting executable, | ||
23 | without including the source code for Qt in the source distribution. | ||
24 | */ | ||
25 | #ifndef DATENAVIGATORCONTAINER_H | ||
26 | #define DATENAVIGATORCONTAINER_H | ||
27 | |||
28 | class KDateNavigator; | ||
29 | |||
30 | #include <qwidget.h> | ||
31 | #include <libkcal/calendar.h> | ||
32 | using namespace KCal; | ||
33 | |||
34 | class DateNavigatorContainer: public QWidget | ||
35 | { | ||
36 | Q_OBJECT | ||
37 | public: | ||
38 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); | ||
39 | ~DateNavigatorContainer(); | ||
40 | |||
41 | /** | ||
42 | Associate date navigator with a calendar. It is used by KODayMatrix. | ||
43 | */ | ||
44 | void setCalendar( Calendar * ); | ||
45 | |||
46 | QSize minimumSizeHint() const; | ||
47 | QSize sizeHint() const; | ||
48 | KDateNavigator * navigatorView() { return mNavigatorView;} | ||
49 | |||
50 | public slots: | ||
51 | void selectDates( const KCal::DateList & ); | ||
52 | void updateView(); | ||
53 | void updateConfig(); | ||
54 | void updateDayMatrix(); | ||
55 | void updateToday(); | ||
56 | |||
57 | signals: | ||
58 | void datesSelected( const KCal::DateList & ); | ||
59 | void incidenceDropped( Incidence *, const QDate & ); | ||
60 | void incidenceDroppedMove( Incidence *, const QDate & ); | ||
61 | void weekClicked( const QDate &); | ||
62 | |||
63 | void goPrevious(); | ||
64 | void goNext(); | ||
65 | |||
66 | void goNextMonth(); | ||
67 | void goPrevMonth(); | ||
68 | void goNextYear(); | ||
69 | void goPrevYear(); | ||
70 | |||
71 | void monthSelected( int month ); | ||
72 | |||
73 | protected: | ||
74 | void resizeEvent( QResizeEvent * ); | ||
75 | |||
76 | void setBaseDates(); | ||
77 | void connectNavigatorView( KDateNavigator *v ); | ||
78 | |||
79 | private: | ||
80 | KDateNavigator *mNavigatorView; | ||
81 | |||
82 | KCal::Calendar *mCalendar; | ||
83 | |||
84 | QPtrList<KDateNavigator> mExtraViews; | ||
85 | |||
86 | int mHorizontalCount; | ||
87 | int mVerticalCount; | ||
88 | }; | ||
89 | |||
90 | #endif | ||
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index c08f44f..e76a85a 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,367 +1,381 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | bool show_week_nums, const char *name, | ||
50 | QDate startDate ) | ||
51 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
52 | updateTimer(0L) | 50 | updateTimer(0L) |
53 | { | 51 | { |
54 | mCalendar = calendar; | 52 | setFrameStyle(QFrame::NoFrame); |
55 | 53 | QDate startDate = QDate::currentDate(); | |
56 | setFrameStyle(QFrame::NoFrame); | ||
57 | |||
58 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
59 | 55 | ||
60 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
61 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
62 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
63 | } | 59 | } |
64 | 60 | ||
65 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
66 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
67 | m_bShowWeekNums = show_week_nums; | 63 | m_bShowWeekNums = true; |
68 | 64 | ||
69 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
70 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
71 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
72 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
73 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
74 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
75 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
76 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
77 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
78 | 74 | ||
79 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
80 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
81 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
82 | 78 | ||
83 | int i; | 79 | int i; |
84 | 80 | ||
85 | // Set up the heading fields. | 81 | // Set up the heading fields. |
86 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
87 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
88 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
89 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
90 | 86 | ||
91 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
92 | } | 88 | } |
93 | 89 | ||
94 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
95 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
96 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
97 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
98 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
99 | if(!show_week_nums) { | 95 | if(!m_bShowWeekNums) { |
100 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
101 | } | 97 | } |
102 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
103 | 99 | ||
104 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
105 | } | 101 | } |
106 | 102 | ||
107 | daymatrix = new KODayMatrix( this, mCalendar, dayone, | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
108 | "KDateNavigator::DayMatrix"); | ||
109 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
111 | 106 | ||
112 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
113 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
114 | 109 | ||
115 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
116 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
117 | 112 | ||
118 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
119 | 114 | ||
120 | // read settings from configuration file. | 115 | // read settings from configuration file. |
121 | updateConfig(); | 116 | updateConfig(); |
122 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
123 | setFixedSize ( sizeHint() ); | 118 | //setFixedSize ( sizeHint() ); |
119 | } | ||
120 | void KDateNavigator::setCalendar( Calendar *cal ) | ||
121 | { | ||
122 | daymatrix->setCalendar( cal ); | ||
123 | } | ||
124 | |||
125 | void KDateNavigator::setBaseDate( const QDate &date ) | ||
126 | { | ||
127 | m_MthYr = date; | ||
128 | |||
129 | updateDates(); | ||
130 | updateView(); | ||
131 | |||
132 | KCal::DateList dates; | ||
133 | dates.append( date ); | ||
134 | mNavigatorBar->selectDates( dates ); | ||
135 | |||
136 | daymatrix->clearSelection(); | ||
137 | daymatrix->repaint(); | ||
124 | } | 138 | } |
125 | 139 | ||
126 | void KDateNavigator::enableRollover(RolloverType r) | 140 | void KDateNavigator::enableRollover(RolloverType r) |
127 | { | 141 | { |
128 | switch(r) | 142 | switch(r) |
129 | { | 143 | { |
130 | case None : | 144 | case None : |
131 | if (updateTimer) | 145 | if (updateTimer) |
132 | { | 146 | { |
133 | updateTimer->stop(); | 147 | updateTimer->stop(); |
134 | delete updateTimer; | 148 | delete updateTimer; |
135 | updateTimer=0L; | 149 | updateTimer=0L; |
136 | } | 150 | } |
137 | break; | 151 | break; |
138 | case FollowDay : | 152 | case FollowDay : |
139 | case FollowMonth : | 153 | case FollowMonth : |
140 | if (!updateTimer) | 154 | if (!updateTimer) |
141 | { | 155 | { |
142 | updateTimer = new QTimer(this); | 156 | updateTimer = new QTimer(this); |
143 | QObject::connect(updateTimer,SIGNAL(timeout()), | 157 | QObject::connect(updateTimer,SIGNAL(timeout()), |
144 | this,SLOT(possiblyPastMidnight())); | 158 | this,SLOT(possiblyPastMidnight())); |
145 | } | 159 | } |
146 | updateTimer->start(0,true); | 160 | updateTimer->start(0,true); |
147 | lastDayChecked = QDate::currentDate(); | 161 | lastDayChecked = QDate::currentDate(); |
148 | } | 162 | } |
149 | updateRollover=r; | 163 | updateRollover=r; |
150 | } | 164 | } |
151 | 165 | ||
152 | 166 | ||
153 | KDateNavigator::~KDateNavigator() | 167 | KDateNavigator::~KDateNavigator() |
154 | { | 168 | { |
155 | } | 169 | } |
156 | 170 | ||
157 | 171 | ||
158 | void KDateNavigator::passedMidnight() | 172 | void KDateNavigator::passedMidnight() |
159 | { | 173 | { |
160 | QDate today = QDate::currentDate(); | 174 | QDate today = QDate::currentDate(); |
161 | bool emitMonth = false; | 175 | bool emitMonth = false; |
162 | 176 | ||
163 | if (today.month() != lastDayChecked.month()) | 177 | if (today.month() != lastDayChecked.month()) |
164 | { | 178 | { |
165 | if (updateRollover==FollowMonth && | 179 | if (updateRollover==FollowMonth && |
166 | daymatrix->isEndOfMonth()) { | 180 | daymatrix->isEndOfMonth()) { |
167 | goNextMonth(); | 181 | goNextMonth(); |
168 | emitMonth=true; | 182 | emitMonth=true; |
169 | } | 183 | } |
170 | } | 184 | } |
171 | daymatrix->recalculateToday(); | 185 | daymatrix->recalculateToday(); |
172 | daymatrix->repaint(); | 186 | daymatrix->repaint(); |
173 | emit dayPassed(today); | 187 | emit dayPassed(today); |
174 | if (emitMonth) { emit monthPassed(today); } | 188 | if (emitMonth) { emit monthPassed(today); } |
175 | } | 189 | } |
176 | 190 | ||
177 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 191 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
178 | { | 192 | { |
179 | if (lastDayChecked!=QDate::currentDate()) | 193 | if (lastDayChecked!=QDate::currentDate()) |
180 | { | 194 | { |
181 | passedMidnight(); | 195 | passedMidnight(); |
182 | lastDayChecked=QDate::currentDate(); | 196 | lastDayChecked=QDate::currentDate(); |
183 | } | 197 | } |
184 | // Set the timer to go off 1 second after midnight | 198 | // Set the timer to go off 1 second after midnight |
185 | // or after 8 minutes, whichever comes first. | 199 | // or after 8 minutes, whichever comes first. |
186 | if (updateTimer) | 200 | if (updateTimer) |
187 | { | 201 | { |
188 | QTime now = QTime::currentTime(); | 202 | QTime now = QTime::currentTime(); |
189 | QTime midnight = QTime(23,59,59); | 203 | QTime midnight = QTime(23,59,59); |
190 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 204 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
191 | 205 | ||
192 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 206 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
193 | //.arg(now.toString()).arg(midnight.toString())); | 207 | //.arg(now.toString()).arg(midnight.toString())); |
194 | 208 | ||
195 | updateTimer->stop(); | 209 | updateTimer->stop(); |
196 | updateTimer->start(msecsWait,true); | 210 | updateTimer->start(msecsWait,true); |
197 | } | 211 | } |
198 | } | 212 | } |
199 | 213 | ||
200 | void KDateNavigator::updateDates() | 214 | void KDateNavigator::updateDates() |
201 | { | 215 | { |
202 | // Find the first day of the week of the current month. | 216 | // Find the first day of the week of the current month. |
203 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 217 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
204 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 218 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
205 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 219 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
206 | //int di = d1 - d2 + 1; | 220 | //int di = d1 - d2 + 1; |
207 | dayone = dayone.addDays( -d2 + 1 ); | 221 | dayone = dayone.addDays( -d2 + 1 ); |
208 | 222 | ||
209 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 223 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
210 | 224 | ||
211 | // If month begins on Monday and Monday is first day of week, | 225 | // If month begins on Monday and Monday is first day of week, |
212 | // month should begin on second line. Sunday doesn't have this problem. | 226 | // month should begin on second line. Sunday doesn't have this problem. |
213 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 227 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
214 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 228 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
215 | 229 | ||
216 | // update the matrix dates | 230 | // update the matrix dates |
217 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 231 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
218 | 232 | ||
219 | 233 | ||
220 | daymatrix->updateView(dayone.addDays(index)); | 234 | daymatrix->updateView(dayone.addDays(index)); |
221 | //each updateDates is followed by an updateView -> repaint is issued there ! | 235 | //each updateDates is followed by an updateView -> repaint is issued there ! |
222 | // daymatrix->repaint(); | 236 | // daymatrix->repaint(); |
223 | } | 237 | } |
224 | 238 | ||
225 | void KDateNavigator::updateDayMatrix() | 239 | void KDateNavigator::updateDayMatrix() |
226 | { | 240 | { |
227 | daymatrix->updateView(); | 241 | daymatrix->updateView(); |
228 | //daymatrix->repaint(); | 242 | //daymatrix->repaint(); |
229 | } | 243 | } |
230 | 244 | ||
231 | 245 | ||
232 | void KDateNavigator::updateView() | 246 | void KDateNavigator::updateView() |
233 | { | 247 | { |
234 | 248 | ||
235 | setUpdatesEnabled( false ); | 249 | setUpdatesEnabled( false ); |
236 | 250 | ||
237 | int i; | 251 | int i; |
238 | 252 | ||
239 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 253 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
240 | daymatrix->updateView(); | 254 | daymatrix->updateView(); |
241 | 255 | ||
242 | // set the week numbers. | 256 | // set the week numbers. |
243 | for(i = 0; i < 6; i++) { | 257 | for(i = 0; i < 6; i++) { |
244 | QString weeknum; | 258 | QString weeknum; |
245 | // remember, according to ISO 8601, the first week of the year is the | 259 | // remember, according to ISO 8601, the first week of the year is the |
246 | // first week that contains a thursday. Thus we must subtract off 4, | 260 | // first week that contains a thursday. Thus we must subtract off 4, |
247 | // not just 1. | 261 | // not just 1. |
248 | 262 | ||
249 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 263 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
250 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 264 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
251 | 265 | ||
252 | int add = 0; | 266 | int add = 0; |
253 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 267 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
254 | ++add; | 268 | ++add; |
255 | if (dayOfYear % 7 != 0) | 269 | if (dayOfYear % 7 != 0) |
256 | weeknum.setNum(dayOfYear / 7 + 1+add); | 270 | weeknum.setNum(dayOfYear / 7 + 1+add); |
257 | else | 271 | else |
258 | weeknum.setNum(dayOfYear / 7 +add); | 272 | weeknum.setNum(dayOfYear / 7 +add); |
259 | weeknos[i]->setText(weeknum); | 273 | weeknos[i]->setText(weeknum); |
260 | } | 274 | } |
261 | 275 | ||
262 | setUpdatesEnabled( true ); | 276 | setUpdatesEnabled( true ); |
263 | // kdDebug() << "updateView() -> repaint()" << endl; | 277 | // kdDebug() << "updateView() -> repaint()" << endl; |
264 | repaint(); | 278 | repaint(); |
265 | // daymatrix->repaint(); | 279 | // daymatrix->repaint(); |
266 | } | 280 | } |
267 | 281 | ||
268 | void KDateNavigator::updateConfig() | 282 | void KDateNavigator::updateConfig() |
269 | { | 283 | { |
270 | int day; | 284 | int day; |
271 | for(int i=0; i<7; i++) { | 285 | for(int i=0; i<7; i++) { |
272 | // take the first letter of the day name to be the abbreviation | 286 | // take the first letter of the day name to be the abbreviation |
273 | if (KGlobal::locale()->weekStartsMonday()) { | 287 | if (KGlobal::locale()->weekStartsMonday()) { |
274 | day = i+1; | 288 | day = i+1; |
275 | } else { | 289 | } else { |
276 | if (i==0) day = 7; | 290 | if (i==0) day = 7; |
277 | else day = i; | 291 | else day = i; |
278 | } | 292 | } |
279 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 293 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
280 | true ); | 294 | true ); |
281 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 295 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
282 | headings[i]->setText( dayName ); | 296 | headings[i]->setText( dayName ); |
283 | } | 297 | } |
284 | updateDates(); | 298 | updateDates(); |
285 | updateView(); | 299 | updateView(); |
286 | } | 300 | } |
287 | 301 | ||
288 | void KDateNavigator::setShowWeekNums(bool enabled) | 302 | void KDateNavigator::setShowWeekNums(bool enabled) |
289 | { | 303 | { |
290 | m_bShowWeekNums = enabled; | 304 | m_bShowWeekNums = enabled; |
291 | for(int i=0; i<6; i++) { | 305 | for(int i=0; i<6; i++) { |
292 | if(enabled) | 306 | if(enabled) |
293 | weeknos[i]->show(); | 307 | weeknos[i]->show(); |
294 | else | 308 | else |
295 | weeknos[i]->hide(); | 309 | weeknos[i]->hide(); |
296 | } | 310 | } |
297 | resize(size()); | 311 | resize(size()); |
298 | } | 312 | } |
299 | 313 | ||
300 | void KDateNavigator::selectDates(const DateList& dateList) | 314 | void KDateNavigator::selectDates(const DateList& dateList) |
301 | { | 315 | { |
302 | 316 | ||
303 | if (dateList.count() > 0) { | 317 | if (dateList.count() > 0) { |
304 | mNavigatorBar->selectDates( dateList ); | 318 | mNavigatorBar->selectDates( dateList ); |
305 | mSelectedDates = dateList; | 319 | mSelectedDates = dateList; |
306 | 320 | ||
307 | // set our record of the month and year that this datetbl is | 321 | // set our record of the month and year that this datetbl is |
308 | // displaying. | 322 | // displaying. |
309 | m_MthYr = mSelectedDates.first(); | 323 | m_MthYr = mSelectedDates.first(); |
310 | 324 | ||
311 | 325 | ||
312 | // set our record of the first day of the week of the current | 326 | // set our record of the first day of the week of the current |
313 | // month. This needs to be done before calling dayToIndex, since it | 327 | // month. This needs to be done before calling dayToIndex, since it |
314 | // relies on this information being up to date. | 328 | // relies on this information being up to date. |
315 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 329 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
316 | m_fstDayOfWk = dayone.dayOfWeek(); | 330 | m_fstDayOfWk = dayone.dayOfWeek(); |
317 | 331 | ||
318 | updateDates(); | 332 | updateDates(); |
319 | 333 | ||
320 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 334 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
321 | 335 | ||
322 | updateView(); | 336 | updateView(); |
323 | } | 337 | } |
324 | } | 338 | } |
325 | 339 | ||
326 | int KDateNavigator::dayNum(int row, int col) | 340 | int KDateNavigator::dayNum(int row, int col) |
327 | { | 341 | { |
328 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 342 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
329 | } | 343 | } |
330 | 344 | ||
331 | int KDateNavigator::dayToIndex(int dayNum) | 345 | int KDateNavigator::dayToIndex(int dayNum) |
332 | { | 346 | { |
333 | int row, col; | 347 | int row, col; |
334 | 348 | ||
335 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 349 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
336 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 350 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
337 | row++; | 351 | row++; |
338 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 352 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
339 | return row * 7 + col; | 353 | return row * 7 + col; |
340 | } | 354 | } |
341 | 355 | ||
342 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 356 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
343 | { | 357 | { |
344 | if(e->delta()>0) emit goPrevious(); | 358 | if(e->delta()>0) emit goPrevious(); |
345 | else emit goNext(); | 359 | else emit goNext(); |
346 | 360 | ||
347 | e->accept(); | 361 | e->accept(); |
348 | } | 362 | } |
349 | 363 | ||
350 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 364 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
351 | { | 365 | { |
352 | if (e->type() == QEvent::MouseButtonPress) { | 366 | if (e->type() == QEvent::MouseButtonPress) { |
353 | int i; | 367 | int i; |
354 | for(i=0;i<6;++i) { | 368 | for(i=0;i<6;++i) { |
355 | if (o == weeknos[i]) { | 369 | if (o == weeknos[i]) { |
356 | QDate weekstart = daymatrix->getDate(i*7); | 370 | QDate weekstart = daymatrix->getDate(i*7); |
357 | emit weekClicked(weekstart); | 371 | emit weekClicked(weekstart); |
358 | break; | 372 | break; |
359 | } | 373 | } |
360 | } | 374 | } |
361 | return true; | 375 | return true; |
362 | } else { | 376 | } else { |
363 | return false; | 377 | return false; |
364 | } | 378 | } |
365 | } | 379 | } |
366 | 380 | ||
367 | //#include "kdatenavigator.moc" | 381 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 3ae1648..0aeb77a 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,148 +1,150 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0, Calendar *calendar = 0, | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | bool show_week_numbers = false, const char *name = 0, | ||
47 | QDate date = QDate::currentDate() ); | ||
48 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
49 | 47 | ||
50 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
51 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
52 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
53 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
54 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
55 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
56 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
57 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
58 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
59 | */ | 57 | */ |
60 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
61 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
62 | 60 | ||
63 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | ||
63 | void setBaseDate( const QDate & ); | ||
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | ||
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | ||
64 | 66 | ||
65 | public slots: | 67 | public slots: |
66 | void selectDates( const KCal::DateList & ); | 68 | void selectDates( const KCal::DateList & ); |
67 | void updateView(); | 69 | void updateView(); |
68 | void updateConfig(); | 70 | void updateConfig(); |
69 | void updateDayMatrix(); | 71 | void updateDayMatrix(); |
70 | 72 | ||
71 | signals: | 73 | signals: |
72 | void datesSelected( const KCal::DateList & ); | 74 | void datesSelected( const KCal::DateList & ); |
73 | void eventDropped( Event * ); | 75 | void eventDropped( Event * ); |
74 | void weekClicked( const QDate &); | 76 | void weekClicked( const QDate &); |
75 | 77 | ||
76 | void goPrevious(); | 78 | void goPrevious(); |
77 | void goNext(); | 79 | void goNext(); |
78 | 80 | ||
79 | void goNextMonth(); | 81 | void goNextMonth(); |
80 | void goPrevMonth(); | 82 | void goPrevMonth(); |
81 | void goNextYear(); | 83 | void goNextYear(); |
82 | void goPrevYear(); | 84 | void goPrevYear(); |
83 | void monthSelected( int ); | 85 | void monthSelected( int ); |
84 | 86 | ||
85 | // Signals emitted at midnight carrying the new date. | 87 | // Signals emitted at midnight carrying the new date. |
86 | void dayPassed( QDate ); | 88 | void dayPassed( QDate ); |
87 | void monthPassed( QDate ); | 89 | void monthPassed( QDate ); |
88 | 90 | ||
89 | protected slots: | 91 | protected slots: |
90 | 92 | ||
91 | /** | 93 | /** |
92 | * Called regularly to see if we need to update the view | 94 | * Called regularly to see if we need to update the view |
93 | * wrt. the today box and the month box. Only important | 95 | * wrt. the today box and the month box. Only important |
94 | * if you leave KOrganizer idle for long periods of time. | 96 | * if you leave KOrganizer idle for long periods of time. |
95 | * | 97 | * |
96 | * Until we have a reliable way of setting QTimers to go | 98 | * Until we have a reliable way of setting QTimers to go |
97 | * off at a particular wall-clock time, we need this, | 99 | * off at a particular wall-clock time, we need this, |
98 | * which calls passedMidnight() at the right moments. | 100 | * which calls passedMidnight() at the right moments. |
99 | */ | 101 | */ |
100 | void possiblyPastMidnight(); | 102 | void possiblyPastMidnight(); |
101 | 103 | ||
102 | /** handles updating the view when midnight has come by due to idle time. | 104 | /** handles updating the view when midnight has come by due to idle time. |
103 | * | 105 | * |
104 | */ | 106 | */ |
105 | void passedMidnight(); | 107 | void passedMidnight(); |
106 | 108 | ||
107 | protected: | 109 | protected: |
108 | void updateDates(); | 110 | void updateDates(); |
109 | 111 | ||
110 | void wheelEvent (QWheelEvent *); | 112 | void wheelEvent (QWheelEvent *); |
111 | 113 | ||
112 | bool eventFilter (QObject *,QEvent *); | 114 | bool eventFilter (QObject *,QEvent *); |
113 | 115 | ||
114 | private: | 116 | private: |
115 | NavigatorBar *mNavigatorBar; | 117 | NavigatorBar *mNavigatorBar; |
116 | 118 | ||
117 | QFrame *headingSep; | 119 | QFrame *headingSep; |
118 | QFrame *weeknumSep; | 120 | QFrame *weeknumSep; |
119 | QLabel *headings[7]; | 121 | QLabel *headings[7]; |
120 | QLabel *weeknos[7]; | 122 | QLabel *weeknos[7]; |
121 | KODayMatrix *daymatrix; | 123 | KODayMatrix *daymatrix; |
122 | 124 | ||
123 | KCal::DateList mSelectedDates; | 125 | KCal::DateList mSelectedDates; |
124 | QDate m_MthYr; | 126 | QDate m_MthYr; |
125 | int m_fstDayOfWk; | 127 | int m_fstDayOfWk; |
126 | bool m_bShowWeekNums; | 128 | bool m_bShowWeekNums; |
127 | 129 | ||
128 | int dayNum(int row, int col); | 130 | int dayNum(int row, int col); |
129 | int dayToIndex(int dayNum); | 131 | int dayToIndex(int dayNum); |
130 | 132 | ||
131 | Calendar *mCalendar; | 133 | Calendar *mCalendar; |
132 | KCalendarSystem *mCalendarSystem; | 134 | KCalendarSystem *mCalendarSystem; |
133 | 135 | ||
134 | const QString *curHeaders; | 136 | const QString *curHeaders; |
135 | 137 | ||
136 | /** used to update the day view periodically, in particular every | 138 | /** used to update the day view periodically, in particular every |
137 | * midnight to move the "today" rectangle. | 139 | * midnight to move the "today" rectangle. |
138 | */ | 140 | */ |
139 | QTimer *updateTimer; | 141 | QTimer *updateTimer; |
140 | QDate lastDayChecked; | 142 | QDate lastDayChecked; |
141 | RolloverType updateRollover; | 143 | RolloverType updateRollover; |
142 | 144 | ||
143 | // Disabling copy constructor and assignment operator | 145 | // Disabling copy constructor and assignment operator |
144 | KDateNavigator(const KDateNavigator & ); | 146 | KDateNavigator(const KDateNavigator & ); |
145 | KDateNavigator &operator=(const KDateNavigator &); | 147 | KDateNavigator &operator=(const KDateNavigator &); |
146 | }; | 148 | }; |
147 | 149 | ||
148 | #endif | 150 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 989f758..a886f4a 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,629 +1,672 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
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 ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <libkcal/vcaldrag.h> | 34 | #include <libkcal/vcaldrag.h> |
35 | #include <libkcal/icaldrag.h> | 35 | #include <libkcal/icaldrag.h> |
36 | #include <libkcal/dndfactory.h> | 36 | #include <libkcal/dndfactory.h> |
37 | #include <libkcal/calendarresources.h> | 37 | #include <libkcal/calendarresources.h> |
38 | #include <libkcal/resourcecalendar.h> | 38 | #include <libkcal/resourcecalendar.h> |
39 | #include <kresources/resourceselectdialog.h> | 39 | #include <kresources/resourceselectdialog.h> |
40 | 40 | ||
41 | #include <kcalendarsystem.h> | 41 | #include <kcalendarsystem.h> |
42 | 42 | ||
43 | #ifndef KORG_NOPLUGINS | 43 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 44 | #include "kocore.h" |
45 | #endif | 45 | #endif |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | 48 | ||
49 | #include "kodaymatrix.h" | 49 | #include "kodaymatrix.h" |
50 | 50 | ||
51 | // ============================================================================ | 51 | // ============================================================================ |
52 | // D Y N A M I C T I P | 52 | // D Y N A M I C T I P |
53 | // ============================================================================ | 53 | // ============================================================================ |
54 | 54 | ||
55 | DynamicTip::DynamicTip( QWidget * parent ) | 55 | DynamicTip::DynamicTip( QWidget * parent ) |
56 | : QToolTip( parent ) | 56 | : QToolTip( parent ) |
57 | { | 57 | { |
58 | matrix = (KODayMatrix*)parent; | 58 | matrix = (KODayMatrix*)parent; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void DynamicTip::maybeTip( const QPoint &pos ) | 62 | void DynamicTip::maybeTip( const QPoint &pos ) |
63 | { | 63 | { |
64 | //calculate which cell of the matrix the mouse is in | 64 | //calculate which cell of the matrix the mouse is in |
65 | QRect sz = matrix->frameRect(); | 65 | QRect sz = matrix->frameRect(); |
66 | int dheight = sz.height()*7 / 42; | 66 | int dheight = sz.height()*7 / 42; |
67 | int dwidth = sz.width() / 7; | 67 | int dwidth = sz.width() / 7; |
68 | int row = pos.y()/dheight; | 68 | int row = pos.y()/dheight; |
69 | int col = pos.x()/dwidth; | 69 | int col = pos.x()/dwidth; |
70 | 70 | ||
71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
72 | 72 | ||
73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
74 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 74 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
75 | 75 | ||
76 | //show holiday names only | 76 | //show holiday names only |
77 | QString str = matrix->getHolidayLabel(col+row*7); | 77 | QString str = matrix->getHolidayLabel(col+row*7); |
78 | if (str.isEmpty()) return; | 78 | if (str.isEmpty()) return; |
79 | tip(rct, str); | 79 | tip(rct, str); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // ============================================================================ | 83 | // ============================================================================ |
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | ||
91 | : QFrame( parent, name ), mCalendar( 0 ) | ||
92 | |||
93 | #if 0 | ||
90 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
91 | QFrame(parent, name) | 95 | QFrame(parent, name) |
96 | #endif | ||
92 | { | 97 | { |
93 | mCalendar = calendar; | 98 | |
94 | mPendingUpdateBeforeRepaint = false; | 99 | mPendingUpdateBeforeRepaint = false; |
95 | 100 | ||
96 | // initialize dynamic arrays | 101 | // initialize dynamic arrays |
97 | days = new QDate[NUMDAYS]; | 102 | days = new QDate[NUMDAYS]; |
98 | daylbls = new QString[NUMDAYS]; | 103 | daylbls = new QString[NUMDAYS]; |
99 | events = new int[NUMDAYS]; | 104 | events = new int[NUMDAYS]; |
100 | mToolTip = new DynamicTip(this); | 105 | mToolTip = new DynamicTip(this); |
101 | 106 | ||
102 | // set default values used for drawing the matrix | 107 | // set default values used for drawing the matrix |
103 | mDefaultBackColor = palette().active().base(); | 108 | mDefaultBackColor = palette().active().base(); |
104 | mDefaultTextColor = palette().active().foreground(); | 109 | mDefaultTextColor = palette().active().foreground(); |
105 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
106 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
107 | mSelectedDaysColor = QColor("white"); | 112 | mSelectedDaysColor = QColor("white"); |
108 | mTodayMarginWidth = 2; | 113 | mTodayMarginWidth = 2; |
109 | mSelEnd = mSelStart = NOSELECTION; | 114 | mSelEnd = mSelStart = NOSELECTION; |
110 | 115 | ||
111 | setAcceptDrops(true); | 116 | setAcceptDrops(true); |
112 | //setFont( QFont("Arial", 10) ); | 117 | //setFont( QFont("Arial", 10) ); |
113 | 118 | ||
114 | mUpdateTimer = new QTimer( this ); | 119 | mUpdateTimer = new QTimer( this ); |
115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
116 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
118 | mDayChanged = false; | 123 | mDayChanged = false; |
119 | updateView(); | 124 | updateView(); |
120 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | ||
127 | { | ||
128 | mCalendar = cal; | ||
129 | |||
130 | setAcceptDrops( mCalendar ); | ||
131 | |||
132 | updateEvents(); | ||
133 | } | ||
121 | 134 | ||
122 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
123 | { | 136 | { |
124 | QColor shaded; | 137 | QColor shaded; |
125 | int h=0; | 138 | int h=0; |
126 | int s=0; | 139 | int s=0; |
127 | int v=0; | 140 | int v=0; |
128 | color.hsv(&h,&s,&v); | 141 | color.hsv(&h,&s,&v); |
129 | s = s/4; | 142 | s = s/4; |
130 | v = 192+v/4; | 143 | v = 192+v/4; |
131 | shaded.setHsv(h,s,v); | 144 | shaded.setHsv(h,s,v); |
132 | 145 | ||
133 | return shaded; | 146 | return shaded; |
134 | } | 147 | } |
135 | 148 | ||
136 | KODayMatrix::~KODayMatrix() | 149 | KODayMatrix::~KODayMatrix() |
137 | { | 150 | { |
138 | delete [] days; | 151 | delete [] days; |
139 | delete [] daylbls; | 152 | delete [] daylbls; |
140 | delete [] events; | 153 | delete [] events; |
141 | delete mToolTip; | 154 | delete mToolTip; |
142 | } | 155 | } |
143 | 156 | ||
144 | /* | 157 | /* |
145 | void KODayMatrix::setStartDate(QDate start) | 158 | void KODayMatrix::setStartDate(QDate start) |
146 | { | 159 | { |
147 | updateView(start); | 160 | updateView(start); |
148 | } | 161 | } |
149 | */ | 162 | */ |
150 | 163 | ||
151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
152 | { | 165 | { |
153 | 166 | ||
154 | if (mSelStart == NOSELECTION) { | 167 | if (mSelStart == NOSELECTION) { |
155 | return; | 168 | return; |
156 | } | 169 | } |
157 | 170 | ||
158 | //cope with selection being out of matrix limits at top (< 0) | 171 | //cope with selection being out of matrix limits at top (< 0) |
159 | int i0 = mSelStart; | 172 | int i0 = mSelStart; |
160 | if (i0 < 0) { | 173 | if (i0 < 0) { |
161 | for (int i = i0; i < 0; i++) { | 174 | for (int i = i0; i < 0; i++) { |
162 | selDays.append(days[0].addDays(i)); | 175 | selDays.append(days[0].addDays(i)); |
163 | } | 176 | } |
164 | i0 = 0; | 177 | i0 = 0; |
165 | } | 178 | } |
166 | 179 | ||
167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
168 | if (mSelEnd > NUMDAYS-1) { | 181 | if (mSelEnd > NUMDAYS-1) { |
169 | for (int i = i0; i <= NUMDAYS-1; i++) { | 182 | for (int i = i0; i <= NUMDAYS-1; i++) { |
170 | selDays.append(days[i]); | 183 | selDays.append(days[i]); |
171 | } | 184 | } |
172 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 185 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
173 | selDays.append(days[0].addDays(i)); | 186 | selDays.append(days[0].addDays(i)); |
174 | } | 187 | } |
175 | 188 | ||
176 | // apply normal routine to selection being entirely within matrix limits | 189 | // apply normal routine to selection being entirely within matrix limits |
177 | } else { | 190 | } else { |
178 | for (int i = i0; i <= mSelEnd; i++) { | 191 | for (int i = i0; i <= mSelEnd; i++) { |
179 | selDays.append(days[i]); | 192 | selDays.append(days[i]); |
180 | } | 193 | } |
181 | } | 194 | } |
182 | } | 195 | } |
183 | 196 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 198 | { |
186 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
188 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | ||
203 | { | ||
204 | mSelEnd = mSelStart = NOSELECTION; | ||
205 | } | ||
189 | 206 | ||
190 | 207 | ||
191 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
192 | { | 209 | { |
193 | today = -1; | 210 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
195 | events[i] = 0; | 212 | events[i] = 0; |
196 | days[i] = startdate.addDays(i); | 213 | days[i] = startdate.addDays(i); |
197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
198 | 215 | ||
199 | // if today is in the currently displayed month, hilight today | 216 | // if today is in the currently displayed month, hilight today |
200 | if (days[i].year() == QDate::currentDate().year() && | 217 | if (days[i].year() == QDate::currentDate().year() && |
201 | days[i].month() == QDate::currentDate().month() && | 218 | days[i].month() == QDate::currentDate().month() && |
202 | days[i].day() == QDate::currentDate().day()) { | 219 | days[i].day() == QDate::currentDate().day()) { |
203 | today = i; | 220 | today = i; |
204 | } | 221 | } |
205 | } | 222 | } |
206 | // qDebug(QString("Today is visible at %1.").arg(today)); | 223 | // qDebug(QString("Today is visible at %1.").arg(today)); |
207 | } | 224 | } |
208 | 225 | ||
209 | void KODayMatrix::updateView() | 226 | void KODayMatrix::updateView() |
210 | { | 227 | { |
211 | updateView(startdate); | 228 | updateView(startdate); |
212 | } | 229 | } |
213 | void KODayMatrix::repaintViewTimed() | 230 | void KODayMatrix::repaintViewTimed() |
214 | { | 231 | { |
215 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
216 | repaint(false); | 233 | repaint(false); |
217 | } | 234 | } |
218 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
219 | { | 236 | { |
220 | |||
221 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | ||
239 | qDebug("NOT CAL "); | ||
240 | return; | ||
241 | } | ||
242 | //qDebug("KODayMatrix::updateViewTimed "); | ||
222 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
223 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
225 | Event *event; | 246 | Event *event; |
226 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
227 | QString holiStr = ""; | 248 | QString holiStr = ""; |
228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
229 | ushort recurType = event->recurrence()->doesRecur(); | 250 | ushort recurType = event->recurrence()->doesRecur(); |
230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
232 | numEvents--; | 253 | numEvents--; |
233 | } | 254 | } |
234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
235 | if ( !holiStr.isEmpty() ) | 256 | if ( !holiStr.isEmpty() ) |
236 | holiStr += "\n"; | 257 | holiStr += "\n"; |
237 | holiStr += event->summary(); | 258 | holiStr += event->summary(); |
238 | } | 259 | } |
239 | } | 260 | } |
240 | events[i] = numEvents; | 261 | events[i] = numEvents; |
241 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 262 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
243 | !holiStr.isEmpty()) { | 264 | !holiStr.isEmpty()) { |
244 | mHolidays[i] = holiStr; | 265 | mHolidays[i] = holiStr; |
245 | } else { | 266 | } else { |
246 | mHolidays[i] = QString::null; | 267 | mHolidays[i] = QString::null; |
247 | } | 268 | } |
248 | } | 269 | } |
249 | if ( ! mPendingUpdateBeforeRepaint ) | 270 | if ( ! mPendingUpdateBeforeRepaint ) |
250 | repaint(false); | 271 | repaint(false); |
251 | } | 272 | } |
252 | void KODayMatrix::updateView(QDate actdate) | 273 | void KODayMatrix::updateView(QDate actdate) |
253 | { | 274 | { |
254 | 275 | ||
255 | if ( ! actdate.isValid() ) { | 276 | if ( ! actdate.isValid() ) { |
256 | //qDebug("date not valid "); | 277 | //qDebug("date not valid "); |
257 | return; | 278 | return; |
258 | } | 279 | } |
259 | mDayChanged = false; | 280 | mDayChanged = false; |
260 | //flag to indicate if the starting day of the matrix has changed by this call | 281 | //flag to indicate if the starting day of the matrix has changed by this call |
261 | //mDayChanged = false; | 282 | //mDayChanged = false; |
262 | // if a new startdate is to be set then apply Cornelius's calculation | 283 | // if a new startdate is to be set then apply Cornelius's calculation |
263 | // of the first day to be shown | 284 | // of the first day to be shown |
264 | if (actdate != startdate) { | 285 | if (actdate != startdate) { |
265 | // reset index of selection according to shift of starting date from startdate to actdate | 286 | // reset index of selection according to shift of starting date from startdate to actdate |
266 | if (mSelStart != NOSELECTION) { | 287 | if (mSelStart != NOSELECTION) { |
267 | int tmp = actdate.daysTo(startdate); | 288 | int tmp = actdate.daysTo(startdate); |
268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
269 | // shift selection if new one would be visible at least partly ! | 290 | // shift selection if new one would be visible at least partly ! |
270 | 291 | ||
271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
272 | // nested if is required for next X display pushed from a different month - correction required | 293 | // nested if is required for next X display pushed from a different month - correction required |
273 | // otherwise, for month forward and backward, it must be avoided | 294 | // otherwise, for month forward and backward, it must be avoided |
274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
275 | mSelStart = mSelStart + tmp; | 296 | mSelStart = mSelStart + tmp; |
276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
277 | mSelEnd = mSelEnd + tmp; | 298 | mSelEnd = mSelEnd + tmp; |
278 | } | 299 | } |
279 | } | 300 | } |
280 | startdate = actdate; | 301 | startdate = actdate; |
281 | mDayChanged = true; | 302 | mDayChanged = true; |
282 | recalculateToday(); | 303 | recalculateToday(); |
283 | } | 304 | } |
284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
285 | if ( !isVisible() ) { | 306 | if ( !isVisible() ) { |
286 | mPendingUpdateBeforeRepaint = true; | 307 | mPendingUpdateBeforeRepaint = true; |
287 | } else { | 308 | } else { |
288 | #ifdef DESKTOP_VERSION | 309 | #ifdef DESKTOP_VERSION |
289 | //mRepaintTimer->start( 250 ); | 310 | //mRepaintTimer->start( 250 ); |
290 | mUpdateTimer->start( 250 ); | 311 | mUpdateTimer->start( 250 ); |
291 | #else | 312 | #else |
292 | mRepaintTimer->start( 350 ); | 313 | mRepaintTimer->start( 350 ); |
293 | mUpdateTimer->start( 2000 ); | 314 | mUpdateTimer->start( 2000 ); |
294 | #endif | 315 | #endif |
295 | } | 316 | } |
296 | } | 317 | } |
318 | void KODayMatrix::updateEvents() | ||
319 | { | ||
320 | if ( !mCalendar ) return; | ||
321 | |||
322 | for( int i = 0; i < NUMDAYS; i++ ) { | ||
323 | // if events are set for the day then remember to draw it bold | ||
324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | ||
325 | int numEvents = eventlist.count(); | ||
326 | Event *event; | ||
327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | ||
328 | ushort recurType = event->doesRecur(); | ||
329 | |||
330 | if ( ( recurType == Recurrence::rDaily && | ||
331 | !KOPrefs::instance()->mDailyRecur ) || | ||
332 | ( recurType == Recurrence::rWeekly && | ||
333 | !KOPrefs::instance()->mWeeklyRecur ) ) { | ||
334 | numEvents--; | ||
335 | } | ||
336 | } | ||
337 | events[ i ] = numEvents; | ||
338 | } | ||
339 | } | ||
297 | 340 | ||
298 | const QDate& KODayMatrix::getDate(int offset) | 341 | const QDate& KODayMatrix::getDate(int offset) |
299 | { | 342 | { |
300 | if (offset < 0 || offset > NUMDAYS-1) { | 343 | if (offset < 0 || offset > NUMDAYS-1) { |
301 | qDebug("Wrong offset2 "); | 344 | qDebug("Wrong offset2 "); |
302 | return days[0]; | 345 | return days[0]; |
303 | } | 346 | } |
304 | return days[offset]; | 347 | return days[offset]; |
305 | } | 348 | } |
306 | 349 | ||
307 | QString KODayMatrix::getHolidayLabel(int offset) | 350 | QString KODayMatrix::getHolidayLabel(int offset) |
308 | { | 351 | { |
309 | if (offset < 0 || offset > NUMDAYS-1) { | 352 | if (offset < 0 || offset > NUMDAYS-1) { |
310 | qDebug("Wrong offset1 "); | 353 | qDebug("Wrong offset1 "); |
311 | return 0; | 354 | return 0; |
312 | } | 355 | } |
313 | return mHolidays[offset]; | 356 | return mHolidays[offset]; |
314 | } | 357 | } |
315 | 358 | ||
316 | int KODayMatrix::getDayIndexFrom(int x, int y) | 359 | int KODayMatrix::getDayIndexFrom(int x, int y) |
317 | { | 360 | { |
318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
319 | 6 - x/daysize.width() : x/daysize.width()); | 362 | 6 - x/daysize.width() : x/daysize.width()); |
320 | } | 363 | } |
321 | 364 | ||
322 | // ---------------------------------------------------------------------------- | 365 | // ---------------------------------------------------------------------------- |
323 | // M O U S E E V E N T H A N D L I N G | 366 | // M O U S E E V E N T H A N D L I N G |
324 | // ---------------------------------------------------------------------------- | 367 | // ---------------------------------------------------------------------------- |
325 | 368 | ||
326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
327 | { | 370 | { |
328 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 371 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
330 | mSelInit = mSelStart; | 373 | mSelInit = mSelStart; |
331 | } | 374 | } |
332 | 375 | ||
333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
334 | { | 377 | { |
335 | 378 | ||
336 | int tmp = getDayIndexFrom(e->x(), e->y()); | 379 | int tmp = getDayIndexFrom(e->x(), e->y()); |
337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
338 | 381 | ||
339 | if (mSelInit > tmp) { | 382 | if (mSelInit > tmp) { |
340 | mSelEnd = mSelInit; | 383 | mSelEnd = mSelInit; |
341 | if (tmp != mSelStart) { | 384 | if (tmp != mSelStart) { |
342 | mSelStart = tmp; | 385 | mSelStart = tmp; |
343 | repaint(false); | 386 | repaint(false); |
344 | } | 387 | } |
345 | } else { | 388 | } else { |
346 | mSelStart = mSelInit; | 389 | mSelStart = mSelInit; |
347 | 390 | ||
348 | //repaint only if selection has changed | 391 | //repaint only if selection has changed |
349 | if (tmp != mSelEnd) { | 392 | if (tmp != mSelEnd) { |
350 | mSelEnd = tmp; | 393 | mSelEnd = tmp; |
351 | repaint(false); | 394 | repaint(false); |
352 | } | 395 | } |
353 | } | 396 | } |
354 | 397 | ||
355 | DateList daylist; | 398 | DateList daylist; |
356 | if ( mSelStart < 0 ) | 399 | if ( mSelStart < 0 ) |
357 | mSelStart = 0; | 400 | mSelStart = 0; |
358 | for (int i = mSelStart; i <= mSelEnd; i++) { | 401 | for (int i = mSelStart; i <= mSelEnd; i++) { |
359 | daylist.append(days[i]); | 402 | daylist.append(days[i]); |
360 | } | 403 | } |
361 | emit selected((const DateList)daylist); | 404 | emit selected((const DateList)daylist); |
362 | 405 | ||
363 | } | 406 | } |
364 | 407 | ||
365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 408 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
366 | { | 409 | { |
367 | int tmp = getDayIndexFrom(e->x(), e->y()); | 410 | int tmp = getDayIndexFrom(e->x(), e->y()); |
368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 411 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
369 | 412 | ||
370 | if (mSelInit > tmp) { | 413 | if (mSelInit > tmp) { |
371 | mSelEnd = mSelInit; | 414 | mSelEnd = mSelInit; |
372 | if (tmp != mSelStart) { | 415 | if (tmp != mSelStart) { |
373 | mSelStart = tmp; | 416 | mSelStart = tmp; |
374 | repaint(false); | 417 | repaint(false); |
375 | } | 418 | } |
376 | } else { | 419 | } else { |
377 | mSelStart = mSelInit; | 420 | mSelStart = mSelInit; |
378 | 421 | ||
379 | //repaint only if selection has changed | 422 | //repaint only if selection has changed |
380 | if (tmp != mSelEnd) { | 423 | if (tmp != mSelEnd) { |
381 | mSelEnd = tmp; | 424 | mSelEnd = tmp; |
382 | repaint(false); | 425 | repaint(false); |
383 | } | 426 | } |
384 | } | 427 | } |
385 | } | 428 | } |
386 | 429 | ||
387 | // ---------------------------------------------------------------------------- | 430 | // ---------------------------------------------------------------------------- |
388 | // D R A G ' N D R O P H A N D L I N G | 431 | // D R A G ' N D R O P H A N D L I N G |
389 | // ---------------------------------------------------------------------------- | 432 | // ---------------------------------------------------------------------------- |
390 | 433 | ||
391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 434 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
392 | { | 435 | { |
393 | #ifndef KORG_NODND | 436 | #ifndef KORG_NODND |
394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 437 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
395 | e->ignore(); | 438 | e->ignore(); |
396 | return; | 439 | return; |
397 | } | 440 | } |
398 | 441 | ||
399 | // some visual feedback | 442 | // some visual feedback |
400 | // oldPalette = palette(); | 443 | // oldPalette = palette(); |
401 | // setPalette(my_HilitePalette); | 444 | // setPalette(my_HilitePalette); |
402 | // update(); | 445 | // update(); |
403 | #endif | 446 | #endif |
404 | } | 447 | } |
405 | 448 | ||
406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 449 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
407 | { | 450 | { |
408 | #ifndef KORG_NODND | 451 | #ifndef KORG_NODND |
409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 452 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
410 | e->ignore(); | 453 | e->ignore(); |
411 | return; | 454 | return; |
412 | } | 455 | } |
413 | 456 | ||
414 | e->accept(); | 457 | e->accept(); |
415 | #endif | 458 | #endif |
416 | } | 459 | } |
417 | 460 | ||
418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 461 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
419 | { | 462 | { |
420 | #ifndef KORG_NODND | 463 | #ifndef KORG_NODND |
421 | // setPalette(oldPalette); | 464 | // setPalette(oldPalette); |
422 | // update(); | 465 | // update(); |
423 | #endif | 466 | #endif |
424 | } | 467 | } |
425 | 468 | ||
426 | void KODayMatrix::dropEvent(QDropEvent *e) | 469 | void KODayMatrix::dropEvent(QDropEvent *e) |
427 | { | 470 | { |
428 | #ifndef KORG_NODND | 471 | #ifndef KORG_NODND |
429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
430 | 473 | ||
431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
432 | e->ignore(); | 475 | e->ignore(); |
433 | return; | 476 | return; |
434 | } | 477 | } |
435 | 478 | ||
436 | DndFactory factory( mCalendar ); | 479 | DndFactory factory( mCalendar ); |
437 | Event *event = factory.createDrop(e); | 480 | Event *event = factory.createDrop(e); |
438 | 481 | ||
439 | if (event) { | 482 | if (event) { |
440 | e->acceptAction(); | 483 | e->acceptAction(); |
441 | 484 | ||
442 | Event *existingEvent = mCalendar->event(event->uid()); | 485 | Event *existingEvent = mCalendar->event(event->uid()); |
443 | 486 | ||
444 | if(existingEvent) { | 487 | if(existingEvent) { |
445 | // uniquify event | 488 | // uniquify event |
446 | event->recreate(); | 489 | event->recreate(); |
447 | /* | 490 | /* |
448 | KMessageBox::sorry(this, | 491 | KMessageBox::sorry(this, |
449 | i18n("Event already exists in this calendar."), | 492 | i18n("Event already exists in this calendar."), |
450 | i18n("Drop Event")); | 493 | i18n("Drop Event")); |
451 | delete event; | 494 | delete event; |
452 | return; | 495 | return; |
453 | */ | 496 | */ |
454 | } | 497 | } |
455 | // kdDebug() << "Drop new Event" << endl; | 498 | // kdDebug() << "Drop new Event" << endl; |
456 | // Adjust date | 499 | // Adjust date |
457 | QDateTime start = event->dtStart(); | 500 | QDateTime start = event->dtStart(); |
458 | QDateTime end = event->dtEnd(); | 501 | QDateTime end = event->dtEnd(); |
459 | int duration = start.daysTo(end); | 502 | int duration = start.daysTo(end); |
460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 503 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
461 | 504 | ||
462 | start.setDate(days[idx]); | 505 | start.setDate(days[idx]); |
463 | end.setDate(days[idx].addDays(duration)); | 506 | end.setDate(days[idx].addDays(duration)); |
464 | 507 | ||
465 | event->setDtStart(start); | 508 | event->setDtStart(start); |
466 | event->setDtEnd(end); | 509 | event->setDtEnd(end); |
467 | mCalendar->addEvent(event); | 510 | mCalendar->addEvent(event); |
468 | 511 | ||
469 | emit eventDropped(event); | 512 | emit eventDropped(event); |
470 | } else { | 513 | } else { |
471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 514 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
472 | e->ignore(); | 515 | e->ignore(); |
473 | } | 516 | } |
474 | #endif | 517 | #endif |
475 | } | 518 | } |
476 | 519 | ||
477 | // ---------------------------------------------------------------------------- | 520 | // ---------------------------------------------------------------------------- |
478 | // P A I N T E V E N T H A N D L I N G | 521 | // P A I N T E V E N T H A N D L I N G |
479 | // ---------------------------------------------------------------------------- | 522 | // ---------------------------------------------------------------------------- |
480 | 523 | ||
481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 524 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
482 | { | 525 | { |
483 | if ( width() <= 0 || height() <= 0 ) | 526 | if ( width() <= 0 || height() <= 0 ) |
484 | return; | 527 | return; |
485 | if ( mPendingUpdateBeforeRepaint ) { | 528 | if ( mPendingUpdateBeforeRepaint ) { |
486 | updateViewTimed(); | 529 | updateViewTimed(); |
487 | mPendingUpdateBeforeRepaint = false; | 530 | mPendingUpdateBeforeRepaint = false; |
488 | } | 531 | } |
489 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 532 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
490 | myPix.resize(size() ); | 533 | myPix.resize(size() ); |
491 | } | 534 | } |
492 | QPainter p(&myPix); | 535 | QPainter p(&myPix); |
493 | p.setFont(font()); | 536 | p.setFont(font()); |
494 | 537 | ||
495 | QRect sz = frameRect(); | 538 | QRect sz = frameRect(); |
496 | int dheight = daysize.height(); | 539 | int dheight = daysize.height(); |
497 | int dwidth = daysize.width(); | 540 | int dwidth = daysize.width(); |
498 | int row,col; | 541 | int row,col; |
499 | int selw, selh; | 542 | int selw, selh; |
500 | bool isRTL = KOGlobals::self()->reverseLayout(); | 543 | bool isRTL = KOGlobals::self()->reverseLayout(); |
501 | 544 | ||
502 | // draw background and topleft frame | 545 | // draw background and topleft frame |
503 | p.fillRect(pevent->rect(), mDefaultBackColor); | 546 | p.fillRect(pevent->rect(), mDefaultBackColor); |
504 | p.setPen(mDefaultTextColor); | 547 | p.setPen(mDefaultTextColor); |
505 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 548 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
506 | 549 | ||
507 | // draw selected days with highlighted background color | 550 | // draw selected days with highlighted background color |
508 | if (mSelStart != NOSELECTION) { | 551 | if (mSelStart != NOSELECTION) { |
509 | 552 | ||
510 | row = mSelStart/7; | 553 | row = mSelStart/7; |
511 | col = mSelStart -row*7; | 554 | col = mSelStart -row*7; |
512 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 555 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
513 | 556 | ||
514 | if (row == mSelEnd/7) { | 557 | if (row == mSelEnd/7) { |
515 | // Single row selection | 558 | // Single row selection |
516 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 559 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
517 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 560 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
518 | } else { | 561 | } else { |
519 | // draw first row to the right | 562 | // draw first row to the right |
520 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 563 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
521 | dheight, selcol); | 564 | dheight, selcol); |
522 | // draw full block till last line | 565 | // draw full block till last line |
523 | selh = mSelEnd/7-row; | 566 | selh = mSelEnd/7-row; |
524 | if (selh > 1) { | 567 | if (selh > 1) { |
525 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 568 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
526 | } | 569 | } |
527 | // draw last block from left to mSelEnd | 570 | // draw last block from left to mSelEnd |
528 | selw = mSelEnd-7*(mSelEnd/7)+1; | 571 | selw = mSelEnd-7*(mSelEnd/7)+1; |
529 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 572 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
530 | selw*dwidth, dheight, selcol); | 573 | selw*dwidth, dheight, selcol); |
531 | } | 574 | } |
532 | } | 575 | } |
533 | 576 | ||
534 | // iterate over all days in the matrix and draw the day label in appropriate colors | 577 | // iterate over all days in the matrix and draw the day label in appropriate colors |
535 | QColor actcol = mDefaultTextColorShaded; | 578 | QColor actcol = mDefaultTextColorShaded; |
536 | p.setPen(actcol); | 579 | p.setPen(actcol); |
537 | QPen tmppen; | 580 | QPen tmppen; |
538 | for(int i = 0; i < NUMDAYS; i++) { | 581 | for(int i = 0; i < NUMDAYS; i++) { |
539 | row = i/7; | 582 | row = i/7; |
540 | col = isRTL ? 6-(i-row*7) : i-row*7; | 583 | col = isRTL ? 6-(i-row*7) : i-row*7; |
541 | 584 | ||
542 | // if it is the first day of a month switch color from normal to shaded and vice versa | 585 | // if it is the first day of a month switch color from normal to shaded and vice versa |
543 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 586 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
544 | if (actcol == mDefaultTextColorShaded) { | 587 | if (actcol == mDefaultTextColorShaded) { |
545 | actcol = mDefaultTextColor; | 588 | actcol = mDefaultTextColor; |
546 | } else { | 589 | } else { |
547 | actcol = mDefaultTextColorShaded; | 590 | actcol = mDefaultTextColorShaded; |
548 | } | 591 | } |
549 | p.setPen(actcol); | 592 | p.setPen(actcol); |
550 | } | 593 | } |
551 | 594 | ||
552 | //Reset pen color after selected days block | 595 | //Reset pen color after selected days block |
553 | if (i == mSelEnd+1) { | 596 | if (i == mSelEnd+1) { |
554 | p.setPen(actcol); | 597 | p.setPen(actcol); |
555 | } | 598 | } |
556 | 599 | ||
557 | // if today then draw rectangle around day | 600 | // if today then draw rectangle around day |
558 | if (today == i) { | 601 | if (today == i) { |
559 | tmppen = p.pen(); | 602 | tmppen = p.pen(); |
560 | QPen mTodayPen(p.pen()); | 603 | QPen mTodayPen(p.pen()); |
561 | 604 | ||
562 | mTodayPen.setWidth(mTodayMarginWidth); | 605 | mTodayPen.setWidth(mTodayMarginWidth); |
563 | //draw red rectangle for holidays | 606 | //draw red rectangle for holidays |
564 | if (!mHolidays[i].isNull()) { | 607 | if (!mHolidays[i].isNull()) { |
565 | if (actcol == mDefaultTextColor) { | 608 | if (actcol == mDefaultTextColor) { |
566 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 609 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
567 | } else { | 610 | } else { |
568 | mTodayPen.setColor(mHolidayColorShaded); | 611 | mTodayPen.setColor(mHolidayColorShaded); |
569 | } | 612 | } |
570 | } | 613 | } |
571 | //draw gray rectangle for today if in selection | 614 | //draw gray rectangle for today if in selection |
572 | if (i >= mSelStart && i <= mSelEnd) { | 615 | if (i >= mSelStart && i <= mSelEnd) { |
573 | QColor grey("grey"); | 616 | QColor grey("grey"); |
574 | mTodayPen.setColor(grey); | 617 | mTodayPen.setColor(grey); |
575 | } | 618 | } |
576 | p.setPen(mTodayPen); | 619 | p.setPen(mTodayPen); |
577 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 620 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
578 | p.setPen(tmppen); | 621 | p.setPen(tmppen); |
579 | } | 622 | } |
580 | 623 | ||
581 | // if any events are on that day then draw it using a bold font | 624 | // if any events are on that day then draw it using a bold font |
582 | if (events[i] > 0) { | 625 | if (events[i] > 0) { |
583 | QFont myFont = font(); | 626 | QFont myFont = font(); |
584 | myFont.setBold(true); | 627 | myFont.setBold(true); |
585 | p.setFont(myFont); | 628 | p.setFont(myFont); |
586 | } | 629 | } |
587 | 630 | ||
588 | // if it is a holiday then use the default holiday color | 631 | // if it is a holiday then use the default holiday color |
589 | if (!mHolidays[i].isNull()) { | 632 | if (!mHolidays[i].isNull()) { |
590 | if (actcol == mDefaultTextColor) { | 633 | if (actcol == mDefaultTextColor) { |
591 | p.setPen(KOPrefs::instance()->mHolidayColor); | 634 | p.setPen(KOPrefs::instance()->mHolidayColor); |
592 | } else { | 635 | } else { |
593 | p.setPen(mHolidayColorShaded); | 636 | p.setPen(mHolidayColorShaded); |
594 | } | 637 | } |
595 | } | 638 | } |
596 | 639 | ||
597 | // draw selected days with special color | 640 | // draw selected days with special color |
598 | // DO NOT specially highlight holidays in selection ! | 641 | // DO NOT specially highlight holidays in selection ! |
599 | if (i >= mSelStart && i <= mSelEnd) { | 642 | if (i >= mSelStart && i <= mSelEnd) { |
600 | p.setPen(mSelectedDaysColor); | 643 | p.setPen(mSelectedDaysColor); |
601 | } | 644 | } |
602 | 645 | ||
603 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 646 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
604 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 647 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
605 | 648 | ||
606 | // reset color to actual color | 649 | // reset color to actual color |
607 | if (!mHolidays[i].isNull()) { | 650 | if (!mHolidays[i].isNull()) { |
608 | p.setPen(actcol); | 651 | p.setPen(actcol); |
609 | } | 652 | } |
610 | // reset bold font to plain font | 653 | // reset bold font to plain font |
611 | if (events[i] > 0) { | 654 | if (events[i] > 0) { |
612 | QFont myFont = font(); | 655 | QFont myFont = font(); |
613 | myFont.setBold(false); | 656 | myFont.setBold(false); |
614 | p.setFont(myFont); | 657 | p.setFont(myFont); |
615 | } | 658 | } |
616 | } | 659 | } |
617 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 660 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
618 | } | 661 | } |
619 | 662 | ||
620 | // ---------------------------------------------------------------------------- | 663 | // ---------------------------------------------------------------------------- |
621 | // R E SI Z E E V E N T H A N D L I N G | 664 | // R E SI Z E E V E N T H A N D L I N G |
622 | // ---------------------------------------------------------------------------- | 665 | // ---------------------------------------------------------------------------- |
623 | 666 | ||
624 | void KODayMatrix::resizeEvent(QResizeEvent *) | 667 | void KODayMatrix::resizeEvent(QResizeEvent *) |
625 | { | 668 | { |
626 | QRect sz = frameRect(); | 669 | QRect sz = frameRect(); |
627 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 670 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
628 | daysize.setWidth(sz.width() / 7); | 671 | daysize.setWidth(sz.width() / 7); |
629 | } | 672 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 2dd112a..ba4853f 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,316 +1,318 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KODAYMAT_H | 23 | #ifndef _KODAYMAT_H |
24 | #define _KODAYMAT_H | 24 | #define _KODAYMAT_H |
25 | 25 | ||
26 | #include <libkcal/calendar.h> | 26 | #include <libkcal/calendar.h> |
27 | 27 | ||
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qcolor.h> | 30 | #include <qcolor.h> |
31 | #include <qpen.h> | 31 | #include <qpen.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qtooltip.h> | 33 | #include <qtooltip.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | 35 | ||
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragMoveEvent; | 39 | class QDragMoveEvent; |
40 | class QDragLeaveEvent; | 40 | class QDragLeaveEvent; |
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * small helper class to dynamically show tooltips inside the day matrix. | 49 | * small helper class to dynamically show tooltips inside the day matrix. |
50 | * This class asks the day matrix object for a appropriate label which | 50 | * This class asks the day matrix object for a appropriate label which |
51 | * is in our special case the name of the holiday or null if this day is no holiday. | 51 | * is in our special case the name of the holiday or null if this day is no holiday. |
52 | */ | 52 | */ |
53 | class DynamicTip : public QToolTip | 53 | class DynamicTip : public QToolTip |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Constructor that expects a KODayMatrix object as parent. | 58 | * Constructor that expects a KODayMatrix object as parent. |
59 | * | 59 | * |
60 | * @param parent the parent KODayMatrix control. | 60 | * @param parent the parent KODayMatrix control. |
61 | */ | 61 | */ |
62 | DynamicTip(QWidget* parent ); | 62 | DynamicTip(QWidget* parent ); |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Qt's callback to ask the object to provide an approrpiate text for the | 67 | * Qt's callback to ask the object to provide an approrpiate text for the |
68 | * tooltip to be shown. | 68 | * tooltip to be shown. |
69 | * | 69 | * |
70 | * @param pos coordinates of the mouse. | 70 | * @param pos coordinates of the mouse. |
71 | */ | 71 | */ |
72 | void maybeTip( const QPoint & pos); | 72 | void maybeTip( const QPoint & pos); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | 75 | ||
76 | /** the parent control this tooltip is designed for. */ | 76 | /** the parent control this tooltip is designed for. */ |
77 | KODayMatrix* matrix; | 77 | KODayMatrix* matrix; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
82 | * Cornelius thought this was a waste of memory and a lot of overhead. | 82 | * Cornelius thought this was a waste of memory and a lot of overhead. |
83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
84 | * that draws the labels and allows for dragging selection while maintaining nearly full | 84 | * that draws the labels and allows for dragging selection while maintaining nearly full |
85 | * compatibility in behaviour with its predecessor. | 85 | * compatibility in behaviour with its predecessor. |
86 | * | 86 | * |
87 | * The following functionality has been changed: | 87 | * The following functionality has been changed: |
88 | * | 88 | * |
89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
91 | * o no support for Ctrl+click to create groups of dates | 91 | * o no support for Ctrl+click to create groups of dates |
92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
93 | * user friendly.) | 93 | * user friendly.) |
94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
96 | * two distinct groups of date selections as in the old class) | 96 | * two distinct groups of date selections as in the old class) |
97 | * o now that you can select more then a week it can happen that not all selected days are | 97 | * o now that you can select more then a week it can happen that not all selected days are |
98 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 98 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
99 | * adjust the selection and leave some days undisplayed while scrolling through the months | 99 | * adjust the selection and leave some days undisplayed while scrolling through the months |
100 | * | 100 | * |
101 | * @short day matrix widget of the KDateNavigator | 101 | * @short day matrix widget of the KDateNavigator |
102 | * | 102 | * |
103 | * @author Eitzenberger Thomas | 103 | * @author Eitzenberger Thomas |
104 | */ | 104 | */ |
105 | class KODayMatrix: public QFrame { | 105 | class KODayMatrix: public QFrame { |
106 | 106 | ||
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | 108 | ||
109 | public: | 109 | public: |
110 | 110 | ||
111 | /** constructor to create a day matrix widget. | 111 | /** constructor to create a day matrix widget. |
112 | * | 112 | * |
113 | * @param parent widget that is the parent of the day matrix. Normally this should | 113 | * @param parent widget that is the parent of the day matrix. Normally this should |
114 | * be a KDateNavigator | 114 | * be a KDateNavigator |
115 | * @param calendar instance of a calendar on which all calculations are based | 115 | * @param calendar instance of a calendar on which all calculations are based |
116 | * @param date start date of the matrix (is expected to be already fixed). It is | 116 | * @param date start date of the matrix (is expected to be already fixed). It is |
117 | * assumed that this date is the first week day to be shown in the matrix. | 117 | * assumed that this date is the first week day to be shown in the matrix. |
118 | * @param name name of the widget | 118 | * @param name name of the widget |
119 | */ | 119 | */ |
120 | KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 120 | KODayMatrix( QWidget *parent, const char *name ); |
121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | ||
121 | 122 | ||
122 | /** destructor that deallocates all dynamically allocated private members. | 123 | /** destructor that deallocates all dynamically allocated private members. |
123 | */ | 124 | */ |
124 | ~KODayMatrix(); | 125 | ~KODayMatrix(); |
125 | 126 | ||
126 | /** updates the day matrix to start with the given date. Does all the necessary | 127 | /** updates the day matrix to start with the given date. Does all the necessary |
127 | * checks for holidays or events on a day and stores them for display later on. | 128 | * checks for holidays or events on a day and stores them for display later on. |
128 | * Does NOT update the view visually. Call repaint() for this. | 129 | * Does NOT update the view visually. Call repaint() for this. |
129 | * | 130 | * |
130 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 131 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
131 | * date. | 132 | * date. |
132 | */ | 133 | */ |
133 | void updateView(QDate actdate); | 134 | void updateView(QDate actdate); |
135 | void updateEvents(); | ||
134 | 136 | ||
135 | /** returns the QDate object associated with day indexed by the | 137 | /** returns the QDate object associated with day indexed by the |
136 | * supplied offset. | 138 | * supplied offset. |
137 | */ | 139 | */ |
138 | const QDate& getDate(int offset); | 140 | const QDate& getDate(int offset); |
139 | 141 | void setCalendar( Calendar * ); | |
140 | /** returns the official name of this holy day or 0 if there is no label | 142 | /** returns the official name of this holy day or 0 if there is no label |
141 | * for this day. | 143 | * for this day. |
142 | */ | 144 | */ |
143 | QString getHolidayLabel(int offset); | 145 | QString getHolidayLabel(int offset); |
144 | 146 | ||
145 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 147 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
146 | * DateList. | 148 | * DateList. |
147 | */ | 149 | */ |
148 | void addSelectedDaysTo(DateList&); | 150 | void addSelectedDaysTo(DateList&); |
149 | 151 | ||
150 | /** sets the actual to be displayed selection in the day matrix starting from | 152 | /** sets the actual to be displayed selection in the day matrix starting from |
151 | * start and ending with end. Theview must be manually updated by calling | 153 | * start and ending with end. Theview must be manually updated by calling |
152 | * repaint. (?) | 154 | * repaint. (?) |
153 | */ | 155 | */ |
154 | void setSelectedDaysFrom(const QDate& start, const QDate& end); | 156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); |
155 | 157 | void clearSelection(); | |
156 | 158 | ||
157 | /** Is today visible in the view? Keep this in sync with | 159 | /** Is today visible in the view? Keep this in sync with |
158 | * the values today (below) can take. | 160 | * the values today (below) can take. |
159 | */ | 161 | */ |
160 | bool isTodayVisible() const { return today>=0; } ; | 162 | bool isTodayVisible() const { return today>=0; } ; |
161 | 163 | ||
162 | /** If today is visible, then we can find out if today is | 164 | /** If today is visible, then we can find out if today is |
163 | * near the beginning or the end of the month. | 165 | * near the beginning or the end of the month. |
164 | * This is dependent on today remaining the index | 166 | * This is dependent on today remaining the index |
165 | * in the array of visible dates and going from | 167 | * in the array of visible dates and going from |
166 | * top left (0) to bottom right (41). | 168 | * top left (0) to bottom right (41). |
167 | */ | 169 | */ |
168 | bool isBeginningOfMonth() const { return today<=8; } ; | 170 | bool isBeginningOfMonth() const { return today<=8; } ; |
169 | bool isEndOfMonth() const { return today>=27; } ; | 171 | bool isEndOfMonth() const { return today>=27; } ; |
170 | 172 | ||
171 | public slots: | 173 | public slots: |
172 | /** Recalculates all the flags of the days in the matrix like holidays or events | 174 | /** Recalculates all the flags of the days in the matrix like holidays or events |
173 | * on a day (Actually calls above method with the actual startdate). | 175 | * on a day (Actually calls above method with the actual startdate). |
174 | */ | 176 | */ |
175 | void updateView(); | 177 | void updateView(); |
176 | void updateViewTimed(); | 178 | void updateViewTimed(); |
177 | void repaintViewTimed(); | 179 | void repaintViewTimed(); |
178 | 180 | ||
179 | /** | 181 | /** |
180 | * Calculate which square in the matrix should be | 182 | * Calculate which square in the matrix should be |
181 | * hilighted to indicate it's today. | 183 | * hilighted to indicate it's today. |
182 | */ | 184 | */ |
183 | void recalculateToday(); | 185 | void recalculateToday(); |
184 | 186 | ||
185 | /* | 187 | /* |
186 | void setStartDate(QDate); | 188 | void setStartDate(QDate); |
187 | */ | 189 | */ |
188 | 190 | ||
189 | signals: | 191 | signals: |
190 | 192 | ||
191 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 193 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
192 | * inside the matrix | 194 | * inside the matrix |
193 | * | 195 | * |
194 | * @param daylist list of days that have been selected by the user | 196 | * @param daylist list of days that have been selected by the user |
195 | */ | 197 | */ |
196 | void selected( const KCal::DateList &daylist ); | 198 | void selected( const KCal::DateList &daylist ); |
197 | 199 | ||
198 | /** emitted if the user has dropped an event inside the matrix | 200 | /** emitted if the user has dropped an event inside the matrix |
199 | * | 201 | * |
200 | * @param event the dropped calendar event | 202 | * @param event the dropped calendar event |
201 | */ | 203 | */ |
202 | void eventDropped(Event *event); | 204 | void eventDropped(Event *event); |
203 | 205 | ||
204 | protected: | 206 | protected: |
205 | 207 | ||
206 | void paintEvent(QPaintEvent *ev); | 208 | void paintEvent(QPaintEvent *ev); |
207 | 209 | ||
208 | void mousePressEvent (QMouseEvent* e); | 210 | void mousePressEvent (QMouseEvent* e); |
209 | 211 | ||
210 | void mouseReleaseEvent (QMouseEvent* e); | 212 | void mouseReleaseEvent (QMouseEvent* e); |
211 | 213 | ||
212 | void mouseMoveEvent (QMouseEvent* e); | 214 | void mouseMoveEvent (QMouseEvent* e); |
213 | 215 | ||
214 | void dragEnterEvent(QDragEnterEvent *); | 216 | void dragEnterEvent(QDragEnterEvent *); |
215 | 217 | ||
216 | void dragMoveEvent(QDragMoveEvent *); | 218 | void dragMoveEvent(QDragMoveEvent *); |
217 | 219 | ||
218 | void dragLeaveEvent(QDragLeaveEvent *); | 220 | void dragLeaveEvent(QDragLeaveEvent *); |
219 | 221 | ||
220 | void dropEvent(QDropEvent *); | 222 | void dropEvent(QDropEvent *); |
221 | 223 | ||
222 | void resizeEvent(QResizeEvent *); | 224 | void resizeEvent(QResizeEvent *); |
223 | 225 | ||
224 | private: | 226 | private: |
225 | QPixmap myPix; | 227 | QPixmap myPix; |
226 | QTimer* mUpdateTimer; | 228 | QTimer* mUpdateTimer; |
227 | QTimer* mRepaintTimer; | 229 | QTimer* mRepaintTimer; |
228 | bool mDayChanged; | 230 | bool mDayChanged; |
229 | bool mPendingUpdateBeforeRepaint; | 231 | bool mPendingUpdateBeforeRepaint; |
230 | 232 | ||
231 | /** returns the index of the day located at the matrix's widget (x,y) position. | 233 | /** returns the index of the day located at the matrix's widget (x,y) position. |
232 | * | 234 | * |
233 | * @param x horizontal coordinate | 235 | * @param x horizontal coordinate |
234 | * @param y vertical coordinate | 236 | * @param y vertical coordinate |
235 | */ | 237 | */ |
236 | int getDayIndexFrom(int x, int y); | 238 | int getDayIndexFrom(int x, int y); |
237 | 239 | ||
238 | /** calculates a "shaded" color from the supplied color object. | 240 | /** calculates a "shaded" color from the supplied color object. |
239 | * (Copied from Cornelius's kdpdatebutton.cpp) | 241 | * (Copied from Cornelius's kdpdatebutton.cpp) |
240 | * | 242 | * |
241 | * @param color source based on which a shaded color should be calculated. | 243 | * @param color source based on which a shaded color should be calculated. |
242 | */ | 244 | */ |
243 | QColor getShadedColor(QColor color); | 245 | QColor getShadedColor(QColor color); |
244 | 246 | ||
245 | /** number of days to be displayed. For now there is no support for any other number then 42. | 247 | /** number of days to be displayed. For now there is no support for any other number then 42. |
246 | so change it at your own risk :o) */ | 248 | so change it at your own risk :o) */ |
247 | static const int NUMDAYS; | 249 | static const int NUMDAYS; |
248 | 250 | ||
249 | /** calendar instance to be queried for holidays, events, ... */ | 251 | /** calendar instance to be queried for holidays, events, ... */ |
250 | Calendar *mCalendar; | 252 | Calendar *mCalendar; |
251 | 253 | ||
252 | /** starting date of the matrix */ | 254 | /** starting date of the matrix */ |
253 | QDate startdate; | 255 | QDate startdate; |
254 | 256 | ||
255 | /** array of day labels to optimeize drawing performance. */ | 257 | /** array of day labels to optimeize drawing performance. */ |
256 | QString *daylbls; | 258 | QString *daylbls; |
257 | 259 | ||
258 | /** array of days displayed to reduce memory consumption by | 260 | /** array of days displayed to reduce memory consumption by |
259 | subsequently calling QDate::addDays(). */ | 261 | subsequently calling QDate::addDays(). */ |
260 | QDate *days; | 262 | QDate *days; |
261 | 263 | ||
262 | /** array of storing the number of events on a given day. | 264 | /** array of storing the number of events on a given day. |
263 | * used for drawing a bold font if there is at least one event on that day. | 265 | * used for drawing a bold font if there is at least one event on that day. |
264 | */ | 266 | */ |
265 | int *events; | 267 | int *events; |
266 | 268 | ||
267 | /** stores holiday names of the days shown in the matrix. */ | 269 | /** stores holiday names of the days shown in the matrix. */ |
268 | QMap<int,QString> mHolidays; | 270 | QMap<int,QString> mHolidays; |
269 | 271 | ||
270 | /** indey of today or -1 if today is not visible in the matrix. */ | 272 | /** indey of today or -1 if today is not visible in the matrix. */ |
271 | int today; | 273 | int today; |
272 | 274 | ||
273 | /** index of day where dragged selection was initiated. | 275 | /** index of day where dragged selection was initiated. |
274 | used to detect "negative" timely selections */ | 276 | used to detect "negative" timely selections */ |
275 | int mSelInit; | 277 | int mSelInit; |
276 | 278 | ||
277 | /** if mSelStart has this value it indicates that there is no | 279 | /** if mSelStart has this value it indicates that there is no |
278 | actual selection in the matrix. */ | 280 | actual selection in the matrix. */ |
279 | static const int NOSELECTION; | 281 | static const int NOSELECTION; |
280 | 282 | ||
281 | /** index of first selected day. */ | 283 | /** index of first selected day. */ |
282 | int mSelStart; | 284 | int mSelStart; |
283 | 285 | ||
284 | /** index of last selected day. */ | 286 | /** index of last selected day. */ |
285 | int mSelEnd; | 287 | int mSelEnd; |
286 | 288 | ||
287 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 289 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
288 | DynamicTip* mToolTip; | 290 | DynamicTip* mToolTip; |
289 | 291 | ||
290 | 292 | ||
291 | /** default background colour of the matrix. */ | 293 | /** default background colour of the matrix. */ |
292 | QColor mDefaultBackColor; | 294 | QColor mDefaultBackColor; |
293 | 295 | ||
294 | /** default text color of the matrix. */ | 296 | /** default text color of the matrix. */ |
295 | QColor mDefaultTextColor; | 297 | QColor mDefaultTextColor; |
296 | 298 | ||
297 | /** default text color for days not in the actual month. */ | 299 | /** default text color for days not in the actual month. */ |
298 | QColor mDefaultTextColorShaded; | 300 | QColor mDefaultTextColorShaded; |
299 | 301 | ||
300 | /** default text color for holidays not in the actual month. */ | 302 | /** default text color for holidays not in the actual month. */ |
301 | QColor mHolidayColorShaded; | 303 | QColor mHolidayColorShaded; |
302 | 304 | ||
303 | /** text color for selected days. */ | 305 | /** text color for selected days. */ |
304 | QColor mSelectedDaysColor; | 306 | QColor mSelectedDaysColor; |
305 | 307 | ||
306 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 308 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
307 | int mTodayMarginWidth; | 309 | int mTodayMarginWidth; |
308 | 310 | ||
309 | /** stores actual size of each day in the widget so that I dont need to ask this data | 311 | /** stores actual size of each day in the widget so that I dont need to ask this data |
310 | * on every repaint. | 312 | * on every repaint. |
311 | */ | 313 | */ |
312 | QRect daysize; | 314 | QRect daysize; |
313 | 315 | ||
314 | }; | 316 | }; |
315 | 317 | ||
316 | #endif | 318 | #endif |
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro index e6c3f8d..91b5a01 100644 --- a/korganizer/korganizerE.pro +++ b/korganizer/korganizerE.pro | |||
@@ -1,152 +1,152 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = kopi | 3 | TARGET = kopi |
4 | OBJECTS_DIR = obj/$(PLATFORM) | 4 | OBJECTS_DIR = obj/$(PLATFORM) |
5 | MOC_DIR = moc/$(PLATFORM) | 5 | MOC_DIR = moc/$(PLATFORM) |
6 | DESTDIR=$(QPEDIR)/bin | 6 | DESTDIR=$(QPEDIR)/bin |
7 | 7 | ||
8 | INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include | 8 | INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include |
9 | 9 | ||
10 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 10 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
11 | DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 11 | DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
12 | DEFINES += KORG_NOLVALTERNATION | 12 | DEFINES += KORG_NOLVALTERNATION |
13 | #KORG_NOKABC | 13 | #KORG_NOKABC |
14 | LIBS += -lmicrokdepim | 14 | LIBS += -lmicrokdepim |
15 | LIBS += -lmicrokcal | 15 | LIBS += -lmicrokcal |
16 | LIBS += -lmicrokde | 16 | LIBS += -lmicrokde |
17 | LIBS += -lmicroqtcompat | 17 | LIBS += -lmicroqtcompat |
18 | 18 | ||
19 | LIBS += $(GCC3EXTRALIB1) | 19 | LIBS += $(GCC3EXTRALIB1) |
20 | LIBS += $(GCC3EXTRALIB2) | 20 | LIBS += $(GCC3EXTRALIB2) |
21 | 21 | ||
22 | 22 | ||
23 | LIBS += -lqpe | 23 | LIBS += -lqpe |
24 | LIBS += -ljpeg | 24 | LIBS += -ljpeg |
25 | LIBS += $(QTOPIALIB) | 25 | LIBS += $(QTOPIALIB) |
26 | LIBS += -L$(QPEDIR)/lib | 26 | LIBS += -L$(QPEDIR)/lib |
27 | 27 | ||
28 | INTERFACES = kofilterview_base.ui | 28 | INTERFACES = kofilterview_base.ui |
29 | #filteredit_base.ui | 29 | #filteredit_base.ui |
30 | 30 | ||
31 | HEADERS = \ | 31 | HEADERS = datenavigatorcontainer.h \ |
32 | wordsgerman.h \ | 32 | wordsgerman.h \ |
33 | filteredit_base.h \ | 33 | filteredit_base.h \ |
34 | alarmclient.h \ | 34 | alarmclient.h \ |
35 | calendarview.h \ | 35 | calendarview.h \ |
36 | customlistviewitem.h \ | 36 | customlistviewitem.h \ |
37 | datenavigator.h \ | 37 | datenavigator.h \ |
38 | docprefs.h \ | 38 | docprefs.h \ |
39 | filtereditdialog.h \ | 39 | filtereditdialog.h \ |
40 | incomingdialog.h \ | 40 | incomingdialog.h \ |
41 | incomingdialog_base.h \ | 41 | incomingdialog_base.h \ |
42 | interfaces/korganizer/baseview.h \ | 42 | interfaces/korganizer/baseview.h \ |
43 | interfaces/korganizer/calendarviewbase.h \ | 43 | interfaces/korganizer/calendarviewbase.h \ |
44 | journalentry.h \ | 44 | journalentry.h \ |
45 | kdateedit.h \ | 45 | kdateedit.h \ |
46 | kdatenavigator.h \ | 46 | kdatenavigator.h \ |
47 | koagenda.h \ | 47 | koagenda.h \ |
48 | koagendaitem.h \ | 48 | koagendaitem.h \ |
49 | koagendaview.h \ | 49 | koagendaview.h \ |
50 | kocounterdialog.h \ | 50 | kocounterdialog.h \ |
51 | kodaymatrix.h \ | 51 | kodaymatrix.h \ |
52 | kodialogmanager.h \ | 52 | kodialogmanager.h \ |
53 | koeditordetails.h \ | 53 | koeditordetails.h \ |
54 | koeditorgeneral.h \ | 54 | koeditorgeneral.h \ |
55 | koeditorgeneralevent.h \ | 55 | koeditorgeneralevent.h \ |
56 | koeditorgeneraltodo.h \ | 56 | koeditorgeneraltodo.h \ |
57 | koeditorrecurrence.h \ | 57 | koeditorrecurrence.h \ |
58 | koeventeditor.h \ | 58 | koeventeditor.h \ |
59 | koeventpopupmenu.h \ | 59 | koeventpopupmenu.h \ |
60 | koeventview.h \ | 60 | koeventview.h \ |
61 | koeventviewer.h \ | 61 | koeventviewer.h \ |
62 | koeventviewerdialog.h \ | 62 | koeventviewerdialog.h \ |
63 | kofilterview.h \ | 63 | kofilterview.h \ |
64 | koglobals.h \ | 64 | koglobals.h \ |
65 | koincidenceeditor.h \ | 65 | koincidenceeditor.h \ |
66 | kojournalview.h \ | 66 | kojournalview.h \ |
67 | kolistview.h \ | 67 | kolistview.h \ |
68 | kolocationbox.h \ | 68 | kolocationbox.h \ |
69 | komonthview.h \ | 69 | komonthview.h \ |
70 | koprefs.h \ | 70 | koprefs.h \ |
71 | koprefsdialog.h \ | 71 | koprefsdialog.h \ |
72 | kotimespanview.h \ | 72 | kotimespanview.h \ |
73 | kotodoeditor.h \ | 73 | kotodoeditor.h \ |
74 | kotodoview.h \ | 74 | kotodoview.h \ |
75 | kotodoviewitem.h \ | 75 | kotodoviewitem.h \ |
76 | koviewmanager.h \ | 76 | koviewmanager.h \ |
77 | kowhatsnextview.h \ | 77 | kowhatsnextview.h \ |
78 | ktimeedit.h \ | 78 | ktimeedit.h \ |
79 | lineview.h \ | 79 | lineview.h \ |
80 | mainwindow.h \ | 80 | mainwindow.h \ |
81 | navigatorbar.h \ | 81 | navigatorbar.h \ |
82 | outgoingdialog.h \ | 82 | outgoingdialog.h \ |
83 | outgoingdialog_base.h \ | 83 | outgoingdialog_base.h \ |
84 | publishdialog.h \ | 84 | publishdialog.h \ |
85 | publishdialog_base.h \ | 85 | publishdialog_base.h \ |
86 | savetemplatedialog.h \ | 86 | savetemplatedialog.h \ |
87 | searchdialog.h \ | 87 | searchdialog.h \ |
88 | simplealarmclient.h \ | 88 | simplealarmclient.h \ |
89 | statusdialog.h \ | 89 | statusdialog.h \ |
90 | timeline.h \ | 90 | timeline.h \ |
91 | timespanview.h \ | 91 | timespanview.h \ |
92 | version.h \ | 92 | version.h \ |
93 | ../kalarmd/alarmdialog.h | 93 | ../kalarmd/alarmdialog.h |
94 | 94 | ||
95 | SOURCES = \ | 95 | SOURCES = datenavigatorcontainer.cpp \ |
96 | filteredit_base.cpp \ | 96 | filteredit_base.cpp \ |
97 | calendarview.cpp \ | 97 | calendarview.cpp \ |
98 | datenavigator.cpp \ | 98 | datenavigator.cpp \ |
99 | docprefs.cpp \ | 99 | docprefs.cpp \ |
100 | filtereditdialog.cpp \ | 100 | filtereditdialog.cpp \ |
101 | incomingdialog.cpp \ | 101 | incomingdialog.cpp \ |
102 | incomingdialog_base.cpp \ | 102 | incomingdialog_base.cpp \ |
103 | journalentry.cpp \ | 103 | journalentry.cpp \ |
104 | kdatenavigator.cpp \ | 104 | kdatenavigator.cpp \ |
105 | koagenda.cpp \ | 105 | koagenda.cpp \ |
106 | koagendaitem.cpp \ | 106 | koagendaitem.cpp \ |
107 | koagendaview.cpp \ | 107 | koagendaview.cpp \ |
108 | kocounterdialog.cpp \ | 108 | kocounterdialog.cpp \ |
109 | kodaymatrix.cpp \ | 109 | kodaymatrix.cpp \ |
110 | kodialogmanager.cpp \ | 110 | kodialogmanager.cpp \ |
111 | koeditordetails.cpp \ | 111 | koeditordetails.cpp \ |
112 | koeditorgeneral.cpp \ | 112 | koeditorgeneral.cpp \ |
113 | koeditorgeneralevent.cpp \ | 113 | koeditorgeneralevent.cpp \ |
114 | koeditorgeneraltodo.cpp \ | 114 | koeditorgeneraltodo.cpp \ |
115 | koeditorrecurrence.cpp \ | 115 | koeditorrecurrence.cpp \ |
116 | koeventeditor.cpp \ | 116 | koeventeditor.cpp \ |
117 | koeventpopupmenu.cpp \ | 117 | koeventpopupmenu.cpp \ |
118 | koeventview.cpp \ | 118 | koeventview.cpp \ |
119 | koeventviewer.cpp \ | 119 | koeventviewer.cpp \ |
120 | koeventviewerdialog.cpp \ | 120 | koeventviewerdialog.cpp \ |
121 | kofilterview.cpp \ | 121 | kofilterview.cpp \ |
122 | koglobals.cpp \ | 122 | koglobals.cpp \ |
123 | koincidenceeditor.cpp \ | 123 | koincidenceeditor.cpp \ |
124 | kojournalview.cpp \ | 124 | kojournalview.cpp \ |
125 | kolistview.cpp \ | 125 | kolistview.cpp \ |
126 | kolocationbox.cpp \ | 126 | kolocationbox.cpp \ |
127 | komonthview.cpp \ | 127 | komonthview.cpp \ |
128 | koprefs.cpp \ | 128 | koprefs.cpp \ |
129 | koprefsdialog.cpp \ | 129 | koprefsdialog.cpp \ |
130 | kotimespanview.cpp \ | 130 | kotimespanview.cpp \ |
131 | kotodoeditor.cpp \ | 131 | kotodoeditor.cpp \ |
132 | kotodoview.cpp \ | 132 | kotodoview.cpp \ |
133 | kotodoviewitem.cpp \ | 133 | kotodoviewitem.cpp \ |
134 | koviewmanager.cpp \ | 134 | koviewmanager.cpp \ |
135 | kowhatsnextview.cpp \ | 135 | kowhatsnextview.cpp \ |
136 | ktimeedit.cpp \ | 136 | ktimeedit.cpp \ |
137 | lineview.cpp \ | 137 | lineview.cpp \ |
138 | main.cpp \ | 138 | main.cpp \ |
139 | mainwindow.cpp \ | 139 | mainwindow.cpp \ |
140 | navigatorbar.cpp \ | 140 | navigatorbar.cpp \ |
141 | outgoingdialog.cpp \ | 141 | outgoingdialog.cpp \ |
142 | outgoingdialog_base.cpp \ | 142 | outgoingdialog_base.cpp \ |
143 | publishdialog.cpp \ | 143 | publishdialog.cpp \ |
144 | publishdialog_base.cpp \ | 144 | publishdialog_base.cpp \ |
145 | savetemplatedialog.cpp \ | 145 | savetemplatedialog.cpp \ |
146 | searchdialog.cpp \ | 146 | searchdialog.cpp \ |
147 | simplealarmclient.cpp \ | 147 | simplealarmclient.cpp \ |
148 | statusdialog.cpp \ | 148 | statusdialog.cpp \ |
149 | timeline.cpp \ | 149 | timeline.cpp \ |
150 | timespanview.cpp \ | 150 | timespanview.cpp \ |
151 | ../kalarmd/alarmdialog.cpp | 151 | ../kalarmd/alarmdialog.cpp |
152 | 152 | ||
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 934e153..27d4d17 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,222 +1,244 @@ | |||
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 <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | 43 | #include <kglobalsettings.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
46 | #include "kocore.h" | 46 | #include "kocore.h" |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
50 | 50 | ||
51 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
52 | 52 | ||
53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
55 | { | 55 | { |
56 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
57 | 57 | ||
58 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
59 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | QFont tfont = font(); | 65 | QFont tfont = font(); |
66 | if ( QApplication::desktop()->width() >= 480 ) | 66 | if ( QApplication::desktop()->width() >= 480 ) |
67 | tfont.setPointSize(tfont.pointSize()+2); | 67 | tfont.setPointSize(tfont.pointSize()+2); |
68 | tfont.setBold(true); | 68 | tfont.setBold(true); |
69 | 69 | ||
70 | bool isRTL = KOGlobals::self()->reverseLayout(); | 70 | bool isRTL = KOGlobals::self()->reverseLayout(); |
71 | #ifndef DESKTOP_VERSION | 71 | #ifndef DESKTOP_VERSION |
72 | bool isDesktop = false; | 72 | bool isDesktop = false; |
73 | #else | 73 | #else |
74 | bool isDesktop = true; | 74 | bool isDesktop = true; |
75 | #endif | 75 | #endif |
76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
77 | isDesktop = true; | 77 | isDesktop = true; |
78 | // Create backward navigation buttons | 78 | // Create backward navigation buttons |
79 | mPrevYear = new QPushButton( mCtrlFrame ); | 79 | mPrevYear = new QPushButton( mCtrlFrame ); |
80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
82 | 82 | ||
83 | mPrevMonth = new QPushButton( mCtrlFrame ); | 83 | mPrevMonth = new QPushButton( mCtrlFrame ); |
84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
86 | 86 | ||
87 | // Create forward navigation buttons | 87 | // Create forward navigation buttons |
88 | mNextMonth = new QPushButton( mCtrlFrame ); | 88 | mNextMonth = new QPushButton( mCtrlFrame ); |
89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
90 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 90 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
91 | 91 | ||
92 | mPrevWeek = new QPushButton( mCtrlFrame ); | 92 | mPrevWeek = new QPushButton( mCtrlFrame ); |
93 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 93 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
94 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 94 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
95 | 95 | ||
96 | // Create forward navigation buttons | 96 | // Create forward navigation buttons |
97 | mNextWeek = new QPushButton( mCtrlFrame ); | 97 | mNextWeek = new QPushButton( mCtrlFrame ); |
98 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 98 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
99 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 99 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
100 | 100 | ||
101 | mNextYear = new QPushButton( mCtrlFrame ); | 101 | mNextYear = new QPushButton( mCtrlFrame ); |
102 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 102 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
103 | QToolTip::add( mNextYear, i18n("Next Year") ); | 103 | QToolTip::add( mNextYear, i18n("Next Year") ); |
104 | mSelectMonth = new QPushButton( mCtrlFrame ); | 104 | mSelectMonth = new QPushButton( mCtrlFrame ); |
105 | // Create month name label | 105 | // Create month name label |
106 | //selectMonth->setFont( tfont ); | 106 | //selectMonth->setFont( tfont ); |
107 | // selectMonth->setAlignment( AlignCenter ); | 107 | // selectMonth->setAlignment( AlignCenter ); |
108 | //mDateLabel = new QLabel( selectMonth ); | 108 | //mDateLabel = new QLabel( selectMonth ); |
109 | //mDateLabel->setFont( tfont ); | 109 | //mDateLabel->setFont( tfont ); |
110 | //mDateLabel->setAlignment( AlignCenter ); | 110 | //mDateLabel->setAlignment( AlignCenter ); |
111 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 111 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
112 | mNextMonth->setFlat( true); | 112 | mNextMonth->setFlat( true); |
113 | mNextWeek->setFlat( true); | 113 | mNextWeek->setFlat( true); |
114 | mNextYear->setFlat( true); | 114 | mNextYear->setFlat( true); |
115 | mSelectMonth->setFlat( true); | 115 | mSelectMonth->setFlat( true); |
116 | mPrevYear->setFlat( true); | 116 | mPrevYear->setFlat( true); |
117 | mPrevMonth->setFlat( true); | 117 | mPrevMonth->setFlat( true); |
118 | mPrevWeek->setFlat( true); | 118 | mPrevWeek->setFlat( true); |
119 | } else { | 119 | } else { |
120 | mPrevWeek->hide(); | 120 | mPrevWeek->hide(); |
121 | mNextWeek->hide(); | 121 | mNextWeek->hide(); |
122 | } | 122 | } |
123 | mSelectMonth->setFont( tfont ); | 123 | mSelectMonth->setFont( tfont ); |
124 | // Set minimum width to width of widest month name label | 124 | // Set minimum width to width of widest month name label |
125 | int i; | 125 | int i; |
126 | int maxwidth = 0; | 126 | int maxwidth = 0; |
127 | QFontMetrics fm ( mSelectMonth->font() ); | 127 | QFontMetrics fm ( mSelectMonth->font() ); |
128 | int width = fm.width("September '00" ); | 128 | int width = fm.width("September '00" ); |
129 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | 129 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); |
130 | // ++i ) { | 130 | // ++i ) { |
131 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | 131 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, |
132 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | 132 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); |
133 | // int width = fm.width("September 2000" ); | 133 | // int width = fm.width("September 2000" ); |
134 | // if ( width > maxwidth ) maxwidth = width; | 134 | // if ( width > maxwidth ) maxwidth = width; |
135 | // } | 135 | // } |
136 | maxwidth = width+2; | 136 | maxwidth = width+2; |
137 | int size = fm.height()+2; | 137 | int size = fm.height()+2; |
138 | if ( QApplication::desktop()->width() >= 480 ) { | 138 | if ( QApplication::desktop()->width() >= 480 ) { |
139 | size += 6; | 139 | size += 6; |
140 | maxwidth+= 6; | 140 | maxwidth+= 6; |
141 | } | 141 | } |
142 | 142 | ||
143 | mSelectMonth->setFixedWidth( maxwidth ); | 143 | mSelectMonth->setFixedWidth( maxwidth ); |
144 | mSelectMonth->setFixedHeight( size ); | 144 | mSelectMonth->setFixedHeight( size ); |
145 | mPrevYear->setFixedHeight( size ); | 145 | mPrevYear->setFixedHeight( size ); |
146 | mPrevMonth->setFixedHeight( size ); | 146 | mPrevMonth->setFixedHeight( size ); |
147 | mPrevWeek->setFixedHeight( size ); | 147 | mPrevWeek->setFixedHeight( size ); |
148 | mNextMonth->setFixedHeight( size ); | 148 | mNextMonth->setFixedHeight( size ); |
149 | mNextWeek->setFixedHeight( size ); | 149 | mNextWeek->setFixedHeight( size ); |
150 | mNextYear->setFixedHeight ( size ); | 150 | mNextYear->setFixedHeight ( size ); |
151 | // set up control frame layout | 151 | // set up control frame layout |
152 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 152 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
153 | ctrlLayout->addWidget( mPrevYear, 3 ); | 153 | ctrlLayout->addWidget( mPrevYear, 3 ); |
154 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 154 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
155 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 155 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
156 | //ctrlLayout->addStretch( 1 ); | 156 | //ctrlLayout->addStretch( 1 ); |
157 | // ctrlLayout->addSpacing( 1 ); | 157 | // ctrlLayout->addSpacing( 1 ); |
158 | // ctrlLayout->addWidget( mDateLabel ); | 158 | // ctrlLayout->addWidget( mDateLabel ); |
159 | ctrlLayout->addWidget( mSelectMonth ); | 159 | ctrlLayout->addWidget( mSelectMonth ); |
160 | // ctrlLayout->addSpacing( 1 ); | 160 | // ctrlLayout->addSpacing( 1 ); |
161 | // ctrlLayout->addStretch( 1 ); | 161 | // ctrlLayout->addStretch( 1 ); |
162 | ctrlLayout->addWidget( mNextWeek, 3 ); | 162 | ctrlLayout->addWidget( mNextWeek, 3 ); |
163 | ctrlLayout->addWidget( mNextMonth, 3 ); | 163 | ctrlLayout->addWidget( mNextMonth, 3 ); |
164 | ctrlLayout->addWidget( mNextYear, 3 ); | 164 | ctrlLayout->addWidget( mNextYear, 3 ); |
165 | 165 | ||
166 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 166 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
167 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 167 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
168 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 168 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
169 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 169 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
170 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 170 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
171 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 171 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
172 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 172 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
173 | mPrevYear->setFocusPolicy(NoFocus); | 173 | mPrevYear->setFocusPolicy(NoFocus); |
174 | mPrevMonth->setFocusPolicy(NoFocus); | 174 | mPrevMonth->setFocusPolicy(NoFocus); |
175 | mNextMonth->setFocusPolicy(NoFocus); | 175 | mNextMonth->setFocusPolicy(NoFocus); |
176 | mPrevWeek->setFocusPolicy(NoFocus); | 176 | mPrevWeek->setFocusPolicy(NoFocus); |
177 | mNextWeek->setFocusPolicy(NoFocus); | 177 | mNextWeek->setFocusPolicy(NoFocus); |
178 | mNextYear->setFocusPolicy(NoFocus); | 178 | mNextYear->setFocusPolicy(NoFocus); |
179 | mSelectMonth->setFocusPolicy(NoFocus); | 179 | mSelectMonth->setFocusPolicy(NoFocus); |
180 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 180 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | NavigatorBar::~NavigatorBar() | 184 | NavigatorBar::~NavigatorBar() |
185 | { | 185 | { |
186 | } | 186 | } |
187 | void NavigatorBar::showButtons( bool left, bool right ) | ||
188 | { | ||
189 | if ( left ) { | ||
190 | mPrevYear->show(); | ||
191 | mPrevMonth->show(); | ||
192 | } else { | ||
193 | mPrevYear->hide(); | ||
194 | mPrevMonth->hide(); | ||
195 | } | ||
196 | |||
197 | if ( right ) { | ||
198 | mNextYear->show(); | ||
199 | mNextMonth->show(); | ||
200 | } else { | ||
201 | mNextYear->hide(); | ||
202 | mNextMonth->hide(); | ||
203 | } | ||
204 | if ( !left && !right ) { | ||
205 | mSelectMonth->setMaximumWidth( 1024 ); | ||
206 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | ||
207 | } | ||
208 | } | ||
187 | 209 | ||
188 | void NavigatorBar::selectMonth() | 210 | void NavigatorBar::selectMonth() |
189 | { | 211 | { |
190 | 212 | ||
191 | int month; | 213 | int month; |
192 | KPopupFrame* popup = new KPopupFrame(this); | 214 | KPopupFrame* popup = new KPopupFrame(this); |
193 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 215 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
194 | // ----- | 216 | // ----- |
195 | picker->resize(picker->sizeHint()); | 217 | picker->resize(picker->sizeHint()); |
196 | popup->setMainWidget(picker); | 218 | popup->setMainWidget(picker); |
197 | picker->setFocus(); | 219 | picker->setFocus(); |
198 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 220 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
199 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 221 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
200 | { | 222 | { |
201 | month = picker->getResult(); | 223 | month = picker->getResult(); |
202 | emit monthSelected ( month ); | 224 | emit monthSelected ( month ); |
203 | } else { | 225 | } else { |
204 | KNotifyClient::beep(); | 226 | KNotifyClient::beep(); |
205 | } | 227 | } |
206 | delete popup; | 228 | delete popup; |
207 | } | 229 | } |
208 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 230 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
209 | { | 231 | { |
210 | if (dateList.count() > 0) { | 232 | if (dateList.count() > 0) { |
211 | QDate date = dateList.first(); | 233 | QDate date = dateList.first(); |
212 | 234 | ||
213 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 235 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
214 | 236 | ||
215 | // compute the label at the top of the navigator | 237 | // compute the label at the top of the navigator |
216 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 238 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
217 | QString::number( calSys->year( date ) ).right(2); | 239 | QString::number( calSys->year( date ) ).right(2); |
218 | 240 | ||
219 | mSelectMonth->setText( dtstr ); | 241 | mSelectMonth->setText( dtstr ); |
220 | } | 242 | } |
221 | } | 243 | } |
222 | 244 | ||
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 803c817..4442caa 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h | |||
@@ -1,69 +1,70 @@ | |||
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 | void showButtons( bool left, bool right ); | ||
41 | 42 | ||
42 | public slots: | 43 | public slots: |
43 | void selectDates( const KCal::DateList & ); | 44 | void selectDates( const KCal::DateList & ); |
44 | void selectMonth(); | 45 | void selectMonth(); |
45 | 46 | ||
46 | signals: | 47 | signals: |
47 | void goNextMonth(); | 48 | void goNextMonth(); |
48 | void goPrevMonth(); | 49 | void goPrevMonth(); |
49 | void goNextWeek(); | 50 | void goNextWeek(); |
50 | void goPrevWeek(); | 51 | void goPrevWeek(); |
51 | void goNextYear(); | 52 | void goNextYear(); |
52 | void goPrevYear(); | 53 | void goPrevYear(); |
53 | void monthSelected( int ); | 54 | void monthSelected( int ); |
54 | 55 | ||
55 | private: | 56 | private: |
56 | QFrame *mCtrlFrame; | 57 | QFrame *mCtrlFrame; |
57 | 58 | ||
58 | QPushButton *mPrevYear; | 59 | QPushButton *mPrevYear; |
59 | QPushButton *mPrevMonth; | 60 | QPushButton *mPrevMonth; |
60 | QPushButton *mNextMonth; | 61 | QPushButton *mNextMonth; |
61 | QPushButton *mPrevWeek; | 62 | QPushButton *mPrevWeek; |
62 | QPushButton *mNextWeek; | 63 | QPushButton *mNextWeek; |
63 | QPushButton *mNextYear; | 64 | QPushButton *mNextYear; |
64 | QPushButton *mSelectMonth; | 65 | QPushButton *mSelectMonth; |
65 | 66 | ||
66 | //QLabel *mDateLabel; | 67 | //QLabel *mDateLabel; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | #endif | 70 | #endif |