author | zautrix <zautrix> | 2005-03-29 00:10:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-29 00:10:48 (UTC) |
commit | a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46 (patch) (unidiff) | |
tree | b9f1b2710da1cd0105382831ac0a3e3d7d44f09c | |
parent | 4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (diff) | |
download | kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.zip kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.gz kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.bz2 |
fix
-rw-r--r-- | korganizer/komonthview.cpp | 42 |
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,426 +1,432 @@ | |||
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 |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
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 | ||
68 | protected: | 68 | protected: |
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 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::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 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString 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 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 102 | void 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 | ||
163 | void KNoScrollListBox::oneDown() | 167 | void 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 | } |
174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 180 | void 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 | ||
185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 191 | void 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 | ||
194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 200 | MonthViewItem::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 | } |
208 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 214 | void 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 | ||
221 | void MonthViewItem::paint(QPainter *p) | 227 | void 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 | } |
299 | 305 | ||
300 | if ( mIncidence->type() == "Todo" ){ | 306 | if ( mIncidence->type() == "Todo" ){ |
301 | Todo* td = ( Todo* ) mIncidence; | 307 | Todo* td = ( Todo* ) mIncidence; |
302 | if ( td->isCompleted() ) { | 308 | if ( td->isCompleted() ) { |
303 | int half = size/2; | 309 | int half = size/2; |
304 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 310 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
305 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 311 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
306 | x += half+half + 4; | 312 | x += half+half + 4; |
307 | 313 | ||
308 | } else { | 314 | } else { |
309 | int val = td->percentComplete()/20; | 315 | int val = td->percentComplete()/20; |
310 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); | 316 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); |
311 | p->drawRect ( x, y-1,7,size+2); | 317 | p->drawRect ( x, y-1,7,size+2); |
312 | x += size + 3; | 318 | x += size + 3; |
313 | } | 319 | } |
314 | } | 320 | } |
315 | QFontMetrics fm = p->fontMetrics(); | 321 | QFontMetrics fm = p->fontMetrics(); |
316 | int yPos; | 322 | int yPos; |
317 | int pmheight = size; | 323 | int pmheight = size; |
318 | if( pmheight < fm.height() ) | 324 | if( pmheight < fm.height() ) |
319 | yPos = fm.ascent() + fm.leading()/2; | 325 | yPos = fm.ascent() + fm.leading()/2; |
320 | else | 326 | else |
321 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 327 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
322 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 328 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
323 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 329 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
324 | p->drawText( x, yPos, text() ); | 330 | p->drawText( x, yPos, text() ); |
325 | if ( mIncidence->cancelled() ) { | 331 | if ( mIncidence->cancelled() ) { |
326 | int wid = fm.width( text() ); | 332 | int wid = fm.width( text() ); |
327 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 333 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
328 | } | 334 | } |
329 | 335 | ||
330 | } | 336 | } |
331 | 337 | ||
332 | int MonthViewItem::height(const QListBox *lb) const | 338 | int MonthViewItem::height(const QListBox *lb) const |
333 | { | 339 | { |
334 | int ret = 10; | 340 | int ret = 10; |
335 | if ( lb ) | 341 | if ( lb ) |
336 | ret = lb->fontMetrics().lineSpacing()+1; | 342 | ret = lb->fontMetrics().lineSpacing()+1; |
337 | return ret; | 343 | return ret; |
338 | } | 344 | } |
339 | 345 | ||
340 | int MonthViewItem::width(const QListBox *lb) const | 346 | int MonthViewItem::width(const QListBox *lb) const |
341 | { | 347 | { |
342 | 348 | ||
343 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 349 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
344 | int size = PIXMAP_SIZE; | 350 | int size = PIXMAP_SIZE; |
345 | if ( QApplication::desktop()->width() < 300 ) | 351 | if ( QApplication::desktop()->width() < 300 ) |
346 | size = 3; | 352 | size = 3; |
347 | int x = 1; | 353 | int x = 1; |
348 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 354 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
349 | if ( mInfo ) { | 355 | if ( mInfo ) { |
350 | x += size + 1; | 356 | x += size + 1; |
351 | } | 357 | } |
352 | if( mRecur ) { | 358 | if( mRecur ) { |
353 | x += size+1; | 359 | x += size+1; |
354 | } | 360 | } |
355 | if( mAlarm ) { | 361 | if( mAlarm ) { |
356 | x += size+1; | 362 | x += size+1; |
357 | } | 363 | } |
358 | if( mReply ) { | 364 | if( mReply ) { |
359 | x += size+1; | 365 | x += size+1; |
360 | } | 366 | } |
361 | } | 367 | } |
362 | if( mMultiday ) { | 368 | if( mMultiday ) { |
363 | x += size+1+2+size/2; | 369 | x += size+1+2+size/2; |
364 | } | 370 | } |
365 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 371 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
366 | } | 372 | } |
367 | if ( ! lb ) | 373 | if ( ! lb ) |
368 | return 10; | 374 | return 10; |
369 | //qDebug("ret wid %d ", lb->width()); | 375 | //qDebug("ret wid %d ", lb->width()); |
370 | return lb->width(); | 376 | return lb->width(); |
371 | } | 377 | } |
372 | 378 | ||
373 | 379 | ||
374 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 380 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
375 | : KNoScrollListBox( par ), | 381 | : KNoScrollListBox( par ), |
376 | mMonthView( parent ) | 382 | mMonthView( parent ) |
377 | { | 383 | { |
378 | 384 | ||
379 | mCurrentAvailItem = 0; | 385 | mCurrentAvailItem = 0; |
380 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 386 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
381 | currentPalette = 0; | 387 | currentPalette = 0; |
382 | // mLabel = new QLabel( this );QPushButton | 388 | // mLabel = new QLabel( this );QPushButton |
383 | mLabel = new QPushButton( this ); | 389 | mLabel = new QPushButton( this ); |
384 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 390 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
385 | //mLabel->setLineWidth( 1 ); | 391 | //mLabel->setLineWidth( 1 ); |
386 | //mLabel->setAlignment( AlignCenter ); | 392 | //mLabel->setAlignment( AlignCenter ); |
387 | mLabel->setFlat( true ); | 393 | mLabel->setFlat( true ); |
388 | mLabel->setFocusPolicy(NoFocus); | 394 | mLabel->setFocusPolicy(NoFocus); |
389 | //mItemList = new KNoScrollListBox( this ); | 395 | //mItemList = new KNoScrollListBox( this ); |
390 | setMinimumSize( 10, 10 ); | 396 | setMinimumSize( 10, 10 ); |
391 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 397 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
392 | setLineWidth( 1 ); | 398 | setLineWidth( 1 ); |
393 | //topLayout->addWidget( mItemList ); | 399 | //topLayout->addWidget( mItemList ); |
394 | mLabel->raise(); | 400 | mLabel->raise(); |
395 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 401 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
396 | mStandardPalette = palette(); | 402 | mStandardPalette = palette(); |
397 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 403 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
398 | 404 | ||
399 | enableScrollBars( false ); | 405 | enableScrollBars( false ); |
400 | updateConfig(); | 406 | updateConfig(); |
401 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 407 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
402 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 408 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
403 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 409 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
404 | SLOT( defaultAction( QListBoxItem * ) ) ); | 410 | SLOT( defaultAction( QListBoxItem * ) ) ); |
405 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 411 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
406 | const QPoint &) ), | 412 | const QPoint &) ), |
407 | SLOT( contextMenu( QListBoxItem * ) ) ); | 413 | SLOT( contextMenu( QListBoxItem * ) ) ); |
408 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 414 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
409 | SLOT( selection( QListBoxItem * ) ) ); | 415 | SLOT( selection( QListBoxItem * ) ) ); |
410 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 416 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
411 | SLOT( cellClicked( QListBoxItem * ) ) ); | 417 | SLOT( cellClicked( QListBoxItem * ) ) ); |
412 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 418 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
413 | SLOT( selection( QListBoxItem * ) ) ); | 419 | SLOT( selection( QListBoxItem * ) ) ); |
414 | } | 420 | } |
415 | #ifdef DESKTOP_VERSION | 421 | #ifdef DESKTOP_VERSION |
416 | QToolTipGroup *MonthViewCell::toolTipGroup() | 422 | QToolTipGroup *MonthViewCell::toolTipGroup() |
417 | { | 423 | { |
418 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 424 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
419 | return mToolTipGroup; | 425 | return mToolTipGroup; |
420 | } | 426 | } |
421 | #endif | 427 | #endif |
422 | 428 | ||
423 | void MonthViewCell::setDate( const QDate &date ) | 429 | void MonthViewCell::setDate( const QDate &date ) |
424 | { | 430 | { |
425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 431 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
426 | mDate = date; | 432 | mDate = date; |