-rw-r--r-- | korganizer/calendarview.cpp | 68 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 36 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 40 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 6 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 11 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 67 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 1 |
9 files changed, 179 insertions, 53 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3ce123c..ab59d00 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -107,439 +107,443 @@ | |||
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
146 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
147 | { | 147 | { |
148 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
149 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
150 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
151 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
153 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
156 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
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 | 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 ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | 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 ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | 238 | ||
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | QWidget *mainBox = new QWidget( this ); | 299 | //QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | QBoxLayout * mainBoxLayout; | 301 | //QBoxLayout * mainBoxLayout; |
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);; | 305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | 306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | ||
308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | ||
307 | } else { | 309 | } else { |
308 | mainBoxLayout = new QHBoxLayout(mainBox); | 310 | //mainBoxLayout = new QHBoxLayout(mainBox); |
309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; | 312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | ||
314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | ||
311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
312 | } | 316 | } |
313 | //QBoxLayout * leftFrameLayout; | 317 | //QBoxLayout * leftFrameLayout; |
314 | topLayout->addWidget( mainBox ); | 318 | topLayout->addWidget( mMainFrame ); |
315 | mainBoxLayout->addWidget (mLeftFrame); | 319 | //mainBoxLayout->addWidget (mLeftFrame); |
316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 320 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
317 | "CalendarView::DateNavigator" ); | 321 | "CalendarView::DateNavigator" ); |
318 | #if 0 | 322 | #if 0 |
319 | // FIXME | 323 | // FIXME |
320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 324 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
321 | "CalendarView::DateNavigator", QDate::currentDate()); | 325 | "CalendarView::DateNavigator", QDate::currentDate()); |
322 | #endif | 326 | #endif |
323 | // mDateNavigator->blockSignals( true ); | 327 | // mDateNavigator->blockSignals( true ); |
324 | //leftFrameLayout->addWidget( mDateNavigator ); | 328 | //leftFrameLayout->addWidget( mDateNavigator ); |
325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 329 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 330 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
327 | mTodoList->setNavigator( mNavigator ); | 331 | mTodoList->setNavigator( mNavigator ); |
328 | #if 0 | 332 | #if 0 |
329 | if ( QApplication::desktop()->width() < 480 ) { | 333 | if ( QApplication::desktop()->width() < 480 ) { |
330 | leftFrameLayout->addWidget(mFilterView); | 334 | leftFrameLayout->addWidget(mFilterView); |
331 | leftFrameLayout->addWidget(mTodoList, 2 ); | 335 | leftFrameLayout->addWidget(mTodoList, 2 ); |
332 | 336 | ||
333 | } else { | 337 | } else { |
334 | leftFrameLayout->addWidget(mTodoList,2 ); | 338 | leftFrameLayout->addWidget(mTodoList,2 ); |
335 | leftFrameLayout->addWidget(mFilterView ); | 339 | leftFrameLayout->addWidget(mFilterView ); |
336 | } | 340 | } |
337 | #endif | 341 | #endif |
338 | mFilterView->hide(); | 342 | mFilterView->hide(); |
339 | QWidget *rightBox = new QWidget( mainBox ); | 343 | QWidget *rightBox = new QWidget( mMainFrame ); |
340 | mainBoxLayout->addWidget ( rightBox, 10 ); | 344 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 345 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
342 | mRightFrame = new QWidgetStack( rightBox ); | 346 | mRightFrame = new QWidgetStack( rightBox ); |
343 | rightLayout->addWidget( mRightFrame, 10 ); | 347 | rightLayout->addWidget( mRightFrame, 10 ); |
344 | 348 | ||
345 | //mLeftFrame = (QWidget *)leftFrame; | 349 | //mLeftFrame = (QWidget *)leftFrame; |
346 | if ( KOPrefs::instance()->mVerticalScreen ) { | 350 | if ( KOPrefs::instance()->mVerticalScreen ) { |
347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 351 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 352 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
349 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 353 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 354 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
351 | } else { | 355 | } else { |
352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 356 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
353 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 357 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 358 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
355 | } | 359 | } |
356 | if ( !KOPrefs::instance()->mShowDateNavigator) | 360 | if ( !KOPrefs::instance()->mShowDateNavigator) |
357 | mDateNavigator->hide(); | 361 | mDateNavigator->hide(); |
358 | //qDebug("Calendarview Size %d %d ", width(), height()); | 362 | //qDebug("Calendarview Size %d %d ", width(), height()); |
359 | #endif | 363 | #endif |
360 | 364 | ||
361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 365 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
362 | SLOT( showDates( const KCal::DateList & ) ) ); | 366 | SLOT( showDates( const KCal::DateList & ) ) ); |
363 | 367 | ||
364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 368 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 369 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
366 | 370 | ||
367 | 371 | ||
368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 372 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 373 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
370 | 374 | ||
371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
372 | mNavigator, SLOT( selectPreviousYear() ) ); | 376 | mNavigator, SLOT( selectPreviousYear() ) ); |
373 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 377 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
374 | mNavigator, SLOT( selectNextYear() ) ); | 378 | mNavigator, SLOT( selectNextYear() ) ); |
375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 379 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
376 | mNavigator, SLOT( selectPreviousMonth() ) ); | 380 | mNavigator, SLOT( selectPreviousMonth() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 381 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
378 | mNavigator, SLOT( selectNextMonth() ) ); | 382 | mNavigator, SLOT( selectNextMonth() ) ); |
379 | 383 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 384 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
381 | mNavigator, SLOT( selectPrevious() ) ); | 385 | mNavigator, SLOT( selectPrevious() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNext() ), | 386 | connect( mDateNavigator, SIGNAL( goNext() ), |
383 | mNavigator, SLOT( selectNext() ) ); | 387 | mNavigator, SLOT( selectNext() ) ); |
384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 388 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 389 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
386 | 390 | ||
387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 391 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 392 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
389 | #if 0 | 393 | #if 0 |
390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 394 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
391 | SLOT( incidenceAdded( Incidence *) ) ); | 395 | SLOT( incidenceAdded( Incidence *) ) ); |
392 | #endif | 396 | #endif |
393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 397 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
394 | 398 | ||
395 | connect( this, SIGNAL( configChanged() ), | 399 | connect( this, SIGNAL( configChanged() ), |
396 | mDateNavigator, SLOT( updateConfig() ) ); | 400 | mDateNavigator, SLOT( updateConfig() ) ); |
397 | 401 | ||
398 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 402 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
399 | SLOT( newTodo() ) ); | 403 | SLOT( newTodo() ) ); |
400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 404 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
401 | SLOT( newSubTodo( Todo * ) ) ); | 405 | SLOT( newSubTodo( Todo * ) ) ); |
402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 406 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
403 | SLOT( editTodo( Todo * ) ) ); | 407 | SLOT( editTodo( Todo * ) ) ); |
404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 408 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
405 | SLOT( showTodo( Todo *) ) ); | 409 | SLOT( showTodo( Todo *) ) ); |
406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 410 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
407 | SLOT( deleteTodo( Todo *) ) ); | 411 | SLOT( deleteTodo( Todo *) ) ); |
408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 412 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 413 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
410 | SLOT( purgeCompleted() ) ); | 414 | SLOT( purgeCompleted() ) ); |
411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 415 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
412 | SIGNAL( todoModified( Todo *, int ) ) ); | 416 | SIGNAL( todoModified( Todo *, int ) ) ); |
413 | 417 | ||
414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 419 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 420 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
417 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 421 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
418 | 422 | ||
419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 423 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
420 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 424 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 425 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
422 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 426 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
423 | 427 | ||
424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 428 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
425 | this, SLOT ( todo_unsub( Todo * ) ) ); | 429 | this, SLOT ( todo_unsub( Todo * ) ) ); |
426 | 430 | ||
427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 431 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 432 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 433 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
430 | SLOT( updateTodo( Todo *, int ) ) ); | 434 | SLOT( updateTodo( Todo *, int ) ) ); |
431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 435 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 436 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
433 | 437 | ||
434 | 438 | ||
435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 439 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 440 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 441 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 442 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
439 | 443 | ||
440 | 444 | ||
441 | 445 | ||
442 | 446 | ||
443 | 447 | ||
444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 448 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
445 | SLOT(checkClipboard())); | 449 | SLOT(checkClipboard())); |
446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 450 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
447 | SLOT( processTodoListSelection( Incidence * ) ) ); | 451 | SLOT( processTodoListSelection( Incidence * ) ) ); |
448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 452 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
449 | 453 | ||
450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 454 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
451 | 455 | ||
452 | mDateFrame = new QVBox(0,0,WType_Popup); | 456 | mDateFrame = new QVBox(0,0,WType_Popup); |
453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 457 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 458 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
455 | mDateFrame->setLineWidth(3); | 459 | mDateFrame->setLineWidth(3); |
456 | mDateFrame->hide(); | 460 | mDateFrame->hide(); |
457 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 461 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 462 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
459 | 463 | ||
460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 464 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
461 | 465 | ||
462 | mEventEditor = mDialogManager->getEventEditor(); | 466 | mEventEditor = mDialogManager->getEventEditor(); |
463 | mTodoEditor = mDialogManager->getTodoEditor(); | 467 | mTodoEditor = mDialogManager->getTodoEditor(); |
464 | 468 | ||
465 | mFlagEditDescription = false; | 469 | mFlagEditDescription = false; |
466 | 470 | ||
467 | mSuspendTimer = new QTimer( this ); | 471 | mSuspendTimer = new QTimer( this ); |
468 | mAlarmTimer = new QTimer( this ); | 472 | mAlarmTimer = new QTimer( this ); |
469 | mRecheckAlarmTimer = new QTimer( this ); | 473 | mRecheckAlarmTimer = new QTimer( this ); |
470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 474 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 475 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 476 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
473 | mAlarmDialog = new AlarmDialog( this ); | 477 | mAlarmDialog = new AlarmDialog( this ); |
474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 478 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
475 | mAlarmDialog->setServerNotification( false ); | 479 | mAlarmDialog->setServerNotification( false ); |
476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 480 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
477 | 481 | ||
478 | 482 | ||
479 | #ifndef DESKTOP_VERSION | 483 | #ifndef DESKTOP_VERSION |
480 | //US listen for arriving address resultsets | 484 | //US listen for arriving address resultsets |
481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 485 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(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&))); | 486 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
483 | #endif | 487 | #endif |
484 | mDateNavigator->setCalendar( mCalendar ); | 488 | mDateNavigator->setCalendar( mCalendar ); |
485 | } | 489 | } |
486 | 490 | ||
487 | 491 | ||
488 | CalendarView::~CalendarView() | 492 | CalendarView::~CalendarView() |
489 | { | 493 | { |
490 | // kdDebug() << "~CalendarView()" << endl; | 494 | // kdDebug() << "~CalendarView()" << endl; |
491 | //qDebug("CalendarView::~CalendarView() "); | 495 | //qDebug("CalendarView::~CalendarView() "); |
492 | delete mDialogManager; | 496 | delete mDialogManager; |
493 | delete mViewManager; | 497 | delete mViewManager; |
494 | delete mStorage; | 498 | delete mStorage; |
495 | delete mDateFrame ; | 499 | delete mDateFrame ; |
496 | delete beamDialog; | 500 | delete beamDialog; |
497 | delete mEventViewerDialog; | 501 | delete mEventViewerDialog; |
498 | //kdDebug() << "~CalendarView() done" << endl; | 502 | //kdDebug() << "~CalendarView() done" << endl; |
499 | } | 503 | } |
500 | 504 | ||
501 | void CalendarView::showDay( QDate d ) | 505 | void CalendarView::showDay( QDate d ) |
502 | { | 506 | { |
503 | dateNavigator()->blockSignals( true ); | 507 | dateNavigator()->blockSignals( true ); |
504 | dateNavigator()->selectDate( d ); | 508 | dateNavigator()->selectDate( d ); |
505 | dateNavigator()->blockSignals( false ); | 509 | dateNavigator()->blockSignals( false ); |
506 | mViewManager->showDayView(); | 510 | mViewManager->showDayView(); |
507 | //dateNavigator()->selectDate( d ); | 511 | //dateNavigator()->selectDate( d ); |
508 | } | 512 | } |
509 | void CalendarView::timerAlarm() | 513 | void CalendarView::timerAlarm() |
510 | { | 514 | { |
511 | //qDebug("CalendarView::timerAlarm() "); | 515 | //qDebug("CalendarView::timerAlarm() "); |
512 | computeAlarm(mAlarmNotification ); | 516 | computeAlarm(mAlarmNotification ); |
513 | } | 517 | } |
514 | 518 | ||
515 | void CalendarView::suspendAlarm() | 519 | void CalendarView::suspendAlarm() |
516 | { | 520 | { |
517 | //qDebug(" CalendarView::suspendAlarm() "); | 521 | //qDebug(" CalendarView::suspendAlarm() "); |
518 | computeAlarm(mSuspendAlarmNotification ); | 522 | computeAlarm(mSuspendAlarmNotification ); |
519 | 523 | ||
520 | } | 524 | } |
521 | 525 | ||
522 | void CalendarView::startAlarm( QString mess , QString filename) | 526 | void CalendarView::startAlarm( QString mess , QString filename) |
523 | { | 527 | { |
524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 528 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 529 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
526 | 530 | ||
527 | } | 531 | } |
528 | 532 | ||
529 | void CalendarView::checkNextTimerAlarm() | 533 | void CalendarView::checkNextTimerAlarm() |
530 | { | 534 | { |
531 | mCalendar->checkAlarmForIncidence( 0, true ); | 535 | mCalendar->checkAlarmForIncidence( 0, true ); |
532 | } | 536 | } |
533 | 537 | ||
534 | void CalendarView::computeAlarm( QString msg ) | 538 | void CalendarView::computeAlarm( QString msg ) |
535 | { | 539 | { |
536 | 540 | ||
537 | QString mess = msg; | 541 | QString mess = msg; |
538 | QString mAlarmMessage = mess.mid( 9 ); | 542 | QString mAlarmMessage = mess.mid( 9 ); |
539 | QString filename = MainWindow::resourcePath(); | 543 | QString filename = MainWindow::resourcePath(); |
540 | filename += "koalarm.wav"; | 544 | filename += "koalarm.wav"; |
541 | QString tempfilename; | 545 | QString tempfilename; |
542 | if ( mess.left( 13 ) == "suspend_alarm") { | 546 | if ( mess.left( 13 ) == "suspend_alarm") { |
543 | bool error = false; | 547 | bool error = false; |
544 | int len = mess.mid( 13 ).find("+++"); | 548 | int len = mess.mid( 13 ).find("+++"); |
545 | if ( len < 2 ) | 549 | if ( len < 2 ) |
@@ -1667,457 +1671,489 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
1667 | if ( !merge ) { | 1671 | if ( !merge ) { |
1668 | mCalendar->close(); | 1672 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1673 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1674 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1675 | mTodoList->setDocumentId( filename ); |
1672 | } | 1676 | } |
1673 | 1677 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1678 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1679 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1680 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1681 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1682 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1683 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1684 | updateUnmanagedViews(); |
1681 | updateView(); | 1685 | updateView(); |
1682 | } | 1686 | } |
1683 | return false; | 1687 | return false; |
1684 | } | 1688 | } |
1685 | void CalendarView::showOpenError() | 1689 | void CalendarView::showOpenError() |
1686 | { | 1690 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1691 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1692 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1693 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1694 | { |
1691 | loadedFileVersion = dt; | 1695 | loadedFileVersion = dt; |
1692 | } | 1696 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1697 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1698 | { |
1695 | QFileInfo finf ( fn ); | 1699 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1700 | if ( !finf.exists() ) |
1697 | return true; | 1701 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1702 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1703 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1704 | return false; |
1701 | return true; | 1705 | return true; |
1702 | 1706 | ||
1703 | } | 1707 | } |
1704 | void CalendarView::watchSavedFile() | 1708 | void CalendarView::watchSavedFile() |
1705 | { | 1709 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1710 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1711 | if ( !finf.exists() ) |
1708 | return; | 1712 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1713 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1714 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1715 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1716 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1717 | return; |
1714 | } | 1718 | } |
1715 | loadedFileVersion = dt; | 1719 | loadedFileVersion = dt; |
1716 | } | 1720 | } |
1717 | 1721 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1722 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1723 | { |
1720 | QFileInfo finf ( fn ); | 1724 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1725 | if ( !finf.exists() ) |
1722 | return true; | 1726 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1727 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1728 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1729 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1730 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1731 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1732 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1733 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1734 | i18n("Sync+save")); |
1731 | 1735 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1736 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1737 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1738 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1739 | return true; |
1736 | 1740 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1741 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1742 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1743 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1744 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1745 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1746 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1747 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1748 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1749 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1750 | updateView(); |
1747 | return true; | 1751 | return true; |
1748 | } | 1752 | } |
1749 | 1753 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1754 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1755 | { |
1752 | 1756 | ||
1753 | // Store back all unsaved data into calendar object | 1757 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1758 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1759 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1760 | mViewManager->currentView()->flushView(); |
1757 | 1761 | ||
1758 | 1762 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1763 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1764 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1765 | mStorage->setFileName( filename ); |
1762 | bool success; | 1766 | bool success; |
1763 | success = mStorage->save(); | 1767 | success = mStorage->save(); |
1764 | if ( !success ) { | 1768 | if ( !success ) { |
1765 | return false; | 1769 | return false; |
1766 | } | 1770 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1771 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1772 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1773 | watchSavedFile(); |
1770 | } | 1774 | } |
1771 | return true; | 1775 | return true; |
1772 | } | 1776 | } |
1773 | 1777 | ||
1774 | void CalendarView::closeCalendar() | 1778 | void CalendarView::closeCalendar() |
1775 | { | 1779 | { |
1776 | 1780 | ||
1777 | // child windows no longer valid | 1781 | // child windows no longer valid |
1778 | emit closingDown(); | 1782 | emit closingDown(); |
1779 | 1783 | ||
1780 | mCalendar->close(); | 1784 | mCalendar->close(); |
1781 | setModified(false); | 1785 | setModified(false); |
1782 | updateView(); | 1786 | updateView(); |
1783 | } | 1787 | } |
1784 | 1788 | ||
1785 | void CalendarView::archiveCalendar() | 1789 | void CalendarView::archiveCalendar() |
1786 | { | 1790 | { |
1787 | mDialogManager->showArchiveDialog(); | 1791 | mDialogManager->showArchiveDialog(); |
1788 | } | 1792 | } |
1789 | 1793 | ||
1790 | 1794 | ||
1791 | void CalendarView::readSettings() | 1795 | void CalendarView::readSettings() |
1792 | { | 1796 | { |
1793 | 1797 | ||
1794 | 1798 | ||
1795 | // mViewManager->showAgendaView(); | 1799 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1800 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1801 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1802 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1803 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1804 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1805 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1806 | config->setGroup("KOrganizer Geometry"); |
1803 | 1807 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1808 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1809 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1810 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1811 | sizes << 300; |
1808 | } | 1812 | } |
1809 | mPanner->setSizes(sizes); | 1813 | mPanner->setSizes(sizes); |
1810 | 1814 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1815 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1816 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1817 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1818 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1819 | } |
1816 | #endif | 1820 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1821 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1822 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1823 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1824 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1825 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1826 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1827 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1828 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1829 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1830 | ||
1827 | int resetval = 0; | 1831 | int resetval = 0; |
1828 | int maxVal = 0; | 1832 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1833 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1834 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1835 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1836 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1837 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1838 | } |
1835 | } | 1839 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1840 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1841 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1842 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1843 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1844 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1845 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1846 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1847 | } |
1844 | } | 1848 | } |
1845 | if ( resetval ) { | 1849 | if ( resetval ) { |
1846 | sizes.clear(); | 1850 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1851 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1852 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1853 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1854 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1855 | } |
1852 | sizes << resetval; | 1856 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1857 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1858 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1859 | sizes << resetval; |
1856 | sizes << 100; | 1860 | sizes << 100; |
1857 | } | 1861 | } |
1858 | mLeftFrame->setSizes(sizes); | 1862 | mLeftFrame->setSizes(sizes); |
1863 | sizes = config->readIntListEntry("Main Splitter Frame"); | ||
1864 | if (sizes.count() != 3) { | ||
1865 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1866 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1867 | } else { | ||
1868 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1869 | } | ||
1870 | } | ||
1871 | if ( !resetval ){// i.e. sizes.count() == 3 | ||
1872 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1873 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | ||
1874 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1875 | } else { | ||
1876 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | ||
1877 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1878 | } | ||
1879 | } | ||
1880 | if ( resetval ) { | ||
1881 | sizes.clear(); | ||
1882 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1883 | maxVal = QApplication::desktop()->width() -10; | ||
1884 | } else { | ||
1885 | maxVal = QApplication::desktop()->height()-10; | ||
1886 | } | ||
1887 | sizes << resetval; | ||
1888 | if ( maxVal < resetval + resetval) | ||
1889 | resetval = maxVal - resetval; | ||
1890 | sizes << resetval; | ||
1891 | } | ||
1892 | mMainFrame->setSizes(sizes); | ||
1893 | |||
1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1894 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1895 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1861 | else mNavigator->selectDates( dateCount ); | 1896 | else mNavigator->selectDates( dateCount ); |
1862 | // mViewManager->readSettings( config ); | 1897 | // mViewManager->readSettings( config ); |
1863 | updateConfig(); | 1898 | updateConfig(); |
1864 | globalFlagBlockAgenda = 2; | 1899 | globalFlagBlockAgenda = 2; |
1865 | mViewManager->readSettings( config ); | 1900 | mViewManager->readSettings( config ); |
1866 | #ifdef DESKTOP_VERSION | 1901 | #ifdef DESKTOP_VERSION |
1867 | config->setGroup("WidgetLayout"); | 1902 | config->setGroup("WidgetLayout"); |
1868 | QStringList list; | 1903 | QStringList list; |
1869 | list = config->readListEntry("MainLayout"); | 1904 | list = config->readListEntry("MainLayout"); |
1870 | int x,y,w,h; | 1905 | int x,y,w,h; |
1871 | if ( ! list.isEmpty() ) { | 1906 | if ( ! list.isEmpty() ) { |
1872 | x = list[0].toInt(); | 1907 | x = list[0].toInt(); |
1873 | y = list[1].toInt(); | 1908 | y = list[1].toInt(); |
1874 | w = list[2].toInt(); | 1909 | w = list[2].toInt(); |
1875 | h = list[3].toInt(); | 1910 | h = list[3].toInt(); |
1876 | topLevelWidget()->setGeometry(x,y,w,h); | 1911 | topLevelWidget()->setGeometry(x,y,w,h); |
1877 | 1912 | ||
1878 | } else { | 1913 | } else { |
1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1914 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1880 | } | 1915 | } |
1881 | list = config->readListEntry("EditEventLayout"); | 1916 | list = config->readListEntry("EditEventLayout"); |
1882 | if ( ! list.isEmpty() ) { | 1917 | if ( ! list.isEmpty() ) { |
1883 | x = list[0].toInt(); | 1918 | x = list[0].toInt(); |
1884 | y = list[1].toInt(); | 1919 | y = list[1].toInt(); |
1885 | w = list[2].toInt(); | 1920 | w = list[2].toInt(); |
1886 | h = list[3].toInt(); | 1921 | h = list[3].toInt(); |
1887 | mEventEditor->setGeometry(x,y,w,h); | 1922 | mEventEditor->setGeometry(x,y,w,h); |
1888 | 1923 | ||
1889 | } | 1924 | } |
1890 | list = config->readListEntry("EditTodoLayout"); | 1925 | list = config->readListEntry("EditTodoLayout"); |
1891 | if ( ! list.isEmpty() ) { | 1926 | if ( ! list.isEmpty() ) { |
1892 | x = list[0].toInt(); | 1927 | x = list[0].toInt(); |
1893 | y = list[1].toInt(); | 1928 | y = list[1].toInt(); |
1894 | w = list[2].toInt(); | 1929 | w = list[2].toInt(); |
1895 | h = list[3].toInt(); | 1930 | h = list[3].toInt(); |
1896 | mTodoEditor->setGeometry(x,y,w,h); | 1931 | mTodoEditor->setGeometry(x,y,w,h); |
1897 | 1932 | ||
1898 | } | 1933 | } |
1899 | list = config->readListEntry("ViewerLayout"); | 1934 | list = config->readListEntry("ViewerLayout"); |
1900 | if ( ! list.isEmpty() ) { | 1935 | if ( ! list.isEmpty() ) { |
1901 | x = list[0].toInt(); | 1936 | x = list[0].toInt(); |
1902 | y = list[1].toInt(); | 1937 | y = list[1].toInt(); |
1903 | w = list[2].toInt(); | 1938 | w = list[2].toInt(); |
1904 | h = list[3].toInt(); | 1939 | h = list[3].toInt(); |
1905 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1940 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1906 | } | 1941 | } |
1907 | #endif | 1942 | #endif |
1908 | 1943 | ||
1909 | } | 1944 | } |
1910 | 1945 | ||
1911 | 1946 | ||
1912 | void CalendarView::writeSettings() | 1947 | void CalendarView::writeSettings() |
1913 | { | 1948 | { |
1914 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1949 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1915 | 1950 | ||
1916 | KConfig *config = KOGlobals::config(); | 1951 | KConfig *config = KOGlobals::config(); |
1917 | 1952 | ||
1918 | mViewManager->writeSettings( config ); | 1953 | mViewManager->writeSettings( config ); |
1919 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1954 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1920 | mDialogManager->writeSettings( config ); | 1955 | mDialogManager->writeSettings( config ); |
1921 | //KOPrefs::instance()->usrWriteConfig(); | 1956 | //KOPrefs::instance()->usrWriteConfig(); |
1922 | KOPrefs::instance()->writeConfig(); | 1957 | KOPrefs::instance()->writeConfig(); |
1923 | 1958 | ||
1924 | writeFilterSettings(config); | 1959 | writeFilterSettings(config); |
1925 | 1960 | ||
1926 | config->setGroup( "Views" ); | 1961 | config->setGroup( "Views" ); |
1927 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1962 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1928 | 1963 | ||
1929 | QValueList<int> listINT = mLeftFrame->sizes(); | 1964 | QValueList<int> listINT = mLeftFrame->sizes(); |
1930 | config->writeEntry("Left Splitter Frame",listINT); | 1965 | config->writeEntry("Left Splitter Frame",listINT); |
1931 | 1966 | listINT = mMainFrame->sizes(); | |
1967 | config->writeEntry("Main Splitter Frame",listINT); | ||
1932 | #ifdef DESKTOP_VERSION | 1968 | #ifdef DESKTOP_VERSION |
1933 | config->setGroup("WidgetLayout"); | 1969 | config->setGroup("WidgetLayout"); |
1934 | QStringList list ;//= config->readListEntry("MainLayout"); | 1970 | QStringList list ;//= config->readListEntry("MainLayout"); |
1935 | int x,y,w,h; | 1971 | int x,y,w,h; |
1936 | QWidget* wid; | 1972 | QWidget* wid; |
1937 | wid = topLevelWidget(); | 1973 | wid = topLevelWidget(); |
1938 | x = wid->geometry().x(); | 1974 | x = wid->geometry().x(); |
1939 | y = wid->geometry().y(); | 1975 | y = wid->geometry().y(); |
1940 | w = wid->width(); | 1976 | w = wid->width(); |
1941 | h = wid->height(); | 1977 | h = wid->height(); |
1942 | list.clear(); | 1978 | list.clear(); |
1943 | list << QString::number( x ); | 1979 | list << QString::number( x ); |
1944 | list << QString::number( y ); | 1980 | list << QString::number( y ); |
1945 | list << QString::number( w ); | 1981 | list << QString::number( w ); |
1946 | list << QString::number( h ); | 1982 | list << QString::number( h ); |
1947 | config->writeEntry("MainLayout",list ); | 1983 | config->writeEntry("MainLayout",list ); |
1948 | 1984 | ||
1949 | wid = mEventEditor; | 1985 | wid = mEventEditor; |
1950 | x = wid->geometry().x(); | 1986 | x = wid->geometry().x(); |
1951 | y = wid->geometry().y(); | 1987 | y = wid->geometry().y(); |
1952 | w = wid->width(); | 1988 | w = wid->width(); |
1953 | h = wid->height(); | 1989 | h = wid->height(); |
1954 | list.clear(); | 1990 | list.clear(); |
1955 | list << QString::number( x ); | 1991 | list << QString::number( x ); |
1956 | list << QString::number( y ); | 1992 | list << QString::number( y ); |
1957 | list << QString::number( w ); | 1993 | list << QString::number( w ); |
1958 | list << QString::number( h ); | 1994 | list << QString::number( h ); |
1959 | config->writeEntry("EditEventLayout",list ); | 1995 | config->writeEntry("EditEventLayout",list ); |
1960 | 1996 | ||
1961 | wid = mTodoEditor; | 1997 | wid = mTodoEditor; |
1962 | x = wid->geometry().x(); | 1998 | x = wid->geometry().x(); |
1963 | y = wid->geometry().y(); | 1999 | y = wid->geometry().y(); |
1964 | w = wid->width(); | 2000 | w = wid->width(); |
1965 | h = wid->height(); | 2001 | h = wid->height(); |
1966 | list.clear(); | 2002 | list.clear(); |
1967 | list << QString::number( x ); | 2003 | list << QString::number( x ); |
1968 | list << QString::number( y ); | 2004 | list << QString::number( y ); |
1969 | list << QString::number( w ); | 2005 | list << QString::number( w ); |
1970 | list << QString::number( h ); | 2006 | list << QString::number( h ); |
1971 | config->writeEntry("EditTodoLayout",list ); | 2007 | config->writeEntry("EditTodoLayout",list ); |
1972 | wid = getEventViewerDialog(); | 2008 | wid = getEventViewerDialog(); |
1973 | x = wid->geometry().x(); | 2009 | x = wid->geometry().x(); |
1974 | y = wid->geometry().y(); | 2010 | y = wid->geometry().y(); |
1975 | w = wid->width(); | 2011 | w = wid->width(); |
1976 | h = wid->height(); | 2012 | h = wid->height(); |
1977 | list.clear(); | 2013 | list.clear(); |
1978 | list << QString::number( x ); | 2014 | list << QString::number( x ); |
1979 | list << QString::number( y ); | 2015 | list << QString::number( y ); |
1980 | list << QString::number( w ); | 2016 | list << QString::number( w ); |
1981 | list << QString::number( h ); | 2017 | list << QString::number( h ); |
1982 | config->writeEntry("ViewerLayout",list ); | 2018 | config->writeEntry("ViewerLayout",list ); |
1983 | wid = mDialogManager->getSearchDialog(); | 2019 | wid = mDialogManager->getSearchDialog(); |
1984 | if ( wid ) { | 2020 | if ( wid ) { |
1985 | x = wid->geometry().x(); | 2021 | x = wid->geometry().x(); |
1986 | y = wid->geometry().y(); | 2022 | y = wid->geometry().y(); |
1987 | w = wid->width(); | 2023 | w = wid->width(); |
1988 | h = wid->height(); | 2024 | h = wid->height(); |
1989 | list.clear(); | 2025 | list.clear(); |
1990 | list << QString::number( x ); | 2026 | list << QString::number( x ); |
1991 | list << QString::number( y ); | 2027 | list << QString::number( y ); |
1992 | list << QString::number( w ); | 2028 | list << QString::number( w ); |
1993 | list << QString::number( h ); | 2029 | list << QString::number( h ); |
1994 | config->writeEntry("SearchLayout",list ); | 2030 | config->writeEntry("SearchLayout",list ); |
1995 | } | 2031 | } |
1996 | #endif | 2032 | #endif |
1997 | 2033 | ||
1998 | 2034 | ||
1999 | config->sync(); | 2035 | config->sync(); |
2000 | } | 2036 | } |
2001 | 2037 | ||
2002 | void CalendarView::readFilterSettings(KConfig *config) | 2038 | void CalendarView::readFilterSettings(KConfig *config) |
2003 | { | 2039 | { |
2004 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2040 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2005 | 2041 | ||
2006 | mFilters.clear(); | 2042 | mFilters.clear(); |
2007 | 2043 | ||
2008 | config->setGroup("General"); | 2044 | config->setGroup("General"); |
2009 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2045 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2010 | 2046 | ||
2011 | QStringList::ConstIterator it = filterList.begin(); | 2047 | QStringList::ConstIterator it = filterList.begin(); |
2012 | QStringList::ConstIterator end = filterList.end(); | 2048 | QStringList::ConstIterator end = filterList.end(); |
2013 | while(it != end) { | 2049 | while(it != end) { |
2014 | // kdDebug() << " filter: " << (*it) << endl; | 2050 | // kdDebug() << " filter: " << (*it) << endl; |
2015 | 2051 | ||
2016 | CalFilter *filter; | 2052 | CalFilter *filter; |
2017 | filter = new CalFilter(*it); | 2053 | filter = new CalFilter(*it); |
2018 | config->setGroup("Filter_" + (*it)); | 2054 | config->setGroup("Filter_" + (*it)); |
2019 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2055 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2020 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2056 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2021 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2057 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2022 | mFilters.append(filter); | 2058 | mFilters.append(filter); |
2023 | 2059 | ||
2024 | ++it; | 2060 | ++it; |
2025 | } | 2061 | } |
2026 | 2062 | ||
2027 | if (mFilters.count() == 0) { | 2063 | if (mFilters.count() == 0) { |
2028 | CalFilter *filter = new CalFilter(i18n("Default")); | 2064 | CalFilter *filter = new CalFilter(i18n("Default")); |
2029 | mFilters.append(filter); | 2065 | mFilters.append(filter); |
2030 | } | 2066 | } |
2031 | mFilterView->updateFilters(); | 2067 | mFilterView->updateFilters(); |
2032 | config->setGroup("FilterView"); | 2068 | config->setGroup("FilterView"); |
2033 | 2069 | ||
2034 | mFilterView->blockSignals(true); | 2070 | mFilterView->blockSignals(true); |
2035 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2071 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2036 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2072 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2037 | mFilterView->blockSignals(false); | 2073 | mFilterView->blockSignals(false); |
2038 | // We do it manually to avoid it being done twice by the above calls | 2074 | // We do it manually to avoid it being done twice by the above calls |
2039 | updateFilter(); | 2075 | updateFilter(); |
2040 | } | 2076 | } |
2041 | 2077 | ||
2042 | void CalendarView::writeFilterSettings(KConfig *config) | 2078 | void CalendarView::writeFilterSettings(KConfig *config) |
2043 | { | 2079 | { |
2044 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2080 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2045 | 2081 | ||
2046 | QStringList filterList; | 2082 | QStringList filterList; |
2047 | 2083 | ||
2048 | CalFilter *filter = mFilters.first(); | 2084 | CalFilter *filter = mFilters.first(); |
2049 | while(filter) { | 2085 | while(filter) { |
2050 | // kdDebug() << " fn: " << filter->name() << endl; | 2086 | // kdDebug() << " fn: " << filter->name() << endl; |
2051 | filterList << filter->name(); | 2087 | filterList << filter->name(); |
2052 | config->setGroup("Filter_" + filter->name()); | 2088 | config->setGroup("Filter_" + filter->name()); |
2053 | config->writeEntry("Criteria",filter->criteria()); | 2089 | config->writeEntry("Criteria",filter->criteria()); |
2054 | config->writeEntry("CategoryList",filter->categoryList()); | 2090 | config->writeEntry("CategoryList",filter->categoryList()); |
2055 | filter = mFilters.next(); | 2091 | filter = mFilters.next(); |
2056 | } | 2092 | } |
2057 | config->setGroup("General"); | 2093 | config->setGroup("General"); |
2058 | config->writeEntry("CalendarFilters",filterList); | 2094 | config->writeEntry("CalendarFilters",filterList); |
2059 | 2095 | ||
2060 | config->setGroup("FilterView"); | 2096 | config->setGroup("FilterView"); |
2061 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2097 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2062 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2098 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2063 | } | 2099 | } |
2064 | 2100 | ||
2065 | 2101 | ||
2066 | void CalendarView::goToday() | 2102 | void CalendarView::goToday() |
2067 | { | 2103 | { |
2068 | if ( mViewManager->currentView()->isMonthView() ) | 2104 | if ( mViewManager->currentView()->isMonthView() ) |
2069 | mNavigator->selectTodayMonth(); | 2105 | mNavigator->selectTodayMonth(); |
2070 | else | 2106 | else |
2071 | mNavigator->selectToday(); | 2107 | mNavigator->selectToday(); |
2072 | } | 2108 | } |
2073 | 2109 | ||
2074 | void CalendarView::goNext() | 2110 | void CalendarView::goNext() |
2075 | { | 2111 | { |
2076 | mNavigator->selectNext(); | 2112 | mNavigator->selectNext(); |
2077 | } | 2113 | } |
2078 | 2114 | ||
2079 | void CalendarView::goPrevious() | 2115 | void CalendarView::goPrevious() |
2080 | { | 2116 | { |
2081 | mNavigator->selectPrevious(); | 2117 | mNavigator->selectPrevious(); |
2082 | } | 2118 | } |
2083 | void CalendarView::goNextMonth() | 2119 | void CalendarView::goNextMonth() |
2084 | { | 2120 | { |
2085 | mNavigator->selectNextMonth(); | 2121 | mNavigator->selectNextMonth(); |
2086 | } | 2122 | } |
2087 | 2123 | ||
2088 | void CalendarView::goPreviousMonth() | 2124 | void CalendarView::goPreviousMonth() |
2089 | { | 2125 | { |
2090 | mNavigator->selectPreviousMonth(); | 2126 | mNavigator->selectPreviousMonth(); |
2091 | } | 2127 | } |
2092 | void CalendarView::writeLocale() | 2128 | void CalendarView::writeLocale() |
2093 | { | 2129 | { |
2094 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2130 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2095 | #if 0 | 2131 | #if 0 |
2096 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2132 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2097 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2133 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2098 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2134 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2099 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2135 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2100 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2136 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2101 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2137 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2102 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2138 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2103 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2139 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2104 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2140 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2105 | KOPrefs::instance()->mDaylightsavingStart, | 2141 | KOPrefs::instance()->mDaylightsavingStart, |
2106 | KOPrefs::instance()->mDaylightsavingEnd ); | 2142 | KOPrefs::instance()->mDaylightsavingEnd ); |
2107 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2143 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2108 | #endif | 2144 | #endif |
2109 | } | 2145 | } |
2110 | void CalendarView::updateConfig() | 2146 | void CalendarView::updateConfig() |
2111 | { | 2147 | { |
2112 | writeLocale(); | 2148 | writeLocale(); |
2113 | if ( KOPrefs::instance()->mUseAppColors ) | 2149 | if ( KOPrefs::instance()->mUseAppColors ) |
2114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2150 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2115 | emit configChanged(); | 2151 | emit configChanged(); |
2116 | mTodoList->updateConfig(); | 2152 | mTodoList->updateConfig(); |
2117 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2153 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2118 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2154 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2119 | // To make the "fill window" configurations work | 2155 | // To make the "fill window" configurations work |
2120 | //mViewManager->raiseCurrentView(); | 2156 | //mViewManager->raiseCurrentView(); |
2121 | } | 2157 | } |
2122 | 2158 | ||
2123 | 2159 | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index fac9a9e..16e671f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -342,276 +342,276 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
342 | /** pop up a dialog to show an existing appointment. */ | 342 | /** pop up a dialog to show an existing appointment. */ |
343 | void appointment_show(); | 343 | void appointment_show(); |
344 | /** | 344 | /** |
345 | * pop up an Appointment Dialog to edit an existing appointment.Get | 345 | * pop up an Appointment Dialog to edit an existing appointment.Get |
346 | * 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 |
347 | * currently in the View, called currIds. | 347 | * currently in the View, called currIds. |
348 | */ | 348 | */ |
349 | void appointment_edit(); | 349 | void appointment_edit(); |
350 | /** | 350 | /** |
351 | * pop up dialog confirming deletion of currently selected event in the | 351 | * pop up dialog confirming deletion of currently selected event in the |
352 | * View. | 352 | * View. |
353 | */ | 353 | */ |
354 | void appointment_delete(); | 354 | void appointment_delete(); |
355 | 355 | ||
356 | /** 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 |
357 | attachment. */ | 357 | attachment. */ |
358 | void action_mail(); | 358 | void action_mail(); |
359 | 359 | ||
360 | /* frees a subtodo from it's relation */ | 360 | /* frees a subtodo from it's relation */ |
361 | void todo_unsub( Todo * ); | 361 | void todo_unsub( Todo * ); |
362 | void todo_resub( Todo * parent, Todo * sub ); | 362 | void todo_resub( Todo * parent, Todo * sub ); |
363 | 363 | ||
364 | /** Take ownership of selected event. */ | 364 | /** Take ownership of selected event. */ |
365 | void takeOverEvent(); | 365 | void takeOverEvent(); |
366 | 366 | ||
367 | /** Take ownership of all events in calendar. */ | 367 | /** Take ownership of all events in calendar. */ |
368 | void takeOverCalendar(); | 368 | void takeOverCalendar(); |
369 | 369 | ||
370 | /** query whether or not the calendar is "dirty". */ | 370 | /** query whether or not the calendar is "dirty". */ |
371 | bool isModified(); | 371 | bool isModified(); |
372 | /** 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. */ |
373 | void setModified(bool modified=true); | 373 | void setModified(bool modified=true); |
374 | 374 | ||
375 | /** query if the calendar is read-only. */ | 375 | /** query if the calendar is read-only. */ |
376 | bool isReadOnly(); | 376 | bool isReadOnly(); |
377 | /** set state of calendar to read-only */ | 377 | /** set state of calendar to read-only */ |
378 | void setReadOnly(bool readOnly=true); | 378 | void setReadOnly(bool readOnly=true); |
379 | 379 | ||
380 | void eventUpdated(Incidence *); | 380 | void eventUpdated(Incidence *); |
381 | 381 | ||
382 | /* iTIP scheduling actions */ | 382 | /* iTIP scheduling actions */ |
383 | void schedule_publish(Incidence *incidence = 0); | 383 | void schedule_publish(Incidence *incidence = 0); |
384 | void schedule_request(Incidence *incidence = 0); | 384 | void schedule_request(Incidence *incidence = 0); |
385 | void schedule_refresh(Incidence *incidence = 0); | 385 | void schedule_refresh(Incidence *incidence = 0); |
386 | void schedule_cancel(Incidence *incidence = 0); | 386 | void schedule_cancel(Incidence *incidence = 0); |
387 | void schedule_add(Incidence *incidence = 0); | 387 | void schedule_add(Incidence *incidence = 0); |
388 | void schedule_reply(Incidence *incidence = 0); | 388 | void schedule_reply(Incidence *incidence = 0); |
389 | void schedule_counter(Incidence *incidence = 0); | 389 | void schedule_counter(Incidence *incidence = 0); |
390 | void schedule_declinecounter(Incidence *incidence = 0); | 390 | void schedule_declinecounter(Incidence *incidence = 0); |
391 | void schedule_publish_freebusy(int daysToPublish = 30); | 391 | void schedule_publish_freebusy(int daysToPublish = 30); |
392 | 392 | ||
393 | void openAddressbook(); | 393 | void openAddressbook(); |
394 | 394 | ||
395 | void editFilters(); | 395 | void editFilters(); |
396 | void toggleFilerEnabled(); | 396 | void toggleFilerEnabled(); |
397 | QPtrList<CalFilter> filters(); | 397 | QPtrList<CalFilter> filters(); |
398 | void toggleFilter(); | 398 | void toggleFilter(); |
399 | void showFilter(bool visible); | 399 | void showFilter(bool visible); |
400 | void updateFilter(); | 400 | void updateFilter(); |
401 | void filterEdited(); | 401 | void filterEdited(); |
402 | void selectFilter( int ); | 402 | void selectFilter( int ); |
403 | KOFilterView *filterView(); | 403 | KOFilterView *filterView(); |
404 | 404 | ||
405 | void showIntro(); | 405 | void showIntro(); |
406 | 406 | ||
407 | /** Move the curdatepient view date to today */ | 407 | /** Move the curdatepient view date to today */ |
408 | void goToday(); | 408 | void goToday(); |
409 | 409 | ||
410 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
411 | void goNext(); | 411 | void goNext(); |
412 | 412 | ||
413 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
414 | void goPrevious(); | 414 | void goPrevious(); |
415 | /** Move to the next date(s) in the current view */ | 415 | /** Move to the next date(s) in the current view */ |
416 | void goNextMonth(); | 416 | void goNextMonth(); |
417 | 417 | ||
418 | /** Move to the previous date(s) in the current view */ | 418 | /** Move to the previous date(s) in the current view */ |
419 | void goPreviousMonth(); | 419 | void goPreviousMonth(); |
420 | 420 | ||
421 | void toggleExpand(); | 421 | void toggleExpand(); |
422 | void toggleDateNavigatorWidget(); | 422 | void toggleDateNavigatorWidget(); |
423 | void toggleAllDaySize(); | 423 | void toggleAllDaySize(); |
424 | void dialogClosing(Incidence *); | 424 | void dialogClosing(Incidence *); |
425 | 425 | ||
426 | /** Look for new messages in the inbox */ | 426 | /** Look for new messages in the inbox */ |
427 | void lookForIncomingMessages(); | 427 | void lookForIncomingMessages(); |
428 | /** Look for new messages in the outbox */ | 428 | /** Look for new messages in the outbox */ |
429 | void lookForOutgoingMessages(); | 429 | void lookForOutgoingMessages(); |
430 | 430 | ||
431 | void processMainViewSelection( Incidence * ); | 431 | void processMainViewSelection( Incidence * ); |
432 | void processTodoListSelection( Incidence * ); | 432 | void processTodoListSelection( Incidence * ); |
433 | 433 | ||
434 | void processIncidenceSelection( Incidence * ); | 434 | void processIncidenceSelection( Incidence * ); |
435 | 435 | ||
436 | void purgeCompleted(); | 436 | void purgeCompleted(); |
437 | bool removeCompletedSubTodos( Todo* ); | 437 | bool removeCompletedSubTodos( Todo* ); |
438 | void slotCalendarChanged(); | 438 | void slotCalendarChanged(); |
439 | bool importBday(); | 439 | bool importBday(); |
440 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 440 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
441 | bool importQtopia( const QString &categoriesFile, | 441 | bool importQtopia( const QString &categoriesFile, |
442 | const QString &datebookFile, | 442 | const QString &datebookFile, |
443 | const QString &tasklistFile ); | 443 | const QString &tasklistFile ); |
444 | void syncExternal( int mode ); | 444 | void syncExternal( int mode ); |
445 | void slotSelectPickerDate( QDate ) ; | 445 | void slotSelectPickerDate( QDate ) ; |
446 | void showDatePicker() ; | 446 | void showDatePicker() ; |
447 | void showDatePickerPopup() ; | 447 | void showDatePickerPopup() ; |
448 | void moveIncidence(Incidence *) ; | 448 | void moveIncidence(Incidence *) ; |
449 | void beamIncidence(Incidence *) ; | 449 | void beamIncidence(Incidence *) ; |
450 | void beamCalendar() ; | 450 | void beamCalendar() ; |
451 | void beamFilteredCalendar() ; | 451 | void beamFilteredCalendar() ; |
452 | void beamIncidenceList(QPtrList<Incidence>) ; | 452 | void beamIncidenceList(QPtrList<Incidence>) ; |
453 | void manageCategories(); | 453 | void manageCategories(); |
454 | int addCategories(); | 454 | int addCategories(); |
455 | void removeCategories(); | 455 | void removeCategories(); |
456 | void setSyncDevice( QString ); | 456 | void setSyncDevice( QString ); |
457 | void setSyncName( QString ); | 457 | void setSyncName( QString ); |
458 | void showDay( QDate ); | 458 | void showDay( QDate ); |
459 | void undo_delete(); | 459 | void undo_delete(); |
460 | protected slots: | 460 | protected slots: |
461 | void resetFocus(); | 461 | void resetFocus(); |
462 | void slotViewerClosed(); | 462 | void slotViewerClosed(); |
463 | void timerAlarm(); | 463 | void timerAlarm(); |
464 | void suspendAlarm(); | 464 | void suspendAlarm(); |
465 | void beamDone( Ir *ir ); | 465 | void beamDone( Ir *ir ); |
466 | /** 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. */ |
467 | void showDates( const KCal::DateList & ); | 467 | void showDates( const KCal::DateList & ); |
468 | void selectWeekNum ( int ); | 468 | void selectWeekNum ( int ); |
469 | 469 | ||
470 | public: | 470 | public: |
471 | // show a standard warning | 471 | // show a standard warning |
472 | // returns KMsgBox::yesNoCancel() | 472 | // returns KMsgBox::yesNoCancel() |
473 | int msgCalModified(); | 473 | int msgCalModified(); |
474 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 474 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
475 | 475 | ||
476 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 476 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
477 | virtual void removeSyncInfo( QString syncProfile); | 477 | virtual void removeSyncInfo( QString syncProfile); |
478 | void setSyncManager(KSyncManager* manager); | 478 | void setSyncManager(KSyncManager* manager); |
479 | void setLoadedFileVersion(QDateTime); | 479 | void setLoadedFileVersion(QDateTime); |
480 | bool checkFileVersion(QString fn); | 480 | bool checkFileVersion(QString fn); |
481 | bool checkFileChanged(QString fn); | 481 | bool checkFileChanged(QString fn); |
482 | Event* getLastSyncEvent(); | 482 | Event* getLastSyncEvent(); |
483 | /** Adapt navigation units correpsonding to step size of navigation of the | 483 | /** Adapt navigation units correpsonding to step size of navigation of the |
484 | * current view. | 484 | * current view. |
485 | */ | 485 | */ |
486 | void adaptNavigationUnits(); | 486 | void adaptNavigationUnits(); |
487 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 487 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
488 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 488 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
489 | //Attendee* getYourAttendee(Event *event); | 489 | //Attendee* getYourAttendee(Event *event); |
490 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 490 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
491 | protected: | 491 | protected: |
492 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 492 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
493 | 493 | ||
494 | // returns KMsgBox::OKCandel() | 494 | // returns KMsgBox::OKCandel() |
495 | int msgItemDelete(const QString name); | 495 | int msgItemDelete(const QString name); |
496 | void showEventEditor(); | 496 | void showEventEditor(); |
497 | void showTodoEditor(); | 497 | void showTodoEditor(); |
498 | void writeLocale(); | 498 | void writeLocale(); |
499 | Todo *selectedTodo(); | 499 | Todo *selectedTodo(); |
500 | 500 | ||
501 | private: | 501 | private: |
502 | bool mViewerCallerIsSearchDialog; | 502 | bool mViewerCallerIsSearchDialog; |
503 | bool mBlockShowDates; | 503 | bool mBlockShowDates; |
504 | KSyncManager* mSyncManager; | 504 | KSyncManager* mSyncManager; |
505 | AlarmDialog * mAlarmDialog; | 505 | AlarmDialog * mAlarmDialog; |
506 | QString mAlarmNotification; | 506 | QString mAlarmNotification; |
507 | QString mSuspendAlarmNotification; | 507 | QString mSuspendAlarmNotification; |
508 | QTimer* mSuspendTimer; | 508 | QTimer* mSuspendTimer; |
509 | QTimer* mAlarmTimer; | 509 | QTimer* mAlarmTimer; |
510 | QTimer* mRecheckAlarmTimer; | 510 | QTimer* mRecheckAlarmTimer; |
511 | void computeAlarm( QString ); | 511 | void computeAlarm( QString ); |
512 | void startAlarm( QString, QString ); | 512 | void startAlarm( QString, QString ); |
513 | void setSyncEventsReadOnly(); | 513 | void setSyncEventsReadOnly(); |
514 | 514 | ||
515 | QDateTime loadedFileVersion; | 515 | QDateTime loadedFileVersion; |
516 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 516 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
517 | void checkExternalId( Incidence * inc ); | 517 | void checkExternalId( Incidence * inc ); |
518 | int mGlobalSyncMode; | 518 | int mGlobalSyncMode; |
519 | QString mCurrentSyncDevice; | 519 | QString mCurrentSyncDevice; |
520 | QString mCurrentSyncName; | 520 | QString mCurrentSyncName; |
521 | KOBeamPrefs* beamDialog; | 521 | KOBeamPrefs* beamDialog; |
522 | void init(); | 522 | void init(); |
523 | int mDatePickerMode; | 523 | int mDatePickerMode; |
524 | bool mFlagEditDescription; | 524 | bool mFlagEditDescription; |
525 | QDateTime mLastCalendarSync; | 525 | QDateTime mLastCalendarSync; |
526 | void createPrinter(); | 526 | void createPrinter(); |
527 | 527 | ||
528 | void calendarModified( bool, Calendar * ); | 528 | void calendarModified( bool, Calendar * ); |
529 | 529 | ||
530 | CalPrinter *mCalPrinter; | 530 | CalPrinter *mCalPrinter; |
531 | 531 | ||
532 | QSplitter *mPanner; | 532 | QSplitter *mPanner; |
533 | QSplitter *mLeftSplitter; | 533 | QSplitter *mLeftSplitter; |
534 | KDGanttMinimizeSplitter *mLeftFrame; | 534 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
535 | QWidgetStack *mRightFrame; | 535 | QWidgetStack *mRightFrame; |
536 | 536 | ||
537 | KDatePicker* mDatePicker; | 537 | KDatePicker* mDatePicker; |
538 | QVBox* mDateFrame; | 538 | QVBox* mDateFrame; |
539 | 539 | ||
540 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 540 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
541 | 541 | ||
542 | KOFilterView *mFilterView; | 542 | KOFilterView *mFilterView; |
543 | 543 | ||
544 | ResourceView *mResourceView; | 544 | ResourceView *mResourceView; |
545 | 545 | ||
546 | // calendar object for this viewing instance | 546 | // calendar object for this viewing instance |
547 | Calendar *mCalendar; | 547 | Calendar *mCalendar; |
548 | 548 | ||
549 | CalendarResourceManager *mResourceManager; | 549 | CalendarResourceManager *mResourceManager; |
550 | 550 | ||
551 | FileStorage *mStorage; | 551 | FileStorage *mStorage; |
552 | 552 | ||
553 | DateNavigator *mNavigator; | 553 | DateNavigator *mNavigator; |
554 | 554 | ||
555 | KOViewManager *mViewManager; | 555 | KOViewManager *mViewManager; |
556 | KODialogManager *mDialogManager; | 556 | KODialogManager *mDialogManager; |
557 | 557 | ||
558 | // Calendar filters | 558 | // Calendar filters |
559 | QPtrList<CalFilter> mFilters; | 559 | QPtrList<CalFilter> mFilters; |
560 | 560 | ||
561 | // various housekeeping variables. | 561 | // various housekeeping variables. |
562 | bool mModified; // flag indicating if calendar is modified | 562 | bool mModified; // flag indicating if calendar is modified |
563 | bool mReadOnly; // flag indicating if calendar is read-only | 563 | bool mReadOnly; // flag indicating if calendar is read-only |
564 | QDate mSaveSingleDate; | 564 | QDate mSaveSingleDate; |
565 | 565 | ||
566 | Incidence *mSelectedIncidence; | 566 | Incidence *mSelectedIncidence; |
567 | Incidence *mMoveIncidence; | 567 | Incidence *mMoveIncidence; |
568 | QDate mMoveIncidenceOldDate; | 568 | QDate mMoveIncidenceOldDate; |
569 | KOTodoView *mTodoList; | 569 | KOTodoView *mTodoList; |
570 | KOEventEditor * mEventEditor; | 570 | KOEventEditor * mEventEditor; |
571 | KOTodoEditor * mTodoEditor; | 571 | KOTodoEditor * mTodoEditor; |
572 | KOEventViewerDialog * mEventViewerDialog; | 572 | KOEventViewerDialog * mEventViewerDialog; |
573 | void keyPressEvent ( QKeyEvent *e) ; | 573 | void keyPressEvent ( QKeyEvent *e) ; |
574 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 574 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
575 | }; | 575 | }; |
576 | 576 | ||
577 | 577 | ||
578 | class CalendarViewVisitor : public Incidence::Visitor | 578 | class CalendarViewVisitor : public Incidence::Visitor |
579 | { | 579 | { |
580 | public: | 580 | public: |
581 | CalendarViewVisitor() : mView( 0 ) {} | 581 | CalendarViewVisitor() : mView( 0 ) {} |
582 | 582 | ||
583 | bool act( Incidence *incidence, CalendarView *view ) | 583 | bool act( Incidence *incidence, CalendarView *view ) |
584 | { | 584 | { |
585 | mView = view; | 585 | mView = view; |
586 | return incidence->accept( *this ); | 586 | return incidence->accept( *this ); |
587 | } | 587 | } |
588 | 588 | ||
589 | protected: | 589 | protected: |
590 | CalendarView *mView; | 590 | CalendarView *mView; |
591 | }; | 591 | }; |
592 | 592 | ||
593 | class ShowIncidenceVisitor : public CalendarViewVisitor | 593 | class ShowIncidenceVisitor : public CalendarViewVisitor |
594 | { | 594 | { |
595 | protected: | 595 | protected: |
596 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 596 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
597 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 597 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
598 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 598 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
599 | }; | 599 | }; |
600 | 600 | ||
601 | class EditIncidenceVisitor : public CalendarViewVisitor | 601 | class EditIncidenceVisitor : public CalendarViewVisitor |
602 | { | 602 | { |
603 | protected: | 603 | protected: |
604 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 604 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
605 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 605 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
606 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 606 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
607 | }; | 607 | }; |
608 | 608 | ||
609 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 609 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
610 | { | 610 | { |
611 | protected: | 611 | protected: |
612 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 612 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
613 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 613 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
614 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 614 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
615 | }; | 615 | }; |
616 | 616 | ||
617 | #endif | 617 | #endif |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index b9bd1b9..3358ecf 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,229 +1,257 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 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 | 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. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | #include "koprefs.h" | ||
36 | 37 | ||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
38 | const char *name ) | 39 | const char *name ) |
39 | : QWidget( parent, name ), mCalendar( 0 ), | 40 | : QWidget( parent, name ), mCalendar( 0 ), |
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
41 | { | 42 | { |
42 | mExtraViews.setAutoDelete( true ); | 43 | mExtraViews.setAutoDelete( true ); |
43 | 44 | ||
44 | mNavigatorView = new KDateNavigator( this, name ); | 45 | mNavigatorView = new KDateNavigator( this, name ); |
45 | 46 | ||
46 | connectNavigatorView( mNavigatorView ); | 47 | connectNavigatorView( mNavigatorView ); |
47 | } | 48 | } |
48 | 49 | ||
49 | DateNavigatorContainer::~DateNavigatorContainer() | 50 | DateNavigatorContainer::~DateNavigatorContainer() |
50 | { | 51 | { |
51 | } | 52 | } |
52 | 53 | ||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 54 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
54 | { | 55 | { |
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 56 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 57 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
57 | #if 0 | 58 | #if 0 |
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 59 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 60 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 61 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 62 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
62 | #endif | 63 | #endif |
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 64 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
64 | SIGNAL( weekClicked( const QDate & ) ) ); | 65 | SIGNAL( weekClicked( const QDate & ) ) ); |
65 | 66 | ||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 67 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 68 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
68 | 69 | ||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 70 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 71 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 73 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
73 | 74 | ||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 75 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
75 | } | 76 | } |
76 | 77 | ||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 78 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
78 | { | 79 | { |
79 | mCalendar = cal; | 80 | mCalendar = cal; |
80 | mNavigatorView->setCalendar( cal ); | 81 | mNavigatorView->setCalendar( cal ); |
81 | KDateNavigator *n; | 82 | KDateNavigator *n; |
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 83 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
83 | n->setCalendar( cal ); | 84 | n->setCalendar( cal ); |
84 | } | 85 | } |
85 | } | 86 | } |
86 | 87 | ||
87 | void DateNavigatorContainer::updateDayMatrix() | 88 | void DateNavigatorContainer::updateDayMatrix() |
88 | { | 89 | { |
89 | mNavigatorView->updateDayMatrix(); | 90 | mNavigatorView->updateDayMatrix(); |
90 | KDateNavigator *n; | 91 | KDateNavigator *n; |
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 92 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
92 | n->updateDayMatrix(); | 93 | n->updateDayMatrix(); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | void DateNavigatorContainer::updateToday() | 97 | void DateNavigatorContainer::updateToday() |
97 | { | 98 | { |
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 99 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
99 | #if 0 | 100 | #if 0 |
100 | mNavigatorView->updateToday(); | 101 | mNavigatorView->updateToday(); |
101 | KDateNavigator *n; | 102 | KDateNavigator *n; |
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 103 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
103 | n->updateToday(); | 104 | n->updateToday(); |
104 | } | 105 | } |
105 | #endif | 106 | #endif |
106 | } | 107 | } |
107 | 108 | ||
108 | void DateNavigatorContainer::updateView() | 109 | void DateNavigatorContainer::updateView() |
109 | { | 110 | { |
110 | mNavigatorView->updateView(); | 111 | mNavigatorView->updateView(); |
111 | KDateNavigator *n; | 112 | KDateNavigator *n; |
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 113 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
113 | n->updateView(); | 114 | n->updateView(); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | void DateNavigatorContainer::updateConfig() | 118 | void DateNavigatorContainer::updateConfig() |
118 | { | 119 | { |
119 | mNavigatorView->updateConfig(); | 120 | mNavigatorView->updateConfig(); |
120 | KDateNavigator *n; | 121 | KDateNavigator *n; |
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 122 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
122 | n->updateConfig(); | 123 | n->updateConfig(); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 127 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 128 | { |
128 | mNavigatorView->selectDates( dateList ); | 129 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 130 | setBaseDates(); |
130 | if ( mExtraViews.count() ) { | 131 | if ( mExtraViews.count() ) { |
131 | KDateNavigator *view = mExtraViews.at( 0 ); | 132 | KDateNavigator *view = mExtraViews.at( 0 ); |
132 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 133 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
133 | view->dayMatrix()->repaint(); | 134 | view->dayMatrix()->repaint(); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | void DateNavigatorContainer::setBaseDates() | 138 | void DateNavigatorContainer::setBaseDates() |
138 | { | 139 | { |
139 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 140 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
140 | if ( dateList.isEmpty() ) { | 141 | if ( dateList.isEmpty() ) { |
141 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 142 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
142 | } | 143 | } |
143 | QDate baseDate = dateList.first(); | 144 | QDate baseDate = dateList.first(); |
144 | KDateNavigator *n; | 145 | KDateNavigator *n; |
145 | bool doRepaint = false; // skip first repaint | 146 | bool doRepaint = false; // skip first repaint |
146 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 147 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
147 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 148 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
148 | n->setBaseDate( baseDate, doRepaint ); | 149 | n->setBaseDate( baseDate, doRepaint ); |
149 | doRepaint = true; | 150 | doRepaint = true; |
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 154 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
154 | { | 155 | { |
155 | #if 0 | 156 | #if 0 |
156 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 157 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
157 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 158 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
158 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 159 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
159 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 160 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
160 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 161 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
161 | #endif | 162 | #endif |
162 | QSize minSize = mNavigatorView->yourSizeHint(); | 163 | QSize minSize = mNavigatorView->yourSizeHint(); |
163 | 164 | ||
164 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 165 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
165 | 166 | ||
166 | int verticalCount = size().height() / minSize.height(); | 167 | int verticalCount = size().height() / minSize.height(); |
167 | int horizontalCount = size().width() / minSize.width(); | 168 | int horizontalCount = size().width() / minSize.width(); |
168 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 169 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
169 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 170 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
171 | bool fontchange = false; | ||
172 | QFont fo; | ||
170 | if ( horizontalCount != mHorizontalCount || | 173 | if ( horizontalCount != mHorizontalCount || |
171 | verticalCount != mVerticalCount ) { | 174 | verticalCount != mVerticalCount ) { |
172 | uint count = horizontalCount * verticalCount; | 175 | uint count = horizontalCount * verticalCount; |
173 | if ( count == 0 ) { | 176 | if ( count == 0 ) { |
174 | mNavigatorView->resize( minSize ); | 177 | bool ok; |
175 | return; | 178 | fo = mNavigatorView->yourFontHint( size() , &ok); |
179 | //mNavigatorView->resize( size() ); | ||
180 | //if ( ! ok ) | ||
181 | // return; | ||
182 | minSize = mNavigatorView->sizeHint(); | ||
183 | verticalCount = size().height() / minSize.height(); | ||
184 | horizontalCount = size().width() / minSize.width(); | ||
185 | if ( horizontalCount == 0 ) | ||
186 | horizontalCount = 1; | ||
187 | if ( verticalCount == 0 ) | ||
188 | verticalCount = 1; | ||
189 | fontchange = true; | ||
190 | count = horizontalCount * verticalCount; | ||
191 | } else { | ||
192 | if ( mNavigatorView->fontChanged() ) { | ||
193 | fontchange = true; | ||
194 | fo = KOPrefs::instance()->mDateNavigatorFont; | ||
195 | mNavigatorView->changeFont( fo ); | ||
196 | mNavigatorView->unsetFontChanged(); | ||
197 | } | ||
176 | } | 198 | } |
177 | 199 | ||
178 | while ( count > ( mExtraViews.count() + 1 ) ) { | 200 | while ( count > ( mExtraViews.count() + 1 ) ) { |
179 | KDateNavigator *n = new KDateNavigator( this ); | 201 | KDateNavigator *n = new KDateNavigator( this ); |
180 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 202 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
181 | mExtraViews.append( n ); | 203 | mExtraViews.append( n ); |
182 | n->setCalendar( mCalendar ); | 204 | n->setCalendar( mCalendar ); |
183 | setBaseDates(); | 205 | setBaseDates(); |
184 | connectNavigatorView( n ); | 206 | connectNavigatorView( n ); |
185 | n->show(); | 207 | n->show(); |
186 | } | 208 | } |
187 | 209 | ||
188 | while ( count < ( mExtraViews.count() + 1 ) ) { | 210 | while ( count < ( mExtraViews.count() + 1 ) ) { |
189 | mExtraViews.removeLast(); | 211 | mExtraViews.removeLast(); |
190 | } | 212 | } |
191 | 213 | if ( fontchange ) { | |
214 | //mNavigatorView->changeFont( fo ); | ||
215 | uint i; | ||
216 | for( i = 0; i < mExtraViews.count(); ++i ) { | ||
217 | KDateNavigator *view = mExtraViews.at( i ); | ||
218 | view->changeFont( fo ); | ||
219 | } | ||
220 | } | ||
192 | mHorizontalCount = horizontalCount; | 221 | mHorizontalCount = horizontalCount; |
193 | mVerticalCount = verticalCount; | 222 | mVerticalCount = verticalCount; |
194 | } | 223 | } |
195 | |||
196 | int height = size().height() / verticalCount; | 224 | int height = size().height() / verticalCount; |
197 | int width = size().width() / horizontalCount; | 225 | int width = size().width() / horizontalCount; |
198 | 226 | ||
199 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 227 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
200 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 228 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
201 | else bar->showButtons( true, true ); | 229 | else bar->showButtons( true, true ); |
202 | 230 | ||
203 | mNavigatorView->setGeometry(0, | 231 | mNavigatorView->setGeometry(0, |
204 | 0, width, height ); | 232 | 0, width, height ); |
205 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 233 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
206 | int x = ( i + 1 ) % horizontalCount; | 234 | int x = ( i + 1 ) % horizontalCount; |
207 | int y = ( i + 1 ) / horizontalCount; | 235 | int y = ( i + 1 ) / horizontalCount; |
208 | 236 | ||
209 | KDateNavigator *view = mExtraViews.at( i ); | 237 | KDateNavigator *view = mExtraViews.at( i ); |
210 | bar = view->navigatorBar(); | 238 | bar = view->navigatorBar(); |
211 | if ( y > 0 ) bar->showButtons( false, false ); | 239 | if ( y > 0 ) bar->showButtons( false, false ); |
212 | else { | 240 | else { |
213 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 241 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
214 | else bar->showButtons( false, false ); | 242 | else bar->showButtons( false, false ); |
215 | } | 243 | } |
216 | view->setGeometry( x * width, | 244 | view->setGeometry( x * width, |
217 | y * height, width, height ); | 245 | y * height, width, height ); |
218 | } | 246 | } |
219 | } | 247 | } |
220 | 248 | ||
221 | QSize DateNavigatorContainer::minimumSizeHint() const | 249 | QSize DateNavigatorContainer::minimumSizeHint() const |
222 | { | 250 | { |
223 | return mNavigatorView->minimumSizeHint(); | 251 | return mNavigatorView->minimumSizeHint(); |
224 | } | 252 | } |
225 | 253 | ||
226 | QSize DateNavigatorContainer::sizeHint() const | 254 | QSize DateNavigatorContainer::sizeHint() const |
227 | { | 255 | { |
228 | return mNavigatorView->sizeHint(); | 256 | return mNavigatorView->sizeHint(); |
229 | } | 257 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index b097dc1..92a0ac2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,310 +1,350 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | mySizeHint = sizeHint(); | 118 | mySizeHint = sizeHint(); |
119 | mFontChanged = false; | ||
120 | } | ||
121 | void KDateNavigator::changeFont ( QFont fo ) | ||
122 | { | ||
123 | setFont( fo ); | ||
124 | mNavigatorBar->resetFont( fo ); | ||
125 | } | ||
126 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | ||
127 | { | ||
128 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | ||
129 | *b = false; | ||
130 | int fontPoint = fo.pointSize(); | ||
131 | while ( fontPoint > 5 ) { | ||
132 | --fontPoint; | ||
133 | fo.setPointSize( fontPoint ); | ||
134 | setFont( fo ); | ||
135 | mFontChanged = true; | ||
136 | mNavigatorBar->resetFont( fo ); | ||
137 | QSize sh = sizeHint(); | ||
138 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | ||
139 | if ( si.width() > sh.width() && si.height() > sh.height()) { | ||
140 | *b = true; | ||
141 | //qDebug("fooooooooooooooooooooooouuuuund "); | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | ||
146 | return fo; | ||
147 | } | ||
148 | QSize KDateNavigator::sizeHint() const | ||
149 | { | ||
150 | QFontMetrics fm ( font() ); | ||
151 | QSize day = daymatrix->sizeHint(); | ||
152 | QSize nav = mNavigatorBar->sizeHint(); | ||
153 | int wid = fm.width( "30") + day.width()+3; | ||
154 | int hei = fm.height() +day.height()+nav.height()+2; | ||
155 | if ( wid < nav.width() ) | ||
156 | wid = nav.width() ; | ||
157 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | ||
158 | return QSize ( wid, hei ); | ||
119 | } | 159 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | 160 | void KDateNavigator::slotMonthSelected( int m ) |
121 | { | 161 | { |
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | 162 | if ( m_MthYr.month() <= mMonthSignalOffset) |
123 | m += 12; | 163 | m += 12; |
124 | int mo = m - mMonthSignalOffset; | 164 | int mo = m - mMonthSignalOffset; |
125 | emit monthSelected( m - mMonthSignalOffset ); | 165 | emit monthSelected( m - mMonthSignalOffset ); |
126 | 166 | ||
127 | } | 167 | } |
128 | void KDateNavigator::setCalendar( Calendar *cal ) | 168 | void KDateNavigator::setCalendar( Calendar *cal ) |
129 | { | 169 | { |
130 | daymatrix->setCalendar( cal ); | 170 | daymatrix->setCalendar( cal ); |
131 | } | 171 | } |
132 | 172 | ||
133 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 173 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
134 | { | 174 | { |
135 | m_MthYr = date; | 175 | m_MthYr = date; |
136 | 176 | ||
137 | updateDates(); | 177 | updateDates(); |
138 | updateView(); | 178 | updateView(); |
139 | 179 | ||
140 | KCal::DateList dates; | 180 | KCal::DateList dates; |
141 | dates.append( date ); | 181 | dates.append( date ); |
142 | mNavigatorBar->selectDates( dates ); | 182 | mNavigatorBar->selectDates( dates ); |
143 | 183 | ||
144 | daymatrix->clearSelection(); | 184 | daymatrix->clearSelection(); |
145 | if ( doRepaint ) | 185 | if ( doRepaint ) |
146 | daymatrix->repaint(); | 186 | daymatrix->repaint(); |
147 | } | 187 | } |
148 | 188 | ||
149 | void KDateNavigator::enableRollover(RolloverType r) | 189 | void KDateNavigator::enableRollover(RolloverType r) |
150 | { | 190 | { |
151 | switch(r) | 191 | switch(r) |
152 | { | 192 | { |
153 | case None : | 193 | case None : |
154 | if (updateTimer) | 194 | if (updateTimer) |
155 | { | 195 | { |
156 | updateTimer->stop(); | 196 | updateTimer->stop(); |
157 | delete updateTimer; | 197 | delete updateTimer; |
158 | updateTimer=0L; | 198 | updateTimer=0L; |
159 | } | 199 | } |
160 | break; | 200 | break; |
161 | case FollowDay : | 201 | case FollowDay : |
162 | case FollowMonth : | 202 | case FollowMonth : |
163 | if (!updateTimer) | 203 | if (!updateTimer) |
164 | { | 204 | { |
165 | updateTimer = new QTimer(this); | 205 | updateTimer = new QTimer(this); |
166 | QObject::connect(updateTimer,SIGNAL(timeout()), | 206 | QObject::connect(updateTimer,SIGNAL(timeout()), |
167 | this,SLOT(possiblyPastMidnight())); | 207 | this,SLOT(possiblyPastMidnight())); |
168 | } | 208 | } |
169 | updateTimer->start(0,true); | 209 | updateTimer->start(0,true); |
170 | lastDayChecked = QDate::currentDate(); | 210 | lastDayChecked = QDate::currentDate(); |
171 | } | 211 | } |
172 | updateRollover=r; | 212 | updateRollover=r; |
173 | } | 213 | } |
174 | 214 | ||
175 | 215 | ||
176 | KDateNavigator::~KDateNavigator() | 216 | KDateNavigator::~KDateNavigator() |
177 | { | 217 | { |
178 | } | 218 | } |
179 | 219 | ||
180 | 220 | ||
181 | void KDateNavigator::passedMidnight() | 221 | void KDateNavigator::passedMidnight() |
182 | { | 222 | { |
183 | QDate today = QDate::currentDate(); | 223 | QDate today = QDate::currentDate(); |
184 | bool emitMonth = false; | 224 | bool emitMonth = false; |
185 | 225 | ||
186 | if (today.month() != lastDayChecked.month()) | 226 | if (today.month() != lastDayChecked.month()) |
187 | { | 227 | { |
188 | if (updateRollover==FollowMonth && | 228 | if (updateRollover==FollowMonth && |
189 | daymatrix->isEndOfMonth()) { | 229 | daymatrix->isEndOfMonth()) { |
190 | goNextMonth(); | 230 | goNextMonth(); |
191 | emitMonth=true; | 231 | emitMonth=true; |
192 | } | 232 | } |
193 | } | 233 | } |
194 | daymatrix->recalculateToday(); | 234 | daymatrix->recalculateToday(); |
195 | daymatrix->repaint(); | 235 | daymatrix->repaint(); |
196 | emit dayPassed(today); | 236 | emit dayPassed(today); |
197 | if (emitMonth) { emit monthPassed(today); } | 237 | if (emitMonth) { emit monthPassed(today); } |
198 | } | 238 | } |
199 | 239 | ||
200 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 240 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
201 | { | 241 | { |
202 | if (lastDayChecked!=QDate::currentDate()) | 242 | if (lastDayChecked!=QDate::currentDate()) |
203 | { | 243 | { |
204 | passedMidnight(); | 244 | passedMidnight(); |
205 | lastDayChecked=QDate::currentDate(); | 245 | lastDayChecked=QDate::currentDate(); |
206 | } | 246 | } |
207 | // Set the timer to go off 1 second after midnight | 247 | // Set the timer to go off 1 second after midnight |
208 | // or after 8 minutes, whichever comes first. | 248 | // or after 8 minutes, whichever comes first. |
209 | if (updateTimer) | 249 | if (updateTimer) |
210 | { | 250 | { |
211 | QTime now = QTime::currentTime(); | 251 | QTime now = QTime::currentTime(); |
212 | QTime midnight = QTime(23,59,59); | 252 | QTime midnight = QTime(23,59,59); |
213 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 253 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
214 | 254 | ||
215 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 255 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
216 | //.arg(now.toString()).arg(midnight.toString())); | 256 | //.arg(now.toString()).arg(midnight.toString())); |
217 | 257 | ||
218 | updateTimer->stop(); | 258 | updateTimer->stop(); |
219 | updateTimer->start(msecsWait,true); | 259 | updateTimer->start(msecsWait,true); |
220 | } | 260 | } |
221 | } | 261 | } |
222 | 262 | ||
223 | void KDateNavigator::updateDates() | 263 | void KDateNavigator::updateDates() |
224 | { | 264 | { |
225 | // Find the first day of the week of the current month. | 265 | // Find the first day of the week of the current month. |
226 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 266 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
227 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 267 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
228 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 268 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
229 | //int di = d1 - d2 + 1; | 269 | //int di = d1 - d2 + 1; |
230 | dayone = dayone.addDays( -d2 + 1 ); | 270 | dayone = dayone.addDays( -d2 + 1 ); |
231 | 271 | ||
232 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 272 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
233 | 273 | ||
234 | // If month begins on Monday and Monday is first day of week, | 274 | // If month begins on Monday and Monday is first day of week, |
235 | // month should begin on second line. Sunday doesn't have this problem. | 275 | // month should begin on second line. Sunday doesn't have this problem. |
236 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 276 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
237 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 277 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
238 | 278 | ||
239 | // update the matrix dates | 279 | // update the matrix dates |
240 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 280 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
241 | 281 | ||
242 | 282 | ||
243 | daymatrix->updateView(dayone.addDays(index)); | 283 | daymatrix->updateView(dayone.addDays(index)); |
244 | //each updateDates is followed by an updateView -> repaint is issued there ! | 284 | //each updateDates is followed by an updateView -> repaint is issued there ! |
245 | // daymatrix->repaint(); | 285 | // daymatrix->repaint(); |
246 | } | 286 | } |
247 | 287 | ||
248 | void KDateNavigator::updateDayMatrix() | 288 | void KDateNavigator::updateDayMatrix() |
249 | { | 289 | { |
250 | daymatrix->updateView(); | 290 | daymatrix->updateView(); |
251 | //daymatrix->repaint(); | 291 | //daymatrix->repaint(); |
252 | } | 292 | } |
253 | 293 | ||
254 | 294 | ||
255 | void KDateNavigator::updateView() | 295 | void KDateNavigator::updateView() |
256 | { | 296 | { |
257 | 297 | ||
258 | setUpdatesEnabled( false ); | 298 | setUpdatesEnabled( false ); |
259 | 299 | ||
260 | int i; | 300 | int i; |
261 | 301 | ||
262 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 302 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
263 | daymatrix->updateView(); | 303 | daymatrix->updateView(); |
264 | 304 | ||
265 | // set the week numbers. | 305 | // set the week numbers. |
266 | for(i = 0; i < 6; i++) { | 306 | for(i = 0; i < 6; i++) { |
267 | QString weeknum; | 307 | QString weeknum; |
268 | // remember, according to ISO 8601, the first week of the year is the | 308 | // remember, according to ISO 8601, the first week of the year is the |
269 | // first week that contains a thursday. Thus we must subtract off 4, | 309 | // first week that contains a thursday. Thus we must subtract off 4, |
270 | // not just 1. | 310 | // not just 1. |
271 | 311 | ||
272 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 312 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
273 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 313 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
274 | 314 | ||
275 | int add = 0; | 315 | int add = 0; |
276 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 316 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
277 | ++add; | 317 | ++add; |
278 | if (dayOfYear % 7 != 0) | 318 | if (dayOfYear % 7 != 0) |
279 | weeknum.setNum(dayOfYear / 7 + 1+add); | 319 | weeknum.setNum(dayOfYear / 7 + 1+add); |
280 | else | 320 | else |
281 | weeknum.setNum(dayOfYear / 7 +add); | 321 | weeknum.setNum(dayOfYear / 7 +add); |
282 | weeknos[i]->setText(weeknum); | 322 | weeknos[i]->setText(weeknum); |
283 | } | 323 | } |
284 | 324 | ||
285 | setUpdatesEnabled( true ); | 325 | setUpdatesEnabled( true ); |
286 | // kdDebug() << "updateView() -> repaint()" << endl; | 326 | // kdDebug() << "updateView() -> repaint()" << endl; |
287 | repaint(); | 327 | repaint(); |
288 | // daymatrix->repaint(); | 328 | // daymatrix->repaint(); |
289 | } | 329 | } |
290 | 330 | ||
291 | void KDateNavigator::updateConfig() | 331 | void KDateNavigator::updateConfig() |
292 | { | 332 | { |
293 | int day; | 333 | int day; |
294 | for(int i=0; i<7; i++) { | 334 | for(int i=0; i<7; i++) { |
295 | // take the first letter of the day name to be the abbreviation | 335 | // take the first letter of the day name to be the abbreviation |
296 | if (KGlobal::locale()->weekStartsMonday()) { | 336 | if (KGlobal::locale()->weekStartsMonday()) { |
297 | day = i+1; | 337 | day = i+1; |
298 | } else { | 338 | } else { |
299 | if (i==0) day = 7; | 339 | if (i==0) day = 7; |
300 | else day = i; | 340 | else day = i; |
301 | } | 341 | } |
302 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 342 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
303 | true ); | 343 | true ); |
304 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 344 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
305 | headings[i]->setText( dayName ); | 345 | headings[i]->setText( dayName ); |
306 | } | 346 | } |
307 | updateDates(); | 347 | updateDates(); |
308 | updateView(); | 348 | updateView(); |
309 | } | 349 | } |
310 | 350 | ||
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 292e71c..3177687 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,154 +1,160 @@ | |||
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,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & , bool doRepaint = true ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 64 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} |
67 | QSize yourSizeHint() { return mySizeHint; } | 67 | QSize yourSizeHint() { return mySizeHint; } |
68 | QFont yourFontHint( QSize , bool * b); | ||
69 | bool fontChanged() {return mFontChanged; } | ||
70 | void unsetFontChanged() { mFontChanged = false; } | ||
68 | KODayMatrix *dayMatrix() { return daymatrix ;} | 71 | KODayMatrix *dayMatrix() { return daymatrix ;} |
72 | QSize sizeHint() const; | ||
73 | void changeFont ( QFont fo ); | ||
69 | public slots: | 74 | public slots: |
70 | void selectDates( const KCal::DateList & ); | 75 | void selectDates( const KCal::DateList & ); |
71 | void updateView(); | 76 | void updateView(); |
72 | void updateConfig(); | 77 | void updateConfig(); |
73 | void updateDayMatrix(); | 78 | void updateDayMatrix(); |
74 | 79 | ||
75 | signals: | 80 | signals: |
76 | void datesSelected( const KCal::DateList & ); | 81 | void datesSelected( const KCal::DateList & ); |
77 | void eventDropped( Event * ); | 82 | void eventDropped( Event * ); |
78 | void weekClicked( const QDate &); | 83 | void weekClicked( const QDate &); |
79 | 84 | ||
80 | void goPrevious(); | 85 | void goPrevious(); |
81 | void goNext(); | 86 | void goNext(); |
82 | 87 | ||
83 | void goNextMonth(); | 88 | void goNextMonth(); |
84 | void goPrevMonth(); | 89 | void goPrevMonth(); |
85 | void goNextYear(); | 90 | void goNextYear(); |
86 | void goPrevYear(); | 91 | void goPrevYear(); |
87 | void monthSelected( int ); | 92 | void monthSelected( int ); |
88 | 93 | ||
89 | // Signals emitted at midnight carrying the new date. | 94 | // Signals emitted at midnight carrying the new date. |
90 | void dayPassed( QDate ); | 95 | void dayPassed( QDate ); |
91 | void monthPassed( QDate ); | 96 | void monthPassed( QDate ); |
92 | 97 | ||
93 | protected slots: | 98 | protected slots: |
94 | 99 | ||
95 | /** | 100 | /** |
96 | * Called regularly to see if we need to update the view | 101 | * Called regularly to see if we need to update the view |
97 | * wrt. the today box and the month box. Only important | 102 | * wrt. the today box and the month box. Only important |
98 | * if you leave KOrganizer idle for long periods of time. | 103 | * if you leave KOrganizer idle for long periods of time. |
99 | * | 104 | * |
100 | * Until we have a reliable way of setting QTimers to go | 105 | * Until we have a reliable way of setting QTimers to go |
101 | * off at a particular wall-clock time, we need this, | 106 | * off at a particular wall-clock time, we need this, |
102 | * which calls passedMidnight() at the right moments. | 107 | * which calls passedMidnight() at the right moments. |
103 | */ | 108 | */ |
104 | void possiblyPastMidnight(); | 109 | void possiblyPastMidnight(); |
105 | 110 | ||
106 | /** handles updating the view when midnight has come by due to idle time. | 111 | /** handles updating the view when midnight has come by due to idle time. |
107 | * | 112 | * |
108 | */ | 113 | */ |
109 | void passedMidnight(); | 114 | void passedMidnight(); |
110 | void slotMonthSelected( int m ); | 115 | void slotMonthSelected( int m ); |
111 | protected: | 116 | protected: |
112 | void updateDates(); | 117 | void updateDates(); |
113 | 118 | ||
114 | void wheelEvent (QWheelEvent *); | 119 | void wheelEvent (QWheelEvent *); |
115 | 120 | ||
116 | bool eventFilter (QObject *,QEvent *); | 121 | bool eventFilter (QObject *,QEvent *); |
117 | 122 | ||
118 | private: | 123 | private: |
119 | QSize mySizeHint; | 124 | QSize mySizeHint; |
125 | bool mFontChanged; | ||
120 | int mMonthSignalOffset; | 126 | int mMonthSignalOffset; |
121 | NavigatorBar *mNavigatorBar; | 127 | NavigatorBar *mNavigatorBar; |
122 | 128 | ||
123 | QFrame *headingSep; | 129 | QFrame *headingSep; |
124 | QFrame *weeknumSep; | 130 | QFrame *weeknumSep; |
125 | QLabel *headings[7]; | 131 | QLabel *headings[7]; |
126 | QLabel *weeknos[7]; | 132 | QLabel *weeknos[7]; |
127 | KODayMatrix *daymatrix; | 133 | KODayMatrix *daymatrix; |
128 | 134 | ||
129 | KCal::DateList mSelectedDates; | 135 | KCal::DateList mSelectedDates; |
130 | QDate m_MthYr; | 136 | QDate m_MthYr; |
131 | int m_fstDayOfWk; | 137 | int m_fstDayOfWk; |
132 | bool m_bShowWeekNums; | 138 | bool m_bShowWeekNums; |
133 | 139 | ||
134 | int dayNum(int row, int col); | 140 | int dayNum(int row, int col); |
135 | int dayToIndex(int dayNum); | 141 | int dayToIndex(int dayNum); |
136 | 142 | ||
137 | Calendar *mCalendar; | 143 | Calendar *mCalendar; |
138 | KCalendarSystem *mCalendarSystem; | 144 | KCalendarSystem *mCalendarSystem; |
139 | 145 | ||
140 | const QString *curHeaders; | 146 | const QString *curHeaders; |
141 | 147 | ||
142 | /** used to update the day view periodically, in particular every | 148 | /** used to update the day view periodically, in particular every |
143 | * midnight to move the "today" rectangle. | 149 | * midnight to move the "today" rectangle. |
144 | */ | 150 | */ |
145 | QTimer *updateTimer; | 151 | QTimer *updateTimer; |
146 | QDate lastDayChecked; | 152 | QDate lastDayChecked; |
147 | RolloverType updateRollover; | 153 | RolloverType updateRollover; |
148 | 154 | ||
149 | // Disabling copy constructor and assignment operator | 155 | // Disabling copy constructor and assignment operator |
150 | KDateNavigator(const KDateNavigator & ); | 156 | KDateNavigator(const KDateNavigator & ); |
151 | KDateNavigator &operator=(const KDateNavigator &); | 157 | KDateNavigator &operator=(const KDateNavigator &); |
152 | }; | 158 | }; |
153 | 159 | ||
154 | #endif | 160 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 619ae39..9181936 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -607,192 +607,203 @@ void KODayMatrix::dropEvent(QDropEvent *e) | |||
607 | 607 | ||
608 | emit eventDropped(event); | 608 | emit eventDropped(event); |
609 | } else { | 609 | } else { |
610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
611 | e->ignore(); | 611 | e->ignore(); |
612 | } | 612 | } |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
616 | // ---------------------------------------------------------------------------- | 616 | // ---------------------------------------------------------------------------- |
617 | // P A I N T E V E N T H A N D L I N G | 617 | // P A I N T E V E N T H A N D L I N G |
618 | // ---------------------------------------------------------------------------- | 618 | // ---------------------------------------------------------------------------- |
619 | 619 | ||
620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
621 | { | 621 | { |
622 | if ( width() <= 0 || height() <= 0 ) | 622 | if ( width() <= 0 || height() <= 0 ) |
623 | return; | 623 | return; |
624 | if ( mPendingUpdateBeforeRepaint ) { | 624 | if ( mPendingUpdateBeforeRepaint ) { |
625 | updateViewTimed(); | 625 | updateViewTimed(); |
626 | mPendingUpdateBeforeRepaint = false; | 626 | mPendingUpdateBeforeRepaint = false; |
627 | } | 627 | } |
628 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 628 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
629 | myPix.resize(size() ); | 629 | myPix.resize(size() ); |
630 | } | 630 | } |
631 | QPainter p(&myPix); | 631 | QPainter p(&myPix); |
632 | p.setFont(font()); | 632 | p.setFont(font()); |
633 | 633 | ||
634 | QRect sz = frameRect(); | 634 | QRect sz = frameRect(); |
635 | int dheight = daysize.height(); | 635 | int dheight = daysize.height(); |
636 | int dwidth = daysize.width(); | 636 | int dwidth = daysize.width(); |
637 | int row,col; | 637 | int row,col; |
638 | int selw, selh; | 638 | int selw, selh; |
639 | bool isRTL = KOGlobals::self()->reverseLayout(); | 639 | bool isRTL = KOGlobals::self()->reverseLayout(); |
640 | 640 | ||
641 | // draw background and topleft frame | 641 | // draw background and topleft frame |
642 | p.fillRect(pevent->rect(), mDefaultBackColor); | 642 | p.fillRect(pevent->rect(), mDefaultBackColor); |
643 | p.setPen(mDefaultTextColor); | 643 | p.setPen(mDefaultTextColor); |
644 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 644 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
645 | int mSelStartT = mSelStart; | 645 | int mSelStartT = mSelStart; |
646 | int mSelEndT = mSelEnd; | 646 | int mSelEndT = mSelEnd; |
647 | if ( mSelEndT >= NUMDAYS ) | 647 | if ( mSelEndT >= NUMDAYS ) |
648 | mSelEndT = NUMDAYS-1; | 648 | mSelEndT = NUMDAYS-1; |
649 | // draw selected days with highlighted background color | 649 | // draw selected days with highlighted background color |
650 | if (mSelStart != NOSELECTION) { | 650 | if (mSelStart != NOSELECTION) { |
651 | bool skip = false; | 651 | bool skip = false; |
652 | if ( ! mouseDown ) { | 652 | if ( ! mouseDown ) { |
653 | int mo = days[20].month(); | 653 | int mo = days[20].month(); |
654 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 654 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
655 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 655 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
656 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { | 656 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { |
657 | skip = true; | 657 | skip = true; |
658 | } else { | 658 | } else { |
659 | if ( days[mSelStartT].month() != mo ) { | 659 | if ( days[mSelStartT].month() != mo ) { |
660 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 660 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
661 | mSelStartT += add +1; | 661 | mSelStartT += add +1; |
662 | } | 662 | } |
663 | if ( days[mSelEndT].month() != mo ) { | 663 | if ( days[mSelEndT].month() != mo ) { |
664 | int sub = days[mSelEndT].day(); | 664 | int sub = days[mSelEndT].day(); |
665 | mSelEndT -= sub ; | 665 | mSelEndT -= sub ; |
666 | } | 666 | } |
667 | } | 667 | } |
668 | } | 668 | } |
669 | if ( ! skip ) { | 669 | if ( ! skip ) { |
670 | row = mSelStartT/7; | 670 | row = mSelStartT/7; |
671 | col = mSelStartT -row*7; | 671 | col = mSelStartT -row*7; |
672 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 672 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
673 | 673 | ||
674 | if (row == mSelEndT/7) { | 674 | if (row == mSelEndT/7) { |
675 | // Single row selection | 675 | // Single row selection |
676 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, | 676 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, |
677 | row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); | 677 | row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); |
678 | } else { | 678 | } else { |
679 | // draw first row to the right | 679 | // draw first row to the right |
680 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 680 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
681 | dheight, selcol); | 681 | dheight, selcol); |
682 | // draw full block till last line | 682 | // draw full block till last line |
683 | selh = mSelEndT/7-row; | 683 | selh = mSelEndT/7-row; |
684 | if (selh > 1) { | 684 | if (selh > 1) { |
685 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 685 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
686 | } | 686 | } |
687 | // draw last block from left to mSelEndT | 687 | // draw last block from left to mSelEndT |
688 | selw = mSelEndT-7*(mSelEndT/7)+1; | 688 | selw = mSelEndT-7*(mSelEndT/7)+1; |
689 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 689 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
690 | selw*dwidth, dheight, selcol); | 690 | selw*dwidth, dheight, selcol); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | ||
695 | // iterate over all days in the matrix and draw the day label in appropriate colors | 695 | // iterate over all days in the matrix and draw the day label in appropriate colors |
696 | QColor actcol = mDefaultTextColorShaded; | 696 | QColor actcol = mDefaultTextColorShaded; |
697 | p.setPen(actcol); | 697 | p.setPen(actcol); |
698 | QPen tmppen; | 698 | QPen tmppen; |
699 | for(int i = 0; i < NUMDAYS; i++) { | 699 | for(int i = 0; i < NUMDAYS; i++) { |
700 | row = i/7; | 700 | row = i/7; |
701 | col = isRTL ? 6-(i-row*7) : i-row*7; | 701 | col = isRTL ? 6-(i-row*7) : i-row*7; |
702 | 702 | ||
703 | // if it is the first day of a month switch color from normal to shaded and vice versa | 703 | // if it is the first day of a month switch color from normal to shaded and vice versa |
704 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 704 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
705 | if (actcol == mDefaultTextColorShaded) { | 705 | if (actcol == mDefaultTextColorShaded) { |
706 | actcol = mDefaultTextColor; | 706 | actcol = mDefaultTextColor; |
707 | } else { | 707 | } else { |
708 | actcol = mDefaultTextColorShaded; | 708 | actcol = mDefaultTextColorShaded; |
709 | } | 709 | } |
710 | p.setPen(actcol); | 710 | p.setPen(actcol); |
711 | } | 711 | } |
712 | if (actcol == mDefaultTextColorShaded) { | 712 | if (actcol == mDefaultTextColorShaded) { |
713 | if ( ! mouseDown ) { | 713 | if ( ! mouseDown ) { |
714 | continue; | 714 | continue; |
715 | } | 715 | } |
716 | } | 716 | } |
717 | //Reset pen color after selected days block | 717 | //Reset pen color after selected days block |
718 | if (i == mSelEndT+1) { | 718 | if (i == mSelEndT+1) { |
719 | p.setPen(actcol); | 719 | p.setPen(actcol); |
720 | } | 720 | } |
721 | 721 | ||
722 | // if today then draw rectangle around day | 722 | // if today then draw rectangle around day |
723 | if (today == i) { | 723 | if (today == i) { |
724 | tmppen = p.pen(); | 724 | tmppen = p.pen(); |
725 | QPen mTodayPen(p.pen()); | 725 | QPen mTodayPen(p.pen()); |
726 | 726 | ||
727 | mTodayPen.setWidth(mTodayMarginWidth); | 727 | mTodayPen.setWidth(mTodayMarginWidth); |
728 | //draw red rectangle for holidays | 728 | //draw red rectangle for holidays |
729 | if (!mHolidays[i].isNull()) { | 729 | if (!mHolidays[i].isNull()) { |
730 | if (actcol == mDefaultTextColor) { | 730 | if (actcol == mDefaultTextColor) { |
731 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 731 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
732 | } else { | 732 | } else { |
733 | mTodayPen.setColor(mHolidayColorShaded); | 733 | mTodayPen.setColor(mHolidayColorShaded); |
734 | } | 734 | } |
735 | } | 735 | } |
736 | //draw gray rectangle for today if in selection | 736 | //draw gray rectangle for today if in selection |
737 | if (i >= mSelStartT && i <= mSelEndT) { | 737 | if (i >= mSelStartT && i <= mSelEndT) { |
738 | QColor grey("grey"); | 738 | QColor grey("grey"); |
739 | mTodayPen.setColor(grey); | 739 | mTodayPen.setColor(grey); |
740 | } | 740 | } |
741 | p.setPen(mTodayPen); | 741 | p.setPen(mTodayPen); |
742 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 742 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
743 | p.setPen(tmppen); | 743 | p.setPen(tmppen); |
744 | } | 744 | } |
745 | 745 | ||
746 | // if any events are on that day then draw it using a bold font | 746 | // if any events are on that day then draw it using a bold font |
747 | if (events[i] > 0) { | 747 | if (events[i] > 0) { |
748 | QFont myFont = font(); | 748 | QFont myFont = font(); |
749 | myFont.setBold(true); | 749 | myFont.setBold(true); |
750 | p.setFont(myFont); | 750 | p.setFont(myFont); |
751 | } | 751 | } |
752 | 752 | ||
753 | // if it is a holiday then use the default holiday color | 753 | // if it is a holiday then use the default holiday color |
754 | if (!mHolidays[i].isNull()) { | 754 | if (!mHolidays[i].isNull()) { |
755 | if ( bDays.testBit(i) ) { | 755 | if ( bDays.testBit(i) ) { |
756 | p.setPen(Qt::green); | 756 | p.setPen(Qt::green); |
757 | } else { | 757 | } else { |
758 | if (actcol == mDefaultTextColor) { | 758 | if (actcol == mDefaultTextColor) { |
759 | p.setPen(KOPrefs::instance()->mHolidayColor); | 759 | p.setPen(KOPrefs::instance()->mHolidayColor); |
760 | } else { | 760 | } else { |
761 | p.setPen(mHolidayColorShaded); | 761 | p.setPen(mHolidayColorShaded); |
762 | } | 762 | } |
763 | } | 763 | } |
764 | } | 764 | } |
765 | 765 | ||
766 | // draw selected days with special color | 766 | // draw selected days with special color |
767 | // DO NOT specially highlight holidays in selection ! | 767 | // DO NOT specially highlight holidays in selection ! |
768 | if (i >= mSelStartT && i <= mSelEndT) { | 768 | if (i >= mSelStartT && i <= mSelEndT) { |
769 | ;//p.setPen(mSelectedDaysColor); | 769 | ;//p.setPen(mSelectedDaysColor); |
770 | } | 770 | } |
771 | 771 | ||
772 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 772 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
773 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 773 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
774 | 774 | ||
775 | // reset color to actual color | 775 | // reset color to actual color |
776 | if (!mHolidays[i].isNull()) { | 776 | if (!mHolidays[i].isNull()) { |
777 | p.setPen(actcol); | 777 | p.setPen(actcol); |
778 | } | 778 | } |
779 | // reset bold font to plain font | 779 | // reset bold font to plain font |
780 | if (events[i] > 0) { | 780 | if (events[i] > 0) { |
781 | QFont myFont = font(); | 781 | QFont myFont = font(); |
782 | myFont.setBold(false); | 782 | myFont.setBold(false); |
783 | p.setFont(myFont); | 783 | p.setFont(myFont); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 786 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
787 | } | 787 | } |
788 | 788 | ||
789 | // ---------------------------------------------------------------------------- | 789 | // ---------------------------------------------------------------------------- |
790 | // R E SI Z E E V E N T H A N D L I N G | 790 | // R E SI Z E E V E N T H A N D L I N G |
791 | // ---------------------------------------------------------------------------- | 791 | // ---------------------------------------------------------------------------- |
792 | 792 | ||
793 | void KODayMatrix::resizeEvent(QResizeEvent *) | 793 | void KODayMatrix::resizeEvent(QResizeEvent *) |
794 | { | 794 | { |
795 | QRect sz = frameRect(); | 795 | QRect sz = frameRect(); |
796 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 796 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
797 | daysize.setWidth(sz.width() / 7); | 797 | daysize.setWidth(sz.width() / 7); |
798 | } | 798 | } |
799 | |||
800 | QSize KODayMatrix::sizeHint() const | ||
801 | { | ||
802 | |||
803 | QFontMetrics fm ( font() ); | ||
804 | int wid = fm.width( "30") *7+7; | ||
805 | int hei = fm.height() * 6+4; | ||
806 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | ||
807 | return QSize ( wid, hei ); | ||
808 | |||
809 | } | ||
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index c049942..39946de 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,321 +1,322 @@ | |||
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 | #include <qbitarray.h> | 35 | #include <qbitarray.h> |
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, const char *name ); | 120 | KODayMatrix( QWidget *parent, const char *name ); |
121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
122 | 122 | ||
123 | /** destructor that deallocates all dynamically allocated private members. | 123 | /** destructor that deallocates all dynamically allocated private members. |
124 | */ | 124 | */ |
125 | ~KODayMatrix(); | 125 | ~KODayMatrix(); |
126 | 126 | ||
127 | /** 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 |
128 | * 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. |
129 | * Does NOT update the view visually. Call repaint() for this. | 129 | * Does NOT update the view visually. Call repaint() for this. |
130 | * | 130 | * |
131 | * @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 |
132 | * date. | 132 | * date. |
133 | */ | 133 | */ |
134 | void updateView(QDate actdate); | 134 | void updateView(QDate actdate); |
135 | void updateEvents(); | 135 | void updateEvents(); |
136 | 136 | ||
137 | /** returns the QDate object associated with day indexed by the | 137 | /** returns the QDate object associated with day indexed by the |
138 | * supplied offset. | 138 | * supplied offset. |
139 | */ | 139 | */ |
140 | const QDate& getDate(int offset); | 140 | const QDate& getDate(int offset); |
141 | void setCalendar( Calendar * ); | 141 | void setCalendar( Calendar * ); |
142 | /** 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 |
143 | * for this day. | 143 | * for this day. |
144 | */ | 144 | */ |
145 | QString getHolidayLabel(int offset); | 145 | QString getHolidayLabel(int offset); |
146 | 146 | ||
147 | /** 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 |
148 | * DateList. | 148 | * DateList. |
149 | */ | 149 | */ |
150 | void addSelectedDaysTo(DateList&); | 150 | void addSelectedDaysTo(DateList&); |
151 | 151 | ||
152 | /** 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 |
153 | * 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 |
154 | * repaint. (?) | 154 | * repaint. (?) |
155 | */ | 155 | */ |
156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); | 156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); |
157 | void clearSelection(); | 157 | void clearSelection(); |
158 | 158 | ||
159 | /** Is today visible in the view? Keep this in sync with | 159 | /** Is today visible in the view? Keep this in sync with |
160 | * the values today (below) can take. | 160 | * the values today (below) can take. |
161 | */ | 161 | */ |
162 | bool isTodayVisible() const { return today>=0; } ; | 162 | bool isTodayVisible() const { return today>=0; } ; |
163 | 163 | ||
164 | /** 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 |
165 | * near the beginning or the end of the month. | 165 | * near the beginning or the end of the month. |
166 | * This is dependent on today remaining the index | 166 | * This is dependent on today remaining the index |
167 | * in the array of visible dates and going from | 167 | * in the array of visible dates and going from |
168 | * top left (0) to bottom right (41). | 168 | * top left (0) to bottom right (41). |
169 | */ | 169 | */ |
170 | bool isBeginningOfMonth() const { return today<=8; } ; | 170 | bool isBeginningOfMonth() const { return today<=8; } ; |
171 | bool isEndOfMonth() const { return today>=27; } ; | 171 | bool isEndOfMonth() const { return today>=27; } ; |
172 | QString getWhatsThisText( QPoint ) ; | 172 | QString getWhatsThisText( QPoint ) ; |
173 | QSize sizeHint() const; | ||
173 | 174 | ||
174 | public slots: | 175 | public slots: |
175 | /** Recalculates all the flags of the days in the matrix like holidays or events | 176 | /** Recalculates all the flags of the days in the matrix like holidays or events |
176 | * on a day (Actually calls above method with the actual startdate). | 177 | * on a day (Actually calls above method with the actual startdate). |
177 | */ | 178 | */ |
178 | void updateView(); | 179 | void updateView(); |
179 | void updateViewTimed(); | 180 | void updateViewTimed(); |
180 | void repaintViewTimed(); | 181 | void repaintViewTimed(); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | * Calculate which square in the matrix should be | 184 | * Calculate which square in the matrix should be |
184 | * hilighted to indicate it's today. | 185 | * hilighted to indicate it's today. |
185 | */ | 186 | */ |
186 | void recalculateToday(); | 187 | void recalculateToday(); |
187 | 188 | ||
188 | /* | 189 | /* |
189 | void setStartDate(QDate); | 190 | void setStartDate(QDate); |
190 | */ | 191 | */ |
191 | 192 | ||
192 | signals: | 193 | signals: |
193 | 194 | ||
194 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 195 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
195 | * inside the matrix | 196 | * inside the matrix |
196 | * | 197 | * |
197 | * @param daylist list of days that have been selected by the user | 198 | * @param daylist list of days that have been selected by the user |
198 | */ | 199 | */ |
199 | void selected( const KCal::DateList &daylist ); | 200 | void selected( const KCal::DateList &daylist ); |
200 | 201 | ||
201 | /** emitted if the user has dropped an event inside the matrix | 202 | /** emitted if the user has dropped an event inside the matrix |
202 | * | 203 | * |
203 | * @param event the dropped calendar event | 204 | * @param event the dropped calendar event |
204 | */ | 205 | */ |
205 | void eventDropped(Event *event); | 206 | void eventDropped(Event *event); |
206 | 207 | ||
207 | protected: | 208 | protected: |
208 | 209 | ||
209 | void paintEvent(QPaintEvent *ev); | 210 | void paintEvent(QPaintEvent *ev); |
210 | 211 | ||
211 | void mousePressEvent (QMouseEvent* e); | 212 | void mousePressEvent (QMouseEvent* e); |
212 | 213 | ||
213 | void mouseReleaseEvent (QMouseEvent* e); | 214 | void mouseReleaseEvent (QMouseEvent* e); |
214 | 215 | ||
215 | void mouseMoveEvent (QMouseEvent* e); | 216 | void mouseMoveEvent (QMouseEvent* e); |
216 | 217 | ||
217 | void dragEnterEvent(QDragEnterEvent *); | 218 | void dragEnterEvent(QDragEnterEvent *); |
218 | 219 | ||
219 | void dragMoveEvent(QDragMoveEvent *); | 220 | void dragMoveEvent(QDragMoveEvent *); |
220 | 221 | ||
221 | void dragLeaveEvent(QDragLeaveEvent *); | 222 | void dragLeaveEvent(QDragLeaveEvent *); |
222 | 223 | ||
223 | void dropEvent(QDropEvent *); | 224 | void dropEvent(QDropEvent *); |
224 | 225 | ||
225 | void resizeEvent(QResizeEvent *); | 226 | void resizeEvent(QResizeEvent *); |
226 | 227 | ||
227 | private: | 228 | private: |
228 | bool mouseDown; | 229 | bool mouseDown; |
229 | QBitArray bDays; | 230 | QBitArray bDays; |
230 | QPixmap myPix; | 231 | QPixmap myPix; |
231 | QTimer* mUpdateTimer; | 232 | QTimer* mUpdateTimer; |
232 | QTimer* mRepaintTimer; | 233 | QTimer* mRepaintTimer; |
233 | bool mDayChanged; | 234 | bool mDayChanged; |
234 | bool mPendingUpdateBeforeRepaint; | 235 | bool mPendingUpdateBeforeRepaint; |
235 | 236 | ||
236 | /** returns the index of the day located at the matrix's widget (x,y) position. | 237 | /** returns the index of the day located at the matrix's widget (x,y) position. |
237 | * | 238 | * |
238 | * @param x horizontal coordinate | 239 | * @param x horizontal coordinate |
239 | * @param y vertical coordinate | 240 | * @param y vertical coordinate |
240 | */ | 241 | */ |
241 | int getDayIndexFrom(int x, int y); | 242 | int getDayIndexFrom(int x, int y); |
242 | 243 | ||
243 | /** calculates a "shaded" color from the supplied color object. | 244 | /** calculates a "shaded" color from the supplied color object. |
244 | * (Copied from Cornelius's kdpdatebutton.cpp) | 245 | * (Copied from Cornelius's kdpdatebutton.cpp) |
245 | * | 246 | * |
246 | * @param color source based on which a shaded color should be calculated. | 247 | * @param color source based on which a shaded color should be calculated. |
247 | */ | 248 | */ |
248 | QColor getShadedColor(QColor color); | 249 | QColor getShadedColor(QColor color); |
249 | 250 | ||
250 | /** number of days to be displayed. For now there is no support for any other number then 42. | 251 | /** number of days to be displayed. For now there is no support for any other number then 42. |
251 | so change it at your own risk :o) */ | 252 | so change it at your own risk :o) */ |
252 | static const int NUMDAYS; | 253 | static const int NUMDAYS; |
253 | 254 | ||
254 | /** calendar instance to be queried for holidays, events, ... */ | 255 | /** calendar instance to be queried for holidays, events, ... */ |
255 | Calendar *mCalendar; | 256 | Calendar *mCalendar; |
256 | 257 | ||
257 | /** starting date of the matrix */ | 258 | /** starting date of the matrix */ |
258 | QDate startdate; | 259 | QDate startdate; |
259 | 260 | ||
260 | /** array of day labels to optimeize drawing performance. */ | 261 | /** array of day labels to optimeize drawing performance. */ |
261 | QString *daylbls; | 262 | QString *daylbls; |
262 | 263 | ||
263 | /** array of days displayed to reduce memory consumption by | 264 | /** array of days displayed to reduce memory consumption by |
264 | subsequently calling QDate::addDays(). */ | 265 | subsequently calling QDate::addDays(). */ |
265 | QDate *days; | 266 | QDate *days; |
266 | 267 | ||
267 | /** array of storing the number of events on a given day. | 268 | /** array of storing the number of events on a given day. |
268 | * used for drawing a bold font if there is at least one event on that day. | 269 | * used for drawing a bold font if there is at least one event on that day. |
269 | */ | 270 | */ |
270 | int *events; | 271 | int *events; |
271 | 272 | ||
272 | /** stores holiday names of the days shown in the matrix. */ | 273 | /** stores holiday names of the days shown in the matrix. */ |
273 | QMap<int,QString> mHolidays; | 274 | QMap<int,QString> mHolidays; |
274 | 275 | ||
275 | /** indey of today or -1 if today is not visible in the matrix. */ | 276 | /** indey of today or -1 if today is not visible in the matrix. */ |
276 | int today; | 277 | int today; |
277 | 278 | ||
278 | /** index of day where dragged selection was initiated. | 279 | /** index of day where dragged selection was initiated. |
279 | used to detect "negative" timely selections */ | 280 | used to detect "negative" timely selections */ |
280 | int mSelInit; | 281 | int mSelInit; |
281 | 282 | ||
282 | /** if mSelStart has this value it indicates that there is no | 283 | /** if mSelStart has this value it indicates that there is no |
283 | actual selection in the matrix. */ | 284 | actual selection in the matrix. */ |
284 | static const int NOSELECTION; | 285 | static const int NOSELECTION; |
285 | 286 | ||
286 | /** index of first selected day. */ | 287 | /** index of first selected day. */ |
287 | int mSelStart; | 288 | int mSelStart; |
288 | 289 | ||
289 | /** index of last selected day. */ | 290 | /** index of last selected day. */ |
290 | int mSelEnd; | 291 | int mSelEnd; |
291 | 292 | ||
292 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 293 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
293 | DynamicTip* mToolTip; | 294 | DynamicTip* mToolTip; |
294 | 295 | ||
295 | 296 | ||
296 | /** default background colour of the matrix. */ | 297 | /** default background colour of the matrix. */ |
297 | QColor mDefaultBackColor; | 298 | QColor mDefaultBackColor; |
298 | 299 | ||
299 | /** default text color of the matrix. */ | 300 | /** default text color of the matrix. */ |
300 | QColor mDefaultTextColor; | 301 | QColor mDefaultTextColor; |
301 | 302 | ||
302 | /** default text color for days not in the actual month. */ | 303 | /** default text color for days not in the actual month. */ |
303 | QColor mDefaultTextColorShaded; | 304 | QColor mDefaultTextColorShaded; |
304 | 305 | ||
305 | /** default text color for holidays not in the actual month. */ | 306 | /** default text color for holidays not in the actual month. */ |
306 | QColor mHolidayColorShaded; | 307 | QColor mHolidayColorShaded; |
307 | 308 | ||
308 | /** text color for selected days. */ | 309 | /** text color for selected days. */ |
309 | QColor mSelectedDaysColor; | 310 | QColor mSelectedDaysColor; |
310 | 311 | ||
311 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 312 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
312 | int mTodayMarginWidth; | 313 | int mTodayMarginWidth; |
313 | 314 | ||
314 | /** stores actual size of each day in the widget so that I dont need to ask this data | 315 | /** stores actual size of each day in the widget so that I dont need to ask this data |
315 | * on every repaint. | 316 | * on every repaint. |
316 | */ | 317 | */ |
317 | QRect daysize; | 318 | QRect daysize; |
318 | 319 | ||
319 | }; | 320 | }; |
320 | 321 | ||
321 | #endif | 322 | #endif |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 27d4d17..4a51bba 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,244 +1,247 @@ | |||
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 | |
66 | if ( QApplication::desktop()->width() >= 480 ) | ||
67 | tfont.setPointSize(tfont.pointSize()+2); | ||
68 | tfont.setBold(true); | ||
69 | 66 | ||
70 | bool isRTL = KOGlobals::self()->reverseLayout(); | 67 | bool isRTL = KOGlobals::self()->reverseLayout(); |
71 | #ifndef DESKTOP_VERSION | 68 | #ifndef DESKTOP_VERSION |
72 | bool isDesktop = false; | 69 | bool isDesktop = false; |
73 | #else | 70 | #else |
74 | bool isDesktop = true; | 71 | bool isDesktop = true; |
75 | #endif | 72 | #endif |
76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
77 | isDesktop = true; | 74 | isDesktop = true; |
78 | // Create backward navigation buttons | 75 | // Create backward navigation buttons |
79 | mPrevYear = new QPushButton( mCtrlFrame ); | 76 | mPrevYear = new QPushButton( mCtrlFrame ); |
80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
82 | 79 | ||
83 | mPrevMonth = new QPushButton( mCtrlFrame ); | 80 | mPrevMonth = new QPushButton( mCtrlFrame ); |
84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
86 | 83 | ||
87 | // Create forward navigation buttons | 84 | // Create forward navigation buttons |
88 | mNextMonth = new QPushButton( mCtrlFrame ); | 85 | mNextMonth = new QPushButton( mCtrlFrame ); |
89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
90 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 87 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
91 | 88 | ||
92 | mPrevWeek = new QPushButton( mCtrlFrame ); | 89 | mPrevWeek = new QPushButton( mCtrlFrame ); |
93 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
94 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
95 | 92 | ||
96 | // Create forward navigation buttons | 93 | // Create forward navigation buttons |
97 | mNextWeek = new QPushButton( mCtrlFrame ); | 94 | mNextWeek = new QPushButton( mCtrlFrame ); |
98 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
99 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 96 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
100 | 97 | ||
101 | mNextYear = new QPushButton( mCtrlFrame ); | 98 | mNextYear = new QPushButton( mCtrlFrame ); |
102 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
103 | QToolTip::add( mNextYear, i18n("Next Year") ); | 100 | QToolTip::add( mNextYear, i18n("Next Year") ); |
104 | mSelectMonth = new QPushButton( mCtrlFrame ); | 101 | mSelectMonth = new QPushButton( mCtrlFrame ); |
105 | // Create month name label | 102 | // Create month name label |
106 | //selectMonth->setFont( tfont ); | 103 | //selectMonth->setFont( tfont ); |
107 | // selectMonth->setAlignment( AlignCenter ); | 104 | // selectMonth->setAlignment( AlignCenter ); |
108 | //mDateLabel = new QLabel( selectMonth ); | 105 | //mDateLabel = new QLabel( selectMonth ); |
109 | //mDateLabel->setFont( tfont ); | 106 | //mDateLabel->setFont( tfont ); |
110 | //mDateLabel->setAlignment( AlignCenter ); | 107 | //mDateLabel->setAlignment( AlignCenter ); |
111 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 108 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
112 | mNextMonth->setFlat( true); | 109 | mNextMonth->setFlat( true); |
113 | mNextWeek->setFlat( true); | 110 | mNextWeek->setFlat( true); |
114 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
115 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
116 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
117 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
118 | mPrevWeek->setFlat( true); | 115 | mPrevWeek->setFlat( true); |
119 | } else { | 116 | } else { |
120 | mPrevWeek->hide(); | 117 | mPrevWeek->hide(); |
121 | mNextWeek->hide(); | 118 | mNextWeek->hide(); |
122 | } | 119 | } |
123 | mSelectMonth->setFont( tfont ); | ||
124 | // Set minimum width to width of widest month name label | ||
125 | int i; | ||
126 | int maxwidth = 0; | ||
127 | QFontMetrics fm ( mSelectMonth->font() ); | ||
128 | int width = fm.width("September '00" ); | ||
129 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | ||
130 | // ++i ) { | ||
131 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | ||
132 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | ||
133 | // int width = fm.width("September 2000" ); | ||
134 | // if ( width > maxwidth ) maxwidth = width; | ||
135 | // } | ||
136 | maxwidth = width+2; | ||
137 | int size = fm.height()+2; | ||
138 | if ( QApplication::desktop()->width() >= 480 ) { | ||
139 | size += 6; | ||
140 | maxwidth+= 6; | ||
141 | } | ||
142 | 120 | ||
143 | mSelectMonth->setFixedWidth( maxwidth ); | 121 | resetFont( font() ); |
144 | mSelectMonth->setFixedHeight( size ); | 122 | |
145 | mPrevYear->setFixedHeight( size ); | 123 | |
146 | mPrevMonth->setFixedHeight( size ); | ||
147 | mPrevWeek->setFixedHeight( size ); | ||
148 | mNextMonth->setFixedHeight( size ); | ||
149 | mNextWeek->setFixedHeight( size ); | ||
150 | mNextYear->setFixedHeight ( size ); | ||
151 | // set up control frame layout | 124 | // set up control frame layout |
152 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
153 | ctrlLayout->addWidget( mPrevYear, 3 ); | 126 | ctrlLayout->addWidget( mPrevYear, 3 ); |
154 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 127 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
155 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 128 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
156 | //ctrlLayout->addStretch( 1 ); | 129 | //ctrlLayout->addStretch( 1 ); |
157 | // ctrlLayout->addSpacing( 1 ); | 130 | // ctrlLayout->addSpacing( 1 ); |
158 | // ctrlLayout->addWidget( mDateLabel ); | 131 | // ctrlLayout->addWidget( mDateLabel ); |
159 | ctrlLayout->addWidget( mSelectMonth ); | 132 | ctrlLayout->addWidget( mSelectMonth ); |
160 | // ctrlLayout->addSpacing( 1 ); | 133 | // ctrlLayout->addSpacing( 1 ); |
161 | // ctrlLayout->addStretch( 1 ); | 134 | // ctrlLayout->addStretch( 1 ); |
162 | ctrlLayout->addWidget( mNextWeek, 3 ); | 135 | ctrlLayout->addWidget( mNextWeek, 3 ); |
163 | ctrlLayout->addWidget( mNextMonth, 3 ); | 136 | ctrlLayout->addWidget( mNextMonth, 3 ); |
164 | ctrlLayout->addWidget( mNextYear, 3 ); | 137 | ctrlLayout->addWidget( mNextYear, 3 ); |
165 | 138 | ||
166 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
167 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
168 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
169 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
170 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
171 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
172 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
173 | mPrevYear->setFocusPolicy(NoFocus); | 146 | mPrevYear->setFocusPolicy(NoFocus); |
174 | mPrevMonth->setFocusPolicy(NoFocus); | 147 | mPrevMonth->setFocusPolicy(NoFocus); |
175 | mNextMonth->setFocusPolicy(NoFocus); | 148 | mNextMonth->setFocusPolicy(NoFocus); |
176 | mPrevWeek->setFocusPolicy(NoFocus); | 149 | mPrevWeek->setFocusPolicy(NoFocus); |
177 | mNextWeek->setFocusPolicy(NoFocus); | 150 | mNextWeek->setFocusPolicy(NoFocus); |
178 | mNextYear->setFocusPolicy(NoFocus); | 151 | mNextYear->setFocusPolicy(NoFocus); |
179 | mSelectMonth->setFocusPolicy(NoFocus); | 152 | mSelectMonth->setFocusPolicy(NoFocus); |
180 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
181 | 154 | ||
182 | } | 155 | } |
183 | 156 | ||
184 | NavigatorBar::~NavigatorBar() | 157 | NavigatorBar::~NavigatorBar() |
185 | { | 158 | { |
186 | } | 159 | } |
160 | void NavigatorBar::resetFont ( QFont fo ) | ||
161 | { | ||
162 | |||
163 | QFont tfont = fo; | ||
164 | if ( QApplication::desktop()->width() >= 480 ) | ||
165 | tfont.setPointSize(tfont.pointSize()+2); | ||
166 | tfont.setBold(true); | ||
167 | |||
168 | mSelectMonth->setFont( tfont ); | ||
169 | // Set minimum width to width of widest month name label | ||
170 | int i; | ||
171 | int maxwidth = 0; | ||
172 | QFontMetrics fm ( mSelectMonth->font() ); | ||
173 | int width = fm.width("September '00" ); | ||
174 | maxwidth = width+2; | ||
175 | int size = fm.height()+2; | ||
176 | if ( QApplication::desktop()->width() >= 480 ) { | ||
177 | size += 6; | ||
178 | maxwidth+= 6; | ||
179 | } | ||
180 | mSelectMonth->setMinimumWidth( maxwidth ); | ||
181 | mSelectMonth->setFixedHeight( size ); | ||
182 | mPrevYear->setFixedHeight( size ); | ||
183 | mPrevMonth->setFixedHeight( size ); | ||
184 | mPrevWeek->setFixedHeight( size ); | ||
185 | mNextMonth->setFixedHeight( size ); | ||
186 | mNextWeek->setFixedHeight( size ); | ||
187 | mNextYear->setFixedHeight ( size ); | ||
188 | } | ||
189 | |||
187 | void NavigatorBar::showButtons( bool left, bool right ) | 190 | void NavigatorBar::showButtons( bool left, bool right ) |
188 | { | 191 | { |
189 | if ( left ) { | 192 | if ( left ) { |
190 | mPrevYear->show(); | 193 | mPrevYear->show(); |
191 | mPrevMonth->show(); | 194 | mPrevMonth->show(); |
192 | } else { | 195 | } else { |
193 | mPrevYear->hide(); | 196 | mPrevYear->hide(); |
194 | mPrevMonth->hide(); | 197 | mPrevMonth->hide(); |
195 | } | 198 | } |
196 | 199 | ||
197 | if ( right ) { | 200 | if ( right ) { |
198 | mNextYear->show(); | 201 | mNextYear->show(); |
199 | mNextMonth->show(); | 202 | mNextMonth->show(); |
200 | } else { | 203 | } else { |
201 | mNextYear->hide(); | 204 | mNextYear->hide(); |
202 | mNextMonth->hide(); | 205 | mNextMonth->hide(); |
203 | } | 206 | } |
204 | if ( !left && !right ) { | 207 | if ( !left && !right ) { |
205 | mSelectMonth->setMaximumWidth( 1024 ); | 208 | //mSelectMonth->setMaximumWidth( 1024 ); |
206 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 209 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
207 | } | 210 | } |
208 | } | 211 | } |
209 | 212 | ||
210 | void NavigatorBar::selectMonth() | 213 | void NavigatorBar::selectMonth() |
211 | { | 214 | { |
212 | 215 | ||
213 | int month; | 216 | int month; |
214 | KPopupFrame* popup = new KPopupFrame(this); | 217 | KPopupFrame* popup = new KPopupFrame(this); |
215 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 218 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
216 | // ----- | 219 | // ----- |
217 | picker->resize(picker->sizeHint()); | 220 | picker->resize(picker->sizeHint()); |
218 | popup->setMainWidget(picker); | 221 | popup->setMainWidget(picker); |
219 | picker->setFocus(); | 222 | picker->setFocus(); |
220 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 223 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
221 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 224 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
222 | { | 225 | { |
223 | month = picker->getResult(); | 226 | month = picker->getResult(); |
224 | emit monthSelected ( month ); | 227 | emit monthSelected ( month ); |
225 | } else { | 228 | } else { |
226 | KNotifyClient::beep(); | 229 | KNotifyClient::beep(); |
227 | } | 230 | } |
228 | delete popup; | 231 | delete popup; |
229 | } | 232 | } |
230 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 233 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
231 | { | 234 | { |
232 | if (dateList.count() > 0) { | 235 | if (dateList.count() > 0) { |
233 | QDate date = dateList.first(); | 236 | QDate date = dateList.first(); |
234 | 237 | ||
235 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 238 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
236 | 239 | ||
237 | // compute the label at the top of the navigator | 240 | // compute the label at the top of the navigator |
238 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 241 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
239 | QString::number( calSys->year( date ) ).right(2); | 242 | QString::number( calSys->year( date ) ).right(2); |
240 | 243 | ||
241 | mSelectMonth->setText( dtstr ); | 244 | mSelectMonth->setText( dtstr ); |
242 | } | 245 | } |
243 | } | 246 | } |
244 | 247 | ||
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 4442caa..0b2f60b 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h | |||
@@ -1,70 +1,71 @@ | |||
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 | void showButtons( bool left, bool right ); |
42 | void resetFont ( QFont fo ); | ||
42 | 43 | ||
43 | public slots: | 44 | public slots: |
44 | void selectDates( const KCal::DateList & ); | 45 | void selectDates( const KCal::DateList & ); |
45 | void selectMonth(); | 46 | void selectMonth(); |
46 | 47 | ||
47 | signals: | 48 | signals: |
48 | void goNextMonth(); | 49 | void goNextMonth(); |
49 | void goPrevMonth(); | 50 | void goPrevMonth(); |
50 | void goNextWeek(); | 51 | void goNextWeek(); |
51 | void goPrevWeek(); | 52 | void goPrevWeek(); |
52 | void goNextYear(); | 53 | void goNextYear(); |
53 | void goPrevYear(); | 54 | void goPrevYear(); |
54 | void monthSelected( int ); | 55 | void monthSelected( int ); |
55 | 56 | ||
56 | private: | 57 | private: |
57 | QFrame *mCtrlFrame; | 58 | QFrame *mCtrlFrame; |
58 | 59 | ||
59 | QPushButton *mPrevYear; | 60 | QPushButton *mPrevYear; |
60 | QPushButton *mPrevMonth; | 61 | QPushButton *mPrevMonth; |
61 | QPushButton *mNextMonth; | 62 | QPushButton *mNextMonth; |
62 | QPushButton *mPrevWeek; | 63 | QPushButton *mPrevWeek; |
63 | QPushButton *mNextWeek; | 64 | QPushButton *mNextWeek; |
64 | QPushButton *mNextYear; | 65 | QPushButton *mNextYear; |
65 | QPushButton *mSelectMonth; | 66 | QPushButton *mSelectMonth; |
66 | 67 | ||
67 | //QLabel *mDateLabel; | 68 | //QLabel *mDateLabel; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | #endif | 71 | #endif |