summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/koagendaview.cpp6
-rw-r--r--korganizer/komonthview.cpp7
-rw-r--r--korganizer/navigatorbar.cpp34
-rw-r--r--korganizer/navigatorbar.h2
5 files changed, 41 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index be78057..e0380fa 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,744 +1,746 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
289 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
290 290
291 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
292 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
293 293
294 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
295#else 295#else
296 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
297 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
298 298
299 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
300 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
301 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
302 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
303 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
304 } else { 304 } else {
305 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
306 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
307 } 307 }
308 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
309 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
311 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
312 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
313 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
316 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
317 317
318 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
319 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
320 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
321 321
322 } else { 322 } else {
323 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
324 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
325 } 325 }
326 mFilterView->hide(); 326 mFilterView->hide();
327 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
328 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
331 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
333 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
334 334
335 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
336 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
339 } else { 339 } else {
340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
342 } 342 }
343 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
344 mDateNavigator->hide(); 344 mDateNavigator->hide();
345 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
346#endif 346#endif
347 347
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
353 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 connect( mNavigatorBar, SIGNAL( selectWeek( int ) ),
362 mNavigator, SLOT( selectWeek( int ) ) );
361 363
362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 364 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 365 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
364 366
365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 367 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
366 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 368 mNavigator, SLOT( selectWeek( const QDate & ) ) );
367 369
368 connect( mDateNavigator, SIGNAL( goPrevYear() ), 370 connect( mDateNavigator, SIGNAL( goPrevYear() ),
369 mNavigator, SLOT( selectPreviousYear() ) ); 371 mNavigator, SLOT( selectPreviousYear() ) );
370 connect( mDateNavigator, SIGNAL( goNextYear() ), 372 connect( mDateNavigator, SIGNAL( goNextYear() ),
371 mNavigator, SLOT( selectNextYear() ) ); 373 mNavigator, SLOT( selectNextYear() ) );
372 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 374 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
373 mNavigator, SLOT( selectPreviousMonth() ) ); 375 mNavigator, SLOT( selectPreviousMonth() ) );
374 connect( mDateNavigator, SIGNAL( goNextMonth() ), 376 connect( mDateNavigator, SIGNAL( goNextMonth() ),
375 mNavigator, SLOT( selectNextMonth() ) ); 377 mNavigator, SLOT( selectNextMonth() ) );
376 378
377 connect( mDateNavigator, SIGNAL( goPrevious() ), 379 connect( mDateNavigator, SIGNAL( goPrevious() ),
378 mNavigator, SLOT( selectPrevious() ) ); 380 mNavigator, SLOT( selectPrevious() ) );
379 connect( mDateNavigator, SIGNAL( goNext() ), 381 connect( mDateNavigator, SIGNAL( goNext() ),
380 mNavigator, SLOT( selectNext() ) ); 382 mNavigator, SLOT( selectNext() ) );
381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 383 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 385 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
384 mNavigator, SLOT( slotMonthSelect( int ) ) ); 386 mNavigator, SLOT( slotMonthSelect( int ) ) );
385 387
386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 388 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 389 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
388 390
389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 391 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
390 SLOT( eventAdded( Event *) ) ); 392 SLOT( eventAdded( Event *) ) );
391 393
392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 394 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
393 395
394 connect( this, SIGNAL( configChanged() ), 396 connect( this, SIGNAL( configChanged() ),
395 mDateNavigator, SLOT( updateConfig() ) ); 397 mDateNavigator, SLOT( updateConfig() ) );
396 398
397 connect( mTodoList, SIGNAL( newTodoSignal() ), 399 connect( mTodoList, SIGNAL( newTodoSignal() ),
398 SLOT( newTodo() ) ); 400 SLOT( newTodo() ) );
399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
400 SLOT( newSubTodo( Todo * ) ) ); 402 SLOT( newSubTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
402 SLOT( editTodo( Todo * ) ) ); 404 SLOT( editTodo( Todo * ) ) );
403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 405 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
404 SLOT( showTodo( Todo *) ) ); 406 SLOT( showTodo( Todo *) ) );
405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 407 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
406 SLOT( deleteTodo( Todo *) ) ); 408 SLOT( deleteTodo( Todo *) ) );
407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 409 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 410 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
409 SLOT( purgeCompleted() ) ); 411 SLOT( purgeCompleted() ) );
410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 412 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
411 SIGNAL( todoModified( Todo *, int ) ) ); 413 SIGNAL( todoModified( Todo *, int ) ) );
412 414
413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
414 this, SLOT ( cloneIncidence( Incidence * ) ) ); 416 this, SLOT ( cloneIncidence( Incidence * ) ) );
415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 417 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
416 this, SLOT (cancelIncidence( Incidence * ) ) ); 418 this, SLOT (cancelIncidence( Incidence * ) ) );
417 419
418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
419 this, SLOT ( moveIncidence( Incidence * ) ) ); 421 this, SLOT ( moveIncidence( Incidence * ) ) );
420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 422 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
421 this, SLOT ( beamIncidence( Incidence * ) ) ); 423 this, SLOT ( beamIncidence( Incidence * ) ) );
422 424
423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 425 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
424 this, SLOT ( todo_unsub( Todo * ) ) ); 426 this, SLOT ( todo_unsub( Todo * ) ) );
425 427
426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 428 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
427 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 429 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 430 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
429 SLOT( updateTodo( Todo *, int ) ) ); 431 SLOT( updateTodo( Todo *, int ) ) );
430 connect( this, SIGNAL( todoModified( Todo *, int )), this, 432 connect( this, SIGNAL( todoModified( Todo *, int )), this,
431 SLOT( changeTodoDisplay( Todo *, int ) ) ); 433 SLOT( changeTodoDisplay( Todo *, int ) ) );
432 434
433 435
434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 436 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 437 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 438 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 439 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
438 440
439 441
440 442
441 443
442 444
443 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 445 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
444 SLOT(checkClipboard())); 446 SLOT(checkClipboard()));
445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 447 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
446 SLOT( processTodoListSelection( Incidence * ) ) ); 448 SLOT( processTodoListSelection( Incidence * ) ) );
447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 449 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
448 450
449 // kdDebug() << "CalendarView::CalendarView() done" << endl; 451 // kdDebug() << "CalendarView::CalendarView() done" << endl;
450 452
451 mDateFrame = new QVBox(0,0,WType_Popup); 453 mDateFrame = new QVBox(0,0,WType_Popup);
452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 454 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 455 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
454 mDateFrame->setLineWidth(3); 456 mDateFrame->setLineWidth(3);
455 mDateFrame->hide(); 457 mDateFrame->hide();
456 mDateFrame->setCaption( i18n( "Pick a date to display")); 458 mDateFrame->setCaption( i18n( "Pick a date to display"));
457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 459 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
458 460
459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 461 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
460 462
461 mEventEditor = mDialogManager->getEventEditor(); 463 mEventEditor = mDialogManager->getEventEditor();
462 mTodoEditor = mDialogManager->getTodoEditor(); 464 mTodoEditor = mDialogManager->getTodoEditor();
463 465
464 mFlagEditDescription = false; 466 mFlagEditDescription = false;
465 467
466 mSuspendTimer = new QTimer( this ); 468 mSuspendTimer = new QTimer( this );
467 mAlarmTimer = new QTimer( this ); 469 mAlarmTimer = new QTimer( this );
468 mRecheckAlarmTimer = new QTimer( this ); 470 mRecheckAlarmTimer = new QTimer( this );
469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 471 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 472 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 473 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
472 mAlarmDialog = new AlarmDialog( this ); 474 mAlarmDialog = new AlarmDialog( this );
473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 475 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
474 mAlarmDialog->setServerNotification( false ); 476 mAlarmDialog->setServerNotification( false );
475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 477 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
476 478
477 479
478#ifndef DESKTOP_VERSION 480#ifndef DESKTOP_VERSION
479//US listen for arriving address resultsets 481//US listen for arriving address resultsets
480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 482 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 483 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
482#endif 484#endif
483 485
484} 486}
485 487
486 488
487CalendarView::~CalendarView() 489CalendarView::~CalendarView()
488{ 490{
489 // kdDebug() << "~CalendarView()" << endl; 491 // kdDebug() << "~CalendarView()" << endl;
490 //qDebug("CalendarView::~CalendarView() "); 492 //qDebug("CalendarView::~CalendarView() ");
491 delete mDialogManager; 493 delete mDialogManager;
492 delete mViewManager; 494 delete mViewManager;
493 delete mStorage; 495 delete mStorage;
494 delete mDateFrame ; 496 delete mDateFrame ;
495 delete beamDialog; 497 delete beamDialog;
496 //kdDebug() << "~CalendarView() done" << endl; 498 //kdDebug() << "~CalendarView() done" << endl;
497} 499}
498 500
499void CalendarView::showDay( QDate d ) 501void CalendarView::showDay( QDate d )
500{ 502{
501 dateNavigator()->blockSignals( true ); 503 dateNavigator()->blockSignals( true );
502 dateNavigator()->selectDate( d ); 504 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false ); 505 dateNavigator()->blockSignals( false );
504 mViewManager->showDayView(); 506 mViewManager->showDayView();
505 //dateNavigator()->selectDate( d ); 507 //dateNavigator()->selectDate( d );
506} 508}
507void CalendarView::timerAlarm() 509void CalendarView::timerAlarm()
508{ 510{
509 //qDebug("CalendarView::timerAlarm() "); 511 //qDebug("CalendarView::timerAlarm() ");
510 computeAlarm(mAlarmNotification ); 512 computeAlarm(mAlarmNotification );
511} 513}
512 514
513void CalendarView::suspendAlarm() 515void CalendarView::suspendAlarm()
514{ 516{
515 //qDebug(" CalendarView::suspendAlarm() "); 517 //qDebug(" CalendarView::suspendAlarm() ");
516 computeAlarm(mSuspendAlarmNotification ); 518 computeAlarm(mSuspendAlarmNotification );
517 519
518} 520}
519 521
520void CalendarView::startAlarm( QString mess , QString filename) 522void CalendarView::startAlarm( QString mess , QString filename)
521{ 523{
522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 524 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 525 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
524 526
525} 527}
526 528
527void CalendarView::checkNextTimerAlarm() 529void CalendarView::checkNextTimerAlarm()
528{ 530{
529 mCalendar->checkAlarmForIncidence( 0, true ); 531 mCalendar->checkAlarmForIncidence( 0, true );
530} 532}
531 533
532void CalendarView::computeAlarm( QString msg ) 534void CalendarView::computeAlarm( QString msg )
533{ 535{
534 536
535 QString mess = msg; 537 QString mess = msg;
536 QString mAlarmMessage = mess.mid( 9 ); 538 QString mAlarmMessage = mess.mid( 9 );
537 QString filename = MainWindow::resourcePath(); 539 QString filename = MainWindow::resourcePath();
538 filename += "koalarm.wav"; 540 filename += "koalarm.wav";
539 QString tempfilename; 541 QString tempfilename;
540 if ( mess.left( 13 ) == "suspend_alarm") { 542 if ( mess.left( 13 ) == "suspend_alarm") {
541 bool error = false; 543 bool error = false;
542 int len = mess.mid( 13 ).find("+++"); 544 int len = mess.mid( 13 ).find("+++");
543 if ( len < 2 ) 545 if ( len < 2 )
544 error = true; 546 error = true;
545 else { 547 else {
546 tempfilename = mess.mid( 13, len ); 548 tempfilename = mess.mid( 13, len );
547 if ( !QFile::exists( tempfilename ) ) 549 if ( !QFile::exists( tempfilename ) )
548 error = true; 550 error = true;
549 } 551 }
550 if ( ! error ) { 552 if ( ! error ) {
551 filename = tempfilename; 553 filename = tempfilename;
552 } 554 }
553 mAlarmMessage = mess.mid( 13+len+3 ); 555 mAlarmMessage = mess.mid( 13+len+3 );
554 //qDebug("suspend file %s ",tempfilename.latin1() ); 556 //qDebug("suspend file %s ",tempfilename.latin1() );
555 startAlarm( mAlarmMessage, filename); 557 startAlarm( mAlarmMessage, filename);
556 return; 558 return;
557 } 559 }
558 if ( mess.left( 11 ) == "timer_alarm") { 560 if ( mess.left( 11 ) == "timer_alarm") {
559 //mTimerTime = 0; 561 //mTimerTime = 0;
560 startAlarm( mess.mid( 11 ), filename ); 562 startAlarm( mess.mid( 11 ), filename );
561 return; 563 return;
562 } 564 }
563 if ( mess.left( 10 ) == "proc_alarm") { 565 if ( mess.left( 10 ) == "proc_alarm") {
564 bool error = false; 566 bool error = false;
565 int len = mess.mid( 10 ).find("+++"); 567 int len = mess.mid( 10 ).find("+++");
566 if ( len < 2 ) 568 if ( len < 2 )
567 error = true; 569 error = true;
568 else { 570 else {
569 tempfilename = mess.mid( 10, len ); 571 tempfilename = mess.mid( 10, len );
570 if ( !QFile::exists( tempfilename ) ) 572 if ( !QFile::exists( tempfilename ) )
571 error = true; 573 error = true;
572 } 574 }
573 if ( error ) { 575 if ( error ) {
574 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 576 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
575 mAlarmMessage += mess.mid( 10+len+3+9 ); 577 mAlarmMessage += mess.mid( 10+len+3+9 );
576 } else { 578 } else {
577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 579 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
578 //qDebug("-----system command %s ",tempfilename.latin1() ); 580 //qDebug("-----system command %s ",tempfilename.latin1() );
579#ifndef _WIN32_ 581#ifndef _WIN32_
580 if ( vfork () == 0 ) { 582 if ( vfork () == 0 ) {
581 execl ( tempfilename.latin1(), 0 ); 583 execl ( tempfilename.latin1(), 0 );
582 return; 584 return;
583 } 585 }
584#else 586#else
585 QProcess* p = new QProcess(); 587 QProcess* p = new QProcess();
586 p->addArgument( tempfilename.latin1() ); 588 p->addArgument( tempfilename.latin1() );
587 p->start(); 589 p->start();
588 return; 590 return;
589#endif 591#endif
590 592
591 return; 593 return;
592 } 594 }
593 595
594 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 596 //qDebug("+++++++system command %s ",tempfilename.latin1() );
595 } 597 }
596 if ( mess.left( 11 ) == "audio_alarm") { 598 if ( mess.left( 11 ) == "audio_alarm") {
597 bool error = false; 599 bool error = false;
598 int len = mess.mid( 11 ).find("+++"); 600 int len = mess.mid( 11 ).find("+++");
599 if ( len < 2 ) 601 if ( len < 2 )
600 error = true; 602 error = true;
601 else { 603 else {
602 tempfilename = mess.mid( 11, len ); 604 tempfilename = mess.mid( 11, len );
603 if ( !QFile::exists( tempfilename ) ) 605 if ( !QFile::exists( tempfilename ) )
604 error = true; 606 error = true;
605 } 607 }
606 if ( ! error ) { 608 if ( ! error ) {
607 filename = tempfilename; 609 filename = tempfilename;
608 } 610 }
609 mAlarmMessage = mess.mid( 11+len+3+9 ); 611 mAlarmMessage = mess.mid( 11+len+3+9 );
610 //qDebug("audio file command %s ",tempfilename.latin1() ); 612 //qDebug("audio file command %s ",tempfilename.latin1() );
611 } 613 }
612 if ( mess.left( 9 ) == "cal_alarm") { 614 if ( mess.left( 9 ) == "cal_alarm") {
613 mAlarmMessage = mess.mid( 9 ) ; 615 mAlarmMessage = mess.mid( 9 ) ;
614 } 616 }
615 617
616 startAlarm( mAlarmMessage, filename ); 618 startAlarm( mAlarmMessage, filename );
617 619
618 620
619} 621}
620 622
621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 623void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
622{ 624{
623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 625 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
624 626
625 mSuspendAlarmNotification = noti; 627 mSuspendAlarmNotification = noti;
626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 628 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 629 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
628 mSuspendTimer->start( ms , true ); 630 mSuspendTimer->start( ms , true );
629 631
630} 632}
631 633
632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 634void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
633{ 635{
634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 636 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 637 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
636#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 639 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
638#endif 640#endif
639 return; 641 return;
640 } 642 }
641 int maxSec; 643 int maxSec;
642 //maxSec = 5; //testing only 644 //maxSec = 5; //testing only
643 maxSec = 86400+3600; // one day+1hour 645 maxSec = 86400+3600; // one day+1hour
644 mAlarmNotification = noti; 646 mAlarmNotification = noti;
645 int sec = QDateTime::currentDateTime().secsTo( qdt ); 647 int sec = QDateTime::currentDateTime().secsTo( qdt );
646 if ( sec > maxSec ) { 648 if ( sec > maxSec ) {
647 mRecheckAlarmTimer->start( maxSec * 1000 ); 649 mRecheckAlarmTimer->start( maxSec * 1000 );
648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 650 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
649 return; 651 return;
650 } else { 652 } else {
651 mRecheckAlarmTimer->stop(); 653 mRecheckAlarmTimer->stop();
652 } 654 }
653 //qDebug("Alarm timer started with secs: %d ", sec); 655 //qDebug("Alarm timer started with secs: %d ", sec);
654 mAlarmTimer->start( sec *1000 , true ); 656 mAlarmTimer->start( sec *1000 , true );
655 657
656} 658}
657// called by mRecheckAlarmTimer to get next alarm 659// called by mRecheckAlarmTimer to get next alarm
658// we need this, because a QTimer has only a max range of 25 days 660// we need this, because a QTimer has only a max range of 25 days
659void CalendarView::recheckTimerAlarm() 661void CalendarView::recheckTimerAlarm()
660{ 662{
661 mAlarmTimer->stop(); 663 mAlarmTimer->stop();
662 mRecheckAlarmTimer->stop(); 664 mRecheckAlarmTimer->stop();
663 mCalendar->checkAlarmForIncidence( 0, true ); 665 mCalendar->checkAlarmForIncidence( 0, true );
664} 666}
665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 667void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
666{ 668{
667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 669 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 670 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
669#ifndef DESKTOP_VERSION 671#ifndef DESKTOP_VERSION
670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 672 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
671#endif 673#endif
672 return; 674 return;
673 } 675 }
674 mAlarmTimer->stop(); 676 mAlarmTimer->stop();
675} 677}
676void CalendarView::selectWeekNum ( int num ) 678void CalendarView::selectWeekNum ( int num )
677{ 679{
678 dateNavigator()->blockSignals( true ); 680 dateNavigator()->blockSignals( true );
679 dateNavigator()->selectWeek( num ); 681 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false ); 682 dateNavigator()->blockSignals( false );
681 mViewManager->showWeekView(); 683 mViewManager->showWeekView();
682} 684}
683KOViewManager *CalendarView::viewManager() 685KOViewManager *CalendarView::viewManager()
684{ 686{
685 return mViewManager; 687 return mViewManager;
686} 688}
687 689
688KODialogManager *CalendarView::dialogManager() 690KODialogManager *CalendarView::dialogManager()
689{ 691{
690 return mDialogManager; 692 return mDialogManager;
691} 693}
692 694
693QDate CalendarView::startDate() 695QDate CalendarView::startDate()
694{ 696{
695 DateList dates = mNavigator->selectedDates(); 697 DateList dates = mNavigator->selectedDates();
696 698
697 return dates.first(); 699 return dates.first();
698} 700}
699 701
700QDate CalendarView::endDate() 702QDate CalendarView::endDate()
701{ 703{
702 DateList dates = mNavigator->selectedDates(); 704 DateList dates = mNavigator->selectedDates();
703 705
704 return dates.last(); 706 return dates.last();
705} 707}
706 708
707 709
708void CalendarView::createPrinter() 710void CalendarView::createPrinter()
709{ 711{
710#ifndef KORG_NOPRINTER 712#ifndef KORG_NOPRINTER
711 if (!mCalPrinter) { 713 if (!mCalPrinter) {
712 mCalPrinter = new CalPrinter(this, mCalendar); 714 mCalPrinter = new CalPrinter(this, mCalendar);
713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 715 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
714 } 716 }
715#endif 717#endif
716} 718}
717 719
718 720
719//KOPrefs::instance()->mWriteBackFile 721//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 722//KOPrefs::instance()->mWriteBackExistingOnly
721 723
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 724// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 725// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 726// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 727// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 728// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 729// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 730
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 731int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 732{
731 733
732 // 0 equal 734 // 0 equal
733 // 1 take local 735 // 1 take local
734 // 2 take remote 736 // 2 take remote
735 // 3 cancel 737 // 3 cancel
736 QDateTime lastSync = mLastCalendarSync; 738 QDateTime lastSync = mLastCalendarSync;
737 QDateTime localMod = local->lastModified(); 739 QDateTime localMod = local->lastModified();
738 QDateTime remoteMod = remote->lastModified(); 740 QDateTime remoteMod = remote->lastModified();
739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 741 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
740 bool remCh, locCh; 742 bool remCh, locCh;
741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 743 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
742 //if ( remCh ) 744 //if ( remCh )
743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 745 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
744 locCh = ( localMod > mLastCalendarSync ); 746 locCh = ( localMod > mLastCalendarSync );
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index aed9bae..c018dc7 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -56,770 +56,774 @@
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 130
131 while (y < cy + ch) { 131 while (y < cy + ch) {
132 p->drawLine(cx,y,cx+tW,y); 132 p->drawLine(cx,y,cx+tW,y);
133 hour.setNum(cell); 133 hour.setNum(cell);
134 suffix = "am"; 134 suffix = "am";
135 135
136 // handle 24h and am/pm time formats 136 // handle 24h and am/pm time formats
137 if (KGlobal::locale()->use12Clock()) { 137 if (KGlobal::locale()->use12Clock()) {
138 if (cell > 11) suffix = "pm"; 138 if (cell > 11) suffix = "pm";
139 if (cell == 0) hour.setNum(12); 139 if (cell == 0) hour.setNum(12);
140 if (cell > 12) hour.setNum(cell - 12); 140 if (cell > 12) hour.setNum(cell - 12);
141 } else { 141 } else {
142 suffix = ":00"; 142 suffix = ":00";
143 } 143 }
144 144
145 // create string in format of "XX:XX" or "XXpm/am" 145 // create string in format of "XX:XX" or "XXpm/am"
146 fullTime = hour + suffix; 146 fullTime = hour + suffix;
147 147
148 // center and draw the time label 148 // center and draw the time label
149 int timeWidth = fm.width(fullTime+"i"); 149 int timeWidth = fm.width(fullTime+"i");
150 int offset = this->width() - timeWidth; 150 int offset = this->width() - timeWidth;
151 int borderWidth = 5; 151 int borderWidth = 5;
152 int timeHeight = fm.height(); 152 int timeHeight = fm.height();
153 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 153 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
154 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 154 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
155 155
156 // increment indices 156 // increment indices
157 y += mCellHeight; 157 y += mCellHeight;
158 cell++; 158 cell++;
159 } 159 }
160} 160}
161 161
162/** 162/**
163 Calculates the minimum width. 163 Calculates the minimum width.
164*/ 164*/
165int TimeLabels::minimumWidth() const 165int TimeLabels::minimumWidth() const
166{ 166{
167 QFontMetrics fm = fontMetrics(); 167 QFontMetrics fm = fontMetrics();
168 168
169 //TODO: calculate this value 169 //TODO: calculate this value
170 int borderWidth = 4; 170 int borderWidth = 4;
171 171
172 // the maximum width possible 172 // the maximum width possible
173 int width = fm.width("88:88x") + borderWidth; 173 int width = fm.width("88:88x") + borderWidth;
174 174
175 return width; 175 return width;
176} 176}
177 177
178/** updates widget's internal state */ 178/** updates widget's internal state */
179void TimeLabels::updateConfig() 179void TimeLabels::updateConfig()
180{ 180{
181 // set the font 181 // set the font
182 // config->setGroup("Fonts"); 182 // config->setGroup("Fonts");
183 // QFont font = config->readFontEntry("TimeBar Font"); 183 // QFont font = config->readFontEntry("TimeBar Font");
184 setFont(KOPrefs::instance()->mTimeBarFont); 184 setFont(KOPrefs::instance()->mTimeBarFont);
185 185
186 // update geometry restrictions based on new settings 186 // update geometry restrictions based on new settings
187 setFixedWidth(minimumWidth()); 187 setFixedWidth(minimumWidth());
188 188
189 // update HourSize 189 // update HourSize
190 mCellHeight = KOPrefs::instance()->mHourSize*4; 190 mCellHeight = KOPrefs::instance()->mHourSize*4;
191 resizeContents(50,mRows * mCellHeight); 191 resizeContents(50,mRows * mCellHeight);
192} 192}
193 193
194/** update time label positions */ 194/** update time label positions */
195void TimeLabels::positionChanged() 195void TimeLabels::positionChanged()
196{ 196{
197 int adjustment = mAgenda->contentsY(); 197 int adjustment = mAgenda->contentsY();
198 setContentsPos(0, adjustment); 198 setContentsPos(0, adjustment);
199} 199}
200 200
201/** */ 201/** */
202void TimeLabels::setAgenda(KOAgenda* agenda) 202void TimeLabels::setAgenda(KOAgenda* agenda)
203{ 203{
204 mAgenda = agenda; 204 mAgenda = agenda;
205} 205}
206 206
207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 207void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
208{ 208{
209 mMouseDownY = e->pos().y(); 209 mMouseDownY = e->pos().y();
210 mOrgCap = topLevelWidget()->caption(); 210 mOrgCap = topLevelWidget()->caption();
211} 211}
212 212
213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 213void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
214{ 214{
215 int diff = mMouseDownY - e->pos().y(); 215 int diff = mMouseDownY - e->pos().y();
216 if ( diff < 10 && diff > -10 ) 216 if ( diff < 10 && diff > -10 )
217 return; 217 return;
218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 218 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
219 if ( tSize < 4 ) 219 if ( tSize < 4 )
220 tSize = 4; 220 tSize = 4;
221 if ( tSize > 22 ) 221 if ( tSize > 22 )
222 tSize = 22; 222 tSize = 22;
223 tSize = (tSize-2)/2; 223 tSize = (tSize-2)/2;
224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 224 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
225 225
226} 226}
227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 227void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
228{ 228{
229 topLevelWidget()->setCaption( mOrgCap ); 229 topLevelWidget()->setCaption( mOrgCap );
230 int diff = mMouseDownY - e->pos().y(); 230 int diff = mMouseDownY - e->pos().y();
231 if ( diff < 10 && diff > -10 ) 231 if ( diff < 10 && diff > -10 )
232 return; 232 return;
233 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 233 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
234 if ( tSize < 4 ) 234 if ( tSize < 4 )
235 tSize = 4; 235 tSize = 4;
236 if ( tSize > 22 ) 236 if ( tSize > 22 )
237 tSize = 22; 237 tSize = 22;
238 tSize = (tSize/2)*2; 238 tSize = (tSize/2)*2;
239 if ( tSize == KOPrefs::instance()->mHourSize ) 239 if ( tSize == KOPrefs::instance()->mHourSize )
240 return; 240 return;
241 KOPrefs::instance()->mHourSize = tSize; 241 KOPrefs::instance()->mHourSize = tSize;
242 emit scaleChanged(); 242 emit scaleChanged();
243} 243}
244 244
245/** This is called in response to repaint() */ 245/** This is called in response to repaint() */
246void TimeLabels::paintEvent(QPaintEvent*) 246void TimeLabels::paintEvent(QPaintEvent*)
247{ 247{
248 248
249 // kdDebug() << "paintevent..." << endl; 249 // kdDebug() << "paintevent..." << endl;
250 // this is another hack! 250 // this is another hack!
251 // QPainter painter(this); 251 // QPainter painter(this);
252 //QString c 252 //QString c
253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 253 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
254} 254}
255 255
256//////////////////////////////////////////////////////////////////////////// 256////////////////////////////////////////////////////////////////////////////
257 257
258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 258EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
259 : QFrame(parent,name) 259 : QFrame(parent,name)
260{ 260{
261 mColumns = 1; 261 mColumns = 1;
262 mTopBox = 0; 262 mTopBox = 0;
263 mLocation = loc; 263 mLocation = loc;
264 mTopLayout = 0; 264 mTopLayout = 0;
265 mPaintWidget = 0; 265 mPaintWidget = 0;
266 mXOffset = 0; 266 mXOffset = 0;
267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 267 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
268 else mPixmap = SmallIcon("1downarrow"); 268 else mPixmap = SmallIcon("1downarrow");
269 mEnabled.resize(mColumns); 269 mEnabled.resize(mColumns);
270 if (mLocation == Top) 270 if (mLocation == Top)
271 setMaximumHeight(0); 271 setMaximumHeight(0);
272 else 272 else
273 setMinimumHeight(mPixmap.height()); 273 setMinimumHeight(mPixmap.height());
274} 274}
275 275
276EventIndicator::~EventIndicator() 276EventIndicator::~EventIndicator()
277{ 277{
278} 278}
279 279
280void EventIndicator::drawContents(QPainter *p) 280void EventIndicator::drawContents(QPainter *p)
281{ 281{
282 282
283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
284 KDGanttSplitterHandle* han = 0; 284 KDGanttSplitterHandle* han = 0;
285 if ( mPaintWidget ) 285 if ( mPaintWidget )
286 han = mPaintWidget->firstHandle(); 286 han = mPaintWidget->firstHandle();
287 if ( ! han ) { 287 if ( ! han ) {
288 int i; 288 int i;
289 for(i=0;i<mColumns;++i) { 289 for(i=0;i<mColumns;++i) {
290 if (mEnabled[i]) { 290 if (mEnabled[i]) {
291 int cellWidth = contentsRect().right()/mColumns; 291 int cellWidth = contentsRect().right()/mColumns;
292 int xOffset = KOGlobals::self()->reverseLayout() ? 292 int xOffset = KOGlobals::self()->reverseLayout() ?
293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
294 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 294 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
295 p->drawPixmap(QPoint(xOffset,0),mPixmap); 295 p->drawPixmap(QPoint(xOffset,0),mPixmap);
296 } 296 }
297 } 297 }
298 } else { 298 } else {
299 han->repaint(); 299 han->repaint();
300 //mPaintWidget->setBackgroundColor( red ); 300 //mPaintWidget->setBackgroundColor( red );
301 301
302 QPainter pa( han ); 302 QPainter pa( han );
303 int i; 303 int i;
304 bool setColor = false; 304 bool setColor = false;
305 for(i=0;i<mColumns;++i) { 305 for(i=0;i<mColumns;++i) {
306 if (mEnabled[i]) { 306 if (mEnabled[i]) {
307 setColor = true; 307 setColor = true;
308 308
309 int cellWidth = contentsRect().right()/mColumns; 309 int cellWidth = contentsRect().right()/mColumns;
310 int xOffset = KOGlobals::self()->reverseLayout() ? 310 int xOffset = KOGlobals::self()->reverseLayout() ?
311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
312 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 312 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
314 //qDebug("222draw pix %d ",xOffset ); 314 //qDebug("222draw pix %d ",xOffset );
315 315
316 } 316 }
317 317
318 } 318 }
319 pa.end(); 319 pa.end();
320 320
321 } 321 }
322} 322}
323 323
324void EventIndicator::setXOffset( int x ) 324void EventIndicator::setXOffset( int x )
325{ 325{
326 mXOffset = x; 326 mXOffset = x;
327} 327}
328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
329{ 329{
330 mPaintWidget = w; 330 mPaintWidget = w;
331} 331}
332void EventIndicator::changeColumns(int columns) 332void EventIndicator::changeColumns(int columns)
333{ 333{
334 mColumns = columns; 334 mColumns = columns;
335 mEnabled.resize(mColumns); 335 mEnabled.resize(mColumns);
336 336
337 update(); 337 update();
338} 338}
339 339
340void EventIndicator::enableColumn(int column, bool enable) 340void EventIndicator::enableColumn(int column, bool enable)
341{ 341{
342 mEnabled[column] = enable; 342 mEnabled[column] = enable;
343} 343}
344 344
345 345
346//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
347//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
348//////////////////////////////////////////////////////////////////////////// 348////////////////////////////////////////////////////////////////////////////
349 349
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
351 KOEventView (cal,parent,name) 351 KOEventView (cal,parent,name)
352{ 352{
353 mBlockUpdating = true; 353 mBlockUpdating = true;
354 mStartHour = 8; 354 mStartHour = 8;
355 mSelectedDates.append(QDate::currentDate()); 355 mSelectedDates.append(QDate::currentDate());
356 356
357 mLayoutDayLabels = 0; 357 mLayoutDayLabels = 0;
358 mDayLabelsFrame = 0; 358 mDayLabelsFrame = 0;
359 mDayLabels = 0; 359 mDayLabels = 0;
360 bool isRTL = KOGlobals::self()->reverseLayout(); 360 bool isRTL = KOGlobals::self()->reverseLayout();
361 361
362 if ( KOPrefs::instance()->mVerticalScreen ) { 362 if ( KOPrefs::instance()->mVerticalScreen ) {
363 mExpandedPixmap = SmallIcon( "1downarrow" ); 363 mExpandedPixmap = SmallIcon( "1downarrow" );
364 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 364 mNotExpandedPixmap = SmallIcon( "1uparrow" );
365 } else { 365 } else {
366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
368 } 368 }
369 369
370 QBoxLayout *topLayout = new QVBoxLayout(this); 370 QBoxLayout *topLayout = new QVBoxLayout(this);
371 371
372 // Create day name labels for agenda columns 372 // Create day name labels for agenda columns
373 mDayLabelsFrame = new QHBox(this); 373 mDayLabelsFrame = new QHBox(this);
374 topLayout->addWidget(mDayLabelsFrame); 374 topLayout->addWidget(mDayLabelsFrame);
375 mDayLabels = new QFrame (mDayLabelsFrame); 375 mDayLabels = new QFrame (mDayLabelsFrame);
376 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 376 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
377 // Create agenda splitter 377 // Create agenda splitter
378#ifndef KORG_NOSPLITTER 378#ifndef KORG_NOSPLITTER
379 mSplitterAgenda = new QSplitter(Vertical,this); 379 mSplitterAgenda = new QSplitter(Vertical,this);
380 topLayout->addWidget(mSplitterAgenda); 380 topLayout->addWidget(mSplitterAgenda);
381 mSplitterAgenda->setOpaqueResize(); 381 mSplitterAgenda->setOpaqueResize();
382 382
383 mAllDayFrame = new QHBox(mSplitterAgenda); 383 mAllDayFrame = new QHBox(mSplitterAgenda);
384 384
385 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 385 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
386#else 386#else
387#if 0 387#if 0
388 QWidget *mainBox = new QWidget( this ); 388 QWidget *mainBox = new QWidget( this );
389 topLayout->addWidget( mainBox ); 389 topLayout->addWidget( mainBox );
390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
391 mAllDayFrame = new QHBox(mainBox); 391 mAllDayFrame = new QHBox(mainBox);
392 mainLayout->addWidget(mAllDayFrame); 392 mainLayout->addWidget(mAllDayFrame);
393 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 393 mainLayout->setStretchFactor( mAllDayFrame, 0 );
394 mAllDayFrame->setFocusPolicy(NoFocus); 394 mAllDayFrame->setFocusPolicy(NoFocus);
395 QWidget *agendaFrame = new QWidget(mainBox); 395 QWidget *agendaFrame = new QWidget(mainBox);
396 mainLayout->addWidget(agendaFrame); 396 mainLayout->addWidget(agendaFrame);
397 mainLayout->setStretchFactor( agendaFrame, 10 ); 397 mainLayout->setStretchFactor( agendaFrame, 10 );
398 398
399 agendaFrame->setFocusPolicy(NoFocus); 399 agendaFrame->setFocusPolicy(NoFocus);
400#endif 400#endif
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 403 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 404 mAllDayFrame = new QHBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 405 mAllDayFrame->setFocusPolicy(NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 406 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 407 agendaFrame->setFocusPolicy(NoFocus);
408 408
409#endif 409#endif
410 410
411 // Create all-day agenda widget 411 // Create all-day agenda widget
412 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 412 mDummyAllDayLeft = new QVBox( mAllDayFrame );
413 413
414 mExpandButton = new QPushButton(mDummyAllDayLeft); 414 mExpandButton = new QPushButton(mDummyAllDayLeft);
415 mExpandButton->setPixmap( mNotExpandedPixmap ); 415 mExpandButton->setPixmap( mNotExpandedPixmap );
416 int widebut = mExpandButton->sizeHint().width(); 416 int widebut = mExpandButton->sizeHint().width();
417 if ( QApplication::desktop()->width() < 480 ) 417 if ( QApplication::desktop()->width() < 480 )
418 widebut = widebut*2; 418 widebut = widebut*2;
419 else 419 else
420 widebut = (widebut*3) / 2; 420 widebut = (widebut*3) / 2;
421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
422 // QSizePolicy::Fixed ) ); 422 // QSizePolicy::Fixed ) );
423 mExpandButton->setFixedSize( widebut, widebut); 423 mExpandButton->setFixedSize( widebut, widebut);
424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
425 mExpandButton->setFocusPolicy(NoFocus); 425 mExpandButton->setFocusPolicy(NoFocus);
426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
427 mAllDayAgenda->setFocusPolicy(NoFocus); 427 mAllDayAgenda->setFocusPolicy(NoFocus);
428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); 428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame);
429 429
430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); 430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
431 QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight ); 431 QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight );
432 432
433 dummyAllDayRightB->setFlat( true ); 433 dummyAllDayRightB->setFlat( true );
434 dummyAllDayRightB->setFocusPolicy(NoFocus); 434 dummyAllDayRightB->setFocusPolicy(NoFocus);
435 // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 435 // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
436 //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 ); 436 //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 );
437 QPopupMenu * wpo = new QPopupMenu (this); 437 QPopupMenu * wpo = new QPopupMenu (this);
438 wpo->insertItem( i18n("W#"), 0 ); 438 wpo->insertItem( i18n("W#"), 0 );
439 int i; 439 int i;
440 for ( i = 1; i < 54; i++ ) 440 for ( i = 1; i < 53; i++ )
441 wpo->insertItem( QString::number( i ),i ); 441 wpo->insertItem( QString::number( i ),i );
442 //Qt bug - we must add some empty fields...
443 for ( i = 53; i < 54; ++i ) {
444 wpo->insertItem( "", 52 );
445 }
442 dummyAllDayRightB->setPopup( wpo ); 446 dummyAllDayRightB->setPopup( wpo );
443 447
444 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 448 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
445 449
446 // Create event context menu for all day agenda 450 // Create event context menu for all day agenda
447 mAllDayAgendaPopup = eventPopup(); 451 mAllDayAgendaPopup = eventPopup();
448 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 452 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
449 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 453 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
450 454
451 // Create agenda frame 455 // Create agenda frame
452 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 456 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
453 // QHBox *agendaFrame = new QHBox(splitterAgenda); 457 // QHBox *agendaFrame = new QHBox(splitterAgenda);
454 458
455 // create event indicator bars 459 // create event indicator bars
456 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 460 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
457 agendaLayout->addWidget(mEventIndicatorTop,0,1); 461 agendaLayout->addWidget(mEventIndicatorTop,0,1);
458 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 462 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
459 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 463 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
460 agendaFrame); 464 agendaFrame);
461 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 465 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
462 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 466 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
463 agendaLayout->addWidget(dummyAgendaRight,0,2); 467 agendaLayout->addWidget(dummyAgendaRight,0,2);
464 468
465 // Create time labels 469 // Create time labels
466 mTimeLabels = new TimeLabels(24,agendaFrame); 470 mTimeLabels = new TimeLabels(24,agendaFrame);
467 agendaLayout->addWidget(mTimeLabels,1,0); 471 agendaLayout->addWidget(mTimeLabels,1,0);
468 connect(mTimeLabels,SIGNAL( scaleChanged()), 472 connect(mTimeLabels,SIGNAL( scaleChanged()),
469 this,SLOT(updateConfig())); 473 this,SLOT(updateConfig()));
470 474
471 // Create agenda 475 // Create agenda
472 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 476 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
473 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 477 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
474 agendaLayout->setColStretch(1,1); 478 agendaLayout->setColStretch(1,1);
475 mAgenda->setFocusPolicy(NoFocus); 479 mAgenda->setFocusPolicy(NoFocus);
476 // Create event context menu for agenda 480 // Create event context menu for agenda
477 mAgendaPopup = eventPopup(); 481 mAgendaPopup = eventPopup();
478 482
479 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 483 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
480 i18n("Toggle Alarm"),mAgenda, 484 i18n("Toggle Alarm"),mAgenda,
481 SLOT(popupAlarm()),true); 485 SLOT(popupAlarm()),true);
482 486
483 487
484 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 488 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
485 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 489 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
486 490
487 // make connections between dependent widgets 491 // make connections between dependent widgets
488 mTimeLabels->setAgenda(mAgenda); 492 mTimeLabels->setAgenda(mAgenda);
489 493
490 // Update widgets to reflect user preferences 494 // Update widgets to reflect user preferences
491 // updateConfig(); 495 // updateConfig();
492 496
493 // createDayLabels(); 497 // createDayLabels();
494 498
495 // these blank widgets make the All Day Event box line up with the agenda 499 // these blank widgets make the All Day Event box line up with the agenda
496 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 500 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
497 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 501 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
498 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 502 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
499 503
500 // Scrolling 504 // Scrolling
501 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 505 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
502 mTimeLabels, SLOT(positionChanged())); 506 mTimeLabels, SLOT(positionChanged()));
503 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 507 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
504 SLOT(setContentsPos(int))); 508 SLOT(setContentsPos(int)));
505 509
506 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 510 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
507 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 511 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
508 512
509 // Create/Show/Edit/Delete Event 513 // Create/Show/Edit/Delete Event
510 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 514 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
511 SLOT(newEvent(int,int))); 515 SLOT(newEvent(int,int)));
512 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 516 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
513 SLOT(newTodo(int,int))); 517 SLOT(newTodo(int,int)));
514 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 518 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
515 SLOT(newEvent(int,int,int,int))); 519 SLOT(newEvent(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 520 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
517 SLOT(newEventAllDay(int,int))); 521 SLOT(newEventAllDay(int,int)));
518 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 522 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
519 SLOT(newTodoAllDay(int,int))); 523 SLOT(newTodoAllDay(int,int)));
520 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 524 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
521 SLOT(newEventAllDay(int,int))); 525 SLOT(newEventAllDay(int,int)));
522 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 526 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
523 SLOT(newTimeSpanSelected(int,int,int,int))); 527 SLOT(newTimeSpanSelected(int,int,int,int)));
524 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 528 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
525 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 529 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
526 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 530 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
527 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 531 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
528 532
529 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 533 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
530 SIGNAL(editIncidenceSignal(Incidence *))); 534 SIGNAL(editIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 535 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
532 SIGNAL(editIncidenceSignal(Incidence *))); 536 SIGNAL(editIncidenceSignal(Incidence *)));
533 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 537 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
534 SIGNAL(showIncidenceSignal(Incidence *))); 538 SIGNAL(showIncidenceSignal(Incidence *)));
535 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 539 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
536 SIGNAL(showIncidenceSignal(Incidence *))); 540 SIGNAL(showIncidenceSignal(Incidence *)));
537 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 541 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
538 SIGNAL(deleteIncidenceSignal(Incidence *))); 542 SIGNAL(deleteIncidenceSignal(Incidence *)));
539 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 543 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
540 SIGNAL(deleteIncidenceSignal(Incidence *))); 544 SIGNAL(deleteIncidenceSignal(Incidence *)));
541 545
542 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 546 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
543 SLOT(updateEventDates(KOAgendaItem *, int ))); 547 SLOT(updateEventDates(KOAgendaItem *, int )));
544 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 548 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
545 SLOT(updateEventDates(KOAgendaItem *, int))); 549 SLOT(updateEventDates(KOAgendaItem *, int)));
546 550
547 // event indicator update 551 // event indicator update
548 connect(mAgenda,SIGNAL(lowerYChanged(int)), 552 connect(mAgenda,SIGNAL(lowerYChanged(int)),
549 SLOT(updateEventIndicatorTop(int))); 553 SLOT(updateEventIndicatorTop(int)));
550 connect(mAgenda,SIGNAL(upperYChanged(int)), 554 connect(mAgenda,SIGNAL(upperYChanged(int)),
551 SLOT(updateEventIndicatorBottom(int))); 555 SLOT(updateEventIndicatorBottom(int)));
552 // drag signals 556 // drag signals
553 /* 557 /*
554 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 558 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
555 SLOT(startDrag(Event *))); 559 SLOT(startDrag(Event *)));
556 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 560 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
557 SLOT(startDrag(Event *))); 561 SLOT(startDrag(Event *)));
558 */ 562 */
559 // synchronize selections 563 // synchronize selections
560 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 564 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
561 mAllDayAgenda, SLOT( deselectItem() ) ); 565 mAllDayAgenda, SLOT( deselectItem() ) );
562 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 566 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
563 mAgenda, SLOT( deselectItem() ) ); 567 mAgenda, SLOT( deselectItem() ) );
564 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 568 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
565 SIGNAL( incidenceSelected( Incidence * ) ) ); 569 SIGNAL( incidenceSelected( Incidence * ) ) );
566 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 570 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
567 SIGNAL( incidenceSelected( Incidence * ) ) ); 571 SIGNAL( incidenceSelected( Incidence * ) ) );
568 connect( mAgenda, SIGNAL( resizedSignal() ), 572 connect( mAgenda, SIGNAL( resizedSignal() ),
569 SLOT( updateConfig( ) ) ); 573 SLOT( updateConfig( ) ) );
570 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 574 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
571 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 575 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
572 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 576 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
573 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 577 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
574 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 578 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
575 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 579 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
576 580
577 581
578} 582}
579 583
580void KOAgendaView::toggleAllDay() 584void KOAgendaView::toggleAllDay()
581{ 585{
582 if ( mSplitterAgenda->firstHandle() ) 586 if ( mSplitterAgenda->firstHandle() )
583 mSplitterAgenda->firstHandle()->toggle(); 587 mSplitterAgenda->firstHandle()->toggle();
584} 588}
585void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 589void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
586{ 590{
587 calendar()->addIncidence( inc ); 591 calendar()->addIncidence( inc );
588 592
589 if ( incOld ) { 593 if ( incOld ) {
590 if ( incOld->type() == "Todo" ) 594 if ( incOld->type() == "Todo" )
591 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 595 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
592 else 596 else
593 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 597 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
594 } 598 }
595 599
596} 600}
597 601
598KOAgendaView::~KOAgendaView() 602KOAgendaView::~KOAgendaView()
599{ 603{
600 delete mAgendaPopup; 604 delete mAgendaPopup;
601 delete mAllDayAgendaPopup; 605 delete mAllDayAgendaPopup;
602 delete KOAgendaItem::paintPix(); 606 delete KOAgendaItem::paintPix();
603 delete KOAgendaItem::paintPixSel(); 607 delete KOAgendaItem::paintPixSel();
604} 608}
605void KOAgendaView::resizeEvent( QResizeEvent* e ) 609void KOAgendaView::resizeEvent( QResizeEvent* e )
606{ 610{
607 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 611 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
608 bool uc = false; 612 bool uc = false;
609 int ow = e->oldSize().width(); 613 int ow = e->oldSize().width();
610 int oh = e->oldSize().height(); 614 int oh = e->oldSize().height();
611 int w = e->size().width(); 615 int w = e->size().width();
612 int h = e->size().height(); 616 int h = e->size().height();
613 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 617 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
614 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 618 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
615 uc = true; 619 uc = true;
616 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 620 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
617 } 621 }
618 mUpcomingWidth = e->size().width() ; 622 mUpcomingWidth = e->size().width() ;
619 if ( mBlockUpdating || uc ) { 623 if ( mBlockUpdating || uc ) {
620 mBlockUpdating = false; 624 mBlockUpdating = false;
621 //mAgenda->setMinimumSize(800 , 600 ); 625 //mAgenda->setMinimumSize(800 , 600 );
622 //qDebug("mAgenda->resize+++++++++++++++ "); 626 //qDebug("mAgenda->resize+++++++++++++++ ");
623 updateConfig(); 627 updateConfig();
624 //qDebug("KOAgendaView::Updating now possible "); 628 //qDebug("KOAgendaView::Updating now possible ");
625 } else 629 } else
626 createDayLabels(); 630 createDayLabels();
627 //qDebug("resizeEvent end "); 631 //qDebug("resizeEvent end ");
628 632
629} 633}
630void KOAgendaView::slotDaylabelClicked( int num ) 634void KOAgendaView::slotDaylabelClicked( int num )
631{ 635{
632 636
633 QDate firstDate = mSelectedDates.first(); 637 QDate firstDate = mSelectedDates.first();
634 if ( num == -1 ) 638 if ( num == -1 )
635 emit showDateView( 6, firstDate ); 639 emit showDateView( 6, firstDate );
636 else if (num >= 0 ) { 640 else if (num >= 0 ) {
637 if ( mSelectedDates.count() == 1) 641 if ( mSelectedDates.count() == 1)
638 emit showDateView( 9, firstDate.addDays( num ) ); 642 emit showDateView( 9, firstDate.addDays( num ) );
639 else 643 else
640 emit showDateView( 3, firstDate.addDays( num ) ); 644 emit showDateView( 3, firstDate.addDays( num ) );
641 } 645 }
642 else 646 else
643 showDateView( 10, firstDate.addDays(1) ); 647 showDateView( 10, firstDate.addDays(1) );
644} 648}
645 649
646KOAgendaButton* KOAgendaView::getNewDaylabel() 650KOAgendaButton* KOAgendaView::getNewDaylabel()
647{ 651{
648 652
649 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 653 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
650 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 654 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
651 mDayLabelsList.append( dayLabel ); 655 mDayLabelsList.append( dayLabel );
652 mLayoutDayLabels->addWidget(dayLabel); 656 mLayoutDayLabels->addWidget(dayLabel);
653 return dayLabel ; 657 return dayLabel ;
654} 658}
655 659
656void KOAgendaView::createDayLabels() 660void KOAgendaView::createDayLabels()
657{ 661{
658 662
659 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 663 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
660 // qDebug(" KOAgendaView::createDayLabels() blocked "); 664 // qDebug(" KOAgendaView::createDayLabels() blocked ");
661 return; 665 return;
662 666
663 } 667 }
664 int newHight; 668 int newHight;
665 669
666 // ### Before deleting and recreating we could check if mSelectedDates changed... 670 // ### Before deleting and recreating we could check if mSelectedDates changed...
667 // It would remove some flickering and gain speed (since this is called by 671 // It would remove some flickering and gain speed (since this is called by
668 // each updateView() call) 672 // each updateView() call)
669 673
670 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 674 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
671 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 675 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
672 if ( maxWid < 0 ) 676 if ( maxWid < 0 )
673 maxWid = 20; 677 maxWid = 20;
674 678
675 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 679 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
676 QFontMetrics fm ( dlf ); 680 QFontMetrics fm ( dlf );
677 int selCount = mSelectedDates.count(); 681 int selCount = mSelectedDates.count();
678 QString dayTest = "Mon 20"; 682 QString dayTest = "Mon 20";
679 //QString dayTest = "Mon 20"; 683 //QString dayTest = "Mon 20";
680 int wid = fm.width( dayTest ); 684 int wid = fm.width( dayTest );
681 //maxWid -= ( selCount * 3 ); //working for QLabels 685 //maxWid -= ( selCount * 3 ); //working for QLabels
682 maxWid -= ( selCount * 3 ); //working for QPushButton 686 maxWid -= ( selCount * 3 ); //working for QPushButton
683 if ( maxWid < 0 ) 687 if ( maxWid < 0 )
684 maxWid = 20; 688 maxWid = 20;
685 int needWid = wid * selCount; 689 int needWid = wid * selCount;
686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 690 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
687 //if ( needWid > maxWid ) 691 //if ( needWid > maxWid )
688 // qDebug("DAYLABELS TOOOOOOO BIG "); 692 // qDebug("DAYLABELS TOOOOOOO BIG ");
689 while ( needWid > maxWid ) { 693 while ( needWid > maxWid ) {
690 dayTest = dayTest.left( dayTest.length() - 1 ); 694 dayTest = dayTest.left( dayTest.length() - 1 );
691 wid = fm.width( dayTest ); 695 wid = fm.width( dayTest );
692 needWid = wid * selCount; 696 needWid = wid * selCount;
693 } 697 }
694 int maxLen = dayTest.length(); 698 int maxLen = dayTest.length();
695 int fontPoint = dlf.pointSize(); 699 int fontPoint = dlf.pointSize();
696 if ( maxLen < 2 ) { 700 if ( maxLen < 2 ) {
697 int fontPoint = dlf.pointSize(); 701 int fontPoint = dlf.pointSize();
698 while ( fontPoint > 4 ) { 702 while ( fontPoint > 4 ) {
699 --fontPoint; 703 --fontPoint;
700 dlf.setPointSize( fontPoint ); 704 dlf.setPointSize( fontPoint );
701 QFontMetrics f( dlf ); 705 QFontMetrics f( dlf );
702 wid = f.width( "30" ); 706 wid = f.width( "30" );
703 needWid = wid * selCount; 707 needWid = wid * selCount;
704 if ( needWid < maxWid ) 708 if ( needWid < maxWid )
705 break; 709 break;
706 } 710 }
707 maxLen = 2; 711 maxLen = 2;
708 } 712 }
709 //qDebug("Max len %d ", dayTest.length() ); 713 //qDebug("Max len %d ", dayTest.length() );
710 714
711 QFontMetrics tempF( dlf ); 715 QFontMetrics tempF( dlf );
712 newHight = tempF.height(); 716 newHight = tempF.height();
713 mDayLabels->setFont( dlf ); 717 mDayLabels->setFont( dlf );
714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 718 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
715 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 719 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
716 //mLayoutDayLabels->addSpacing( 2 ); 720 //mLayoutDayLabels->addSpacing( 2 );
717 // QFont lFont = dlf; 721 // QFont lFont = dlf;
718 bool appendLabels = false; 722 bool appendLabels = false;
719 KOAgendaButton *dayLabel; 723 KOAgendaButton *dayLabel;
720 dayLabel = mDayLabelsList.first(); 724 dayLabel = mDayLabelsList.first();
721 if ( !dayLabel ) { 725 if ( !dayLabel ) {
722 appendLabels = true; 726 appendLabels = true;
723 dayLabel = getNewDaylabel(); 727 dayLabel = getNewDaylabel();
724 } 728 }
725 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 729 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
726 dayLabel->setFont( dlf ); 730 dayLabel->setFont( dlf );
727 dayLabel->setNum( -1 ); 731 dayLabel->setNum( -1 );
728 //dayLabel->setAlignment(QLabel::AlignHCenter); 732 //dayLabel->setAlignment(QLabel::AlignHCenter);
729 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 733 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
730 dayLabel->show(); 734 dayLabel->show();
731 DateList::ConstIterator dit; 735 DateList::ConstIterator dit;
732 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 736 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
733 int counter = -1; 737 int counter = -1;
734 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 738 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
735 ++counter; 739 ++counter;
736 QDate date = *dit; 740 QDate date = *dit;
737 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 741 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
738 if ( ! appendLabels ) { 742 if ( ! appendLabels ) {
739 dayLabel = mDayLabelsList.next(); 743 dayLabel = mDayLabelsList.next();
740 if ( !dayLabel ) 744 if ( !dayLabel )
741 appendLabels = true; 745 appendLabels = true;
742 } 746 }
743 if ( appendLabels ) { 747 if ( appendLabels ) {
744 dayLabel = getNewDaylabel(); 748 dayLabel = getNewDaylabel();
745 } 749 }
746 dayLabel->setMinimumWidth( 1 ); 750 dayLabel->setMinimumWidth( 1 );
747 dayLabel->setMaximumWidth( 1024 ); 751 dayLabel->setMaximumWidth( 1024 );
748 dayLabel->setFont( dlf ); 752 dayLabel->setFont( dlf );
749 dayLabel->show(); 753 dayLabel->show();
750 dayLabel->setNum( counter ); 754 dayLabel->setNum( counter );
751 QString str; 755 QString str;
752 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
753 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
754 switch ( maxLen ) { 758 switch ( maxLen ) {
755 case 2: 759 case 2:
756 str = QString::number( date.day() ); 760 str = QString::number( date.day() );
757 break; 761 break;
758 762
759 case 3: 763 case 3:
760 str = dayName.left( 1 ) +QString::number( date.day()); 764 str = dayName.left( 1 ) +QString::number( date.day());
761 765
762 break; 766 break;
763 case 4: 767 case 4:
764 str = dayName.left( 1 ) + " " +QString::number( date.day()); 768 str = dayName.left( 1 ) + " " +QString::number( date.day());
765 769
766 break; 770 break;
767 case 5: 771 case 5:
768 str = dayName.left( 2 ) + " " +QString::number( date.day()); 772 str = dayName.left( 2 ) + " " +QString::number( date.day());
769 773
770 break; 774 break;
771 case 6: 775 case 6:
772 str = dayName.left( 3 ) + " " +QString::number( date.day()); 776 str = dayName.left( 3 ) + " " +QString::number( date.day());
773 break; 777 break;
774 778
775 default: 779 default:
776 break; 780 break;
777 } 781 }
778 if ( oneday ) { 782 if ( oneday ) {
779 QString addString; 783 QString addString;
780 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 784 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
781 addString = i18n("Today"); 785 addString = i18n("Today");
782 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
783 addString = i18n("Tomorrow"); 787 addString = i18n("Tomorrow");
784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
785 addString = i18n("Yesterday"); 789 addString = i18n("Yesterday");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
787 addString = i18n("Day before yesterday"); 791 addString = i18n("Day before yesterday");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
789 addString = i18n("Day after tomorrow"); 793 addString = i18n("Day after tomorrow");
790 if ( !addString.isEmpty() ) { 794 if ( !addString.isEmpty() ) {
791 str = addString+", " + str; 795 str = addString+", " + str;
792 } 796 }
793 } 797 }
794 dayLabel->setText(str); 798 dayLabel->setText(str);
795 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
796 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
797 QFont bFont = dlf; 801 QFont bFont = dlf;
798 bFont.setBold( true ); 802 bFont.setBold( true );
799 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
800 } 804 }
801 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
802 806
803#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
804 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
805 CalendarDecoration *it; 809 CalendarDecoration *it;
806 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
807 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
808 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
809 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
810 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
811 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
812 } 816 }
813 } 817 }
814 818
815 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
816 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
817 if ( wid ) { 821 if ( wid ) {
818 // wid->setHeight(20); 822 // wid->setHeight(20);
819 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
820 } 824 }
821 } 825 }
822#endif 826#endif
823 } 827 }
824 if ( ! appendLabels ) { 828 if ( ! appendLabels ) {
825 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index ab96786..9c1e4c3 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -428,793 +428,788 @@ void MonthViewCell::startUpdateCell()
428 mItemList->insertItem( item ); 428 mItemList->insertItem( item );
429 mToolTip += mHolidayString+"\n"; 429 mToolTip += mHolidayString+"\n";
430 } 430 }
431} 431}
432 432
433void MonthViewCell::insertEvent(Event *event) 433void MonthViewCell::insertEvent(Event *event)
434{ 434{
435 if ( !(event->doesRecur() == Recurrence::rNone) ) { 435 if ( !(event->doesRecur() == Recurrence::rNone) ) {
436 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 436 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
437 return; 437 return;
438 else 438 else
439 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 439 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
440 return; 440 return;
441 } 441 }
442 442
443 if ( event->categories().contains("Holiday") || 443 if ( event->categories().contains("Holiday") ||
444 event->categories().contains(i18n("Holiday"))) { 444 event->categories().contains(i18n("Holiday"))) {
445 setHoliday( true ); 445 setHoliday( true );
446 if ( mDate.dayOfWeek() == 7 ) 446 if ( mDate.dayOfWeek() == 7 )
447 mItemList->setLineWidth( 3 ); 447 mItemList->setLineWidth( 3 );
448 } 448 }
449 QString text; 449 QString text;
450 if (event->isMultiDay()) { 450 if (event->isMultiDay()) {
451 QString prefix = "<->"; 451 QString prefix = "<->";
452 if ( event->doesRecur() ) { 452 if ( event->doesRecur() ) {
453 if ( event->recursOn( mDate) ) 453 if ( event->recursOn( mDate) )
454 prefix ="->" ; 454 prefix ="->" ;
455 else { 455 else {
456 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 456 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
457 if ( event->recursOn( mDate.addDays( -days)) ) 457 if ( event->recursOn( mDate.addDays( -days)) )
458 prefix ="<-" ; 458 prefix ="<-" ;
459 } 459 }
460 460
461 } else { 461 } else {
462 if (mDate == event->dtStart().date()) { 462 if (mDate == event->dtStart().date()) {
463 prefix ="->" ; 463 prefix ="->" ;
464 } else if (mDate == event->dtEnd().date()) { 464 } else if (mDate == event->dtEnd().date()) {
465 prefix ="<-" ; 465 prefix ="<-" ;
466 } 466 }
467 } 467 }
468 if ( !event->doesFloat() ) { 468 if ( !event->doesFloat() ) {
469 if ( mDate == event->dtStart().date () ) 469 if ( mDate == event->dtStart().date () )
470 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 470 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
471 else if ( mDate == event->dtEnd().date () ) 471 else if ( mDate == event->dtEnd().date () )
472 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 472 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
473 473
474 } 474 }
475 text = prefix + event->summary(); 475 text = prefix + event->summary();
476 mToolTip += text; 476 mToolTip += text;
477 } else { 477 } else {
478 if (event->doesFloat()) { 478 if (event->doesFloat()) {
479 text = event->summary(); 479 text = event->summary();
480 mToolTip += text; 480 mToolTip += text;
481 } 481 }
482 else { 482 else {
483 text = KGlobal::locale()->formatTime(event->dtStart().time()); 483 text = KGlobal::locale()->formatTime(event->dtStart().time());
484 text += " " + event->summary(); 484 text += " " + event->summary();
485 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 485 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
486 } 486 }
487 } 487 }
488 488
489 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 489 MonthViewItem *item = new MonthViewItem( event, mDate, text );
490 QPalette pal; 490 QPalette pal;
491 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 491 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
492 QStringList categories = event->categories(); 492 QStringList categories = event->categories();
493 QString cat = categories.first(); 493 QString cat = categories.first();
494 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 494 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
495 pal = getPalette(); 495 pal = getPalette();
496 if (cat.isEmpty()) { 496 if (cat.isEmpty()) {
497 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 497 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
498 } else { 498 } else {
499 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 499 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
500 } 500 }
501 501
502 } else { 502 } else {
503 if (cat.isEmpty()) { 503 if (cat.isEmpty()) {
504 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 504 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
505 } else { 505 } else {
506 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 506 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
507 } 507 }
508 } 508 }
509 509
510 } else { 510 } else {
511 pal = mStandardPalette ; 511 pal = mStandardPalette ;
512 } 512 }
513 item->setPalette( pal ); 513 item->setPalette( pal );
514 item->setRecur( event->recurrence()->doesRecur() ); 514 item->setRecur( event->recurrence()->doesRecur() );
515 item->setAlarm( event->isAlarmEnabled() ); 515 item->setAlarm( event->isAlarmEnabled() );
516 item->setMoreInfo( event->description().length() > 0 ); 516 item->setMoreInfo( event->description().length() > 0 );
517#ifdef DESKTOP_VERSION 517#ifdef DESKTOP_VERSION
518 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 518 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
519 KOPrefs::instance()->email()); 519 KOPrefs::instance()->email());
520 if ( me != 0 ) { 520 if ( me != 0 ) {
521 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 521 if ( me->status() == Attendee::NeedsAction && me->RSVP())
522 item->setReply(true); 522 item->setReply(true);
523 else 523 else
524 item->setReply(false); 524 item->setReply(false);
525 } else 525 } else
526 item->setReply(false); 526 item->setReply(false);
527#endif 527#endif
528 mItemList->insertItem( item ); 528 mItemList->insertItem( item );
529 mToolTip += "\n"; 529 mToolTip += "\n";
530} 530}
531void MonthViewCell::insertTodo(Todo *todo) 531void MonthViewCell::insertTodo(Todo *todo)
532{ 532{
533 QString text; 533 QString text;
534 if (todo->hasDueDate()) { 534 if (todo->hasDueDate()) {
535 if (!todo->doesFloat()) { 535 if (!todo->doesFloat()) {
536 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 536 text += KGlobal::locale()->formatTime(todo->dtDue().time());
537 text += " "; 537 text += " ";
538 } 538 }
539 } 539 }
540 text += i18n("To-Do: %1").arg(todo->summary()); 540 text += i18n("To-Do: %1").arg(todo->summary());
541 541
542 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 542 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
543 //item->setPalette( mStandardPalette ); 543 //item->setPalette( mStandardPalette );
544 QPalette pal; 544 QPalette pal;
545 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 545 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
546 QStringList categories = todo->categories(); 546 QStringList categories = todo->categories();
547 QString cat = categories.first(); 547 QString cat = categories.first();
548 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 548 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
549 pal = getPalette(); 549 pal = getPalette();
550 if (cat.isEmpty()) { 550 if (cat.isEmpty()) {
551 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 551 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
552 } else { 552 } else {
553 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 553 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
554 } 554 }
555 555
556 } else { 556 } else {
557 if (cat.isEmpty()) { 557 if (cat.isEmpty()) {
558 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 558 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
559 } else { 559 } else {
560 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 560 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
561 } 561 }
562 } 562 }
563 563
564 } else { 564 } else {
565 pal = mStandardPalette ; 565 pal = mStandardPalette ;
566 } 566 }
567 item->setPalette( pal ); 567 item->setPalette( pal );
568 mItemList->insertItem( item ); 568 mItemList->insertItem( item );
569 mToolTip += text+"\n"; 569 mToolTip += text+"\n";
570} 570}
571void MonthViewCell::finishUpdateCell() 571void MonthViewCell::finishUpdateCell()
572{ 572{
573#ifdef DESKTOP_VERSION 573#ifdef DESKTOP_VERSION
574 if (mToolTip != "") 574 if (mToolTip != "")
575 QToolTip::add(this,mToolTip,toolTipGroup(),""); 575 QToolTip::add(this,mToolTip,toolTipGroup(),"");
576#endif 576#endif
577 mItemList->sort(); 577 mItemList->sort();
578 //setMyPalette(); 578 //setMyPalette();
579 setMyPalette(); 579 setMyPalette();
580 QString text; 580 QString text;
581 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 581 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
582 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 582 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
583 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 583 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
584 mLabel->resize( mLabelBigSize ); 584 mLabel->resize( mLabelBigSize );
585 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 585 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
586 } else { 586 } else {
587 mLabel->resize( mLabelSize ); 587 mLabel->resize( mLabelSize );
588 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 588 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
589 } 589 }
590 590
591 mLabel->setText( text ); 591 mLabel->setText( text );
592 resizeEvent( 0 ); 592 resizeEvent( 0 );
593} 593}
594void MonthViewCell::updateCell() 594void MonthViewCell::updateCell()
595{ 595{
596 if ( !mMonthView->isUpdatePossible() ) 596 if ( !mMonthView->isUpdatePossible() )
597 return; 597 return;
598 startUpdateCell(); 598 startUpdateCell();
599 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 599 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
600 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 600 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
601 Event *event; 601 Event *event;
602 for( event = events.first(); event; event = events.next() ) { // for event 602 for( event = events.first(); event; event = events.next() ) { // for event
603 insertEvent(event); 603 insertEvent(event);
604 } 604 }
605 // insert due todos 605 // insert due todos
606 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 606 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
607 Todo *todo; 607 Todo *todo;
608 for(todo = todos.first(); todo; todo = todos.next()) { 608 for(todo = todos.first(); todo; todo = todos.next()) {
609 insertTodo( todo ); 609 insertTodo( todo );
610 } 610 }
611 finishUpdateCell(); 611 finishUpdateCell();
612 // if ( isVisible()) 612 // if ( isVisible())
613 //qApp->processEvents(); 613 //qApp->processEvents();
614} 614}
615 615
616void MonthViewCell::updateConfig() 616void MonthViewCell::updateConfig()
617{ 617{
618 setFont( KOPrefs::instance()->mMonthViewFont ); 618 setFont( KOPrefs::instance()->mMonthViewFont );
619 619
620 QFontMetrics fm( font() ); 620 QFontMetrics fm( font() );
621 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 621 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
622 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 622 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
623 mHolidayPalette = mStandardPalette; 623 mHolidayPalette = mStandardPalette;
624 mPrimaryPalette = mStandardPalette; 624 mPrimaryPalette = mStandardPalette;
625 mNonPrimaryPalette = mStandardPalette; 625 mNonPrimaryPalette = mStandardPalette;
626 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 626 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
627 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 627 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
628 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 628 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
629 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 629 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
630 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 630 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
631 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 631 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
632 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 632 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
633 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 633 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
634 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 634 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
635 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 635 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
636 } 636 }
637 //updateCell(); 637 //updateCell();
638} 638}
639 639
640void MonthViewCell::enableScrollBars( bool enabled ) 640void MonthViewCell::enableScrollBars( bool enabled )
641{ 641{
642 if ( enabled ) { 642 if ( enabled ) {
643 mItemList->setVScrollBarMode(QScrollView::Auto); 643 mItemList->setVScrollBarMode(QScrollView::Auto);
644 mItemList->setHScrollBarMode(QScrollView::Auto); 644 mItemList->setHScrollBarMode(QScrollView::Auto);
645 } else { 645 } else {
646 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 646 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
647 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 647 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
648 } 648 }
649} 649}
650 650
651Incidence *MonthViewCell::selectedIncidence() 651Incidence *MonthViewCell::selectedIncidence()
652{ 652{
653 int index = mItemList->currentItem(); 653 int index = mItemList->currentItem();
654 if ( index < 0 ) return 0; 654 if ( index < 0 ) return 0;
655 655
656 MonthViewItem *item = 656 MonthViewItem *item =
657 static_cast<MonthViewItem *>( mItemList->item( index ) ); 657 static_cast<MonthViewItem *>( mItemList->item( index ) );
658 658
659 if ( !item ) return 0; 659 if ( !item ) return 0;
660 660
661 return item->incidence(); 661 return item->incidence();
662} 662}
663 663
664QDate MonthViewCell::selectedIncidenceDate() 664QDate MonthViewCell::selectedIncidenceDate()
665{ 665{
666 QDate qd; 666 QDate qd;
667 int index = mItemList->currentItem(); 667 int index = mItemList->currentItem();
668 if ( index < 0 ) return qd; 668 if ( index < 0 ) return qd;
669 669
670 MonthViewItem *item = 670 MonthViewItem *item =
671 static_cast<MonthViewItem *>( mItemList->item( index ) ); 671 static_cast<MonthViewItem *>( mItemList->item( index ) );
672 672
673 if ( !item ) return qd; 673 if ( !item ) return qd;
674 674
675 return item->incidenceDate(); 675 return item->incidenceDate();
676} 676}
677 677
678void MonthViewCell::deselect() 678void MonthViewCell::deselect()
679{ 679{
680 mItemList->clearSelection(); 680 mItemList->clearSelection();
681 enableScrollBars( false ); 681 enableScrollBars( false );
682 // updateCell(); 682 // updateCell();
683} 683}
684void MonthViewCell::select() 684void MonthViewCell::select()
685{ 685{
686 ;// updateCell(); 686 ;// updateCell();
687} 687}
688 688
689void MonthViewCell::resizeEvent ( QResizeEvent * ) 689void MonthViewCell::resizeEvent ( QResizeEvent * )
690{ 690{
691 if ( !mMonthView->isUpdatePossible() ) 691 if ( !mMonthView->isUpdatePossible() )
692 return; 692 return;
693 693
694 int size = height() - mLabel->height() - 2; 694 int size = height() - mLabel->height() - 2;
695 if ( size > 0 ) 695 if ( size > 0 )
696 mItemList->verticalScrollBar()->setMaximumHeight( size ); 696 mItemList->verticalScrollBar()->setMaximumHeight( size );
697 size = width() - mLabel->width() -2; 697 size = width() - mLabel->width() -2;
698 if ( size > 0 ) 698 if ( size > 0 )
699 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 699 mItemList->horizontalScrollBar()->setMaximumWidth( size );
700 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 700 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
701 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 701 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
702} 702}
703 703
704void MonthViewCell::defaultAction( QListBoxItem *item ) 704void MonthViewCell::defaultAction( QListBoxItem *item )
705{ 705{
706 if ( !item ) return; 706 if ( !item ) return;
707 707
708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
709 Incidence *incidence = eventItem->incidence(); 709 Incidence *incidence = eventItem->incidence();
710 if ( incidence ) mMonthView->defaultAction( incidence ); 710 if ( incidence ) mMonthView->defaultAction( incidence );
711} 711}
712void MonthViewCell::showDay() 712void MonthViewCell::showDay()
713{ 713{
714 emit showDaySignal( date() ); 714 emit showDaySignal( date() );
715} 715}
716void MonthViewCell::newEvent() 716void MonthViewCell::newEvent()
717{ 717{
718 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 718 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
719 emit newEventSignal( dt ); 719 emit newEventSignal( dt );
720} 720}
721void MonthViewCell::cellClicked( QListBoxItem *item ) 721void MonthViewCell::cellClicked( QListBoxItem *item )
722{ 722{
723 static QListBoxItem * lastClicked = 0; 723 static QListBoxItem * lastClicked = 0;
724 if ( item == 0 ) { 724 if ( item == 0 ) {
725 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 725 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
726 emit newEventSignal( dt ); 726 emit newEventSignal( dt );
727 return; 727 return;
728 } 728 }
729 /* 729 /*
730 if ( lastClicked ) 730 if ( lastClicked )
731 if ( ! item ) { 731 if ( ! item ) {
732 if ( lastClicked->listBox() != item->listBox() ) 732 if ( lastClicked->listBox() != item->listBox() )
733 lastClicked->listBox()->clearSelection(); 733 lastClicked->listBox()->clearSelection();
734 } 734 }
735 */ 735 */
736 736
737 mMonthView->setSelectedCell( this ); 737 mMonthView->setSelectedCell( this );
738 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 738 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
739 select(); 739 select();
740} 740}
741 741
742void MonthViewCell::contextMenu( QListBoxItem *item ) 742void MonthViewCell::contextMenu( QListBoxItem *item )
743{ 743{
744 if ( !item ) return; 744 if ( !item ) return;
745 745
746 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 746 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
747 Incidence *incidence = eventItem->incidence(); 747 Incidence *incidence = eventItem->incidence();
748 if ( incidence ) mMonthView->showContextMenu( incidence ); 748 if ( incidence ) mMonthView->showContextMenu( incidence );
749} 749}
750 750
751void MonthViewCell::selection( QListBoxItem *item ) 751void MonthViewCell::selection( QListBoxItem *item )
752{ 752{
753 if ( !item ) return; 753 if ( !item ) return;
754 754
755 mMonthView->setSelectedCell( this ); 755 mMonthView->setSelectedCell( this );
756} 756}
757 757
758 758
759// ******************************************************************************* 759// *******************************************************************************
760// ******************************************************************************* 760// *******************************************************************************
761// ******************************************************************************* 761// *******************************************************************************
762 762
763 763
764KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 764KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
765 : KOEventView( calendar, parent, name ), 765 : KOEventView( calendar, parent, name ),
766 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 766 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
767 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 767 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
768{ 768{
769 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 769 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
770 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 770 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
771 if ( mShowWeekView ) 771 if ( mShowWeekView )
772 mWeekStartsMonday = true; 772 mWeekStartsMonday = true;
773 updatePossible = false; 773 updatePossible = false;
774 mCells.setAutoDelete( true ); 774 mCells.setAutoDelete( true );
775 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 775 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
776 // mDayLayout = new QGridLayout( this ); 776 // mDayLayout = new QGridLayout( this );
777 // create the day of the week labels (Sun, Mon, etc) and add them to 777 // create the day of the week labels (Sun, Mon, etc) and add them to
778 // the layout. 778 // the layout.
779 mDayLabels.resize( mDaysPerWeek ); 779 mDayLabels.resize( mDaysPerWeek );
780 QFont bfont = font(); 780 QFont bfont = font();
781 if ( QApplication::desktop()->width() < 650 ) { 781 if ( QApplication::desktop()->width() < 650 ) {
782 bfont.setPointSize( bfont.pointSize() - 2 ); 782 bfont.setPointSize( bfont.pointSize() - 2 );
783 } 783 }
784 bfont.setBold( true ); 784 bfont.setBold( true );
785 int i; 785 int i;
786 786
787 for( i = 0; i < mDaysPerWeek; i++ ) { 787 for( i = 0; i < mDaysPerWeek; i++ ) {
788 QLabel *label = new QLabel( this ); 788 QLabel *label = new QLabel( this );
789 label->setFont(bfont); 789 label->setFont(bfont);
790 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 790 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
791 label->setLineWidth(1); 791 label->setLineWidth(1);
792 label->setAlignment(AlignCenter); 792 label->setAlignment(AlignCenter);
793 mDayLabels.insert( i, label ); 793 mDayLabels.insert( i, label );
794 } 794 }
795 795
796 bfont.setBold( false ); 796 bfont.setBold( false );
797 mWeekLabels.resize( mNumWeeks+1 ); 797 mWeekLabels.resize( mNumWeeks+1 );
798 for( i = 0; i < mNumWeeks+1; i++ ) { 798 for( i = 0; i < mNumWeeks+1; i++ ) {
799 KOWeekButton *label = new KOWeekButton( this ); 799 KOWeekButton *label = new KOWeekButton( this );
800 label->setFont(bfont); 800 label->setFont(bfont);
801 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 801 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
802 label->setFlat(true); 802 label->setFlat(true);
803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
805 //label->setLineWidth(1); 805 //label->setLineWidth(1);
806 //label->setAlignment(AlignCenter); 806 //label->setAlignment(AlignCenter);
807 mWeekLabels.insert( i, label ); 807 mWeekLabels.insert( i, label );
808 } 808 }
809 mWeekLabels[mNumWeeks]->setText( i18n("")); 809 mWeekLabels[mNumWeeks]->setText( i18n(""));
810 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 810 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
811 int row, col; 811 int row, col;
812 QPopupMenu * wpo = new QPopupMenu (this);
813 wpo->insertItem( i18n("W#"), 0 );
814 for ( i = 1; i < 54; i++ )
815 wpo->insertItem( i18n("%1").arg(i), i );
816 mWeekLabels[mNumWeeks]->setPopup( wpo );
817 mCells.resize( mNumCells ); 812 mCells.resize( mNumCells );
818 for( row = 0; row < mNumWeeks; ++row ) { 813 for( row = 0; row < mNumWeeks; ++row ) {
819 for( col = 0; col < mDaysPerWeek; ++col ) { 814 for( col = 0; col < mDaysPerWeek; ++col ) {
820 MonthViewCell *cell = new MonthViewCell( this ); 815 MonthViewCell *cell = new MonthViewCell( this );
821 mCells.insert( row * mDaysPerWeek + col, cell ); 816 mCells.insert( row * mDaysPerWeek + col, cell );
822 817
823 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 818 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
824 SLOT( defaultAction( Incidence * ) ) ); 819 SLOT( defaultAction( Incidence * ) ) );
825 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 820 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
826 SIGNAL( newEventSignal( QDateTime ) ) ); 821 SIGNAL( newEventSignal( QDateTime ) ) );
827 connect( cell, SIGNAL( showDaySignal( QDate ) ), 822 connect( cell, SIGNAL( showDaySignal( QDate ) ),
828 SIGNAL( showDaySignal( QDate ) ) ); 823 SIGNAL( showDaySignal( QDate ) ) );
829 } 824 }
830 } 825 }
831 826
832 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 827 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
833 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
834 mContextMenu = eventPopup(); 828 mContextMenu = eventPopup();
835 // updateConfig(); //useless here 829 // updateConfig(); //useless here
836 830
831 mWeekLabels[mNumWeeks]->setText( i18n("W"));
837 emit incidenceSelected( 0 ); 832 emit incidenceSelected( 0 );
838} 833}
839 834
840KOMonthView::~KOMonthView() 835KOMonthView::~KOMonthView()
841{ 836{
842 delete mContextMenu; 837 delete mContextMenu;
843} 838}
844void KOMonthView::selectDateWeekNum ( int ) 839void KOMonthView::selectDateWeekNum ( int )
845{ 840{
846 841
847} 842}
848void KOMonthView::selectInternalWeekNum ( int n ) 843void KOMonthView::selectInternalWeekNum ( int n )
849{ 844{
850 emit selectWeekNum ( n ); 845 emit selectWeekNum ( n );
851 switchView(); 846 switchView();
852} 847}
853 848
854void KOMonthView::switchView() 849void KOMonthView::switchView()
855{ 850{
856 if ( selectedCell( ) ) 851 if ( selectedCell( ) )
857 selectedCell()->deselect(); 852 selectedCell()->deselect();
858 mShowWeekView = !mShowWeekView; 853 mShowWeekView = !mShowWeekView;
859 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 854 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
860 //emit showNavigator( !mShowWeekView ); 855 //emit showNavigator( !mShowWeekView );
861 computeLayout(); 856 computeLayout();
862 updateConfig(); 857 updateConfig();
863} 858}
864 859
865int KOMonthView::maxDatesHint() 860int KOMonthView::maxDatesHint()
866{ 861{
867 return mNumCells; 862 return mNumCells;
868} 863}
869 864
870int KOMonthView::currentDateCount() 865int KOMonthView::currentDateCount()
871{ 866{
872 return mNumCells; 867 return mNumCells;
873} 868}
874 869
875QPtrList<Incidence> KOMonthView::selectedIncidences() 870QPtrList<Incidence> KOMonthView::selectedIncidences()
876{ 871{
877 QPtrList<Incidence> selected; 872 QPtrList<Incidence> selected;
878 873
879 if ( mSelectedCell ) { 874 if ( mSelectedCell ) {
880 Incidence *incidence = mSelectedCell->selectedIncidence(); 875 Incidence *incidence = mSelectedCell->selectedIncidence();
881 if ( incidence ) selected.append( incidence ); 876 if ( incidence ) selected.append( incidence );
882 } 877 }
883 878
884 return selected; 879 return selected;
885} 880}
886 881
887DateList KOMonthView::selectedDates() 882DateList KOMonthView::selectedDates()
888{ 883{
889 DateList selected; 884 DateList selected;
890 885
891 if ( mSelectedCell ) { 886 if ( mSelectedCell ) {
892 QDate qd = mSelectedCell->selectedIncidenceDate(); 887 QDate qd = mSelectedCell->selectedIncidenceDate();
893 if ( qd.isValid() ) selected.append( qd ); 888 if ( qd.isValid() ) selected.append( qd );
894 } 889 }
895 890
896 return selected; 891 return selected;
897} 892}
898 893
899void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 894void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
900 const QDate &td) 895 const QDate &td)
901{ 896{
902#ifndef KORG_NOPRINTER 897#ifndef KORG_NOPRINTER
903 calPrinter->preview(CalPrinter::Month, fd, td); 898 calPrinter->preview(CalPrinter::Month, fd, td);
904#endif 899#endif
905} 900}
906 901
907void KOMonthView::updateConfig() 902void KOMonthView::updateConfig()
908{ 903{
909 904
910 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 905 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
911 906
912 if ( mShowWeekView ) { 907 if ( mShowWeekView ) {
913 mWeekStartsMonday = true; 908 mWeekStartsMonday = true;
914 } 909 }
915 QFontMetrics fontmetric(mDayLabels[0]->font()); 910 QFontMetrics fontmetric(mDayLabels[0]->font());
916 mWidthLongDayLabel = 0; 911 mWidthLongDayLabel = 0;
917 912
918 for (int i = 0; i < 7; i++) { 913 for (int i = 0; i < 7; i++) {
919 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
920 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
921 } 916 }
922 bool temp = mShowSatSunComp ; 917 bool temp = mShowSatSunComp ;
923 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 918 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
924 if ( ! mShowWeekView ) { 919 if ( ! mShowWeekView ) {
925 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 920 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
926 computeLayout(); 921 computeLayout();
927 } 922 }
928 updateDayLabels(); 923 updateDayLabels();
929 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 924 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
930 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 925 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
931 //resizeEvent( 0 ); 926 //resizeEvent( 0 );
932 for (uint i = 0; i < mCells.count(); ++i) { 927 for (uint i = 0; i < mCells.count(); ++i) {
933 mCells[i]->updateConfig(); 928 mCells[i]->updateConfig();
934 } 929 }
935#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
936 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 931 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
937#endif 932#endif
938 updateView(); 933 updateView();
939} 934}
940 935
941void KOMonthView::updateDayLabels() 936void KOMonthView::updateDayLabels()
942{ 937{
943 938
944 for (int i = 0; i < 7; i++) { 939 for (int i = 0; i < 7; i++) {
945 if (mWeekStartsMonday) { 940 if (mWeekStartsMonday) {
946 bool show = mShortDayLabels; 941 bool show = mShortDayLabels;
947 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 942 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
948 show = true; 943 show = true;
949 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 944 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
950 } else { 945 } else {
951 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 946 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
952 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 947 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
953 948
954 } 949 }
955 } 950 }
956} 951}
957 952
958void KOMonthView::showDates(const QDate &start, const QDate &) 953void KOMonthView::showDates(const QDate &start, const QDate &)
959{ 954{
960 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 955 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
961 956
962 957
963 mStartDate = start; 958 mStartDate = start;
964 959
965 int startWeekDay = mWeekStartsMonday ? 1 : 7; 960 int startWeekDay = mWeekStartsMonday ? 1 : 7;
966 961
967 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 962 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
968 mStartDate = mStartDate.addDays( -1 ); 963 mStartDate = mStartDate.addDays( -1 );
969 } 964 }
970 965
971 bool primary = false; 966 bool primary = false;
972 uint i; 967 uint i;
973 for( i = 0; i < mCells.size(); ++i ) { 968 for( i = 0; i < mCells.size(); ++i ) {
974 QDate date = mStartDate.addDays( i ); 969 QDate date = mStartDate.addDays( i );
975 mCells[i]->setDate( date ); 970 mCells[i]->setDate( date );
976 971
977#ifndef KORG_NOPLUGINS 972#ifndef KORG_NOPLUGINS
978 // add holiday, if present 973 // add holiday, if present
979 QString hstring(KOCore::self()->holiday(date)); 974 QString hstring(KOCore::self()->holiday(date));
980 mCells[i]->setHoliday( hstring ); 975 mCells[i]->setHoliday( hstring );
981#endif 976#endif
982 977
983 } 978 }
984 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 979 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
985 for( i = 0; i < 6; ++i ) { 980 for( i = 0; i < 6; ++i ) {
986 int wno; 981 int wno;
987 // remember, according to ISO 8601, the first week of the year is the 982 // remember, according to ISO 8601, the first week of the year is the
988 // first week that contains a thursday. Thus we must subtract off 4, 983 // first week that contains a thursday. Thus we must subtract off 4,
989 // not just 1. 984 // not just 1.
990 int dayOfYear = date.dayOfYear(); 985 int dayOfYear = date.dayOfYear();
991 if (dayOfYear % 7 != 0) 986 if (dayOfYear % 7 != 0)
992 wno = dayOfYear / 7 + 1; 987 wno = dayOfYear / 7 + 1;
993 else 988 else
994 wno =dayOfYear / 7; 989 wno =dayOfYear / 7;
995 mWeekLabels[i]->setWeekNum( wno ); 990 mWeekLabels[i]->setWeekNum( wno );
996 date = date.addDays( 7 ); 991 date = date.addDays( 7 );
997 } 992 }
998 updateView(); 993 updateView();
999} 994}
1000 995
1001void KOMonthView::showEvents(QPtrList<Event>) 996void KOMonthView::showEvents(QPtrList<Event>)
1002{ 997{
1003 qDebug("KOMonthView::selectEvents is not implemented yet. "); 998 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1004} 999}
1005 1000
1006void KOMonthView::changeEventDisplay(Event *, int) 1001void KOMonthView::changeEventDisplay(Event *, int)
1007{ 1002{
1008 // this should be re-written to be much more efficient, but this 1003 // this should be re-written to be much more efficient, but this
1009 // quick-and-dirty-hack gets the job done for right now. 1004 // quick-and-dirty-hack gets the job done for right now.
1010 updateView(); 1005 updateView();
1011} 1006}
1012 1007
1013void KOMonthView::updateView() 1008void KOMonthView::updateView()
1014{ 1009{
1015 1010
1016 if ( !updatePossible ) 1011 if ( !updatePossible )
1017 return; 1012 return;
1018 //QTime ti; 1013 //QTime ti;
1019 //ti.start(); 1014 //ti.start();
1020#if 1 1015#if 1
1021 int i; 1016 int i;
1022 int timeSpan = mCells.size()-1; 1017 int timeSpan = mCells.size()-1;
1023 if ( KOPrefs::instance()->mMonthViewWeek ) 1018 if ( KOPrefs::instance()->mMonthViewWeek )
1024 timeSpan = 6; 1019 timeSpan = 6;
1025 for( i = 0; i < timeSpan + 1; ++i ) { 1020 for( i = 0; i < timeSpan + 1; ++i ) {
1026 mCells[i]->startUpdateCell(); 1021 mCells[i]->startUpdateCell();
1027 } 1022 }
1028 1023
1029 QPtrList<Event> events = calendar()->events(); 1024 QPtrList<Event> events = calendar()->events();
1030 Event *event; 1025 Event *event;
1031 QDateTime dt; 1026 QDateTime dt;
1032 bool ok; 1027 bool ok;
1033 QDate endDate = mStartDate.addDays( timeSpan ); 1028 QDate endDate = mStartDate.addDays( timeSpan );
1034 for( event = events.first(); event; event = events.next() ) { // for event 1029 for( event = events.first(); event; event = events.next() ) { // for event
1035 if ( event->doesRecur() ) { 1030 if ( event->doesRecur() ) {
1036 bool last; 1031 bool last;
1037 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1032 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1038 QDateTime incidenceEnd; 1033 QDateTime incidenceEnd;
1039 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1034 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1040 bool invalid = false; 1035 bool invalid = false;
1041 while( true ) { 1036 while( true ) {
1042 if ( incidenceStart.isValid() ) { 1037 if ( incidenceStart.isValid() ) {
1043 incidenceEnd = incidenceStart.addDays( eventlen ); 1038 incidenceEnd = incidenceStart.addDays( eventlen );
1044 int st = incidenceStart.date().daysTo( endDate ); 1039 int st = incidenceStart.date().daysTo( endDate );
1045 if ( st >= 0 ) { // start before timeend 1040 if ( st >= 0 ) { // start before timeend
1046 int end = mStartDate.daysTo( incidenceEnd.date() ); 1041 int end = mStartDate.daysTo( incidenceEnd.date() );
1047 if ( end >= 0 ) { // end after timestart --- got one! 1042 if ( end >= 0 ) { // end after timestart --- got one!
1048 //normalize 1043 //normalize
1049 st = timeSpan - st; 1044 st = timeSpan - st;
1050 if ( st < 0 ) st = 0; 1045 if ( st < 0 ) st = 0;
1051 if ( end > timeSpan ) end = timeSpan; 1046 if ( end > timeSpan ) end = timeSpan;
1052 int iii; 1047 int iii;
1053 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1048 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1054 for ( iii = st;iii<= end;++iii) 1049 for ( iii = st;iii<= end;++iii)
1055 mCells[iii]->insertEvent( event ); 1050 mCells[iii]->insertEvent( event );
1056 } 1051 }
1057 } 1052 }
1058 } else { 1053 } else {
1059 if ( invalid ) 1054 if ( invalid )
1060 break; 1055 break;
1061 invalid = true; 1056 invalid = true;
1062 //qDebug("invalid %s", event->summary().latin1()); 1057 //qDebug("invalid %s", event->summary().latin1());
1063 incidenceStart = QDateTime( mStartDate ); 1058 incidenceStart = QDateTime( mStartDate );
1064 } 1059 }
1065 if ( last ) 1060 if ( last )
1066 break; 1061 break;
1067 bool ok; 1062 bool ok;
1068 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1063 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1069 if ( ! ok ) 1064 if ( ! ok )
1070 break; 1065 break;
1071 if ( incidenceStart.date() > endDate ) 1066 if ( incidenceStart.date() > endDate )
1072 break; 1067 break;
1073 } 1068 }
1074 } else { // no recur 1069 } else { // no recur
1075 int st = event->dtStart().date().daysTo( endDate ); 1070 int st = event->dtStart().date().daysTo( endDate );
1076 if ( st >= 0 ) { // start before timeend 1071 if ( st >= 0 ) { // start before timeend
1077 int end = mStartDate.daysTo( event->dtEnd().date() ); 1072 int end = mStartDate.daysTo( event->dtEnd().date() );
1078 if ( end >= 0 ) { // end after timestart --- got one! 1073 if ( end >= 0 ) { // end after timestart --- got one!
1079 //normalize 1074 //normalize
1080 st = timeSpan - st; 1075 st = timeSpan - st;
1081 if ( st < 0 ) st = 0; 1076 if ( st < 0 ) st = 0;
1082 if ( end > timeSpan ) end = timeSpan; 1077 if ( end > timeSpan ) end = timeSpan;
1083 int iii; 1078 int iii;
1084 for ( iii = st;iii<= end;++iii) 1079 for ( iii = st;iii<= end;++iii)
1085 mCells[iii]->insertEvent( event ); 1080 mCells[iii]->insertEvent( event );
1086 } 1081 }
1087 } 1082 }
1088 } 1083 }
1089 } 1084 }
1090 // insert due todos 1085 // insert due todos
1091 QPtrList<Todo> todos = calendar()->todos( ); 1086 QPtrList<Todo> todos = calendar()->todos( );
1092 Todo *todo; 1087 Todo *todo;
1093 for(todo = todos.first(); todo; todo = todos.next()) { 1088 for(todo = todos.first(); todo; todo = todos.next()) {
1094 //insertTodo( todo ); 1089 //insertTodo( todo );
1095 if ( todo->hasDueDate() ) { 1090 if ( todo->hasDueDate() ) {
1096 int day = mStartDate.daysTo( todo->dtDue().date() ); 1091 int day = mStartDate.daysTo( todo->dtDue().date() );
1097 if ( day >= 0 && day < timeSpan + 1) { 1092 if ( day >= 0 && day < timeSpan + 1) {
1098 mCells[day]->insertTodo( todo ); 1093 mCells[day]->insertTodo( todo );
1099 } 1094 }
1100 } 1095 }
1101 } 1096 }
1102 1097
1103 for( i = 0; i < timeSpan+1; ++i ) { 1098 for( i = 0; i < timeSpan+1; ++i ) {
1104 mCells[i]->finishUpdateCell(); 1099 mCells[i]->finishUpdateCell();
1105 } 1100 }
1106 processSelectionChange(); 1101 processSelectionChange();
1107 mCells[0]->setFocus(); 1102 mCells[0]->setFocus();
1108 1103
1109 1104
1110#else 1105#else
1111 // old code 1106 // old code
1112 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1107 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1113 int i; 1108 int i;
1114 for( i = 0; i < mCells.count(); ++i ) { 1109 for( i = 0; i < mCells.count(); ++i ) {
1115 mCells[i]->updateCell(); 1110 mCells[i]->updateCell();
1116 } 1111 }
1117 1112
1118 //qDebug("KOMonthView::updateView() "); 1113 //qDebug("KOMonthView::updateView() ");
1119 processSelectionChange(); 1114 processSelectionChange();
1120 // qDebug("---------------------------------------------------------------------+ "); 1115 // qDebug("---------------------------------------------------------------------+ ");
1121 mCells[0]->setFocus(); 1116 mCells[0]->setFocus();
1122#endif 1117#endif
1123 1118
1124 //qDebug("update time %d ", ti.elapsed()); 1119 //qDebug("update time %d ", ti.elapsed());
1125} 1120}
1126 1121
1127void KOMonthView::resizeEvent(QResizeEvent * e) 1122void KOMonthView::resizeEvent(QResizeEvent * e)
1128{ 1123{
1129 computeLayout(); 1124 computeLayout();
1130 mCells[0]->setFocus(); 1125 mCells[0]->setFocus();
1131} 1126}
1132void KOMonthView::computeLayoutWeek() 1127void KOMonthView::computeLayoutWeek()
1133{ 1128{
1134 1129
1135 int daysToShow; 1130 int daysToShow;
1136 bool combinedSatSun = false; 1131 bool combinedSatSun = false;
1137 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1132 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1138 daysToShow = 6; 1133 daysToShow = 6;
1139 combinedSatSun = true; 1134 combinedSatSun = true;
1140 } 1135 }
1141 int tWid = topLevelWidget()->size().width(); 1136 int tWid = topLevelWidget()->size().width();
1142 int tHei = topLevelWidget()->size().height(); 1137 int tHei = topLevelWidget()->size().height();
1143 1138
1144 int wid = size().width();//e 1139 int wid = size().width();//e
1145 int hei = size().height()-1; 1140 int hei = size().height()-1;
1146 1141
1147 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1142 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1148 return; 1143 return;
1149 1144
1150 if ( wid < hei ) 1145 if ( wid < hei )
1151 daysToShow = 2; 1146 daysToShow = 2;
1152 else 1147 else
1153 daysToShow = 3; 1148 daysToShow = 3;
1154 mShowSatSunComp = true; 1149 mShowSatSunComp = true;
1155 combinedSatSun = true; 1150 combinedSatSun = true;
1156 1151
1157 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1152 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1158 QFontMetrics fm ( mWeekLabels[0]->font() ); 1153 QFontMetrics fm ( mWeekLabels[0]->font() );
1159 int weeklabelwid = fm.width( "888" ); 1154 int weeklabelwid = fm.width( "888" );
1160 wid -= weeklabelwid; 1155 wid -= weeklabelwid;
1161 1156
1162 int colWid = wid / daysToShow; 1157 int colWid = wid / daysToShow;
1163 int lastCol = wid - ( colWid*6 ); 1158 int lastCol = wid - ( colWid*6 );
1164 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1159 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1165 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1160 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1166 int colModulo = wid % daysToShow; 1161 int colModulo = wid % daysToShow;
1167 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1162 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1168 //qDebug("rowmod %d ", rowModulo); 1163 //qDebug("rowmod %d ", rowModulo);
1169 int i; 1164 int i;
1170 int x,y,w,h; 1165 int x,y,w,h;
1171 x= 0; 1166 x= 0;
1172 y= 0; 1167 y= 0;
1173 w = colWid; 1168 w = colWid;
1174 h = dayLabelHei ; 1169 h = dayLabelHei ;
1175 for ( i = 0; i < 7; i++) { 1170 for ( i = 0; i < 7; i++) {
1176 if ( i && !( i % daysToShow) && i < 6) { 1171 if ( i && !( i % daysToShow) && i < 6) {
1177 y += hei/(5-daysToShow); 1172 y += hei/(5-daysToShow);
1178 x = 0; 1173 x = 0;
1179 w = colWid; 1174 w = colWid;
1180 } 1175 }
1181 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1176 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1182 ++w; 1177 ++w;
1183 } 1178 }
1184 if ( i >= 5 ) { 1179 if ( i >= 5 ) {
1185 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1180 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1186 x -= (w/2 ); 1181 x -= (w/2 );
1187 } 1182 }
1188 else 1183 else
1189 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1184 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1190 x += w; 1185 x += w;
1191 } 1186 }
1192 x= 0; 1187 x= 0;
1193 y= dayLabelHei; 1188 y= dayLabelHei;
1194 w = colWid; 1189 w = colWid;
1195 h = cellHei; 1190 h = cellHei;
1196 for ( i = 0; i < mCells.count(); ++i) { 1191 for ( i = 0; i < mCells.count(); ++i) {
1197 if ( i > 6 ) { 1192 if ( i > 6 ) {
1198 mCells[i]->hide(); 1193 mCells[i]->hide();
1199 continue; 1194 continue;
1200 } 1195 }
1201 1196
1202 w = colWid; 1197 w = colWid;
1203 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1198 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1204 ++w; 1199 ++w;
1205 } 1200 }
1206 if ( i == (daysToShow-1-rowModulo)*7) 1201 if ( i == (daysToShow-1-rowModulo)*7)
1207 ++h; 1202 ++h;
1208 1203
1209 if ( i >= 5 ) { 1204 if ( i >= 5 ) {
1210 if ( i ==5 ) { 1205 if ( i ==5 ) {
1211 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1206 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1212 x -= w ;y += h/2; 1207 x -= w ;y += h/2;
1213 } else { 1208 } else {
1214 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1209 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1215 ++w; 1210 ++w;
1216 } 1211 }
1217 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1212 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1218 y -= h/2; 1213 y -= h/2;
1219 } 1214 }
1220 } else 1215 } else
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index f339c67..2406bb5 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,198 +1,228 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpopupmenu.h>
31#include <qapplication.h> 32#include <qapplication.h>
32 33
33#include <kdebug.h> 34#include <kdebug.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kglobal.h> 36#include <kglobal.h>
36#include <kiconloader.h> 37#include <kiconloader.h>
37#include "libkdepim/kdatepicker.h" 38#include "libkdepim/kdatepicker.h"
38#include <knotifyclient.h> 39#include <knotifyclient.h>
39#include "kdatetbl.h" 40#include "kdatetbl.h"
40 41
41#include "koglobals.h" 42#include "koglobals.h"
42#include "koprefs.h" 43#include "koprefs.h"
43#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
44#include "kocore.h" 45#include "kocore.h"
45#endif 46#endif
46 47
47#include <kcalendarsystem.h> 48#include <kcalendarsystem.h>
48 49
49#include "navigatorbar.h" 50#include "navigatorbar.h"
50 51
51NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 52NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
52 : QWidget( parent, name ) 53 : QWidget( parent, name )
53{ 54{
54 QBoxLayout *topLayout = new QHBoxLayout( this ); 55 QBoxLayout *topLayout = new QHBoxLayout( this );
55 56
56 // Set up the control buttons and date label 57 // Set up the control buttons and date label
57 mCtrlFrame = new QFrame( this ); 58 mCtrlFrame = new QFrame( this );
58 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 59 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
59 mCtrlFrame->setLineWidth(1); 60 mCtrlFrame->setLineWidth(1);
60 61
61 topLayout->addWidget( mCtrlFrame ); 62 topLayout->addWidget( mCtrlFrame );
62 63
63 QFont tfont = font(); 64 QFont tfont = font();
64 if ( QApplication::desktop()->width() >= 480 ) 65 if ( QApplication::desktop()->width() >= 480 )
65 tfont.setPointSize(tfont.pointSize()+2); 66 tfont.setPointSize(tfont.pointSize()+2);
66 tfont.setBold(true); 67 tfont.setBold(true);
67 68
68 bool isRTL = KOGlobals::self()->reverseLayout(); 69 bool isRTL = KOGlobals::self()->reverseLayout();
69#ifndef DESKTOP_VERSION 70#ifndef DESKTOP_VERSION
70 bool isDesktop = false; 71 bool isDesktop = false;
71#else 72#else
72 bool isDesktop = true; 73 bool isDesktop = true;
73#endif 74#endif
74 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 75 bool insertWeek = (QString ( name ) == QString("useBigPixmaps")) ;
76 if ( insertWeek && QApplication::desktop()->width() > 320 )
75 isDesktop = true; 77 isDesktop = true;
76 // Create backward navigation buttons 78 // Create backward navigation buttons
77 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
78 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
79 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
80 82
81 mPrevMonth = new QPushButton( mCtrlFrame ); 83 mPrevMonth = new QPushButton( mCtrlFrame );
82 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
83 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 85 QToolTip::add( mPrevMonth, i18n("Previous Month") );
84 86
85 // Create forward navigation buttons 87 // Create forward navigation buttons
86 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
87 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
88 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
89 91
92 QPushButton * selWeek = 0;
93 if ( insertWeek ) {
94 selWeek = new QPushButton( mCtrlFrame );
95 QToolTip::add( selWeek, i18n("Select Week") );
96 selWeek->setFocusPolicy(NoFocus);
97 }
98
90 mNextYear = new QPushButton( mCtrlFrame ); 99 mNextYear = new QPushButton( mCtrlFrame );
91 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 100 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
92 QToolTip::add( mNextYear, i18n("Next Year") ); 101 QToolTip::add( mNextYear, i18n("Next Year") );
93 mSelectMonth = new QPushButton( mCtrlFrame ); 102 mSelectMonth = new QPushButton( mCtrlFrame );
94 // Create month name label 103 // Create month name label
95 //selectMonth->setFont( tfont ); 104 //selectMonth->setFont( tfont );
96 // selectMonth->setAlignment( AlignCenter ); 105 // selectMonth->setAlignment( AlignCenter );
97 //mDateLabel = new QLabel( selectMonth ); 106 //mDateLabel = new QLabel( selectMonth );
98 //mDateLabel->setFont( tfont ); 107 //mDateLabel->setFont( tfont );
99 //mDateLabel->setAlignment( AlignCenter ); 108 //mDateLabel->setAlignment( AlignCenter );
100 if ( QString ( name ) == QString("useBigPixmaps") ) { 109 if ( QString ( name ) == QString("useBigPixmaps") ) {
101 mNextMonth->setFlat( true); 110 mNextMonth->setFlat( true);
102 mNextYear->setFlat( true); 111 mNextYear->setFlat( true);
103 mSelectMonth->setFlat( true); 112 mSelectMonth->setFlat( true);
104 mPrevYear->setFlat( true); 113 mPrevYear->setFlat( true);
105 mPrevMonth->setFlat( true); 114 mPrevMonth->setFlat( true);
115 if ( insertWeek )
116 selWeek->setFlat( true);
106 } 117 }
107 mSelectMonth->setFont( tfont ); 118 mSelectMonth->setFont( tfont );
108 // Set minimum width to width of widest month name label 119 // Set minimum width to width of widest month name label
109 int i; 120 int i;
110 int maxwidth = 0; 121 int maxwidth = 0;
111 QFontMetrics fm ( mSelectMonth->font() ); 122 QFontMetrics fm ( mSelectMonth->font() );
112 int width = fm.width("September '00" ); 123 int width = fm.width("September '00" );
113// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 124// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
114// ++i ) { 125// ++i ) {
115// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 126// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
116// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 127// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
117// int width = fm.width("September 2000" ); 128// int width = fm.width("September 2000" );
118// if ( width > maxwidth ) maxwidth = width; 129// if ( width > maxwidth ) maxwidth = width;
119// } 130// }
120 maxwidth = width+2; 131 maxwidth = width+2;
121 int size = fm.height()+2; 132 int size = fm.height()+2;
122 if ( QApplication::desktop()->width() >= 480 ) { 133 if ( QApplication::desktop()->width() >= 480 ) {
123 size += 6; 134 size += 6;
124 maxwidth+= 6; 135 maxwidth+= 6;
125 } 136 }
137
138 if ( insertWeek ) {
139 //shit : bug in Qt. after inserting 53 item, only 51 are shown...
140 QPopupMenu * wpo = new QPopupMenu (this);
141 wpo->insertItem( i18n("W#"), 0 );
142 for ( i = 1; i < 53; ++i ) {
143 wpo->insertItem( QString::number(i), i );
144 }
145 for ( i = 53; i < 54; ++i ) {
146 wpo->insertItem( "", 52 );
147 }
148 selWeek->setPopup( wpo );
149 selWeek->setFixedWidth( (size/4)*3 );
150 selWeek->setFixedHeight( size );
151 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) );
152 }
126 mSelectMonth->setFixedWidth( maxwidth ); 153 mSelectMonth->setFixedWidth( maxwidth );
127 mSelectMonth->setFixedHeight( size ); 154 mSelectMonth->setFixedHeight( size );
128 mPrevYear->setFixedHeight( size ); 155 mPrevYear->setFixedHeight( size );
129 mPrevMonth->setFixedHeight( size ); 156 mPrevMonth->setFixedHeight( size );
130 mNextMonth->setFixedHeight( size ); 157 mNextMonth->setFixedHeight( size );
131 mNextYear->setFixedHeight ( size ); 158 mNextYear->setFixedHeight ( size );
132 // set up control frame layout 159 // set up control frame layout
133 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 160 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
134 ctrlLayout->addWidget( mPrevYear, 3 ); 161 ctrlLayout->addWidget( mPrevYear, 3 );
135 ctrlLayout->addWidget( mPrevMonth, 3 ); 162 ctrlLayout->addWidget( mPrevMonth, 3 );
136 //ctrlLayout->addStretch( 1 ); 163 //ctrlLayout->addStretch( 1 );
137 // ctrlLayout->addSpacing( 1 ); 164 // ctrlLayout->addSpacing( 1 );
138 // ctrlLayout->addWidget( mDateLabel ); 165 // ctrlLayout->addWidget( mDateLabel );
139 ctrlLayout->addWidget( mSelectMonth ); 166 ctrlLayout->addWidget( mSelectMonth );
140 // ctrlLayout->addSpacing( 1 ); 167 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addStretch( 1 ); 168 // ctrlLayout->addStretch( 1 );
142 ctrlLayout->addWidget( mNextMonth, 3 ); 169 ctrlLayout->addWidget( mNextMonth, 3 );
143 ctrlLayout->addWidget( mNextYear, 3 ); 170 ctrlLayout->addWidget( mNextYear, 3 );
171 if ( insertWeek )
172 ctrlLayout->addWidget( selWeek );
144 173
145 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 174 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
146 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 175 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
147 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 176 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
148 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 177 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
149 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 178 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
150 mPrevYear->setFocusPolicy(NoFocus); 179 mPrevYear->setFocusPolicy(NoFocus);
151 mPrevMonth->setFocusPolicy(NoFocus); 180 mPrevMonth->setFocusPolicy(NoFocus);
152 mNextMonth->setFocusPolicy(NoFocus); 181 mNextMonth->setFocusPolicy(NoFocus);
153 mNextYear->setFocusPolicy(NoFocus); 182 mNextYear->setFocusPolicy(NoFocus);
154 mSelectMonth->setFocusPolicy(NoFocus); 183 mSelectMonth->setFocusPolicy(NoFocus);
184
155} 185}
156 186
157NavigatorBar::~NavigatorBar() 187NavigatorBar::~NavigatorBar()
158{ 188{
159} 189}
160 190
161void NavigatorBar::selectMonth() 191void NavigatorBar::selectMonth()
162{ 192{
163 193
164 int month; 194 int month;
165 KPopupFrame* popup = new KPopupFrame(this); 195 KPopupFrame* popup = new KPopupFrame(this);
166 int size = 12; 196 int size = 12;
167 if ( QApplication::desktop()->width() >= 480 ) 197 if ( QApplication::desktop()->width() >= 480 )
168 size = 18; 198 size = 18;
169 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); 199 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
170 // ----- 200 // -----
171 picker->resize(picker->sizeHint()); 201 picker->resize(picker->sizeHint());
172 popup->setMainWidget(picker); 202 popup->setMainWidget(picker);
173 picker->setFocus(); 203 picker->setFocus();
174 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 204 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
175 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 205 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
176 { 206 {
177 month = picker->getResult(); 207 month = picker->getResult();
178 emit monthSelected ( month ); 208 emit monthSelected ( month );
179 } else { 209 } else {
180 KNotifyClient::beep(); 210 KNotifyClient::beep();
181 } 211 }
182 delete popup; 212 delete popup;
183} 213}
184void NavigatorBar::selectDates( const KCal::DateList &dateList ) 214void NavigatorBar::selectDates( const KCal::DateList &dateList )
185{ 215{
186 if (dateList.count() > 0) { 216 if (dateList.count() > 0) {
187 QDate date = dateList.first(); 217 QDate date = dateList.first();
188 218
189 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 219 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
190 220
191 // compute the label at the top of the navigator 221 // compute the label at the top of the navigator
192 QString dtstr = i18n(calSys->monthName( date )) + " '" + 222 QString dtstr = i18n(calSys->monthName( date )) + " '" +
193 QString::number( calSys->year( date ) ).right(2); 223 QString::number( calSys->year( date ) ).right(2);
194 224
195 mSelectMonth->setText( dtstr ); 225 mSelectMonth->setText( dtstr );
196 } 226 }
197} 227}
198 228
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h
index 9c5c0cf..ee4c06d 100644
--- a/korganizer/navigatorbar.h
+++ b/korganizer/navigatorbar.h
@@ -1,66 +1,66 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef NAVIGATORBAR_H 24#ifndef NAVIGATORBAR_H
25#define NAVIGATORBAR_H 25#define NAVIGATORBAR_H
26 26
27#include <libkcal/incidencebase.h> 27#include <libkcal/incidencebase.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class QPushButton; 31class QPushButton;
32class QFrame; 32class QFrame;
33class QLabel; 33class QLabel;
34 34
35class NavigatorBar: public QWidget 35class NavigatorBar: public QWidget
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); 39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 );
40 ~NavigatorBar(); 40 ~NavigatorBar();
41 41
42 public slots: 42 public slots:
43 void selectDates( const KCal::DateList & ); 43 void selectDates( const KCal::DateList & );
44 void selectMonth(); 44 void selectMonth();
45 45
46 signals: 46 signals:
47 void goNextMonth(); 47 void goNextMonth();
48 void goPrevMonth(); 48 void goPrevMonth();
49 void goNextYear(); 49 void goNextYear();
50 void goPrevYear(); 50 void goPrevYear();
51 void monthSelected( int ); 51 void monthSelected( int );
52 52 void selectWeek( int );
53 53
54 private: 54 private:
55 QFrame *mCtrlFrame; 55 QFrame *mCtrlFrame;
56 56
57 QPushButton *mPrevYear; 57 QPushButton *mPrevYear;
58 QPushButton *mPrevMonth; 58 QPushButton *mPrevMonth;
59 QPushButton *mNextMonth; 59 QPushButton *mNextMonth;
60 QPushButton *mNextYear; 60 QPushButton *mNextYear;
61 QPushButton *mSelectMonth; 61 QPushButton *mSelectMonth;
62 62
63 //QLabel *mDateLabel; 63 //QLabel *mDateLabel;
64}; 64};
65 65
66#endif 66#endif