summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-29 00:10:48 (UTC)
committer zautrix <zautrix>2005-03-29 00:10:48 (UTC)
commita5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46 (patch) (unidiff)
treeb9f1b2710da1cd0105382831ac0a3e3d7d44f09c /korganizer
parent4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (diff)
downloadkdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.zip
kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.gz
kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index d825493..940d288 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,298 +1,304 @@
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 KOPrefs::instance()->mWTshowDetails, 98 KOPrefs::instance()->mWTshowDetails,
99 KOPrefs::instance()->mWTshowCreated, 99 KOPrefs::instance()->mWTshowCreated,
100 KOPrefs::instance()->mWTshowChanged); 100 KOPrefs::instance()->mWTshowChanged);
101} 101}
102void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 102void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
103{ 103{
104 104
105 switch(e->key()) { 105 switch(e->key()) {
106 case Key_Right: 106 case Key_Right:
107 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 107 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
108 { 108 {
109 e->ignore(); 109 e->ignore();
110 return; 110 return;
111 } 111 }
112 scrollBy(10,0); 112 scrollBy(10,0);
113 break; 113 break;
114 case Key_Left: 114 case Key_Left:
115 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 115 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
116 { 116 {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 scrollBy(-10,0); 120 scrollBy(-10,0);
121 break; 121 break;
122 case Key_Up: 122 case Key_Up:
123 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 123 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
124 e->ignore(); 124 e->ignore();
125 break; 125 break;
126 } 126 }
127 setCurrentItem((currentItem()+count()-1)%count()); 127 if ( count() ) {
128 if(!itemVisible(currentItem())) { 128 setCurrentItem((currentItem()+count()-1)%count());
129 if((unsigned int) currentItem() == (count()-1)) { 129 if(!itemVisible(currentItem())) {
130 setTopItem(currentItem()-numItemsVisible()+1); 130 if((unsigned int) currentItem() == (count()-1)) {
131 } else { 131 setTopItem(currentItem()-numItemsVisible()+1);
132 setTopItem(topItem()-1); 132 } else {
133 setTopItem(topItem()-1);
134 }
133 } 135 }
134 } 136 }
135 break; 137 break;
136 case Key_Down: 138 case Key_Down:
137 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 139 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
138 e->ignore(); 140 e->ignore();
139 break; 141 break;
140 } 142 }
141 setCurrentItem((currentItem()+1)%count()); 143 if ( count () ) {
142 if(!itemVisible(currentItem())) { 144 setCurrentItem((currentItem()+1)%count());
143 if(currentItem() == 0) { 145 if(!itemVisible(currentItem())) {
144 setTopItem(0); 146 if(currentItem() == 0) {
145 } else { 147 setTopItem(0);
146 setTopItem(topItem()+1); 148 } else {
149 setTopItem(topItem()+1);
150 }
147 } 151 }
148 } 152 }
149 break; 153 break;
150 case Key_I: 154 case Key_I:
151 QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); 155 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
152 e->ignore(); 156 e->ignore();
153 break; 157 break;
154 case Key_Shift: 158 case Key_Shift:
155 emit shiftDown(); 159 emit shiftDown();
156 break; 160 break;
157 default: 161 default:
158 e->ignore(); 162 e->ignore();
159 break; 163 break;
160 } 164 }
161} 165}
162 166
163void KNoScrollListBox::oneDown() 167void KNoScrollListBox::oneDown()
164{ 168{
165 setCurrentItem((currentItem()+1)%count()); 169 if ( count () ) {
166 if(!itemVisible(currentItem())) { 170 setCurrentItem((currentItem()+1)%count());
167 if(currentItem() == 0) { 171 if(!itemVisible(currentItem())) {
168 setTopItem(0); 172 if(currentItem() == 0) {
169 } else { 173 setTopItem(0);
170 setTopItem(topItem()+1); 174 } else {
175 setTopItem(topItem()+1);
176 }
171 } 177 }
172 } 178 }
173} 179}
174void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 180void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
175{ 181{
176 switch(e->key()) { 182 switch(e->key()) {
177 case Key_Shift: 183 case Key_Shift:
178 emit shiftUp(); 184 emit shiftUp();
179 break; 185 break;
180 default: 186 default:
181 break; 187 break;
182 } 188 }
183} 189}
184 190
185void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 191void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
186{ 192{
187 QListBox::mousePressEvent(e); 193 QListBox::mousePressEvent(e);
188 194
189 if(e->button() == RightButton) { 195 if(e->button() == RightButton) {
190 emit rightClick(); 196 emit rightClick();
191 } 197 }
192} 198}
193 199
194MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 200MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
195 : QListBoxItem() 201 : QListBoxItem()
196{ 202{
197 mblockRepaint = true; 203 mblockRepaint = true;
198 setText( s ); 204 setText( s );
199 mMultiday = 0; 205 mMultiday = 0;
200 mIncidence = incidence; 206 mIncidence = incidence;
201 mDate = qd; 207 mDate = qd;
202 mRecur = false; 208 mRecur = false;
203 mAlarm = false; 209 mAlarm = false;
204 mReply = false; 210 mReply = false;
205 mInfo = false; 211 mInfo = false;
206 //qDebug("NEWWWWWWWWWWWWW "); 212 //qDebug("NEWWWWWWWWWWWWW ");
207} 213}
208void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 214void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
209{ 215{
210 setText( s ); 216 setText( s );
211 mMultiday = 0; 217 mMultiday = 0;
212 mIncidence = incidence; 218 mIncidence = incidence;
213 mDate = qd; 219 mDate = qd;
214 mRecur = false; 220 mRecur = false;
215 mAlarm = false; 221 mAlarm = false;
216 mReply = false; 222 mReply = false;
217 mInfo = false; 223 mInfo = false;
218 //qDebug("recucleeeeeeeeeeeeeeeee "); 224 //qDebug("recucleeeeeeeeeeeeeeeee ");
219} 225}
220 226
221void MonthViewItem::paint(QPainter *p) 227void MonthViewItem::paint(QPainter *p)
222{ 228{
223 if ( mblockRepaint ) { 229 if ( mblockRepaint ) {
224 //qDebug("block "); 230 //qDebug("block ");
225 return; 231 return;
226 } 232 }
227 //qDebug("NON block "); 233 //qDebug("NON block ");
228#if QT_VERSION >= 0x030000 234#if QT_VERSION >= 0x030000
229 bool sel = isSelected(); 235 bool sel = isSelected();
230#else 236#else
231 bool sel = selected(); 237 bool sel = selected();
232#endif 238#endif
233 239
234 240
235 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 241 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
236 { 242 {
237 p->setBackgroundColor( palette().color( QPalette::Normal, \ 243 p->setBackgroundColor( palette().color( QPalette::Normal, \
238 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 244 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
239 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 245 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
240 } 246 }
241 int x = 1; 247 int x = 1;
242 //int y = 3;//(height() - mRecurPixmap.height()) /2; 248 //int y = 3;//(height() - mRecurPixmap.height()) /2;
243 int size = PIXMAP_SIZE; 249 int size = PIXMAP_SIZE;
244 if ( QApplication::desktop()->width() < 300 ) 250 if ( QApplication::desktop()->width() < 300 )
245 size = 3; 251 size = 3;
246 int heihei = height( listBox () ); 252 int heihei = height( listBox () );
247 int y = (heihei - size -1 ) /2; 253 int y = (heihei - size -1 ) /2;
248 254
249 if ( KOPrefs::instance()->mMonthShowIcons ) { 255 if ( KOPrefs::instance()->mMonthShowIcons ) {
250 if ( mInfo ) { 256 if ( mInfo ) {
251 p->fillRect ( x, y,size,size, Qt::darkGreen ); 257 p->fillRect ( x, y,size,size, Qt::darkGreen );
252 x += size + 1; 258 x += size + 1;
253 } 259 }
254 if ( mRecur ) { 260 if ( mRecur ) {
255 p->fillRect ( x, y,size,size, Qt::blue ); 261 p->fillRect ( x, y,size,size, Qt::blue );
256 x += size + 1; 262 x += size + 1;
257 } 263 }
258 if ( mAlarm ) { 264 if ( mAlarm ) {
259 p->fillRect ( x, y,size,size, Qt::red ); 265 p->fillRect ( x, y,size,size, Qt::red );
260 x += size + 1; 266 x += size + 1;
261 } 267 }
262 if ( mReply ) { 268 if ( mReply ) {
263 p->fillRect ( x, y,size,size, Qt::yellow ); 269 p->fillRect ( x, y,size,size, Qt::yellow );
264 x += size + 1; 270 x += size + 1;
265 } 271 }
266 } 272 }
267 if ( mMultiday ) { 273 if ( mMultiday ) {
268 int yyy = y+(size/2); 274 int yyy = y+(size/2);
269 int sizeM = size+2; 275 int sizeM = size+2;
270 p->setBrush( QBrush::SolidPattern ); 276 p->setBrush( QBrush::SolidPattern );
271 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 277 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
272 if ( mMultiday == 2 || mMultiday == 3 ) { 278 if ( mMultiday == 2 || mMultiday == 3 ) {
273 QPointArray pa ( 3 ); 279 QPointArray pa ( 3 );
274 pa.setPoint (0, x, yyy ); 280 pa.setPoint (0, x, yyy );
275 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 281 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
276 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 282 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
277 p->drawPolygon( pa ); 283 p->drawPolygon( pa );
278 } 284 }
279 if ( mMultiday == 2 || mMultiday == 1 ) { 285 if ( mMultiday == 2 || mMultiday == 1 ) {
280 QPointArray pa ( 3 ); 286 QPointArray pa ( 3 );
281 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 287 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
282 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 288 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
283 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 289 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
284 p->drawPolygon( pa ); 290 p->drawPolygon( pa );
285 } 291 }
286 if ( mMultiday == 1 ) { 292 if ( mMultiday == 1 ) {
287 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 293 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
288 294
289 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 295 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
290 } 296 }
291 if ( mMultiday == 3 ) { 297 if ( mMultiday == 3 ) {
292 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 298 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
293 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 299 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
294 300
295 } 301 }
296 x += sizeM/2 + 1; 302 x += sizeM/2 + 1;
297 x += sizeM + 1; 303 x += sizeM + 1;
298 } 304 }