summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-08 23:15:22 (UTC)
committer zautrix <zautrix>2005-02-08 23:15:22 (UTC)
commitd0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a (patch) (unidiff)
tree751d52e216392132e8ad36ba9e8a23ae64083951
parent2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6 (diff)
downloadkdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.zip
kdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.tar.gz
kdepimpi-d0ab37d35ca9a9d919c9fc4856f3314bfef6dd5a.tar.bz2
fff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--desktop/rpm/kdepim_rpm2
-rw-r--r--korganizer/komonthview.cpp7
-rw-r--r--korganizer/kotodoviewitem.cpp11
-rw-r--r--microkde/kdatetbl.cpp2
-rw-r--r--version2
5 files changed, 14 insertions, 10 deletions
diff --git a/desktop/rpm/kdepim_rpm b/desktop/rpm/kdepim_rpm
index 4c53aac..b7f00ed 100644
--- a/desktop/rpm/kdepim_rpm
+++ b/desktop/rpm/kdepim_rpm
@@ -1,84 +1,84 @@
1Summary: A collection of PIM programs 1Summary: A collection of PIM programs
2Name: KDE-Pim-Pi 2Name: KDE-Pim-Pi
3Version: 2.0.5 3Version: 2.0.6
4Release: SuSE_9.2 4Release: SuSE_9.2
5Copyright:GPL 5Copyright:GPL
6Group: Productivity/Pim 6Group: Productivity/Pim
7Source:http://sourceforge.net/projects/kdepimpi/ 7Source:http://sourceforge.net/projects/kdepimpi/
8URL:http://sourceforge.net/projects/kdepimpi/ 8URL:http://sourceforge.net/projects/kdepimpi/
9Packager: zautrix 9Packager: zautrix
10 10
11%description 11%description
12This package contains the platform-independent PIM programs from 12This package contains the platform-independent PIM programs from
13www.pi-sync.net, compiled for SuSE 9.2: 13www.pi-sync.net, compiled for SuSE 9.2:
14KTimeTacker/Pi 14KTimeTacker/Pi
15KPhone/Pi 15KPhone/Pi
16KAddressbook/Pi 16KAddressbook/Pi
17KOrganizer/Pi 17KOrganizer/Pi
18PasswordManager/Pi 18PasswordManager/Pi
19KOPieMail/Pi 19KOPieMail/Pi
20 20
21These applications do not need anything from the KDE-desktop 21These applications do not need anything from the KDE-desktop
22at all to run on Linux. However, there is a dependency from 22at all to run on Linux. However, there is a dependency from
23two KDE libs, because a small command line program is included 23two KDE libs, because a small command line program is included
24to make it possible to sync with the KDE-desktop applications. 24to make it possible to sync with the KDE-desktop applications.
25 25
26These applications are independent from the KDE-desktop 26These applications are independent from the KDE-desktop
27environment. That means, nothing of your existing 27environment. That means, nothing of your existing
28KDE-desktop setup will be changed, or any data 28KDE-desktop setup will be changed, or any data
29(calendar-addressbook) used by the KDE-desktop 29(calendar-addressbook) used by the KDE-desktop
30applications will be changed or accessed. 30applications will be changed or accessed.
31These applications stores their data and config in 31These applications stores their data and config in
32$HOME/kdepim/ 32$HOME/kdepim/
33However, because the same file format is used, 33However, because the same file format is used,
34an easy exchange of data with the KDE-desktop 34an easy exchange of data with the KDE-desktop
35is possible. 35is possible.
36A small command line program is included 36A small command line program is included
37to make it possible to sync with the KDE-desktop applications. 37to make it possible to sync with the KDE-desktop applications.
38You do not need to call this program from the commandline, 38You do not need to call this program from the commandline,
39it is called from the KDE-Pim/Pi apps when you choose there: 39it is called from the KDE-Pim/Pi apps when you choose there:
40Sync with KDE_Desktop. 40Sync with KDE_Desktop.
41If something is going wrong, please start the 41If something is going wrong, please start the
42KDE-Pim/Pi program itself from the console to get detailed output. 42KDE-Pim/Pi program itself from the console to get detailed output.
43 43
44After installation, you should have a 44After installation, you should have a
45PIM-pi 45PIM-pi
46folder in your KDE start menu, where you can 46folder in your KDE start menu, where you can
47start the applications from. 47start the applications from.
48 48
49These programs makes it possible to sync your Zaurus easily 49These programs makes it possible to sync your Zaurus easily
50(with the KDE-Pim/Pi programs running on the Zaurus) 50(with the KDE-Pim/Pi programs running on the Zaurus)
51with the KDE-desktop calendar/addressbook data. 51with the KDE-desktop calendar/addressbook data.
52If you want to use that, you have to update your 52If you want to use that, you have to update your
53KDE-desktop to version 3.3.0 or higher. 53KDE-desktop to version 3.3.0 or higher.
54SuSE 9.2 contains KDE 3.3.0 such that no update is needed. 54SuSE 9.2 contains KDE 3.3.0 such that no update is needed.
55Actually - after the (non difficult) configuration is set up - 55Actually - after the (non difficult) configuration is set up -
56with two mouseklicks on the Zaurus, 56with two mouseklicks on the Zaurus,
57the Zaurus syncs with the corresponding KDE-Pim/Pi 57the Zaurus syncs with the corresponding KDE-Pim/Pi
58program on the Linux Desktop which syncs automatically 58program on the Linux Desktop which syncs automatically
59with the KDE-desktop data. 59with the KDE-desktop data.
60 60
61If you want to use the KDE-desktop calendar/addressbook applications, 61If you want to use the KDE-desktop calendar/addressbook applications,
62just install these apps in this package and use them as a syncing tool for the 62just install these apps in this package and use them as a syncing tool for the
63Zaurus <-> KDE-desktop sync. 63Zaurus <-> KDE-desktop sync.
64The sync requires a network connection from your Zaurus to 64The sync requires a network connection from your Zaurus to
65the PC. A detailed Sync HowTo is available in the 65the PC. A detailed Sync HowTo is available in the
66Help menu of the applications. 66Help menu of the applications.
67 67
68These applications makes it also possible, that you can sync 68These applications makes it also possible, that you can sync
69(or just export the data to) your mobile phone with your 69(or just export the data to) your mobile phone with your
70data of the KDE-desktop calendar/addressbook applications. 70data of the KDE-desktop calendar/addressbook applications.
71This is tested and working for Nokia mobile phones, 71This is tested and working for Nokia mobile phones,
72it may work with others as well. 72it may work with others as well.
73(More info about that: -> Sync HowTo) 73(More info about that: -> Sync HowTo)
74 74
75NOTE: 75NOTE:
76When using SuSE 9.1 you have to update your KDE to 3.3.x 76When using SuSE 9.1 you have to update your KDE to 3.3.x
77and you have to make an online update in SuSE 9.1 to make it 77and you have to make an online update in SuSE 9.1 to make it
78possible to get the infrared connection working, such that 78possible to get the infrared connection working, such that
79you can sync your (Nokia) mobile phone via infrared. 79you can sync your (Nokia) mobile phone via infrared.
80 80
81%files 81%files
82/opt/kde3/share/applnk/PIM-pi/ 82/opt/kde3/share/applnk/PIM-pi/
83/opt/kdepimpi/ 83/opt/kdepimpi/
84/usr/lib/libmicro* 84/usr/lib/libmicro*
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 02d2585..da81586 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1603 +1,1610 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86} 86}
87KNoScrollListBox::~KNoScrollListBox() 87KNoScrollListBox::~KNoScrollListBox()
88{ 88{
89 89
90} 90}
91QString KNoScrollListBox::getWhatsThisText(QPoint p) 91QString KNoScrollListBox::getWhatsThisText(QPoint p)
92{ 92{
93 QListBoxItem* item = itemAt ( p ); 93 QListBoxItem* item = itemAt ( p );
94 if ( ! item ) { 94 if ( ! item ) {
95 return i18n("Click in the cell\nto add an event!"); 95 return i18n("Click in the cell\nto add an event!");
96 } 96 }
97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
98} 98}
99void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 99void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
100{ 100{
101 101
102 switch(e->key()) { 102 switch(e->key()) {
103 case Key_Right: 103 case Key_Right:
104 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 104 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
105 { 105 {
106 e->ignore(); 106 e->ignore();
107 return; 107 return;
108 } 108 }
109 scrollBy(10,0); 109 scrollBy(10,0);
110 break; 110 break;
111 case Key_Left: 111 case Key_Left:
112 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 112 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
113 { 113 {
114 e->ignore(); 114 e->ignore();
115 return; 115 return;
116 } 116 }
117 scrollBy(-10,0); 117 scrollBy(-10,0);
118 break; 118 break;
119 case Key_Up: 119 case Key_Up:
120 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 120 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
121 e->ignore(); 121 e->ignore();
122 break; 122 break;
123 } 123 }
124 setCurrentItem((currentItem()+count()-1)%count()); 124 setCurrentItem((currentItem()+count()-1)%count());
125 if(!itemVisible(currentItem())) { 125 if(!itemVisible(currentItem())) {
126 if((unsigned int) currentItem() == (count()-1)) { 126 if((unsigned int) currentItem() == (count()-1)) {
127 setTopItem(currentItem()-numItemsVisible()+1); 127 setTopItem(currentItem()-numItemsVisible()+1);
128 } else { 128 } else {
129 setTopItem(topItem()-1); 129 setTopItem(topItem()-1);
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case Key_Down: 133 case Key_Down:
134 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 134 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
135 e->ignore(); 135 e->ignore();
136 break; 136 break;
137 } 137 }
138 setCurrentItem((currentItem()+1)%count()); 138 setCurrentItem((currentItem()+1)%count());
139 if(!itemVisible(currentItem())) { 139 if(!itemVisible(currentItem())) {
140 if(currentItem() == 0) { 140 if(currentItem() == 0) {
141 setTopItem(0); 141 setTopItem(0);
142 } else { 142 } else {
143 setTopItem(topItem()+1); 143 setTopItem(topItem()+1);
144 } 144 }
145 } 145 }
146 break; 146 break;
147 case Key_I: 147 case Key_I:
148 QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); 148 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
149 e->ignore(); 149 e->ignore();
150 break; 150 break;
151 case Key_Shift: 151 case Key_Shift:
152 emit shiftDown(); 152 emit shiftDown();
153 break; 153 break;
154 default: 154 default:
155 e->ignore(); 155 e->ignore();
156 break; 156 break;
157 } 157 }
158} 158}
159 159
160void KNoScrollListBox::oneDown() 160void KNoScrollListBox::oneDown()
161{ 161{
162 setCurrentItem((currentItem()+1)%count()); 162 setCurrentItem((currentItem()+1)%count());
163 if(!itemVisible(currentItem())) { 163 if(!itemVisible(currentItem())) {
164 if(currentItem() == 0) { 164 if(currentItem() == 0) {
165 setTopItem(0); 165 setTopItem(0);
166 } else { 166 } else {
167 setTopItem(topItem()+1); 167 setTopItem(topItem()+1);
168 } 168 }
169 } 169 }
170} 170}
171void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 171void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
172{ 172{
173 switch(e->key()) { 173 switch(e->key()) {
174 case Key_Shift: 174 case Key_Shift:
175 emit shiftUp(); 175 emit shiftUp();
176 break; 176 break;
177 default: 177 default:
178 break; 178 break;
179 } 179 }
180} 180}
181 181
182void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 182void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
183{ 183{
184 QListBox::mousePressEvent(e); 184 QListBox::mousePressEvent(e);
185 185
186 if(e->button() == RightButton) { 186 if(e->button() == RightButton) {
187 emit rightClick(); 187 emit rightClick();
188 } 188 }
189} 189}
190 190
191MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 191MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
192 : QListBoxItem() 192 : QListBoxItem()
193{ 193{
194 setText( s ); 194 setText( s );
195 195
196 mIncidence = incidence; 196 mIncidence = incidence;
197 mDate = qd; 197 mDate = qd;
198 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 198 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
199 mRecur = false; 199 mRecur = false;
200 mAlarm = false; 200 mAlarm = false;
201 mReply = false; 201 mReply = false;
202 mInfo = false; 202 mInfo = false;
203} 203}
204 204
205void MonthViewItem::paint(QPainter *p) 205void MonthViewItem::paint(QPainter *p)
206{ 206{
207#if QT_VERSION >= 0x030000 207#if QT_VERSION >= 0x030000
208 bool sel = isSelected(); 208 bool sel = isSelected();
209#else 209#else
210 bool sel = selected(); 210 bool sel = selected();
211#endif 211#endif
212 212
213 213
214 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 214 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
215 { 215 {
216 p->setBackgroundColor( palette().color( QPalette::Normal, \ 216 p->setBackgroundColor( palette().color( QPalette::Normal, \
217 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 217 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
218 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 218 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
219 } 219 }
220 int x = 1; 220 int x = 1;
221 int y = 3;//(height() - mRecurPixmap.height()) /2; 221 int y = 3;//(height() - mRecurPixmap.height()) /2;
222 int size = PIXMAP_SIZE; 222 int size = PIXMAP_SIZE;
223 if ( QApplication::desktop()->width() < 300 ) 223 if ( QApplication::desktop()->width() < 300 )
224 size = 3; 224 size = 3;
225 if ( KOPrefs::instance()->mMonthShowIcons ) { 225 if ( KOPrefs::instance()->mMonthShowIcons ) {
226 if ( mInfo ) { 226 if ( mInfo ) {
227 p->fillRect ( x, y,size,size, Qt::darkGreen ); 227 p->fillRect ( x, y,size,size, Qt::darkGreen );
228 x += size + 1; 228 x += size + 1;
229 } 229 }
230 if ( mRecur ) { 230 if ( mRecur ) {
231 p->fillRect ( x, y,size,size, Qt::blue ); 231 p->fillRect ( x, y,size,size, Qt::blue );
232 x += size + 1; 232 x += size + 1;
233 } 233 }
234 if ( mAlarm ) { 234 if ( mAlarm ) {
235 p->fillRect ( x, y,size,size, Qt::red ); 235 p->fillRect ( x, y,size,size, Qt::red );
236 x += size + 1; 236 x += size + 1;
237 } 237 }
238 if ( mReply ) { 238 if ( mReply ) {
239 p->fillRect ( x, y,size,size, Qt::yellow ); 239 p->fillRect ( x, y,size,size, Qt::yellow );
240 x += size + 1; 240 x += size + 1;
241 } 241 }
242 } 242 }
243 QFontMetrics fm = p->fontMetrics(); 243 QFontMetrics fm = p->fontMetrics();
244 int yPos; 244 int yPos;
245 int pmheight = size; 245 int pmheight = size;
246 if( pmheight < fm.height() ) 246 if( pmheight < fm.height() )
247 yPos = fm.ascent() + fm.leading()/2; 247 yPos = fm.ascent() + fm.leading()/2;
248 else 248 else
249 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 249 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
250 p->setPen( palette().color( QPalette::Normal, sel ? \ 250 p->setPen( palette().color( QPalette::Normal, sel ? \
251 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 251 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
252 p->drawText( x, yPos, text() ); 252 p->drawText( x, yPos, text() );
253 if ( mIncidence->cancelled() ) { 253 if ( mIncidence->cancelled() ) {
254 int wid = fm.width( text() ); 254 int wid = fm.width( text() );
255 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); 255 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3);
256 } 256 }
257 257
258} 258}
259 259
260int MonthViewItem::height(const QListBox *lb) const 260int MonthViewItem::height(const QListBox *lb) const
261{ 261{
262 return lb->fontMetrics().lineSpacing()+1; 262 return lb->fontMetrics().lineSpacing()+1;
263} 263}
264 264
265int MonthViewItem::width(const QListBox *lb) const 265int MonthViewItem::width(const QListBox *lb) const
266{ 266{
267 int size = PIXMAP_SIZE; 267 int size = PIXMAP_SIZE;
268 if ( QApplication::desktop()->width() < 300 ) 268 if ( QApplication::desktop()->width() < 300 )
269 size = 3; 269 size = 3;
270 int x = 1; 270 int x = 1;
271 if ( mInfo ) { 271 if ( mInfo ) {
272 x += size + 1; 272 x += size + 1;
273 } 273 }
274 if( mRecur ) { 274 if( mRecur ) {
275 x += size+1; 275 x += size+1;
276 } 276 }
277 if( mAlarm ) { 277 if( mAlarm ) {
278 x += size+1; 278 x += size+1;
279 } 279 }
280 if( mReply ) { 280 if( mReply ) {
281 x += size+1; 281 x += size+1;
282 } 282 }
283 283
284 return( x + lb->fontMetrics().width( text() ) + 1 ); 284 return( x + lb->fontMetrics().width( text() ) + 1 );
285} 285}
286 286
287 287
288MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 288MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
289 : QWidget( par ), 289 : QWidget( par ),
290 mMonthView( parent ) 290 mMonthView( parent )
291{ 291{
292 292
293 QVBoxLayout *topLayout = new QVBoxLayout( this ); 293 QVBoxLayout *topLayout = new QVBoxLayout( this );
294 294
295 // mLabel = new QLabel( this );QPushButton 295 // mLabel = new QLabel( this );QPushButton
296 mLabel = new QPushButton( this ); 296 mLabel = new QPushButton( this );
297 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 297 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
298 //mLabel->setLineWidth( 1 ); 298 //mLabel->setLineWidth( 1 );
299 //mLabel->setAlignment( AlignCenter ); 299 //mLabel->setAlignment( AlignCenter );
300 mLabel->setFlat( true ); 300 mLabel->setFlat( true );
301 mLabel->setFocusPolicy(NoFocus); 301 mLabel->setFocusPolicy(NoFocus);
302 mItemList = new KNoScrollListBox( this ); 302 mItemList = new KNoScrollListBox( this );
303 mItemList->setMinimumSize( 10, 10 ); 303 mItemList->setMinimumSize( 10, 10 );
304 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 304 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
305 mItemList->setLineWidth( 1 ); 305 mItemList->setLineWidth( 1 );
306 topLayout->addWidget( mItemList ); 306 topLayout->addWidget( mItemList );
307 mLabel->raise(); 307 mLabel->raise();
308 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 308 // QColor( 0,0,255 ) QColor( 160,1600,255 )
309 mStandardPalette = palette(); 309 mStandardPalette = palette();
310 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 310 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
311 311
312 enableScrollBars( false ); 312 enableScrollBars( false );
313 updateConfig(); 313 updateConfig();
314 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 314 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
315 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 315 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
316 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 316 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
317 SLOT( defaultAction( QListBoxItem * ) ) ); 317 SLOT( defaultAction( QListBoxItem * ) ) );
318 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 318 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
319 const QPoint &) ), 319 const QPoint &) ),
320 SLOT( contextMenu( QListBoxItem * ) ) ); 320 SLOT( contextMenu( QListBoxItem * ) ) );
321 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 321 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
322 SLOT( selection( QListBoxItem * ) ) ); 322 SLOT( selection( QListBoxItem * ) ) );
323 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 323 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
324 SLOT( cellClicked( QListBoxItem * ) ) ); 324 SLOT( cellClicked( QListBoxItem * ) ) );
325 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 325 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
326 SLOT( selection( QListBoxItem * ) ) ); 326 SLOT( selection( QListBoxItem * ) ) );
327} 327}
328#ifdef DESKTOP_VERSION 328#ifdef DESKTOP_VERSION
329QToolTipGroup *MonthViewCell::toolTipGroup() 329QToolTipGroup *MonthViewCell::toolTipGroup()
330{ 330{
331 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 331 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
332 return mToolTipGroup; 332 return mToolTipGroup;
333} 333}
334#endif 334#endif
335 335
336void MonthViewCell::setDate( const QDate &date ) 336void MonthViewCell::setDate( const QDate &date )
337{ 337{
338 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 338 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
339 mDate = date; 339 mDate = date;
340 340
341 341
342 342
343 //resizeEvent( 0 ); 343 //resizeEvent( 0 );
344} 344}
345 345
346QDate MonthViewCell::date() const 346QDate MonthViewCell::date() const
347{ 347{
348 return mDate; 348 return mDate;
349} 349}
350 350
351void MonthViewCell::setPrimary( bool primary ) 351void MonthViewCell::setPrimary( bool primary )
352{ 352{
353 mPrimary = primary; 353 mPrimary = primary;
354 //setMyPalette(); 354 //setMyPalette();
355} 355}
356void MonthViewCell::setMyPalette() 356void MonthViewCell::setMyPalette()
357{ 357{
358 358
359 if ( mHoliday) { 359 if ( mHoliday) {
360 setPalette( mHolidayPalette ); 360 setPalette( mHolidayPalette );
361 } else { 361 } else {
362 if ( mPrimary ) { 362 if ( mPrimary ) {
363 setPalette( mPrimaryPalette ); 363 setPalette( mPrimaryPalette );
364 } else { 364 } else {
365 setPalette( mNonPrimaryPalette ); 365 setPalette( mNonPrimaryPalette );
366 } 366 }
367 } 367 }
368 QPalette pal = palette(); 368 QPalette pal = palette();
369 369
370 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 370 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
371} 371}
372QPalette MonthViewCell::getPalette () 372QPalette MonthViewCell::getPalette ()
373{ 373{
374 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 374 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
375 return mStandardPalette; 375 return mStandardPalette;
376 if ( mHoliday) { 376 if ( mHoliday) {
377 return mHolidayPalette ; 377 return mHolidayPalette ;
378 } else { 378 } else {
379 if ( mPrimary ) { 379 if ( mPrimary ) {
380 return mPrimaryPalette ; 380 return mPrimaryPalette ;
381 } 381 }
382 } 382 }
383 return mNonPrimaryPalette; 383 return mNonPrimaryPalette;
384} 384}
385bool MonthViewCell::isPrimary() const 385bool MonthViewCell::isPrimary() const
386{ 386{
387 return mPrimary; 387 return mPrimary;
388} 388}
389 389
390void MonthViewCell::setHoliday( bool holiday ) 390void MonthViewCell::setHoliday( bool holiday )
391{ 391{
392 mHoliday = holiday; 392 mHoliday = holiday;
393 //setMyPalette(); 393 //setMyPalette();
394} 394}
395 395
396void MonthViewCell::setHoliday( const QString &holiday ) 396void MonthViewCell::setHoliday( const QString &holiday )
397{ 397{
398 mHolidayString = holiday; 398 mHolidayString = holiday;
399 399
400 if ( !holiday.isEmpty() ) { 400 if ( !holiday.isEmpty() ) {
401 setHoliday( true ); 401 setHoliday( true );
402 } 402 }
403} 403}
404void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 404void MonthViewCell::keyPressEvent ( QKeyEvent * e )
405{ 405{
406 406
407 e->ignore(); 407 e->ignore();
408 408
409} 409}
410 410
411void MonthViewCell::startUpdateCell() 411void MonthViewCell::startUpdateCell()
412{ 412{
413 413
414 mItemList->setFocusPolicy(NoFocus); 414 mItemList->setFocusPolicy(NoFocus);
415 if ( !mMonthView->isUpdatePossible() ) 415 if ( !mMonthView->isUpdatePossible() )
416 return; 416 return;
417 417
418 /* 418 /*
419 if ( !isVisible() ){ 419 if ( !isVisible() ){
420 return; 420 return;
421 } 421 }
422 */ 422 */
423 // qDebug("MonthViewCell::updateCell() "); 423 // qDebug("MonthViewCell::updateCell() ");
424 setPrimary( mDate.month()%2 ); 424 setPrimary( mDate.month()%2 );
425 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 425 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
426 if ( mDate == QDate::currentDate() ) { 426 if ( mDate == QDate::currentDate() ) {
427 mItemList->setLineWidth( 3 ); 427 mItemList->setLineWidth( 3 );
428 } else { 428 } else {
429 mItemList->setLineWidth( 1 ); 429 mItemList->setLineWidth( 1 );
430 } 430 }
431 mItemList->clear(); 431 mItemList->clear();
432 432
433#ifdef DESKTOP_VERSION 433#ifdef DESKTOP_VERSION
434 QToolTip::remove(this); 434 QToolTip::remove(this);
435#endif 435#endif
436 mToolTip = ""; 436 mToolTip = "";
437 //qApp->processEvents(); 437 //qApp->processEvents();
438 if ( !mHolidayString.isEmpty() ) { 438 if ( !mHolidayString.isEmpty() ) {
439 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 439 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
440 item->setPalette( mHolidayPalette ); 440 item->setPalette( mHolidayPalette );
441 mItemList->insertItem( item ); 441 mItemList->insertItem( item );
442 mToolTip += mHolidayString+"\n"; 442 mToolTip += mHolidayString+"\n";
443 } 443 }
444} 444}
445 445
446void MonthViewCell::insertEvent(Event *event) 446void MonthViewCell::insertEvent(Event *event)
447{ 447{
448 448
449 mItemList->setFocusPolicy(WheelFocus); 449 mItemList->setFocusPolicy(WheelFocus);
450 if ( !(event->doesRecur() == Recurrence::rNone) ) { 450 if ( !(event->doesRecur() == Recurrence::rNone) ) {
451 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 451 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
452 return; 452 return;
453 else 453 else
454 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 454 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
455 return; 455 return;
456 } 456 }
457 457
458 if ( event->categories().contains("Holiday") || 458 if ( event->categories().contains("Holiday") ||
459 event->categories().contains(i18n("Holiday"))) { 459 event->categories().contains(i18n("Holiday"))) {
460 setHoliday( true ); 460 setHoliday( true );
461 if ( mDate.dayOfWeek() == 7 ) 461 if ( mDate.dayOfWeek() == 7 )
462 mItemList->setLineWidth( 3 ); 462 mItemList->setLineWidth( 3 );
463 } 463 }
464 QString text; 464 QString text;
465 if (event->isMultiDay()) { 465 if (event->isMultiDay()) {
466 QString prefix = "<->"; 466 QString prefix = "<->";
467 if ( event->doesRecur() ) { 467 if ( event->doesRecur() ) {
468 if ( event->recursOn( mDate) ) 468 if ( event->recursOn( mDate) )
469 prefix ="->" ; 469 prefix ="->" ;
470 else { 470 else {
471 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 471 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
472 if ( event->recursOn( mDate.addDays( -days)) ) 472 if ( event->recursOn( mDate.addDays( -days)) )
473 prefix ="<-" ; 473 prefix ="<-" ;
474 } 474 }
475 475
476 } else { 476 } else {
477 if (mDate == event->dtStart().date()) { 477 if (mDate == event->dtStart().date()) {
478 prefix ="->" ; 478 prefix ="->" ;
479 } else if (mDate == event->dtEnd().date()) { 479 } else if (mDate == event->dtEnd().date()) {
480 prefix ="<-" ; 480 prefix ="<-" ;
481 } 481 }
482 } 482 }
483 if ( !event->doesFloat() ) { 483 if ( !event->doesFloat() ) {
484 if ( mDate == event->dtStart().date () ) 484 if ( mDate == event->dtStart().date () )
485 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 485 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
486 else if ( mDate == event->dtEnd().date () ) 486 else if ( mDate == event->dtEnd().date () )
487 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 487 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
488 488
489 } 489 }
490 text = prefix + event->summary(); 490 text = prefix + event->summary();
491 mToolTip += text; 491 mToolTip += text;
492 } else { 492 } else {
493 if (event->doesFloat()) { 493 if (event->doesFloat()) {
494 text = event->summary(); 494 text = event->summary();
495 mToolTip += text; 495 mToolTip += text;
496 } 496 }
497 else { 497 else {
498 text = KGlobal::locale()->formatTime(event->dtStart().time()); 498 text = KGlobal::locale()->formatTime(event->dtStart().time());
499 text += " " + event->summary(); 499 text += " " + event->summary();
500 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 500 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
501 } 501 }
502 } 502 }
503 503
504 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 504 MonthViewItem *item = new MonthViewItem( event, mDate, text );
505 QPalette pal; 505 QPalette pal;
506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
507 QStringList categories = event->categories(); 507 QStringList categories = event->categories();
508 QString cat = categories.first(); 508 QString cat = categories.first();
509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
510 pal = getPalette(); 510 pal = getPalette();
511 if (cat.isEmpty()) { 511 if (cat.isEmpty()) {
512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
513 } else { 513 } else {
514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
515 } 515 }
516 516
517 } else { 517 } else {
518 if (cat.isEmpty()) { 518 if (cat.isEmpty()) {
519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
520 } else { 520 } else {
521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
522 } 522 }
523 } 523 }
524 524
525 } else { 525 } else {
526 pal = mStandardPalette ; 526 pal = mStandardPalette ;
527 } 527 }
528 item->setPalette( pal ); 528 item->setPalette( pal );
529 item->setRecur( event->recurrence()->doesRecur() ); 529 item->setRecur( event->recurrence()->doesRecur() );
530 item->setAlarm( event->isAlarmEnabled() ); 530 item->setAlarm( event->isAlarmEnabled() );
531 item->setMoreInfo( event->description().length() > 0 ); 531 item->setMoreInfo( event->description().length() > 0 );
532#ifdef DESKTOP_VERSION 532#ifdef DESKTOP_VERSION
533 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 533 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
534 KOPrefs::instance()->email()); 534 KOPrefs::instance()->email());
535 if ( me != 0 ) { 535 if ( me != 0 ) {
536 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 536 if ( me->status() == Attendee::NeedsAction && me->RSVP())
537 item->setReply(true); 537 item->setReply(true);
538 else 538 else
539 item->setReply(false); 539 item->setReply(false);
540 } else 540 } else
541 item->setReply(false); 541 item->setReply(false);
542#endif 542#endif
543 mItemList->insertItem( item ); 543 mItemList->insertItem( item );
544 mToolTip += "\n"; 544 mToolTip += "\n";
545} 545}
546void MonthViewCell::insertTodo(Todo *todo) 546void MonthViewCell::insertTodo(Todo *todo)
547{ 547{
548 mItemList->setFocusPolicy(WheelFocus); 548 mItemList->setFocusPolicy(WheelFocus);
549 QString text; 549 QString text;
550 if (todo->hasDueDate()) { 550 if (todo->hasDueDate()) {
551 if (!todo->doesFloat()) { 551 if (!todo->doesFloat()) {
552 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 552 text += KGlobal::locale()->formatTime(todo->dtDue().time());
553 text += " "; 553 text += " ";
554 } 554 }
555 } 555 }
556 text += i18n("Td: %1").arg(todo->summary()); 556 text += i18n("Td: %1").arg(todo->summary());
557 557
558 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 558 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
559 //item->setPalette( mStandardPalette ); 559 //item->setPalette( mStandardPalette );
560 QPalette pal; 560 QPalette pal;
561 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 561 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
562 QStringList categories = todo->categories(); 562 QStringList categories = todo->categories();
563 QString cat = categories.first(); 563 QString cat = categories.first();
564 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 564 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
565 pal = getPalette(); 565 pal = getPalette();
566 if (cat.isEmpty()) { 566 if (cat.isEmpty()) {
567 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 567 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
568 } else { 568 } else {
569 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 569 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
570 } 570 }
571 571
572 } else { 572 } else {
573 if (cat.isEmpty()) { 573 if (cat.isEmpty()) {
574 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 574 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
575 } else { 575 } else {
576 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 576 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
577 } 577 }
578 } 578 }
579 579
580 } else { 580 } else {
581 pal = mStandardPalette ; 581 pal = mStandardPalette ;
582 } 582 }
583 item->setPalette( pal ); 583 item->setPalette( pal );
584 mItemList->insertItem( item ); 584 mItemList->insertItem( item );
585 mToolTip += text+"\n"; 585 mToolTip += text+"\n";
586} 586}
587void MonthViewCell::finishUpdateCell() 587void MonthViewCell::finishUpdateCell()
588{ 588{
589#ifdef DESKTOP_VERSION 589#ifdef DESKTOP_VERSION
590 if (mToolTip != "") 590 if (mToolTip != "")
591 QToolTip::add(this,mToolTip,toolTipGroup(),""); 591 QToolTip::add(this,mToolTip,toolTipGroup(),"");
592#endif 592#endif
593 mItemList->sort(); 593 mItemList->sort();
594 //setMyPalette(); 594 //setMyPalette();
595 setMyPalette(); 595 setMyPalette();
596 QString text; 596 QString text;
597 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 597 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
598 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 598 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
599 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 599 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
600 mLabel->resize( mLabelBigSize ); 600 mLabel->resize( mLabelBigSize );
601 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 601 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
602 } else { 602 } else {
603 mLabel->resize( mLabelSize ); 603 mLabel->resize( mLabelSize );
604 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 604 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
605 } 605 }
606 606
607 mLabel->setText( text ); 607 mLabel->setText( text );
608 resizeEvent( 0 ); 608 resizeEvent( 0 );
609} 609}
610void MonthViewCell::updateCell() 610void MonthViewCell::updateCell()
611{ 611{
612 qDebug("MonthViewCell::updateCell() "); 612 qDebug("MonthViewCell::updateCell() ");
613 if ( !mMonthView->isUpdatePossible() ) 613 if ( !mMonthView->isUpdatePossible() )
614 return; 614 return;
615 startUpdateCell(); 615 startUpdateCell();
616 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 616 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
617 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 617 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
618 Event *event; 618 Event *event;
619 for( event = events.first(); event; event = events.next() ) { // for event 619 for( event = events.first(); event; event = events.next() ) { // for event
620 insertEvent(event); 620 insertEvent(event);
621 } 621 }
622 // insert due todos 622 // insert due todos
623 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 623 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
624 Todo *todo; 624 Todo *todo;
625 for(todo = todos.first(); todo; todo = todos.next()) { 625 for(todo = todos.first(); todo; todo = todos.next()) {
626 insertTodo( todo ); 626 insertTodo( todo );
627 } 627 }
628 finishUpdateCell(); 628 finishUpdateCell();
629 // if ( isVisible()) 629 // if ( isVisible())
630 //qApp->processEvents(); 630 //qApp->processEvents();
631} 631}
632 632
633void MonthViewCell::updateConfig( bool bigFont ) // = false 633void MonthViewCell::updateConfig( bool bigFont ) // = false
634{ 634{
635 635
636 if ( bigFont ) { 636 if ( bigFont ) {
637 QFont fo = KOPrefs::instance()->mMonthViewFont; 637 QFont fo = KOPrefs::instance()->mMonthViewFont;
638 int ps = fo.pointSize() + 2; 638 int ps = fo.pointSize() + 2;
639 if ( ps < 18 ) 639 if ( ps < 18 )
640 ps += 2; 640 ps += 2;
641 fo.setPointSize( ps ); 641 fo.setPointSize( ps );
642 setFont( fo ); 642 setFont( fo );
643 } else 643 } else
644 setFont( KOPrefs::instance()->mMonthViewFont ); 644 setFont( KOPrefs::instance()->mMonthViewFont );
645 645
646 QFontMetrics fm( font() ); 646 QFontMetrics fm( font() );
647 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 647 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
648 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 648 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
649 mHolidayPalette = mStandardPalette; 649 mHolidayPalette = mStandardPalette;
650 mPrimaryPalette = mStandardPalette; 650 mPrimaryPalette = mStandardPalette;
651 mNonPrimaryPalette = mStandardPalette; 651 mNonPrimaryPalette = mStandardPalette;
652 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 652 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
653 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 653 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
654 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 654 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
655 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 655 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
656 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 656 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
657 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 657 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
658 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 658 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
659 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 659 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
660 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 660 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
661 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 661 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
662 } 662 }
663 //updateCell(); 663 //updateCell();
664} 664}
665 665
666void MonthViewCell::enableScrollBars( bool enabled ) 666void MonthViewCell::enableScrollBars( bool enabled )
667{ 667{
668 if ( enabled ) { 668 if ( enabled ) {
669 mItemList->setVScrollBarMode(QScrollView::Auto); 669 mItemList->setVScrollBarMode(QScrollView::Auto);
670 mItemList->setHScrollBarMode(QScrollView::Auto); 670 mItemList->setHScrollBarMode(QScrollView::Auto);
671 } else { 671 } else {
672 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 672 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
673 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 673 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
674 } 674 }
675} 675}
676 676
677Incidence *MonthViewCell::selectedIncidence() 677Incidence *MonthViewCell::selectedIncidence()
678{ 678{
679 int index = mItemList->currentItem(); 679 int index = mItemList->currentItem();
680 if ( index < 0 ) return 0; 680 if ( index < 0 ) return 0;
681 681
682 MonthViewItem *item = 682 MonthViewItem *item =
683 static_cast<MonthViewItem *>( mItemList->item( index ) ); 683 static_cast<MonthViewItem *>( mItemList->item( index ) );
684 684
685 if ( !item ) return 0; 685 if ( !item ) return 0;
686 686
687 return item->incidence(); 687 return item->incidence();
688} 688}
689 689
690QDate MonthViewCell::selectedIncidenceDate() 690QDate MonthViewCell::selectedIncidenceDate()
691{ 691{
692 QDate qd; 692 QDate qd;
693 int index = mItemList->currentItem(); 693 int index = mItemList->currentItem();
694 if ( index < 0 ) return qd; 694 if ( index < 0 ) return qd;
695 695
696 MonthViewItem *item = 696 MonthViewItem *item =
697 static_cast<MonthViewItem *>( mItemList->item( index ) ); 697 static_cast<MonthViewItem *>( mItemList->item( index ) );
698 698
699 if ( !item ) return qd; 699 if ( !item ) return qd;
700 700
701 return item->incidenceDate(); 701 return item->incidenceDate();
702} 702}
703 703
704void MonthViewCell::deselect() 704void MonthViewCell::deselect()
705{ 705{
706 mItemList->clearSelection(); 706 mItemList->clearSelection();
707 enableScrollBars( false ); 707 enableScrollBars( false );
708 // updateCell(); 708 // updateCell();
709} 709}
710void MonthViewCell::select() 710void MonthViewCell::select()
711{ 711{
712 ;// updateCell(); 712 ;// updateCell();
713} 713}
714 714
715void MonthViewCell::resizeEvent ( QResizeEvent * ) 715void MonthViewCell::resizeEvent ( QResizeEvent * )
716{ 716{
717 if ( !mMonthView->isUpdatePossible() ) 717 if ( !mMonthView->isUpdatePossible() )
718 return; 718 return;
719 719
720 int size = height() - mLabel->height() - 2; 720 int size = height() - mLabel->height() - 2;
721 if ( size > 0 ) 721 if ( size > 0 )
722 mItemList->verticalScrollBar()->setMaximumHeight( size ); 722 mItemList->verticalScrollBar()->setMaximumHeight( size );
723 size = width() - mLabel->width() -2; 723 size = width() - mLabel->width() -2;
724 if ( size > 0 ) 724 if ( size > 0 )
725 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 725 mItemList->horizontalScrollBar()->setMaximumWidth( size );
726 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 726 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
727 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 727 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
728} 728}
729 729
730void MonthViewCell::defaultAction( QListBoxItem *item ) 730void MonthViewCell::defaultAction( QListBoxItem *item )
731{ 731{
732 if ( !item ) return; 732 if ( !item ) return;
733 733
734 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 734 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
735 Incidence *incidence = eventItem->incidence(); 735 Incidence *incidence = eventItem->incidence();
736 if ( incidence ) mMonthView->defaultAction( incidence ); 736 if ( incidence ) mMonthView->defaultAction( incidence );
737} 737}
738void MonthViewCell::showDay() 738void MonthViewCell::showDay()
739{ 739{
740 emit showDaySignal( date() ); 740 emit showDaySignal( date() );
741} 741}
742void MonthViewCell::newEvent() 742void MonthViewCell::newEvent()
743{ 743{
744 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 744 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
745 emit newEventSignal( dt ); 745 emit newEventSignal( dt );
746} 746}
747void MonthViewCell::cellClicked( QListBoxItem *item ) 747void MonthViewCell::cellClicked( QListBoxItem *item )
748{ 748{
749 static QListBoxItem * lastClicked = 0; 749 static QListBoxItem * lastClicked = 0;
750 if ( item == 0 ) { 750 if ( item == 0 ) {
751 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 751 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
752 emit newEventSignal( dt ); 752 emit newEventSignal( dt );
753 return; 753 return;
754 } 754 }
755 /* 755 /*
756 if ( lastClicked ) 756 if ( lastClicked )
757 if ( ! item ) { 757 if ( ! item ) {
758 if ( lastClicked->listBox() != item->listBox() ) 758 if ( lastClicked->listBox() != item->listBox() )
759 lastClicked->listBox()->clearSelection(); 759 lastClicked->listBox()->clearSelection();
760 } 760 }
761 */ 761 */
762 762
763 mMonthView->setSelectedCell( this ); 763 mMonthView->setSelectedCell( this );
764 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 764 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
765 select(); 765 select();
766} 766}
767 767
768void MonthViewCell::contextMenu( QListBoxItem *item ) 768void MonthViewCell::contextMenu( QListBoxItem *item )
769{ 769{
770 if ( !item ) return; 770 if ( !item ) return;
771 771
772 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 772 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
773 Incidence *incidence = eventItem->incidence(); 773 Incidence *incidence = eventItem->incidence();
774 if ( incidence ) mMonthView->showContextMenu( incidence ); 774 if ( incidence ) mMonthView->showContextMenu( incidence );
775} 775}
776 776
777void MonthViewCell::selection( QListBoxItem *item ) 777void MonthViewCell::selection( QListBoxItem *item )
778{ 778{
779 if ( !item ) return; 779 if ( !item ) return;
780 780
781 mMonthView->setSelectedCell( this ); 781 mMonthView->setSelectedCell( this );
782} 782}
783 783
784 784
785// ******************************************************************************* 785// *******************************************************************************
786// ******************************************************************************* 786// *******************************************************************************
787// ******************************************************************************* 787// *******************************************************************************
788 788
789 789
790KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 790KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
791 : KOEventView( calendar, parent, name ), 791 : KOEventView( calendar, parent, name ),
792 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 792 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
793 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 793 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
794{ 794{
795 mShortDayLabelsM = false; 795 mShortDayLabelsM = false;
796 mShortDayLabelsW = false; 796 mShortDayLabelsW = false;
797 skipResize = false; 797 skipResize = false;
798 clPending = true; 798 clPending = true;
799 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 799 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
800 mWidStack = new QWidgetStack( this ); 800 mWidStack = new QWidgetStack( this );
801 QVBoxLayout* hb = new QVBoxLayout( this ); 801 QVBoxLayout* hb = new QVBoxLayout( this );
802 mMonthView = new QWidget( mWidStack ); 802 mMonthView = new QWidget( mWidStack );
803 mWeekView = new QWidget( mWidStack ); 803 mWeekView = new QWidget( mWidStack );
804#if QT_VERSION >= 0x030000 804#if QT_VERSION >= 0x030000
805 mWidStack->addWidget(mMonthView ); 805 mWidStack->addWidget(mMonthView );
806 mWidStack->addWidget(mWeekView ); 806 mWidStack->addWidget(mWeekView );
807#else 807#else
808 mWidStack->addWidget( mMonthView, 1 ); 808 mWidStack->addWidget( mMonthView, 1 );
809 mWidStack->addWidget( mWeekView , 1 ); 809 mWidStack->addWidget( mWeekView , 1 );
810#endif 810#endif
811 hb->addWidget( mNavigatorBar ); 811 hb->addWidget( mNavigatorBar );
812 hb->addWidget( mWidStack ); 812 hb->addWidget( mWidStack );
813 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 813 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
814 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 814 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
815 if ( mShowWeekView ) 815 if ( mShowWeekView )
816 mWeekStartsMonday = true; 816 mWeekStartsMonday = true;
817 updatePossible = false; 817 updatePossible = false;
818 //updatePossible = true; 818 //updatePossible = true;
819 mCells.setAutoDelete( true ); 819 mCells.setAutoDelete( true );
820 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 820 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
821 mDayLabels.resize( mDaysPerWeek ); 821 mDayLabels.resize( mDaysPerWeek );
822 mDayLabelsW.resize( mDaysPerWeek ); 822 mDayLabelsW.resize( mDaysPerWeek );
823 QFont bfont = font(); 823 QFont bfont = font();
824 if ( QApplication::desktop()->width() < 650 ) { 824 if ( QApplication::desktop()->width() < 650 ) {
825 bfont.setPointSize( bfont.pointSize() - 2 ); 825 bfont.setPointSize( bfont.pointSize() - 2 );
826 } 826 }
827 bfont.setBold( true ); 827 bfont.setBold( true );
828 int i; 828 int i;
829 829
830 for( i = 0; i < mDaysPerWeek; i++ ) { 830 for( i = 0; i < mDaysPerWeek; i++ ) {
831 QLabel *label = new QLabel( mMonthView ); 831 QLabel *label = new QLabel( mMonthView );
832 label->setFont(bfont); 832 label->setFont(bfont);
833 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 833 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
834 label->setLineWidth(1); 834 label->setLineWidth(1);
835 label->setAlignment(AlignCenter); 835 label->setAlignment(AlignCenter);
836 mDayLabels.insert( i, label ); 836 mDayLabels.insert( i, label );
837 label = new QLabel( mWeekView ); 837 label = new QLabel( mWeekView );
838 label->setFont(bfont); 838 label->setFont(bfont);
839 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 839 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
840 label->setLineWidth(1); 840 label->setLineWidth(1);
841 label->setAlignment(AlignCenter); 841 label->setAlignment(AlignCenter);
842 mDayLabelsW.insert( i, label ); 842 mDayLabelsW.insert( i, label );
843 } 843 }
844 844
845 bfont.setBold( false ); 845 bfont.setBold( false );
846 mWeekLabels.resize( mNumWeeks+1 ); 846 mWeekLabels.resize( mNumWeeks+1 );
847 mWeekLabelsW.resize( 2 ); 847 mWeekLabelsW.resize( 2 );
848 for( i = 0; i < mNumWeeks+1; i++ ) { 848 for( i = 0; i < mNumWeeks+1; i++ ) {
849 KOWeekButton *label = new KOWeekButton( mMonthView ); 849 KOWeekButton *label = new KOWeekButton( mMonthView );
850 label->setFocusPolicy(NoFocus); 850 label->setFocusPolicy(NoFocus);
851 label->setFont(bfont); 851 label->setFont(bfont);
852 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 852 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
853 label->setFlat(true); 853 label->setFlat(true);
854 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 854 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
855 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 855 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
856 //label->setLineWidth(1); 856 //label->setLineWidth(1);
857 //label->setAlignment(AlignCenter); 857 //label->setAlignment(AlignCenter);
858 mWeekLabels.insert( i, label ); 858 mWeekLabels.insert( i, label );
859 } 859 }
860 mWeekLabels[mNumWeeks]->setText( i18n("W")); 860 mWeekLabels[mNumWeeks]->setText( i18n("W"));
861 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 861 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
862 862
863 for( i = 0; i < 1+1; i++ ) { 863 for( i = 0; i < 1+1; i++ ) {
864 KOWeekButton *label = new KOWeekButton( mWeekView ); 864 KOWeekButton *label = new KOWeekButton( mWeekView );
865 label->setFocusPolicy(NoFocus); 865 label->setFocusPolicy(NoFocus);
866 label->setFont(bfont); 866 label->setFont(bfont);
867 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 867 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
868 label->setFlat(true); 868 label->setFlat(true);
869 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 869 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
870 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 870 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
871 //label->setLineWidth(1); 871 //label->setLineWidth(1);
872 //label->setAlignment(AlignCenter); 872 //label->setAlignment(AlignCenter);
873 mWeekLabelsW.insert( i, label ); 873 mWeekLabelsW.insert( i, label );
874 } 874 }
875 mWeekLabelsW[1]->setText( i18n("W")); 875 mWeekLabelsW[1]->setText( i18n("W"));
876 876
877 877
878 int row, col; 878 int row, col;
879 mCells.resize( mNumCells ); 879 mCells.resize( mNumCells );
880 for( row = 0; row < mNumWeeks; ++row ) { 880 for( row = 0; row < mNumWeeks; ++row ) {
881 for( col = 0; col < mDaysPerWeek; ++col ) { 881 for( col = 0; col < mDaysPerWeek; ++col ) {
882 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 882 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
883 mCells.insert( row * mDaysPerWeek + col, cell ); 883 mCells.insert( row * mDaysPerWeek + col, cell );
884 884
885 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 885 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
886 SLOT( defaultAction( Incidence * ) ) ); 886 SLOT( defaultAction( Incidence * ) ) );
887 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 887 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
888 SIGNAL( newEventSignal( QDateTime ) ) ); 888 SIGNAL( newEventSignal( QDateTime ) ) );
889 connect( cell, SIGNAL( showDaySignal( QDate ) ), 889 connect( cell, SIGNAL( showDaySignal( QDate ) ),
890 SIGNAL( showDaySignal( QDate ) ) ); 890 SIGNAL( showDaySignal( QDate ) ) );
891 } 891 }
892 } 892 }
893 mCellsW.resize( mDaysPerWeek ); 893 mCellsW.resize( mDaysPerWeek );
894 for( col = 0; col < mDaysPerWeek; ++col ) { 894 for( col = 0; col < mDaysPerWeek; ++col ) {
895 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 895 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
896 mCellsW.insert( col, cell ); 896 mCellsW.insert( col, cell );
897 897
898 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 898 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
899 SLOT( defaultAction( Incidence * ) ) ); 899 SLOT( defaultAction( Incidence * ) ) );
900 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 900 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
901 SIGNAL( newEventSignal( QDateTime ) ) ); 901 SIGNAL( newEventSignal( QDateTime ) ) );
902 connect( cell, SIGNAL( showDaySignal( QDate ) ), 902 connect( cell, SIGNAL( showDaySignal( QDate ) ),
903 SIGNAL( showDaySignal( QDate ) ) ); 903 SIGNAL( showDaySignal( QDate ) ) );
904 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 904 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
905 } 905 }
906 906
907 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 907 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
908 mContextMenu = eventPopup(); 908 mContextMenu = eventPopup();
909 // updateConfig(); //useless here... 909 // updateConfig(); //useless here...
910 // ... but we need mWidthLongDayLabel computed 910 // ... but we need mWidthLongDayLabel computed
911 QFontMetrics fontmetric(mDayLabels[0]->font()); 911 QFontMetrics fontmetric(mDayLabels[0]->font());
912 mWidthLongDayLabel = 0; 912 mWidthLongDayLabel = 0;
913 for (int i = 0; i < 7; i++) { 913 for (int i = 0; i < 7; i++) {
914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
916 } 916 }
917 917
918 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 918 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
919 919
920#if 0
920 if ( mShowWeekView ) 921 if ( mShowWeekView )
921 mWidStack->raiseWidget( mWeekView ); 922 mWidStack->raiseWidget( mWeekView );
922 else 923 else
923 mWidStack->raiseWidget( mMonthView ); 924 mWidStack->raiseWidget( mMonthView );
925#endif
924 926
925 emit incidenceSelected( 0 ); 927 emit incidenceSelected( 0 );
926#ifndef DESKTOP_VERSION 928#ifndef DESKTOP_VERSION
927 resize( QApplication::desktop()->size() ); 929 resize( QApplication::desktop()->size() );
928#else 930#else
929 resize(640, 480 ); 931 resize(640, 480 );
932 updatePossible = true;
930#endif 933#endif
931 computeLayout(); 934 computeLayout();
932 935
936 if ( mShowWeekView )
937 mWidStack->raiseWidget( mWeekView );
938 else
939 mWidStack->raiseWidget( mMonthView );
933} 940}
934 941
935KOMonthView::~KOMonthView() 942KOMonthView::~KOMonthView()
936{ 943{
937 delete mContextMenu; 944 delete mContextMenu;
938} 945}
939 946
940void KOMonthView::selectInternalWeekNum ( int n ) 947void KOMonthView::selectInternalWeekNum ( int n )
941{ 948{
942 switchView(); 949 switchView();
943 emit selectWeekNum ( n ); 950 emit selectWeekNum ( n );
944} 951}
945 952
946int KOMonthView::currentWeek() 953int KOMonthView::currentWeek()
947{ 954{
948 if ( mShowWeekView ) 955 if ( mShowWeekView )
949 return mWeekLabelsW[0]->getWeekNum(); 956 return mWeekLabelsW[0]->getWeekNum();
950 return mWeekLabels[0]->getWeekNum(); 957 return mWeekLabels[0]->getWeekNum();
951} 958}
952void KOMonthView::switchView() 959void KOMonthView::switchView()
953{ 960{
954 961
955 if ( selectedCell( ) ) 962 if ( selectedCell( ) )
956 selectedCell()->deselect(); 963 selectedCell()->deselect();
957 mShowWeekView = !mShowWeekView; 964 mShowWeekView = !mShowWeekView;
958 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 965 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
959 if ( clPending ) { 966 if ( clPending ) {
960 computeLayout(); 967 computeLayout();
961 updateConfig(); 968 updateConfig();
962 } 969 }
963 if ( mShowWeekView ) 970 if ( mShowWeekView )
964 mWidStack->raiseWidget( mWeekView ); 971 mWidStack->raiseWidget( mWeekView );
965 else 972 else
966 mWidStack->raiseWidget( mMonthView ); 973 mWidStack->raiseWidget( mMonthView );
967 clPending = false; 974 clPending = false;
968} 975}
969 976
970int KOMonthView::maxDatesHint() 977int KOMonthView::maxDatesHint()
971{ 978{
972 return mNumCells; 979 return mNumCells;
973} 980}
974 981
975int KOMonthView::currentDateCount() 982int KOMonthView::currentDateCount()
976{ 983{
977 return mNumCells; 984 return mNumCells;
978} 985}
979 986
980QPtrList<Incidence> KOMonthView::selectedIncidences() 987QPtrList<Incidence> KOMonthView::selectedIncidences()
981{ 988{
982 QPtrList<Incidence> selected; 989 QPtrList<Incidence> selected;
983 990
984 if ( mSelectedCell ) { 991 if ( mSelectedCell ) {
985 Incidence *incidence = mSelectedCell->selectedIncidence(); 992 Incidence *incidence = mSelectedCell->selectedIncidence();
986 if ( incidence ) selected.append( incidence ); 993 if ( incidence ) selected.append( incidence );
987 } 994 }
988 995
989 return selected; 996 return selected;
990} 997}
991 998
992DateList KOMonthView::selectedDates() 999DateList KOMonthView::selectedDates()
993{ 1000{
994 DateList selected; 1001 DateList selected;
995 1002
996 if ( mSelectedCell ) { 1003 if ( mSelectedCell ) {
997 QDate qd = mSelectedCell->selectedIncidenceDate(); 1004 QDate qd = mSelectedCell->selectedIncidenceDate();
998 if ( qd.isValid() ) selected.append( qd ); 1005 if ( qd.isValid() ) selected.append( qd );
999 } 1006 }
1000 1007
1001 return selected; 1008 return selected;
1002} 1009}
1003 1010
1004void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1011void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1005 const QDate &td) 1012 const QDate &td)
1006{ 1013{
1007#ifndef KORG_NOPRINTER 1014#ifndef KORG_NOPRINTER
1008 calPrinter->preview(CalPrinter::Month, fd, td); 1015 calPrinter->preview(CalPrinter::Month, fd, td);
1009#endif 1016#endif
1010} 1017}
1011 1018
1012void KOMonthView::updateConfig() 1019void KOMonthView::updateConfig()
1013{ 1020{
1014 1021
1015 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1022 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1016 1023
1017 if ( mShowWeekView ) { 1024 if ( mShowWeekView ) {
1018 mWeekStartsMonday = true; 1025 mWeekStartsMonday = true;
1019 } 1026 }
1020 QFontMetrics fontmetric(mDayLabels[0]->font()); 1027 QFontMetrics fontmetric(mDayLabels[0]->font());
1021 mWidthLongDayLabel = 0; 1028 mWidthLongDayLabel = 0;
1022 1029
1023 for (int i = 0; i < 7; i++) { 1030 for (int i = 0; i < 7; i++) {
1024 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1031 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1025 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1032 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1026 } 1033 }
1027 bool temp = mShowSatSunComp ; 1034 bool temp = mShowSatSunComp ;
1028 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1035 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1029 if ( ! mShowWeekView ) { 1036 if ( ! mShowWeekView ) {
1030 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1037 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1031 computeLayout(); 1038 computeLayout();
1032 } 1039 }
1033 updateDayLabels(); 1040 updateDayLabels();
1034 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1041 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1035 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1042 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1036 //resizeEvent( 0 ); 1043 //resizeEvent( 0 );
1037 for (uint i = 0; i < mCells.count(); ++i) { 1044 for (uint i = 0; i < mCells.count(); ++i) {
1038 mCells[i]->updateConfig(); 1045 mCells[i]->updateConfig();
1039 } 1046 }
1040 1047
1041 for (uint i = 0; i < mCellsW.count(); ++i) { 1048 for (uint i = 0; i < mCellsW.count(); ++i) {
1042 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1049 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1043 } 1050 }
1044#ifdef DESKTOP_VERSION 1051#ifdef DESKTOP_VERSION
1045 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1052 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1046#endif 1053#endif
1047 updateView(); 1054 updateView();
1048} 1055}
1049 1056
1050void KOMonthView::updateDayLabels() 1057void KOMonthView::updateDayLabels()
1051{ 1058{
1052 1059
1053 QPtrVector<QLabel> *mDayLabelsT; 1060 QPtrVector<QLabel> *mDayLabelsT;
1054 1061
1055 mDayLabelsT = &mDayLabelsW; 1062 mDayLabelsT = &mDayLabelsW;
1056 for (int i = 0; i < 7; i++) { 1063 for (int i = 0; i < 7; i++) {
1057 if (mWeekStartsMonday) { 1064 if (mWeekStartsMonday) {
1058 bool show = mShortDayLabelsW; 1065 bool show = mShortDayLabelsW;
1059 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1066 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1060 show = true; 1067 show = true;
1061 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1068 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1062 } else { 1069 } else {
1063 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); 1070 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1064 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); 1071 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1065 1072
1066 } 1073 }
1067 } 1074 }
1068 mDayLabelsT = &mDayLabels; 1075 mDayLabelsT = &mDayLabels;
1069 for (int i = 0; i < 7; i++) { 1076 for (int i = 0; i < 7; i++) {
1070 if (mWeekStartsMonday) { 1077 if (mWeekStartsMonday) {
1071 bool show = mShortDayLabelsM; 1078 bool show = mShortDayLabelsM;
1072 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1079 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1073 show = true; 1080 show = true;
1074 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1081 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1075 } else { 1082 } else {
1076 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1083 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1077 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1084 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1078 1085
1079 } 1086 }
1080 } 1087 }
1081 1088
1082} 1089}
1083 1090
1084void KOMonthView::showDates(const QDate &start, const QDate &) 1091void KOMonthView::showDates(const QDate &start, const QDate &)
1085{ 1092{
1086 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1093 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1087 1094
1088 QPtrVector<MonthViewCell> *cells; 1095 QPtrVector<MonthViewCell> *cells;
1089 QPtrVector<QLabel> *dayLabels; 1096 QPtrVector<QLabel> *dayLabels;
1090 QPtrVector<KOWeekButton> *weekLabels; 1097 QPtrVector<KOWeekButton> *weekLabels;
1091 int weekNum = 6; 1098 int weekNum = 6;
1092 if ( mShowWeekView ) { 1099 if ( mShowWeekView ) {
1093 weekNum = 1; 1100 weekNum = 1;
1094 cells = &mCellsW; 1101 cells = &mCellsW;
1095 dayLabels = &mDayLabelsW; 1102 dayLabels = &mDayLabelsW;
1096 weekLabels = &mWeekLabelsW; 1103 weekLabels = &mWeekLabelsW;
1097 } else { 1104 } else {
1098 cells = &mCells; 1105 cells = &mCells;
1099 dayLabels = &mDayLabels; 1106 dayLabels = &mDayLabels;
1100 weekLabels = &mWeekLabels; 1107 weekLabels = &mWeekLabels;
1101 } 1108 }
1102 1109
1103 mStartDate = start; 1110 mStartDate = start;
1104 1111
1105 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1112 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1106 1113
1107 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1114 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1108 mStartDate = mStartDate.addDays( -1 ); 1115 mStartDate = mStartDate.addDays( -1 );
1109 } 1116 }
1110 1117
1111 bool primary = false; 1118 bool primary = false;
1112 uint i; 1119 uint i;
1113 for( i = 0; i < (*cells).size(); ++i ) { 1120 for( i = 0; i < (*cells).size(); ++i ) {
1114 QDate date = mStartDate.addDays( i ); 1121 QDate date = mStartDate.addDays( i );
1115 (*cells)[i]->setDate( date ); 1122 (*cells)[i]->setDate( date );
1116 1123
1117#ifndef KORG_NOPLUGINS 1124#ifndef KORG_NOPLUGINS
1118 // add holiday, if present 1125 // add holiday, if present
1119 QString hstring(KOCore::self()->holiday(date)); 1126 QString hstring(KOCore::self()->holiday(date));
1120 (*cells)[i]->setHoliday( hstring ); 1127 (*cells)[i]->setHoliday( hstring );
1121#endif 1128#endif
1122 1129
1123 } 1130 }
1124 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1131 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1125 for( i = 0; i < weekNum; ++i ) { 1132 for( i = 0; i < weekNum; ++i ) {
1126 int wno; 1133 int wno;
1127 // remember, according to ISO 8601, the first week of the year is the 1134 // remember, according to ISO 8601, the first week of the year is the
1128 // first week that contains a thursday. Thus we must subtract off 4, 1135 // first week that contains a thursday. Thus we must subtract off 4,
1129 // not just 1. 1136 // not just 1.
1130 int dayOfYear = date.dayOfYear(); 1137 int dayOfYear = date.dayOfYear();
1131 if (dayOfYear % 7 != 0) 1138 if (dayOfYear % 7 != 0)
1132 wno = dayOfYear / 7 + 1; 1139 wno = dayOfYear / 7 + 1;
1133 else 1140 else
1134 wno =dayOfYear / 7; 1141 wno =dayOfYear / 7;
1135 (*weekLabels)[i]->setWeekNum( wno ); 1142 (*weekLabels)[i]->setWeekNum( wno );
1136 date = date.addDays( 7 ); 1143 date = date.addDays( 7 );
1137 } 1144 }
1138 updateView(); 1145 updateView();
1139} 1146}
1140 1147
1141void KOMonthView::showEvents(QPtrList<Event>) 1148void KOMonthView::showEvents(QPtrList<Event>)
1142{ 1149{
1143 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1150 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1144} 1151}
1145 1152
1146void KOMonthView::changeEventDisplay(Event *, int) 1153void KOMonthView::changeEventDisplay(Event *, int)
1147{ 1154{
1148 // this should be re-written to be much more efficient, but this 1155 // this should be re-written to be much more efficient, but this
1149 // quick-and-dirty-hack gets the job done for right now. 1156 // quick-and-dirty-hack gets the job done for right now.
1150 updateView(); 1157 updateView();
1151} 1158}
1152 1159
1153void KOMonthView::updateView() 1160void KOMonthView::updateView()
1154{ 1161{
1155 1162
1156 if ( !updatePossible ) 1163 if ( !updatePossible )
1157 return; 1164 return;
1158 //QTime ti; 1165 //QTime ti;
1159 //ti.start(); 1166 //ti.start();
1160 QPtrVector<MonthViewCell> *cells; 1167 QPtrVector<MonthViewCell> *cells;
1161 if ( mShowWeekView ) { 1168 if ( mShowWeekView ) {
1162 cells = &mCellsW; 1169 cells = &mCellsW;
1163 } else { 1170 } else {
1164 cells = &mCells; 1171 cells = &mCells;
1165 } 1172 }
1166#if 1 1173#if 1
1167 int i; 1174 int i;
1168 int timeSpan = (*cells).size()-1; 1175 int timeSpan = (*cells).size()-1;
1169 if ( KOPrefs::instance()->mMonthViewWeek ) 1176 if ( KOPrefs::instance()->mMonthViewWeek )
1170 timeSpan = 6; 1177 timeSpan = 6;
1171 for( i = 0; i < timeSpan + 1; ++i ) { 1178 for( i = 0; i < timeSpan + 1; ++i ) {
1172 (*cells)[i]->startUpdateCell(); 1179 (*cells)[i]->startUpdateCell();
1173 } 1180 }
1174 1181
1175 QPtrList<Event> events = calendar()->events(); 1182 QPtrList<Event> events = calendar()->events();
1176 Event *event; 1183 Event *event;
1177 QDateTime dt; 1184 QDateTime dt;
1178 bool ok; 1185 bool ok;
1179 QDate endDate = mStartDate.addDays( timeSpan ); 1186 QDate endDate = mStartDate.addDays( timeSpan );
1180 for( event = events.first(); event; event = events.next() ) { // for event 1187 for( event = events.first(); event; event = events.next() ) { // for event
1181 if ( event->doesRecur() ) { 1188 if ( event->doesRecur() ) {
1182 bool last; 1189 bool last;
1183 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1190 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1184 QDateTime incidenceEnd; 1191 QDateTime incidenceEnd;
1185 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1192 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1186 bool invalid = false; 1193 bool invalid = false;
1187 while( true ) { 1194 while( true ) {
1188 if ( incidenceStart.isValid() ) { 1195 if ( incidenceStart.isValid() ) {
1189 incidenceEnd = incidenceStart.addDays( eventlen ); 1196 incidenceEnd = incidenceStart.addDays( eventlen );
1190 int st = incidenceStart.date().daysTo( endDate ); 1197 int st = incidenceStart.date().daysTo( endDate );
1191 if ( st >= 0 ) { // start before timeend 1198 if ( st >= 0 ) { // start before timeend
1192 int end = mStartDate.daysTo( incidenceEnd.date() ); 1199 int end = mStartDate.daysTo( incidenceEnd.date() );
1193 if ( end >= 0 ) { // end after timestart --- got one! 1200 if ( end >= 0 ) { // end after timestart --- got one!
1194 //normalize 1201 //normalize
1195 st = timeSpan - st; 1202 st = timeSpan - st;
1196 if ( st < 0 ) st = 0; 1203 if ( st < 0 ) st = 0;
1197 if ( end > timeSpan ) end = timeSpan; 1204 if ( end > timeSpan ) end = timeSpan;
1198 int iii; 1205 int iii;
1199 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1206 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1200 for ( iii = st;iii<= end;++iii) 1207 for ( iii = st;iii<= end;++iii)
1201 (*cells)[iii]->insertEvent( event ); 1208 (*cells)[iii]->insertEvent( event );
1202 } 1209 }
1203 } 1210 }
1204 } else { 1211 } else {
1205 if ( invalid ) 1212 if ( invalid )
1206 break; 1213 break;
1207 invalid = true; 1214 invalid = true;
1208 //qDebug("invalid %s", event->summary().latin1()); 1215 //qDebug("invalid %s", event->summary().latin1());
1209 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1216 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1210 } 1217 }
1211 if ( last ) 1218 if ( last )
1212 break; 1219 break;
1213 bool ok; 1220 bool ok;
1214 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1221 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1215 if ( ! ok ) 1222 if ( ! ok )
1216 break; 1223 break;
1217 if ( incidenceStart.date() > endDate ) 1224 if ( incidenceStart.date() > endDate )
1218 break; 1225 break;
1219 } 1226 }
1220 } else { // no recur 1227 } else { // no recur
1221 int st = event->dtStart().date().daysTo( endDate ); 1228 int st = event->dtStart().date().daysTo( endDate );
1222 if ( st >= 0 ) { // start before timeend 1229 if ( st >= 0 ) { // start before timeend
1223 int end = mStartDate.daysTo( event->dtEnd().date() ); 1230 int end = mStartDate.daysTo( event->dtEnd().date() );
1224 if ( end >= 0 ) { // end after timestart --- got one! 1231 if ( end >= 0 ) { // end after timestart --- got one!
1225 //normalize 1232 //normalize
1226 st = timeSpan - st; 1233 st = timeSpan - st;
1227 if ( st < 0 ) st = 0; 1234 if ( st < 0 ) st = 0;
1228 if ( end > timeSpan ) end = timeSpan; 1235 if ( end > timeSpan ) end = timeSpan;
1229 int iii; 1236 int iii;
1230 for ( iii = st;iii<= end;++iii) 1237 for ( iii = st;iii<= end;++iii)
1231 (*cells)[iii]->insertEvent( event ); 1238 (*cells)[iii]->insertEvent( event );
1232 } 1239 }
1233 } 1240 }
1234 } 1241 }
1235 } 1242 }
1236 // insert due todos 1243 // insert due todos
1237 QPtrList<Todo> todos = calendar()->todos( ); 1244 QPtrList<Todo> todos = calendar()->todos( );
1238 Todo *todo; 1245 Todo *todo;
1239 for(todo = todos.first(); todo; todo = todos.next()) { 1246 for(todo = todos.first(); todo; todo = todos.next()) {
1240 //insertTodo( todo ); 1247 //insertTodo( todo );
1241 if ( todo->hasDueDate() ) { 1248 if ( todo->hasDueDate() ) {
1242 int day = mStartDate.daysTo( todo->dtDue().date() ); 1249 int day = mStartDate.daysTo( todo->dtDue().date() );
1243 if ( day >= 0 && day < timeSpan + 1) { 1250 if ( day >= 0 && day < timeSpan + 1) {
1244 (*cells)[day]->insertTodo( todo ); 1251 (*cells)[day]->insertTodo( todo );
1245 } 1252 }
1246 } 1253 }
1247 } 1254 }
1248 1255
1249 for( i = 0; i < timeSpan+1; ++i ) { 1256 for( i = 0; i < timeSpan+1; ++i ) {
1250 (*cells)[i]->finishUpdateCell(); 1257 (*cells)[i]->finishUpdateCell();
1251 } 1258 }
1252 processSelectionChange(); 1259 processSelectionChange();
1253 (*cells)[0]->setFocus(); 1260 (*cells)[0]->setFocus();
1254 1261
1255 1262
1256#else 1263#else
1257 // old code 1264 // old code
1258 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1265 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1259 int i; 1266 int i;
1260 for( i = 0; i < (*cells).count(); ++i ) { 1267 for( i = 0; i < (*cells).count(); ++i ) {
1261 (*cells)[i]->updateCell(); 1268 (*cells)[i]->updateCell();
1262 } 1269 }
1263 1270
1264 //qDebug("KOMonthView::updateView() "); 1271 //qDebug("KOMonthView::updateView() ");
1265 processSelectionChange(); 1272 processSelectionChange();
1266 // qDebug("---------------------------------------------------------------------+ "); 1273 // qDebug("---------------------------------------------------------------------+ ");
1267 (*cells)[0]->setFocus(); 1274 (*cells)[0]->setFocus();
1268#endif 1275#endif
1269 1276
1270 //qDebug("update time %d ", ti.elapsed()); 1277 //qDebug("update time %d ", ti.elapsed());
1271} 1278}
1272 1279
1273void KOMonthView::resizeEvent(QResizeEvent * e) 1280void KOMonthView::resizeEvent(QResizeEvent * e)
1274{ 1281{
1275 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1282 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1276 computeLayout(); 1283 computeLayout();
1277 clPending = true; 1284 clPending = true;
1278 if ( mShowWeekView ) 1285 if ( mShowWeekView )
1279 mCellsW[0]->setFocus(); 1286 mCellsW[0]->setFocus();
1280 else 1287 else
1281 mCells[0]->setFocus(); 1288 mCells[0]->setFocus();
1282} 1289}
1283void KOMonthView::computeLayoutWeek() 1290void KOMonthView::computeLayoutWeek()
1284{ 1291{
1285 static int lastWid = 0; 1292 static int lastWid = 0;
1286 static int lastHei = 0; 1293 static int lastHei = 0;
1287 int daysToShow; 1294 int daysToShow;
1288 bool combinedSatSun = false; 1295 bool combinedSatSun = false;
1289 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1296 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1290 daysToShow = 6; 1297 daysToShow = 6;
1291 combinedSatSun = true; 1298 combinedSatSun = true;
1292 } 1299 }
1293 int tWid = topLevelWidget()->size().width(); 1300 int tWid = topLevelWidget()->size().width();
1294 int tHei = topLevelWidget()->size().height(); 1301 int tHei = topLevelWidget()->size().height();
1295 1302
1296 int wid = width();//e 1303 int wid = width();//e
1297 int hei = height()-1-mNavigatorBar->height(); 1304 int hei = height()-1-mNavigatorBar->height();
1298 1305
1299 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1306 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1300 return; 1307 return;
1301 1308
1302 if ( lastWid == width() && lastHei == height() ) 1309 if ( lastWid == width() && lastHei == height() )
1303 return; 1310 return;
1304 lastWid = width(); 1311 lastWid = width();
1305 lastHei = height(); 1312 lastHei = height();
1306 1313
1307 1314
1308 if ( wid < hei ) 1315 if ( wid < hei )
1309 daysToShow = 2; 1316 daysToShow = 2;
1310 else 1317 else
1311 daysToShow = 3; 1318 daysToShow = 3;
1312 mShowSatSunComp = true; 1319 mShowSatSunComp = true;
1313 combinedSatSun = true; 1320 combinedSatSun = true;
1314 1321
1315 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1322 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1316 QFontMetrics fm ( mWeekLabels[0]->font() ); 1323 QFontMetrics fm ( mWeekLabels[0]->font() );
1317 int weeklabelwid = fm.width( "888" ); 1324 int weeklabelwid = fm.width( "888" );
1318 wid -= weeklabelwid; 1325 wid -= weeklabelwid;
1319 1326
1320 int colWid = wid / daysToShow; 1327 int colWid = wid / daysToShow;
1321 int lastCol = wid - ( colWid*6 ); 1328 int lastCol = wid - ( colWid*6 );
1322 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1329 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1323 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1330 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1324 int colModulo = wid % daysToShow; 1331 int colModulo = wid % daysToShow;
1325 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1332 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1326 //qDebug("rowmod %d ", rowModulo); 1333 //qDebug("rowmod %d ", rowModulo);
1327 int i; 1334 int i;
1328 int x,y,w,h; 1335 int x,y,w,h;
1329 x= 0; 1336 x= 0;
1330 y= 0; 1337 y= 0;
1331 w = colWid; 1338 w = colWid;
1332 h = dayLabelHei ; 1339 h = dayLabelHei ;
1333 for ( i = 0; i < 7; i++) { 1340 for ( i = 0; i < 7; i++) {
1334 if ( i && !( i % daysToShow) && i < 6) { 1341 if ( i && !( i % daysToShow) && i < 6) {
1335 y += hei/(5-daysToShow); 1342 y += hei/(5-daysToShow);
1336 x = 0; 1343 x = 0;
1337 w = colWid; 1344 w = colWid;
1338 } 1345 }
1339 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1346 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1340 ++w; 1347 ++w;
1341 } 1348 }
1342 if ( i >= 5 ) { 1349 if ( i >= 5 ) {
1343 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1350 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1344 x -= (w/2 ); 1351 x -= (w/2 );
1345 } 1352 }
1346 else 1353 else
1347 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1354 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1348 x += w; 1355 x += w;
1349 } 1356 }
1350 x= 0; 1357 x= 0;
1351 y= dayLabelHei; 1358 y= dayLabelHei;
1352 w = colWid; 1359 w = colWid;
1353 h = cellHei; 1360 h = cellHei;
1354 for ( i = 0; i < mCellsW.count(); ++i) { 1361 for ( i = 0; i < mCellsW.count(); ++i) {
1355 if ( i > 6 ) { 1362 if ( i > 6 ) {
1356 mCellsW[i]->hide(); 1363 mCellsW[i]->hide();
1357 continue; 1364 continue;
1358 } 1365 }
1359 1366
1360 w = colWid; 1367 w = colWid;
1361 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1368 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1362 ++w; 1369 ++w;
1363 } 1370 }
1364 if ( i == (daysToShow-1-rowModulo)*7) 1371 if ( i == (daysToShow-1-rowModulo)*7)
1365 ++h; 1372 ++h;
1366 1373
1367 if ( i >= 5 ) { 1374 if ( i >= 5 ) {
1368 if ( i ==5 ) { 1375 if ( i ==5 ) {
1369 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1376 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1370 x -= w ;y += h/2; 1377 x -= w ;y += h/2;
1371 } else { 1378 } else {
1372 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1379 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1373 ++w; 1380 ++w;
1374 } 1381 }
1375 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1382 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1376 y -= h/2; 1383 y -= h/2;
1377 } 1384 }
1378 } else 1385 } else
1379 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1386 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1380 1387
1381 1388
1382 x += w; 1389 x += w;
1383 if ( x + w/2 > wid ) { 1390 if ( x + w/2 > wid ) {
1384 x = 0; 1391 x = 0;
1385 y += h+dayLabelHei ; 1392 y += h+dayLabelHei ;
1386 } 1393 }
1387 } 1394 }
1388 y= dayLabelHei; 1395 y= dayLabelHei;
1389 h = cellHei ; 1396 h = cellHei ;
1390 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1397 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1391 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1398 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1392 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1399 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1393 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1400 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1394 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1401 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1395 updateDayLabels(); 1402 updateDayLabels();
1396 //bool forceUpdate = !updatePossible; 1403 //bool forceUpdate = !updatePossible;
1397 updatePossible = true; 1404 updatePossible = true;
1398 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1405 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1399 //if ( forceUpdate ) 1406 //if ( forceUpdate )
1400 // updateView(); 1407 // updateView();
1401} 1408}
1402void KOMonthView::computeLayout() 1409void KOMonthView::computeLayout()
1403{ 1410{
1404 1411
1405 1412
1406 static int lastWid = 0; 1413 static int lastWid = 0;
1407 static int lastHei = 0; 1414 static int lastHei = 0;
1408 1415
1409 if ( mShowWeekView ){ 1416 if ( mShowWeekView ){
1410 computeLayoutWeek(); 1417 computeLayoutWeek();
1411 return; 1418 return;
1412 } 1419 }
1413 int daysToShow = 7; 1420 int daysToShow = 7;
1414 bool combinedSatSun = false; 1421 bool combinedSatSun = false;
1415 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1422 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1416 daysToShow = 6; 1423 daysToShow = 6;
1417 combinedSatSun = true; 1424 combinedSatSun = true;
1418 } 1425 }
1419 int tWid = topLevelWidget()->size().width(); 1426 int tWid = topLevelWidget()->size().width();
1420 int tHei = topLevelWidget()->size().height(); 1427 int tHei = topLevelWidget()->size().height();
1421 1428
1422 int wid = width();//e 1429 int wid = width();//e
1423 int hei = height()-1-mNavigatorBar->height(); 1430 int hei = height()-1-mNavigatorBar->height();
1424 1431
1425 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1432 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1426 return; 1433 return;
1427 } 1434 }
1428 if ( lastWid == width() && lastHei == height() ){ 1435 if ( lastWid == width() && lastHei == height() ){
1429 return; 1436 return;
1430 } 1437 }
1431 1438
1432 lastWid = width(); 1439 lastWid = width();
1433 lastHei = height(); 1440 lastHei = height();
1434 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); 1441 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ ");
1435 QFontMetrics fm ( mWeekLabels[0]->font() ); 1442 QFontMetrics fm ( mWeekLabels[0]->font() );
1436 int weeklabelwid = fm.width( "888" ); 1443 int weeklabelwid = fm.width( "888" );
1437 wid -= weeklabelwid; 1444 wid -= weeklabelwid;
1438 1445
1439 int colWid = wid / daysToShow; 1446 int colWid = wid / daysToShow;
1440 int lastCol = wid - ( colWid*6 ); 1447 int lastCol = wid - ( colWid*6 );
1441 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1448 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1442 int cellHei = (hei - dayLabelHei) /6; 1449 int cellHei = (hei - dayLabelHei) /6;
1443 int colModulo = wid % daysToShow; 1450 int colModulo = wid % daysToShow;
1444 int rowModulo = (hei- dayLabelHei) % 6; 1451 int rowModulo = (hei- dayLabelHei) % 6;
1445 //qDebug("rowmod %d ", rowModulo); 1452 //qDebug("rowmod %d ", rowModulo);
1446 int i; 1453 int i;
1447 int x,y,w,h; 1454 int x,y,w,h;
1448 x= 0; 1455 x= 0;
1449 y= 0; 1456 y= 0;
1450 w = colWid; 1457 w = colWid;
1451 h = dayLabelHei ; 1458 h = dayLabelHei ;
1452 for ( i = 0; i < 7; i++) { 1459 for ( i = 0; i < 7; i++) {
1453 if ( i == daysToShow-colModulo ) 1460 if ( i == daysToShow-colModulo )
1454 ++w; 1461 ++w;
1455 if ( combinedSatSun ) { 1462 if ( combinedSatSun ) {
1456 if ( i >= daysToShow-1 ) { 1463 if ( i >= daysToShow-1 ) {
1457 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1464 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1458 x -= w/2 ; 1465 x -= w/2 ;
1459 } 1466 }
1460 else 1467 else
1461 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1468 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1462 } else 1469 } else
1463 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1470 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1464 x += w; 1471 x += w;
1465 } 1472 }
1466 x= 0; 1473 x= 0;
1467 y= dayLabelHei; 1474 y= dayLabelHei;
1468 w = colWid; 1475 w = colWid;
1469 h = cellHei ; 1476 h = cellHei ;
1470 for ( i = 0; i < mCells.count(); ++i) { 1477 for ( i = 0; i < mCells.count(); ++i) {
1471 //qDebug("iii %d ", i); 1478 //qDebug("iii %d ", i);
1472 w = colWid; 1479 w = colWid;
1473 if ( ((i) % 7) >= 7-colModulo ) { 1480 if ( ((i) % 7) >= 7-colModulo ) {
1474 ++w; 1481 ++w;
1475 } 1482 }
1476 if ( i == (6-rowModulo)*7) 1483 if ( i == (6-rowModulo)*7)
1477 ++h; 1484 ++h;
1478 if ( combinedSatSun ) { 1485 if ( combinedSatSun ) {
1479 if ( (i)%7 >= daysToShow-1 ) { 1486 if ( (i)%7 >= daysToShow-1 ) {
1480 if ( (i)%7 == daysToShow-1 ) { 1487 if ( (i)%7 == daysToShow-1 ) {
1481 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1488 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1482 x -= w ;y += h/2; 1489 x -= w ;y += h/2;
1483 } else { 1490 } else {
1484 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1491 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1485 y -= h/2; 1492 y -= h/2;
1486 } 1493 }
1487 } else 1494 } else
1488 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1495 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1489 1496
1490 } 1497 }
1491 else 1498 else
1492 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1499 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1493 x += w; 1500 x += w;
1494 if ( x + w/2 > wid ) { 1501 if ( x + w/2 > wid ) {
1495 x = 0; 1502 x = 0;
1496 y += h; 1503 y += h;
1497 } 1504 }
1498 } 1505 }
1499 y= dayLabelHei; 1506 y= dayLabelHei;
1500 h = cellHei ; 1507 h = cellHei ;
1501 for ( i = 0; i < 6; i++) { 1508 for ( i = 0; i < 6; i++) {
1502 if ( i == (6-rowModulo)) 1509 if ( i == (6-rowModulo))
1503 ++h; 1510 ++h;
1504 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1511 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1505 y += h; 1512 y += h;
1506 } 1513 }
1507 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1514 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1508 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1515 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1509 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1516 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1510 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1517 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1511 updateDayLabels(); 1518 updateDayLabels();
1512 //bool forceUpdate = !updatePossible; 1519 //bool forceUpdate = !updatePossible;
1513 updatePossible = true; 1520 updatePossible = true;
1514 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1521 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1515} 1522}
1516 1523
1517void KOMonthView::showContextMenu( Incidence *incidence ) 1524void KOMonthView::showContextMenu( Incidence *incidence )
1518{ 1525{
1519 mContextMenu->showIncidencePopup(incidence); 1526 mContextMenu->showIncidencePopup(incidence);
1520 /* 1527 /*
1521 if( incidence && incidence->type() == "Event" ) { 1528 if( incidence && incidence->type() == "Event" ) {
1522 Event *event = static_cast<Event *>(incidence); 1529 Event *event = static_cast<Event *>(incidence);
1523 mContextMenu->showEventPopup(event); 1530 mContextMenu->showEventPopup(event);
1524 } else { 1531 } else {
1525 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1532 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1526 } 1533 }
1527 */ 1534 */
1528} 1535}
1529MonthViewCell * KOMonthView::selectedCell( ) 1536MonthViewCell * KOMonthView::selectedCell( )
1530{ 1537{
1531 return mSelectedCell; 1538 return mSelectedCell;
1532} 1539}
1533void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1540void KOMonthView::setSelectedCell( MonthViewCell *cell )
1534{ 1541{
1535 // qDebug("KOMonthView::setSelectedCell "); 1542 // qDebug("KOMonthView::setSelectedCell ");
1536 if ( mSelectedCell && mSelectedCell != cell ) { 1543 if ( mSelectedCell && mSelectedCell != cell ) {
1537 MonthViewCell * mvc = mSelectedCell; 1544 MonthViewCell * mvc = mSelectedCell;
1538 mSelectedCell = cell; 1545 mSelectedCell = cell;
1539 mvc->deselect(); 1546 mvc->deselect();
1540 } else 1547 } else
1541 mSelectedCell = cell; 1548 mSelectedCell = cell;
1542 // if ( mSelectedCell ) 1549 // if ( mSelectedCell )
1543 // mSelectedCell->select(); 1550 // mSelectedCell->select();
1544 if ( !mSelectedCell ) 1551 if ( !mSelectedCell )
1545 emit incidenceSelected( 0 ); 1552 emit incidenceSelected( 0 );
1546 else 1553 else
1547 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1554 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1548} 1555}
1549 1556
1550void KOMonthView::processSelectionChange() 1557void KOMonthView::processSelectionChange()
1551{ 1558{
1552 QPtrList<Incidence> incidences = selectedIncidences(); 1559 QPtrList<Incidence> incidences = selectedIncidences();
1553 if (incidences.count() > 0) { 1560 if (incidences.count() > 0) {
1554 emit incidenceSelected( incidences.first() ); 1561 emit incidenceSelected( incidences.first() );
1555 } else { 1562 } else {
1556 emit incidenceSelected( 0 ); 1563 emit incidenceSelected( 0 );
1557 } 1564 }
1558} 1565}
1559 1566
1560void KOMonthView::clearSelection() 1567void KOMonthView::clearSelection()
1561{ 1568{
1562 if ( mSelectedCell ) { 1569 if ( mSelectedCell ) {
1563 mSelectedCell->deselect(); 1570 mSelectedCell->deselect();
1564 mSelectedCell = 0; 1571 mSelectedCell = 0;
1565 } 1572 }
1566} 1573}
1567void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1574void KOMonthView::keyPressEvent ( QKeyEvent * e )
1568{ 1575{
1569 //qDebug("KOMonthView::keyPressEvent "); 1576 //qDebug("KOMonthView::keyPressEvent ");
1570 switch(e->key()) { 1577 switch(e->key()) {
1571 case Key_Up: 1578 case Key_Up:
1572 { 1579 {
1573 emit prevMonth(); 1580 emit prevMonth();
1574 if ( mShowWeekView ) 1581 if ( mShowWeekView )
1575 mCellsW[0]->setFocus(); 1582 mCellsW[0]->setFocus();
1576 else 1583 else
1577 mCells[0]->setFocus(); 1584 mCells[0]->setFocus();
1578 } 1585 }
1579 e->accept(); 1586 e->accept();
1580 break; 1587 break;
1581 case Key_Down: 1588 case Key_Down:
1582 { 1589 {
1583 emit nextMonth(); 1590 emit nextMonth();
1584 if ( mShowWeekView ) 1591 if ( mShowWeekView )
1585 mCellsW[0]->setFocus(); 1592 mCellsW[0]->setFocus();
1586 else 1593 else
1587 mCells[0]->setFocus(); 1594 mCells[0]->setFocus();
1588 1595
1589 } 1596 }
1590 e->accept(); 1597 e->accept();
1591 break; 1598 break;
1592 case Key_Return: 1599 case Key_Return:
1593 case Key_Enter: 1600 case Key_Enter:
1594 { 1601 {
1595 selectInternalWeekNum ( currentWeek() ); 1602 selectInternalWeekNum ( currentWeek() );
1596 } 1603 }
1597 e->accept(); 1604 e->accept();
1598 break; 1605 break;
1599 default: 1606 default:
1600 e->ignore(); 1607 e->ignore();
1601 break; 1608 break;
1602 } 1609 }
1603} 1610}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 78d4027..44db209 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,464 +1,461 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23 23
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include "kotodoviewitem.h" 25#include "kotodoviewitem.h"
26#include "kotodoview.h" 26#include "kotodoview.h"
27#include "koprefs.h" 27#include "koprefs.h"
28 28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{ 31{
32 construct(); 32 construct();
33} 33}
34 34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{ 37{
38 construct(); 38 construct();
39} 39}
40 40
41QString KOTodoViewItem::key(int column,bool) const 41QString KOTodoViewItem::key(int column,bool) const
42{ 42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) { 44 if (it == mKeyMap.end()) {
45 return text(column).lower(); 45 return text(column).lower();
46 } else { 46 } else {
47 return *it; 47 return *it;
48 } 48 }
49} 49}
50 50
51void KOTodoViewItem:: setup() 51void KOTodoViewItem:: setup()
52{ 52{
53 53
54 int h = 20; 54 int h = 20;
55 if ( listView () ) { 55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () ); 56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height(); 57 h = fm.height();
58 } 58 }
59 setHeight( h ); 59 setHeight( h );
60 60
61} 61}
62void KOTodoViewItem::setSortKey(int column,const QString &key) 62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{ 63{
64 mKeyMap.insert(column,key); 64 mKeyMap.insert(column,key);
65} 65}
66 66
67#if QT_VERSION >= 0x030000 67#if QT_VERSION >= 0x030000
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h) 69 int y,int h)
70{ 70{
71 QListViewItem::paintBranches(p,cg,w,y,h); 71 QListViewItem::paintBranches(p,cg,w,y,h);
72} 72}
73#else 73#else
74#endif 74#endif
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 if (isOn()!=state) { 206 if (isOn()!=state) {
207 setOn(state); 207 setOn(state);
208 //qDebug("SETON "); 208 //qDebug("SETON ");
209 return; 209 return;
210 } 210 }
211 if ( mTodo->isCompleted() == state ) { 211 if ( mTodo->isCompleted() == state ) {
212 //qDebug("STATECHANGE:nothing to do "); 212 //qDebug("STATECHANGE:nothing to do ");
213 return; 213 return;
214 } 214 }
215 QString keyd = "=="; 215 QString keyd = "==";
216 QString keyt = "=="; 216 QString keyt = "==";
217 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 217 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
218 mTodo->setCompleted(state); 218 mTodo->setCompleted(state);
219 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 219 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
220 220
221 if (mTodo->hasDueDate()) { 221 if (mTodo->hasDueDate()) {
222 setText(3, mTodo->dtDueDateStr()); 222 setText(3, mTodo->dtDueDateStr());
223 QDate d = mTodo->dtDue().date(); 223 QDate d = mTodo->dtDue().date();
224 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 224 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
225 setSortKey(3,keyd); 225 setSortKey(3,keyd);
226 if (mTodo->doesFloat()) { 226 if (mTodo->doesFloat()) {
227 setText(4,""); 227 setText(4,"");
228 } 228 }
229 else { 229 else {
230 setText(4,mTodo->dtDueTimeStr()); 230 setText(4,mTodo->dtDueTimeStr());
231 QTime t = mTodo->dtDue().time(); 231 QTime t = mTodo->dtDue().time();
232 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 232 keyt.sprintf("%02d%02d",t.hour(),t.minute());
233 setSortKey(4,keyt); 233 setSortKey(4,keyt);
234 } 234 }
235 } 235 }
236 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 236 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
237 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 237 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
238 238
239 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 239 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
240 if (mTodo->percentComplete()<100) { 240 if (mTodo->percentComplete()<100) {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(mTodo->percentComplete())); 242 else setSortKey(2,QString::number(mTodo->percentComplete()));
243 } 243 }
244 else { 244 else {
245 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 245 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
246 else setSortKey(2,QString::number(99)); 246 else setSortKey(2,QString::number(99));
247 } 247 }
248 if ( state ) { 248 if ( state ) {
249 QListViewItem * myChild = firstChild(); 249 QListViewItem * myChild = firstChild();
250 KOTodoViewItem *item; 250 KOTodoViewItem *item;
251 while( myChild ) { 251 while( myChild ) {
252 //qDebug("stateCH "); 252 //qDebug("stateCH ");
253 item = static_cast<KOTodoViewItem*>(myChild); 253 item = static_cast<KOTodoViewItem*>(myChild);
254 item->stateChange(state); 254 item->stateChange(state);
255 myChild = myChild->nextSibling(); 255 myChild = myChild->nextSibling();
256 } 256 }
257 } else { 257 } else {
258 QListViewItem * myChild = parent(); 258 QListViewItem * myChild = parent();
259 if ( myChild ) 259 if ( myChild )
260 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 260 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
261 } 261 }
262 mTodoView->modified(true); 262 mTodoView->modified(true);
263 setMyPixmap(); 263 setMyPixmap();
264 mTodoView->setTodoModified( mTodo ); 264 mTodoView->setTodoModified( mTodo );
265} 265}
266 266
267bool KOTodoViewItem::isAlternate() 267bool KOTodoViewItem::isAlternate()
268{ 268{
269#ifndef KORG_NOLVALTERNATION 269
270 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 270 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
271 if (lv && lv->alternateBackground().isValid()) 271 if (lv && lv->alternateBackground().isValid())
272 { 272 {
273 KOTodoViewItem *above = 0; 273 KOTodoViewItem *above = 0;
274 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 274 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
275 m_known = above ? above->m_known : true; 275 m_known = above ? above->m_known : true;
276 if (m_known) 276 if (m_known)
277 { 277 {
278 m_odd = above ? !above->m_odd : false; 278 m_odd = above ? !above->m_odd : false;
279 } 279 }
280 else 280 else
281 { 281 {
282 KOTodoViewItem *item; 282 KOTodoViewItem *item;
283 bool previous = true; 283 bool previous = true;
284 if (QListViewItem::parent()) 284 if (QListViewItem::parent())
285 { 285 {
286 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 286 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
287 if (item) 287 if (item)
288 previous = item->m_odd; 288 previous = item->m_odd;
289 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 289 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
290 } 290 }
291 else 291 else
292 { 292 {
293 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 293 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
294 } 294 }
295 295
296 while(item) 296 while(item)
297 { 297 {
298 item->m_odd = previous = !previous; 298 item->m_odd = previous = !previous;
299 item->m_known = true; 299 item->m_known = true;
300 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 300 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
301 } 301 }
302 } 302 }
303 return m_odd; 303 return m_odd;
304 } 304 }
305 return false; 305 return false;
306#else
307 return false;
308#endif
309} 306}
310 307
311void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 308void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
312{ 309{
313 QColorGroup _cg = cg; 310 QColorGroup _cg = cg;
314 QColorGroup::ColorRole role; 311 QColorGroup::ColorRole role;
315 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 312 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
316 role = QColorGroup::Text; 313 role = QColorGroup::Text;
317 else 314 else
318 role = QColorGroup::Base; 315 role = QColorGroup::Base;
319 //#ifndef KORG_NOLVALTERNATION 316 //#ifndef KORG_NOLVALTERNATION
320 // if (isAlternate()) 317 if (isAlternate())
321 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 318 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
322 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 319 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
323 QColor colorToSet; 320 QColor colorToSet;
324 if ( setColor ) { 321 if ( setColor ) {
325 QStringList categories = mTodo->categories(); 322 QStringList categories = mTodo->categories();
326 QString cat = categories.first(); 323 QString cat = categories.first();
327 if ( !cat.isEmpty()) { 324 if ( !cat.isEmpty()) {
328 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 325 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
329 } else 326 } else
330 setColor = false; 327 setColor = false;
331 } 328 }
332 329
333 int odue = mTodo->hasDueSubTodo( !isOpen()); 330 int odue = mTodo->hasDueSubTodo( !isOpen());
334 if (odue == 2) { 331 if (odue == 2) {
335 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 332 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
336 setColor = true; 333 setColor = true;
337 } else if ( odue == 1 ) { 334 } else if ( odue == 1 ) {
338 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 335 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
339 setColor = true; 336 setColor = true;
340 } 337 }
341 338
342 339
343 if ( setColor ) { 340 if ( setColor ) {
344 _cg.setColor(role,colorToSet ); 341 _cg.setColor(role,colorToSet );
345 if ( role == QColorGroup::Base) { 342 if ( role == QColorGroup::Base) {
346 int rgb = colorToSet.red(); 343 int rgb = colorToSet.red();
347 rgb += colorToSet.blue()/2; 344 rgb += colorToSet.blue()/2;
348 rgb += colorToSet.green(); 345 rgb += colorToSet.green();
349 if ( rgb < 200 ) 346 if ( rgb < 200 )
350 _cg.setColor(QColorGroup::Text,Qt::white ); 347 _cg.setColor(QColorGroup::Text,Qt::white );
351 } 348 }
352 } 349 }
353 //#endif 350 //#endif
354 if ( column > 0 ){ 351 if ( column > 0 ){
355 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 352 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
356 p->save(); 353 p->save();
357 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 354 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
358 355
359 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 356 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
360 // p->setPen(Qt::black ); //border 357 // p->setPen(Qt::black ); //border
361 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 358 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
362 QColor fc = KOPrefs::instance()->mHighlightColor; 359 QColor fc = KOPrefs::instance()->mHighlightColor;
363 if ( mTodo->percentComplete() == 100 ) 360 if ( mTodo->percentComplete() == 100 )
364 fc = darkGreen; 361 fc = darkGreen;
365 p->drawRect( 2, 2, width-4, height()-4); 362 p->drawRect( 2, 2, width-4, height()-4);
366 p->fillRect( 3, 3, progress, height()-6, 363 p->fillRect( 3, 3, progress, height()-6,
367 fc ); 364 fc );
368 p->restore(); 365 p->restore();
369 } else { 366 } else {
370 QCheckListItem::paintCell(p, _cg, column, width, alignment); 367 QCheckListItem::paintCell(p, _cg, column, width, alignment);
371 } 368 }
372 return; 369 return;
373 } 370 }
374 371
375 int align = alignment; 372 int align = alignment;
376 373
377 if ( !p ) 374 if ( !p )
378 return; 375 return;
379 376
380 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 377 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
381 378
382 QListView *lv = listView(); 379 QListView *lv = listView();
383 if ( !lv ) 380 if ( !lv )
384 return; 381 return;
385 int marg = 2;//lv->itemMargin(); 382 int marg = 2;//lv->itemMargin();
386 int r = 0; 383 int r = 0;
387 QCheckListItem::Type myType = QCheckListItem::CheckBox; 384 QCheckListItem::Type myType = QCheckListItem::CheckBox;
388 int BoxSize = 20; 385 int BoxSize = 20;
389 int boxOffset = 2; 386 int boxOffset = 2;
390 int xOffset = 2; 387 int xOffset = 2;
391 if (qApp->desktop()->width() < 300 ) { 388 if (qApp->desktop()->width() < 300 ) {
392 BoxSize = 14; 389 BoxSize = 14;
393 boxOffset = -1; 390 boxOffset = -1;
394 xOffset = 1; 391 xOffset = 1;
395 // marg = 0; 392 // marg = 0;
396 } 393 }
397 if ( height() < BoxSize ) { 394 if ( height() < BoxSize ) {
398 boxOffset = boxOffset - ((BoxSize - height())/2) ; 395 boxOffset = boxOffset - ((BoxSize - height())/2) ;
399 // qDebug("boxOffset %d height %d", boxOffset, height() ); 396 // qDebug("boxOffset %d height %d", boxOffset, height() );
400 BoxSize = height(); 397 BoxSize = height();
401 398
402 } 399 }
403 //bool winStyle = lv->style() == WindowsStyle; 400 //bool winStyle = lv->style() == WindowsStyle;
404 401
405 int lineStart = 5; 402 int lineStart = 5;
406 if ( myType == Controller ) { 403 if ( myType == Controller ) {
407 if ( !pixmap( 0 ) ) 404 if ( !pixmap( 0 ) )
408 r += BoxSize + 4; 405 r += BoxSize + 4;
409 } else { 406 } else {
410 ASSERT( lv ); //### 407 ASSERT( lv ); //###
411 //QFontMetrics fm( lv->font() ); 408 //QFontMetrics fm( lv->font() );
412 //int d = fm.height(); 409 //int d = fm.height();
413 int x = 0; 410 int x = 0;
414 int y = (height() - BoxSize) / 2; 411 int y = (height() - BoxSize) / 2;
415 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 412 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
416 if ( myType == CheckBox ) { 413 if ( myType == CheckBox ) {
417 if ( isEnabled() ) 414 if ( isEnabled() )
418 p->setPen( QPen( _cg.text(), 1 ) ); 415 p->setPen( QPen( _cg.text(), 1 ) );
419 else 416 else
420 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 417 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
421 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 418 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
422 lineStart = x+marg; 419 lineStart = x+marg;
423 ///////////////////// 420 /////////////////////
424 x++; 421 x++;
425 y++; 422 y++;
426 if ( isOn() ) { 423 if ( isOn() ) {
427 QPointArray a( 7*2 ); 424 QPointArray a( 7*2 );
428 int i, xx, yy; 425 int i, xx, yy;
429 xx = x+xOffset+marg+(boxOffset/2); 426 xx = x+xOffset+marg+(boxOffset/2);
430 yy = y+5+boxOffset; 427 yy = y+5+boxOffset;
431 for ( i=0; i<3; i++ ) { 428 for ( i=0; i<3; i++ ) {
432 a.setPoint( 2*i, xx, yy ); 429 a.setPoint( 2*i, xx, yy );
433 a.setPoint( 2*i+1, xx, yy+2 ); 430 a.setPoint( 2*i+1, xx, yy+2 );
434 // qDebug(" "); 431 // qDebug(" ");
435 xx++; yy++; 432 xx++; yy++;
436 } 433 }
437 yy -= 2; 434 yy -= 2;
438 for ( i=3; i<7; i++ ) { 435 for ( i=3; i<7; i++ ) {
439 a.setPoint( 2*i, xx, yy ); 436 a.setPoint( 2*i, xx, yy );
440 a.setPoint( 2*i+1, xx, yy+2 ); 437 a.setPoint( 2*i+1, xx, yy+2 );
441 xx++; yy--; 438 xx++; yy--;
442 } 439 }
443 p->setPen( darkGreen ); 440 p->setPen( darkGreen );
444 p->drawLineSegments( a ); 441 p->drawLineSegments( a );
445 } 442 }
446 //////////////////////// 443 ////////////////////////
447 } 444 }
448 r += BoxSize + 4; 445 r += BoxSize + 4;
449 } 446 }
450 447
451 p->translate( r, 0 ); 448 p->translate( r, 0 );
452 p->setPen( QPen( _cg.text() ) ); 449 p->setPen( QPen( _cg.text() ) );
453 QListViewItem::paintCell( p, _cg, column, width - r, align ); 450 QListViewItem::paintCell( p, _cg, column, width - r, align );
454 if ( mTodo->cancelled () ) { 451 if ( mTodo->cancelled () ) {
455 p->setPen( black ); 452 p->setPen( black );
456 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 453 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
457 int wid = br.width() +lineStart; 454 int wid = br.width() +lineStart;
458 if ( wid > width-3 ) 455 if ( wid > width-3 )
459 wid = width-3; 456 wid = width-3;
460 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 457 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
461 458
462 } 459 }
463 460
464} 461}
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 1024796..d182279 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -1,939 +1,939 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/////////////////// KDateTable widget class ////////////////////// 21/////////////////// KDateTable widget class //////////////////////
22// 22//
23// Copyright (C) 1997 Tim D. Gilman 23// Copyright (C) 1997 Tim D. Gilman
24// (C) 1998-2001 Mirko Boehm 24// (C) 1998-2001 Mirko Boehm
25// Written using Qt (http://www.troll.no) for the 25// Written using Qt (http://www.troll.no) for the
26// KDE project (http://www.kde.org) 26// KDE project (http://www.kde.org)
27// 27//
28// This is a support class for the KDatePicker class. It just 28// This is a support class for the KDatePicker class. It just
29// draws the calender table without titles, but could theoretically 29// draws the calender table without titles, but could theoretically
30// be used as a standalone. 30// be used as a standalone.
31// 31//
32// When a date is selected by the user, it emits a signal: 32// When a date is selected by the user, it emits a signal:
33// dateSelected(QDate) 33// dateSelected(QDate)
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kglobalsettings.h> 36#include <kglobalsettings.h>
37#include <kapplication.h> 37#include <kapplication.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <knotifyclient.h> 40#include <knotifyclient.h>
41#include "kdatetbl.h" 41#include "kdatetbl.h"
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qstring.h> 43#include <qstring.h>
44#include <qpen.h> 44#include <qpen.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <assert.h> 47#include <assert.h>
48#include <qapplication.h> 48#include <qapplication.h>
49 49
50KDateValidator::KDateValidator(QWidget* parent, const char* name) 50KDateValidator::KDateValidator(QWidget* parent, const char* name)
51 : QValidator(parent, name) 51 : QValidator(parent, name)
52{ 52{
53} 53}
54 54
55QValidator::State 55QValidator::State
56KDateValidator::validate(QString& text, int&) const 56KDateValidator::validate(QString& text, int&) const
57{ 57{
58 QDate temp; 58 QDate temp;
59 // ----- everything is tested in date(): 59 // ----- everything is tested in date():
60 return date(text, temp); 60 return date(text, temp);
61} 61}
62 62
63QValidator::State 63QValidator::State
64KDateValidator::date(const QString& text, QDate& d) const 64KDateValidator::date(const QString& text, QDate& d) const
65{ 65{
66 QDate tmp = KGlobal::locale()->readDate(text); 66 QDate tmp = KGlobal::locale()->readDate(text);
67 if (!tmp.isNull()) 67 if (!tmp.isNull())
68 { 68 {
69 d = tmp; 69 d = tmp;
70 return Acceptable; 70 return Acceptable;
71 } else 71 } else
72 return Valid; 72 return Valid;
73} 73}
74 74
75void 75void
76KDateValidator::fixup( QString& ) const 76KDateValidator::fixup( QString& ) const
77{ 77{
78 78
79} 79}
80 80
81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) 81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
82 : QGridView(parent, name, f) 82 : QGridView(parent, name, f)
83{ 83{
84 setFont( KGlobalSettings::generalFont() ); 84 setFont( KGlobalSettings::generalFont() );
85 if(!date_.isValid()) 85 if(!date_.isValid())
86 { 86 {
87 date_=QDate::currentDate(); 87 date_=QDate::currentDate();
88 } 88 }
89 setFocusPolicy( QWidget::StrongFocus ); 89 setFocusPolicy( QWidget::StrongFocus );
90 setNumRows(7); // 6 weeks max + headline 90 setNumRows(7); // 6 weeks max + headline
91 setNumCols(7); // 7 days a week 91 setNumCols(7); // 7 days a week
92 setHScrollBarMode(AlwaysOff); 92 setHScrollBarMode(AlwaysOff);
93 setVScrollBarMode(AlwaysOff); 93 setVScrollBarMode(AlwaysOff);
94 viewport()->setBackgroundColor(QColor(220,245,255)); 94 viewport()->setBackgroundColor(QColor(220,245,255));
95#if 0 95#if 0
96 viewport()->setEraseColor(lightGray); 96 viewport()->setEraseColor(lightGray);
97#endif 97#endif
98 mMarkCurrent = false; 98 mMarkCurrent = false;
99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth 99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
100} 100}
101 101
102void 102void
103KDateTable::paintCell(QPainter *painter, int row, int col) 103KDateTable::paintCell(QPainter *painter, int row, int col)
104{ 104{
105 QRect rect; 105 QRect rect;
106 QString text; 106 QString text;
107 QPen pen; 107 QPen pen;
108 int w=cellWidth(); 108 int w=cellWidth();
109 int h=cellHeight(); 109 int h=cellHeight();
110 int pos; 110 int pos;
111 QBrush brushBlue(blue); 111 QBrush brushBlue(blue);
112 QBrush brushLightblue(QColor(220,245,255)); 112 QBrush brushLightblue(QColor(220,245,255));
113 QFont _font=font(); 113 QFont _font=font();
114 // ----- 114 // -----
115 if(row==0) 115 if(row==0)
116 { // we are drawing the headline 116 { // we are drawing the headline
117 _font.setBold(true); 117 _font.setBold(true);
118 painter->setFont(_font); 118 painter->setFont(_font);
119 bool normalday = true; 119 bool normalday = true;
120 QString daystr; 120 QString daystr;
121 if (KGlobal::locale()->weekStartsMonday()) 121 if (KGlobal::locale()->weekStartsMonday())
122 { 122 {
123 daystr = KGlobal::locale()->weekDayName(col+1, true); 123 daystr = KGlobal::locale()->weekDayName(col+1, true);
124 if (col == 5 || col == 6) 124 if (col == 5 || col == 6)
125 normalday = false; 125 normalday = false;
126 } else { 126 } else {
127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); 127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
128 if (col == 0 || col == 6) 128 if (col == 0 || col == 6)
129 normalday = false; 129 normalday = false;
130 } 130 }
131 if (!normalday) 131 if (!normalday)
132 { 132 {
133 painter->setPen(QColor(220,245,255)); 133 painter->setPen(QColor(220,245,255));
134 painter->setBrush(brushLightblue); 134 painter->setBrush(brushLightblue);
135 painter->drawRect(0, 0, w, h); 135 painter->drawRect(0, 0, w, h);
136 painter->setPen(blue); 136 painter->setPen(blue);
137 } else { 137 } else {
138 painter->setPen(blue); 138 painter->setPen(blue);
139 painter->setBrush(brushBlue); 139 painter->setBrush(brushBlue);
140 painter->drawRect(0, 0, w, h); 140 painter->drawRect(0, 0, w, h);
141 painter->setPen(white); 141 painter->setPen(white);
142 } 142 }
143 painter->drawText(0, 0, w, h-1, AlignCenter, 143 painter->drawText(0, 0, w, h-1, AlignCenter,
144 daystr, -1, &rect); 144 daystr, -1, &rect);
145 painter->setPen(black); 145 painter->setPen(black);
146 painter->moveTo(0, h-1); 146 painter->moveTo(0, h-1);
147 painter->lineTo(w-1, h-1); 147 painter->lineTo(w-1, h-1);
148 // ----- draw the weekday: 148 // ----- draw the weekday:
149 } else { 149 } else {
150 painter->setFont(_font); 150 painter->setFont(_font);
151 pos=7*(row-1)+col; 151 pos=7*(row-1)+col;
152 if (KGlobal::locale()->weekStartsMonday()) 152 if (KGlobal::locale()->weekStartsMonday())
153 pos++; 153 pos++;
154 if(pos<firstday || (firstday+numdays<=pos)) 154 if(pos<firstday || (firstday+numdays<=pos))
155 { // we are either 155 { // we are either
156 // ° painting a day of the previous month or 156 // ° painting a day of the previous month or
157 // ° painting a day of the following month 157 // ° painting a day of the following month
158 if(pos<firstday) 158 if(pos<firstday)
159 { // previous month 159 { // previous month
160 text.setNum(numDaysPrevMonth+pos-firstday+1); 160 text.setNum(numDaysPrevMonth+pos-firstday+1);
161 } else { // following month 161 } else { // following month
162 text.setNum(pos-firstday-numdays+1); 162 text.setNum(pos-firstday-numdays+1);
163 } 163 }
164 painter->setPen(gray); 164 painter->setPen(gray);
165 } else { // paint a day of the current month 165 } else { // paint a day of the current month
166 text.setNum(pos-firstday+1); 166 text.setNum(pos-firstday+1);
167 painter->setPen(black); 167 painter->setPen(black);
168 } 168 }
169 169
170 pen=painter->pen(); 170 pen=painter->pen();
171 if(firstday+date.day()-1==pos) 171 if(firstday+date.day()-1==pos)
172 { 172 {
173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
174 painter->setPen(green); 174 painter->setPen(green);
175 else 175 else
176 painter->setPen(red); 176 painter->setPen(red);
177 if(hasFocus()) 177 if(hasFocus())
178 { 178 {
179 painter->setBrush(darkRed); 179 painter->setBrush(darkRed);
180 pen=white; 180 pen=white;
181 } else { 181 } else {
182 painter->setBrush(darkGray); 182 painter->setBrush(darkGray);
183 pen=white; 183 pen=white;
184 } 184 }
185 } else { 185 } else {
186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
187 { 187 {
188 painter->setPen(green); 188 painter->setPen(green);
189 painter->setBrush(darkGreen); 189 painter->setBrush(darkGreen);
190 pen=white; 190 pen=white;
191 } else { 191 } else {
192 painter->setBrush(QColor(220,245,255)); 192 painter->setBrush(QColor(220,245,255));
193 painter->setPen(QColor(220,245,255)); 193 painter->setPen(QColor(220,245,255));
194 } 194 }
195 } 195 }
196 painter->drawRect(0, 0, w, h); 196 painter->drawRect(0, 0, w, h);
197 painter->setPen(pen); 197 painter->setPen(pen);
198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); 198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
199 } 199 }
200 /* 200 /*
201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); 201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
202 if(rect.height()>maxCell.height()) { 202 if(rect.height()>maxCell.height()) {
203 maxCell.setHeight(rect.height()); 203 maxCell.setHeight(rect.height());
204 } 204 }
205 */ 205 */
206} 206}
207 207
208void 208void
209KDateTable::keyPressEvent( QKeyEvent *e ) 209KDateTable::keyPressEvent( QKeyEvent *e )
210{ 210{
211 /* 211 /*
212 // not working properly 212 // not working properly
213 if ( e->key() == Qt::Key_Prior ) { 213 if ( e->key() == Qt::Key_Prior ) {
214 if ( date.month() == 1 ) { 214 if ( date.month() == 1 ) {
215 KNotifyClient::beep(); 215 KNotifyClient::beep();
216 return; 216 return;
217 } 217 }
218 int day = date.day(); 218 int day = date.day();
219 if ( day > 27 ) 219 if ( day > 27 )
220 while ( !QDate::isValid( date.year(), date.month()-1, day ) ) 220 while ( !QDate::isValid( date.year(), date.month()-1, day ) )
221 day--; 221 day--;
222 setDate(QDate(date.year(), date.month()-1, day)); 222 setDate(QDate(date.year(), date.month()-1, day));
223 return; 223 return;
224 } 224 }
225 if ( e->key() == Qt::Key_Next ) { 225 if ( e->key() == Qt::Key_Next ) {
226 if ( date.month() == 12 ) { 226 if ( date.month() == 12 ) {
227 KNotifyClient::beep(); 227 KNotifyClient::beep();
228 return; 228 return;
229 } 229 }
230 int day = date.day(); 230 int day = date.day();
231 if ( day > 27 ) 231 if ( day > 27 )
232 while ( !QDate::isValid( date.year(), date.month()+1, day ) ) 232 while ( !QDate::isValid( date.year(), date.month()+1, day ) )
233 day--; 233 day--;
234 setDate(QDate(date.year(), date.month()+1, day)); 234 setDate(QDate(date.year(), date.month()+1, day));
235 return; 235 return;
236 } 236 }
237 */ 237 */
238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
239 239
240 int temp=firstday+date.day()-dayoff; 240 int temp=firstday+date.day()-dayoff;
241 int pos = temp; 241 int pos = temp;
242 bool irgnore = true; 242 bool irgnore = true;
243 if ( e->state() != Qt::ControlButton ) { 243 if ( e->state() != Qt::ControlButton ) {
244 if ( e->key() == Qt::Key_Up ) { 244 if ( e->key() == Qt::Key_Up ) {
245 pos -= 7; 245 pos -= 7;
246 irgnore = false; 246 irgnore = false;
247 } 247 }
248 if ( e->key() == Qt::Key_Down ) { 248 if ( e->key() == Qt::Key_Down ) {
249 pos += 7; 249 pos += 7;
250 irgnore = false; 250 irgnore = false;
251 } 251 }
252 if ( e->key() == Qt::Key_Left ) { 252 if ( e->key() == Qt::Key_Left ) {
253 pos--; 253 pos--;
254 irgnore = false; 254 irgnore = false;
255 } 255 }
256 if ( e->key() == Qt::Key_Right ) { 256 if ( e->key() == Qt::Key_Right ) {
257 pos++; 257 pos++;
258 irgnore = false; 258 irgnore = false;
259 } 259 }
260 } 260 }
261 if ( irgnore ) 261 if ( irgnore )
262 e->ignore(); 262 e->ignore();
263 263
264 if(pos+dayoff<=firstday) 264 if(pos+dayoff<=firstday)
265 { // this day is in the previous month 265 { // this day is in the previous month
266 KNotifyClient::beep(); 266 KNotifyClient::beep();
267 return; 267 return;
268 } 268 }
269 if(firstday+numdays<pos+dayoff) 269 if(firstday+numdays<pos+dayoff)
270 { // this date is in the next month 270 { // this date is in the next month
271 KNotifyClient::beep(i18n( "Month not long enough" )); 271 KNotifyClient::beep(i18n( "Month not long enough" ));
272 return; 272 return;
273 } 273 }
274 274
275 if ( pos == temp ) 275 if ( pos == temp )
276 return; 276 return;
277 277
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); 278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
279 updateCell(temp/7+1, temp%7); // Update the previously selected cell 279 updateCell(temp/7+1, temp%7); // Update the previously selected cell
280 updateCell(pos/7+1, pos%7); // Update the selected cell 280 updateCell(pos/7+1, pos%7); // Update the selected cell
281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
282 282
283 283
284} 284}
285 285
286void 286void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 287KDateTable::viewportResizeEvent(QResizeEvent * e)
288{ 288{
289 QGridView::viewportResizeEvent(e); 289 QGridView::viewportResizeEvent(e);
290 290
291 setCellWidth(viewport()->width()/7); 291 setCellWidth(viewport()->width()/7);
292 setCellHeight(viewport()->height()/7); 292 setCellHeight(viewport()->height()/7);
293} 293}
294 294
295void 295void
296KDateTable::setFontSize(int size) 296KDateTable::setFontSize(int size)
297{ 297{
298 int count; 298 int count;
299 QRect rect; 299 QRect rect;
300 // ----- store rectangles: 300 // ----- store rectangles:
301 fontsize=size; 301 fontsize=size;
302 QFont _font = font(); 302 QFont _font = font();
303 _font.setPointSize(fontsize); 303 _font.setPointSize(fontsize);
304 setFont( _font ); 304 setFont( _font );
305 _font.setBold( true ); 305 _font.setBold( true );
306 QFontMetrics metrics(_font); 306 QFontMetrics metrics(_font);
307 307
308 // ----- find largest day name: 308 // ----- find largest day name:
309 maxCell.setWidth(0); 309 maxCell.setWidth(0);
310 maxCell.setHeight(0); 310 maxCell.setHeight(0);
311 for(count=0; count<7; ++count) 311 for(count=0; count<7; ++count)
312 { 312 {
313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
314 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 314 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
315 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 315 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
316 } 316 }
317 // ----- compare with a real wide number and add some space: 317 // ----- compare with a real wide number and add some space:
318 rect=metrics.boundingRect(QString::fromLatin1("88")); 318 rect=metrics.boundingRect(QString::fromLatin1("88"));
319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
320#ifdef DESKTOP_VERSION 320#ifdef DESKTOP_VERSION
321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
322#else 322#else
323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
324#endif 324#endif
325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
326 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 326 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
327 qDebug("setmax "); 327 qDebug("setmax ");
328 } 328 }
329} 329}
330 330
331void 331void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 332KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 333{
334 if(e->type()!=QEvent::MouseButtonPress) 334 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 335 { // the KDatePicker only reacts on mouse press events:
336 return; 336 return;
337 } 337 }
338 if(!isEnabled()) 338 if(!isEnabled())
339 { 339 {
340 KNotifyClient::beep(); 340 KNotifyClient::beep();
341 return; 341 return;
342 } 342 }
343 343
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 345 // -----
346 int row, col, pos, temp; 346 int row, col, pos, temp;
347 QPoint mouseCoord; 347 QPoint mouseCoord;
348 // ----- 348 // -----
349 mouseCoord = e->pos(); 349 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 350 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 351 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 352 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 353 { // the user clicked on the frame of the table
354 return; 354 return;
355 } 355 }
356 pos=7*(row-1)+col+1; 356 pos=7*(row-1)+col+1;
357#if 0 357#if 0
358 if(pos+dayoff<=firstday) 358 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 359 { // this day is in the previous month
360 KNotifyClient::beep(); 360 KNotifyClient::beep();
361 return; 361 return;
362 } 362 }
363 if(firstday+numdays<pos+dayoff) 363 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 364 { // this date is in the next month
365 KNotifyClient::beep(); 365 KNotifyClient::beep();
366 return; 366 return;
367 } 367 }
368#endif 368#endif
369 temp=firstday+date.day()-dayoff-1; 369 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 370 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 371 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 372 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 373 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 375 emit(tableClicked());
376} 376}
377 377
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::setDate(const QDate& date_)
380{ 380{
381 bool changed=false; 381 bool changed=false;
382 QDate temp; 382 QDate temp;
383 mMarkCurrent = false; 383 mMarkCurrent = false;
384 // ----- 384 // -----
385 if(!date_.isValid()) 385 if(!date_.isValid())
386 { 386 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 388 return false;
389 } 389 }
390 if(date!=date_) 390 if(date!=date_)
391 { 391 {
392 date=date_; 392 date=date_;
393 changed=true; 393 changed=true;
394 } 394 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 396 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 397 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 398 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 399 numdays=date.daysInMonth();
400 if(date.month()==1) 400 if(date.month()==1)
401 { // set to december of previous year 401 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 402 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 403 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 404 temp.setYMD(date.year(), date.month()-1, 1);
405 } 405 }
406 numDaysPrevMonth=temp.daysInMonth(); 406 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 407 if(changed)
408 { 408 {
409 repaintContents(false); 409 repaintContents(false);
410 } 410 }
411 emit(dateChanged(date)); 411 emit(dateChanged(date));
412 return true; 412 return true;
413} 413}
414 414
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::sizeHint() const
435{ 435{
436 if(maxCell.height()>0 && maxCell.width()>0) 436 if(maxCell.height()>0 && maxCell.width()>0)
437 { 437 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 439 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 440 } else {
441 return QSize(-1, -1); 441 return QSize(-1, -1);
442 } 442 }
443} 443}
444 444
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 446(QWidget* parent, const char* name)
447 : QGridView(parent, name), 447 : QGridView(parent, name),
448 result(0) // invalid 448 result(0) // invalid
449{ 449{
450 QRect rect; 450 QRect rect;
451 QFont font; 451 QFont font;
452 // ----- 452 // -----
453 activeCol = -1; 453 activeCol = -1;
454 activeRow = -1; 454 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 455 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 456 int fontsize = 10;
457 int add = 2; 457 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 459 add += 8;
460 if ( QApplication::desktop()->width() > 640 ) 460 if ( QApplication::desktop()->width() > 640 )
461 add += 4; 461 add += 6;
462 font.setPointSize(fontsize+add); 462 font.setPointSize(fontsize+add);
463 setFont(font); 463 setFont(font);
464 setHScrollBarMode(AlwaysOff); 464 setHScrollBarMode(AlwaysOff);
465 setVScrollBarMode(AlwaysOff); 465 setVScrollBarMode(AlwaysOff);
466 setFrameStyle(QFrame::NoFrame); 466 setFrameStyle(QFrame::NoFrame);
467 setNumRows(4); 467 setNumRows(4);
468 setNumCols(3); 468 setNumCols(3);
469 // enable to find drawing failures: 469 // enable to find drawing failures:
470 // setTableFlags(Tbl_clipCellPainting); 470 // setTableFlags(Tbl_clipCellPainting);
471#if 0 471#if 0
472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
473#endif 473#endif
474 // ----- find the preferred size 474 // ----- find the preferred size
475 // (this is slow, possibly, but unfortunatly it is needed here): 475 // (this is slow, possibly, but unfortunatly it is needed here):
476 QFontMetrics metrics(font); 476 QFontMetrics metrics(font);
477 for(int i=1; i <= 12; ++i) 477 for(int i=1; i <= 12; ++i)
478 { 478 {
479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
480 if(max.width()<rect.width()) max.setWidth(rect.width()); 480 if(max.width()<rect.width()) max.setWidth(rect.width());
481 if(max.height()<rect.height()) max.setHeight(rect.height()); 481 if(max.height()<rect.height()) max.setHeight(rect.height());
482 } 482 }
483 483
484} 484}
485 485
486QSize 486QSize
487KDateInternalMonthPicker::sizeHint() const 487KDateInternalMonthPicker::sizeHint() const
488{ 488{
489 return QSize((max.width()+6)*numCols()+2*frameWidth(), 489 return QSize((max.width()+6)*numCols()+2*frameWidth(),
490 (max.height()+6)*numRows()+2*frameWidth()); 490 (max.height()+6)*numRows()+2*frameWidth());
491} 491}
492 492
493int 493int
494KDateInternalMonthPicker::getResult() const 494KDateInternalMonthPicker::getResult() const
495{ 495{
496 return result; 496 return result;
497} 497}
498 498
499void 499void
500KDateInternalMonthPicker::setupPainter(QPainter *p) 500KDateInternalMonthPicker::setupPainter(QPainter *p)
501{ 501{
502 p->setPen(black); 502 p->setPen(black);
503} 503}
504 504
505void 505void
506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
507{ 507{
508 setCellWidth(width()/3); 508 setCellWidth(width()/3);
509 setCellHeight(height()/4); 509 setCellHeight(height()/4);
510} 510}
511 511
512void 512void
513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
514{ 514{
515 int index; 515 int index;
516 QString text; 516 QString text;
517 // ----- find the number of the cell: 517 // ----- find the number of the cell:
518 index=3*row+col+1; 518 index=3*row+col+1;
519 text=KGlobal::locale()->monthName(index, false); 519 text=KGlobal::locale()->monthName(index, false);
520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
521 if ( activeCol == col && activeRow == row ) 521 if ( activeCol == col && activeRow == row )
522 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 522 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
523} 523}
524 524
525void 525void
526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
527{ 527{
528 if(!isEnabled() || e->button() != LeftButton) 528 if(!isEnabled() || e->button() != LeftButton)
529 { 529 {
530 KNotifyClient::beep(); 530 KNotifyClient::beep();
531 return; 531 return;
532 } 532 }
533 // ----- 533 // -----
534 int row, col; 534 int row, col;
535 QPoint mouseCoord; 535 QPoint mouseCoord;
536 // ----- 536 // -----
537 mouseCoord = e->pos(); 537 mouseCoord = e->pos();
538 row=rowAt(mouseCoord.y()); 538 row=rowAt(mouseCoord.y());
539 col=columnAt(mouseCoord.x()); 539 col=columnAt(mouseCoord.x());
540 540
541 if(row<0 || col<0) 541 if(row<0 || col<0)
542 { // the user clicked on the frame of the table 542 { // the user clicked on the frame of the table
543 activeCol = -1; 543 activeCol = -1;
544 activeRow = -1; 544 activeRow = -1;
545 } else { 545 } else {
546 activeCol = col; 546 activeCol = col;
547 activeRow = row; 547 activeRow = row;
548 updateCell( row, col /*, false */ ); 548 updateCell( row, col /*, false */ );
549 } 549 }
550} 550}
551 551
552void 552void
553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
554{ 554{
555 if (e->state() & LeftButton) 555 if (e->state() & LeftButton)
556 { 556 {
557 int row, col; 557 int row, col;
558 QPoint mouseCoord; 558 QPoint mouseCoord;
559 // ----- 559 // -----
560 mouseCoord = e->pos(); 560 mouseCoord = e->pos();
561 row=rowAt(mouseCoord.y()); 561 row=rowAt(mouseCoord.y());
562 col=columnAt(mouseCoord.x()); 562 col=columnAt(mouseCoord.x());
563 int tmpRow = -1, tmpCol = -1; 563 int tmpRow = -1, tmpCol = -1;
564 if(row<0 || col<0) 564 if(row<0 || col<0)
565 { // the user clicked on the frame of the table 565 { // the user clicked on the frame of the table
566 if ( activeCol > -1 ) 566 if ( activeCol > -1 )
567 { 567 {
568 tmpRow = activeRow; 568 tmpRow = activeRow;
569 tmpCol = activeCol; 569 tmpCol = activeCol;
570 } 570 }
571 activeCol = -1; 571 activeCol = -1;
572 activeRow = -1; 572 activeRow = -1;
573 } else { 573 } else {
574 bool differentCell = (activeRow != row || activeCol != col); 574 bool differentCell = (activeRow != row || activeCol != col);
575 if ( activeCol > -1 && differentCell) 575 if ( activeCol > -1 && differentCell)
576 { 576 {
577 tmpRow = activeRow; 577 tmpRow = activeRow;
578 tmpCol = activeCol; 578 tmpCol = activeCol;
579 } 579 }
580 if ( differentCell) 580 if ( differentCell)
581 { 581 {
582 activeRow = row; 582 activeRow = row;
583 activeCol = col; 583 activeCol = col;
584 updateCell( row, col /*, false */ ); // mark the new active cell 584 updateCell( row, col /*, false */ ); // mark the new active cell
585 } 585 }
586 } 586 }
587 if ( tmpRow > -1 ) // repaint the former active cell 587 if ( tmpRow > -1 ) // repaint the former active cell
588 updateCell( tmpRow, tmpCol /*, true */ ); 588 updateCell( tmpRow, tmpCol /*, true */ );
589 } 589 }
590} 590}
591 591
592void 592void
593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) 593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e)
594{ 594{
595 if(!isEnabled()) 595 if(!isEnabled())
596 { 596 {
597 return; 597 return;
598 } 598 }
599 // ----- 599 // -----
600 int row, col, pos; 600 int row, col, pos;
601 QPoint mouseCoord; 601 QPoint mouseCoord;
602 // ----- 602 // -----
603 mouseCoord = e->pos(); 603 mouseCoord = e->pos();
604 row=rowAt(mouseCoord.y()); 604 row=rowAt(mouseCoord.y());
605 col=columnAt(mouseCoord.x()); 605 col=columnAt(mouseCoord.x());
606 if(row<0 || col<0) 606 if(row<0 || col<0)
607 { // the user clicked on the frame of the table 607 { // the user clicked on the frame of the table
608 emit(closeMe(0)); 608 emit(closeMe(0));
609 } 609 }
610 pos=3*row+col+1; 610 pos=3*row+col+1;
611 result=pos; 611 result=pos;
612 emit(closeMe(1)); 612 emit(closeMe(1));
613} 613}
614 614
615 615
616 616
617KDateInternalYearSelector::KDateInternalYearSelector 617KDateInternalYearSelector::KDateInternalYearSelector
618(int fontsize, QWidget* parent, const char* name) 618(int fontsize, QWidget* parent, const char* name)
619 : QLineEdit(parent, name), 619 : QLineEdit(parent, name),
620 val(new QIntValidator(this)), 620 val(new QIntValidator(this)),
621 result(0) 621 result(0)
622{ 622{
623 QFont font; 623 QFont font;
624 // ----- 624 // -----
625 font=KGlobalSettings::generalFont(); 625 font=KGlobalSettings::generalFont();
626 font.setPointSize(fontsize); 626 font.setPointSize(fontsize);
627 setFont(font); 627 setFont(font);
628#if 0 628#if 0
629 setFrameStyle(QFrame::NoFrame); 629 setFrameStyle(QFrame::NoFrame);
630#endif 630#endif
631 // we have to respect the limits of QDate here, I fear: 631 // we have to respect the limits of QDate here, I fear:
632 val->setRange(0, 8000); 632 val->setRange(0, 8000);
633 setValidator(val); 633 setValidator(val);
634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); 634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()));
635} 635}
636 636
637void 637void
638KDateInternalYearSelector::yearEnteredSlot() 638KDateInternalYearSelector::yearEnteredSlot()
639{ 639{
640 bool ok; 640 bool ok;
641 int year; 641 int year;
642 QDate date; 642 QDate date;
643 // ----- check if this is a valid year: 643 // ----- check if this is a valid year:
644 year=text().toInt(&ok); 644 year=text().toInt(&ok);
645 if(!ok) 645 if(!ok)
646 { 646 {
647 KNotifyClient::beep(); 647 KNotifyClient::beep();
648 return; 648 return;
649 } 649 }
650 date.setYMD(year, 1, 1); 650 date.setYMD(year, 1, 1);
651 if(!date.isValid()) 651 if(!date.isValid())
652 { 652 {
653 KNotifyClient::beep(); 653 KNotifyClient::beep();
654 return; 654 return;
655 } 655 }
656 result=year; 656 result=year;
657 emit(closeMe(1)); 657 emit(closeMe(1));
658} 658}
659 659
660int 660int
661KDateInternalYearSelector::getYear() 661KDateInternalYearSelector::getYear()
662{ 662{
663 return result; 663 return result;
664} 664}
665 665
666void 666void
667KDateInternalYearSelector::setYear(int year) 667KDateInternalYearSelector::setYear(int year)
668{ 668{
669 QString temp; 669 QString temp;
670 // ----- 670 // -----
671 temp.setNum(year); 671 temp.setNum(year);
672 setText(temp); 672 setText(temp);
673} 673}
674 674
675KPopupFrame::KPopupFrame(QWidget* parent, const char* name) 675KPopupFrame::KPopupFrame(QWidget* parent, const char* name)
676 : QFrame(parent, name, WType_Popup), 676 : QFrame(parent, name, WType_Popup),
677 result(0), // rejected 677 result(0), // rejected
678 main(0) 678 main(0)
679{ 679{
680 setFrameStyle(QFrame::Box|QFrame::Raised); 680 setFrameStyle(QFrame::Box|QFrame::Raised);
681 setMidLineWidth(2); 681 setMidLineWidth(2);
682} 682}
683 683
684void 684void
685KPopupFrame::keyPressEvent(QKeyEvent* e) 685KPopupFrame::keyPressEvent(QKeyEvent* e)
686{ 686{
687 if(e->key()==Key_Escape) 687 if(e->key()==Key_Escape)
688 { 688 {
689 result=0; // rejected 689 result=0; // rejected
690 qApp->exit_loop(); 690 qApp->exit_loop();
691 } 691 }
692} 692}
693 693
694void 694void
695KPopupFrame::close(int r) 695KPopupFrame::close(int r)
696{ 696{
697 result=r; 697 result=r;
698 qApp->exit_loop(); 698 qApp->exit_loop();
699} 699}
700 700
701void 701void
702KPopupFrame::setMainWidget(QWidget* m) 702KPopupFrame::setMainWidget(QWidget* m)
703{ 703{
704 main=m; 704 main=m;
705 if(main!=0) 705 if(main!=0)
706 { 706 {
707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
708 } 708 }
709} 709}
710 710
711void 711void
712KPopupFrame::resizeEvent(QResizeEvent*) 712KPopupFrame::resizeEvent(QResizeEvent*)
713{ 713{
714 if(main!=0) 714 if(main!=0)
715 { 715 {
716 main->setGeometry(frameWidth(), frameWidth(), 716 main->setGeometry(frameWidth(), frameWidth(),
717 width()-2*frameWidth(), height()-2*frameWidth()); 717 width()-2*frameWidth(), height()-2*frameWidth());
718 } 718 }
719} 719}
720 720
721void 721void
722KPopupFrame::popup(const QPoint &pos) 722KPopupFrame::popup(const QPoint &pos)
723{ 723{
724 // Make sure the whole popup is visible. 724 // Make sure the whole popup is visible.
725 QRect d = QApplication::desktop()->frameGeometry(); 725 QRect d = QApplication::desktop()->frameGeometry();
726 int x = pos.x(); 726 int x = pos.x();
727 int y = pos.y(); 727 int y = pos.y();
728 int w = width(); 728 int w = width();
729 int h = height(); 729 int h = height();
730 if (x+w > d.x()+d.width()) 730 if (x+w > d.x()+d.width())
731 x = d.width() - w; 731 x = d.width() - w;
732 if (y+h > d.y()+d.height()) 732 if (y+h > d.y()+d.height())
733 y = d.height() - h; 733 y = d.height() - h;
734 if (x < d.x()) 734 if (x < d.x())
735 x = 0; 735 x = 0;
736 if (y < d.y()) 736 if (y < d.y())
737 y = 0; 737 y = 0;
738 738
739 // Pop the thingy up. 739 // Pop the thingy up.
740 move(x, y); 740 move(x, y);
741 show(); 741 show();
742} 742}
743 743
744int 744int
745KPopupFrame::exec(QPoint pos) 745KPopupFrame::exec(QPoint pos)
746{ 746{
747 popup(pos); 747 popup(pos);
748 repaint(); 748 repaint();
749 qApp->enter_loop(); 749 qApp->enter_loop();
750 hide(); 750 hide();
751 return result; 751 return result;
752} 752}
753 753
754int 754int
755KPopupFrame::exec(int x, int y) 755KPopupFrame::exec(int x, int y)
756{ 756{
757 return exec(QPoint(x, y)); 757 return exec(QPoint(x, y));
758} 758}
759 759
760void KPopupFrame::virtual_hook( int, void* ) 760void KPopupFrame::virtual_hook( int, void* )
761{ /*BASE::virtual_hook( id, data );*/ } 761{ /*BASE::virtual_hook( id, data );*/ }
762 762
763void KDateTable::virtual_hook( int, void* ) 763void KDateTable::virtual_hook( int, void* )
764{ /*BASE::virtual_hook( id, data );*/ } 764{ /*BASE::virtual_hook( id, data );*/ }
765 765
766//#include "kdatetbl.moc" 766//#include "kdatetbl.moc"
767 767
768 768
769KDateInternalWeekPicker::KDateInternalWeekPicker 769KDateInternalWeekPicker::KDateInternalWeekPicker
770(QWidget* parent, const char* name) 770(QWidget* parent, const char* name)
771 : QGridView(parent, name), 771 : QGridView(parent, name),
772 result(0) // invalid 772 result(0) // invalid
773{ 773{
774 QRect rect; 774 QRect rect;
775 QFont font; 775 QFont font;
776 // ----- 776 // -----
777 activeCol = -1; 777 activeCol = -1;
778 activeRow = -1; 778 activeRow = -1;
779 font=KGlobalSettings::generalFont(); 779 font=KGlobalSettings::generalFont();
780 int fontsize = 10; 780 int fontsize = 10;
781 int add = 2; 781 int add = 2;
782 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 782 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
783 add += 6; 783 add += 6;
784 font.setPointSize(fontsize+add); 784 font.setPointSize(fontsize+add);
785 setFont(font); 785 setFont(font);
786 setHScrollBarMode(AlwaysOff); 786 setHScrollBarMode(AlwaysOff);
787 setVScrollBarMode(AlwaysOff); 787 setVScrollBarMode(AlwaysOff);
788 setFrameStyle(QFrame::NoFrame); 788 setFrameStyle(QFrame::NoFrame);
789 setNumRows(13); 789 setNumRows(13);
790 setNumCols(4); 790 setNumCols(4);
791 // enable to find drawing failures: 791 // enable to find drawing failures:
792 // setTableFlags(Tbl_clipCellPainting); 792 // setTableFlags(Tbl_clipCellPainting);
793#if 0 793#if 0
794 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 794 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
795#endif 795#endif
796 // ----- find the preferred size 796 // ----- find the preferred size
797 // (this is slow, possibly, but unfortunatly it is needed here): 797 // (this is slow, possibly, but unfortunatly it is needed here):
798 QFontMetrics metrics(font); 798 QFontMetrics metrics(font);
799 for(int i=1; i <= 52; ++i) 799 for(int i=1; i <= 52; ++i)
800 { 800 {
801 rect=metrics.boundingRect(QString::number( i )); 801 rect=metrics.boundingRect(QString::number( i ));
802 if(max.width()<rect.width()) max.setWidth(rect.width()); 802 if(max.width()<rect.width()) max.setWidth(rect.width());
803 if(max.height()<rect.height()) max.setHeight(rect.height()); 803 if(max.height()<rect.height()) max.setHeight(rect.height());
804 } 804 }
805 if ( QApplication::desktop()->width() > 640 ) { 805 if ( QApplication::desktop()->width() > 640 ) {
806 806
807 max.setWidth(max.width()+6); 807 max.setWidth(max.width()+6);
808 max.setHeight(max.height()+8); 808 max.setHeight(max.height()+8);
809 } 809 }
810} 810}
811 811
812QSize 812QSize
813KDateInternalWeekPicker::sizeHint() const 813KDateInternalWeekPicker::sizeHint() const
814{ 814{
815 return QSize((max.width()+6)*numCols()+2*frameWidth(), 815 return QSize((max.width()+6)*numCols()+2*frameWidth(),
816 (max.height()+6)*numRows()+2*frameWidth()); 816 (max.height()+6)*numRows()+2*frameWidth());
817} 817}
818 818
819int 819int
820KDateInternalWeekPicker::getResult() const 820KDateInternalWeekPicker::getResult() const
821{ 821{
822 return result; 822 return result;
823} 823}
824 824
825void 825void
826KDateInternalWeekPicker::setupPainter(QPainter *p) 826KDateInternalWeekPicker::setupPainter(QPainter *p)
827{ 827{
828 p->setPen(black); 828 p->setPen(black);
829} 829}
830 830
831void 831void
832KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) 832KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
833{ 833{
834 setCellWidth(width()/4); 834 setCellWidth(width()/4);
835 setCellHeight(height()/13); 835 setCellHeight(height()/13);
836} 836}
837 837
838void 838void
839KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) 839KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
840{ 840{
841 int index; 841 int index;
842 QString text; 842 QString text;
843 // ----- find the number of the cell: 843 // ----- find the number of the cell:
844 index=4*row+col+1; 844 index=4*row+col+1;
845 text=QString::number( index ); 845 text=QString::number( index );
846 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 846 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
847 if ( activeCol == col && activeRow == row ) 847 if ( activeCol == col && activeRow == row )
848 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 848 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
849} 849}
850 850
851void 851void
852KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) 852KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
853{ 853{
854 if(!isEnabled() || e->button() != LeftButton) 854 if(!isEnabled() || e->button() != LeftButton)
855 { 855 {
856 KNotifyClient::beep(); 856 KNotifyClient::beep();
857 return; 857 return;
858 } 858 }
859 // ----- 859 // -----
860 int row, col; 860 int row, col;
861 QPoint mouseCoord; 861 QPoint mouseCoord;
862 // ----- 862 // -----
863 mouseCoord = e->pos(); 863 mouseCoord = e->pos();
864 row=rowAt(mouseCoord.y()); 864 row=rowAt(mouseCoord.y());
865 col=columnAt(mouseCoord.x()); 865 col=columnAt(mouseCoord.x());
866 866
867 if(row<0 || col<0) 867 if(row<0 || col<0)
868 { // the user clicked on the frame of the table 868 { // the user clicked on the frame of the table
869 activeCol = -1; 869 activeCol = -1;
870 activeRow = -1; 870 activeRow = -1;
871 } else { 871 } else {
872 activeCol = col; 872 activeCol = col;
873 activeRow = row; 873 activeRow = row;
874 updateCell( row, col /*, false */ ); 874 updateCell( row, col /*, false */ );
875 } 875 }
876} 876}
877 877
878void 878void
879KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) 879KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
880{ 880{
881 if (e->state() & LeftButton) 881 if (e->state() & LeftButton)
882 { 882 {
883 int row, col; 883 int row, col;
884 QPoint mouseCoord; 884 QPoint mouseCoord;
885 // ----- 885 // -----
886 mouseCoord = e->pos(); 886 mouseCoord = e->pos();
887 row=rowAt(mouseCoord.y()); 887 row=rowAt(mouseCoord.y());
888 col=columnAt(mouseCoord.x()); 888 col=columnAt(mouseCoord.x());
889 int tmpRow = -1, tmpCol = -1; 889 int tmpRow = -1, tmpCol = -1;
890 if(row<0 || col<0) 890 if(row<0 || col<0)
891 { // the user clicked on the frame of the table 891 { // the user clicked on the frame of the table
892 if ( activeCol > -1 ) 892 if ( activeCol > -1 )
893 { 893 {
894 tmpRow = activeRow; 894 tmpRow = activeRow;
895 tmpCol = activeCol; 895 tmpCol = activeCol;
896 } 896 }
897 activeCol = -1; 897 activeCol = -1;
898 activeRow = -1; 898 activeRow = -1;
899 } else { 899 } else {
900 bool differentCell = (activeRow != row || activeCol != col); 900 bool differentCell = (activeRow != row || activeCol != col);
901 if ( activeCol > -1 && differentCell) 901 if ( activeCol > -1 && differentCell)
902 { 902 {
903 tmpRow = activeRow; 903 tmpRow = activeRow;
904 tmpCol = activeCol; 904 tmpCol = activeCol;
905 } 905 }
906 if ( differentCell) 906 if ( differentCell)
907 { 907 {
908 activeRow = row; 908 activeRow = row;
909 activeCol = col; 909 activeCol = col;
910 updateCell( row, col /*, false */ ); // mark the new active cell 910 updateCell( row, col /*, false */ ); // mark the new active cell
911 } 911 }
912 } 912 }
913 if ( tmpRow > -1 ) // repaint the former active cell 913 if ( tmpRow > -1 ) // repaint the former active cell
914 updateCell( tmpRow, tmpCol /*, true */ ); 914 updateCell( tmpRow, tmpCol /*, true */ );
915 } 915 }
916} 916}
917 917
918void 918void
919KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) 919KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
920{ 920{
921 if(!isEnabled()) 921 if(!isEnabled())
922 { 922 {
923 return; 923 return;
924 } 924 }
925 // ----- 925 // -----
926 int row, col, pos; 926 int row, col, pos;
927 QPoint mouseCoord; 927 QPoint mouseCoord;
928 // ----- 928 // -----
929 mouseCoord = e->pos(); 929 mouseCoord = e->pos();
930 row=rowAt(mouseCoord.y()); 930 row=rowAt(mouseCoord.y());
931 col=columnAt(mouseCoord.x()); 931 col=columnAt(mouseCoord.x());
932 if(row<0 || col<0) 932 if(row<0 || col<0)
933 { // the user clicked on the frame of the table 933 { // the user clicked on the frame of the table
934 emit(closeMe(0)); 934 emit(closeMe(0));
935 } 935 }
936 pos=4*row+col+1; 936 pos=4*row+col+1;
937 result=pos; 937 result=pos;
938 emit(closeMe(1)); 938 emit(closeMe(1));
939} 939}
diff --git a/version b/version
index 2976531..c98eacc 100644
--- a/version
+++ b/version
@@ -1 +1 @@
version = "2.0.5"; version = "2.0.6";