author | zautrix <zautrix> | 2005-02-07 13:33:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-07 13:33:33 (UTC) |
commit | d3b63db1205720e0a78cdc1a3cd11b2d02c98c6a (patch) (unidiff) | |
tree | e6c9f78b146bd1a05509795c884f4a8d9be039d7 | |
parent | 7de846e9f01ce27b622541493e6a02e26e37bf2c (diff) | |
download | kdepimpi-d3b63db1205720e0a78cdc1a3cd11b2d02c98c6a.zip kdepimpi-d3b63db1205720e0a78cdc1a3cd11b2d02c98c6a.tar.gz kdepimpi-d3b63db1205720e0a78cdc1a3cd11b2d02c98c6a.tar.bz2 |
desktop compile fix
-rw-r--r-- | korganizer/komonthview.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 7ba0b2f..9b9e164 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,541 +1,542 @@ | |||
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 <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
31 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
32 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
33 | #else | 34 | #else |
34 | #include <qapplication.h> | 35 | #include <qapplication.h> |
35 | #endif | 36 | #endif |
36 | 37 | ||
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <klocale.h> | 39 | #include <klocale.h> |
39 | #include <kglobal.h> | 40 | #include <kglobal.h> |
40 | #include <kconfig.h> | 41 | #include <kconfig.h> |
41 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
42 | 43 | ||
43 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
44 | 45 | ||
45 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
46 | #include "calprinter.h" | 47 | #include "calprinter.h" |
47 | #endif | 48 | #endif |
48 | #include "koprefs.h" | 49 | #include "koprefs.h" |
49 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
50 | #include "kocore.h" | 51 | #include "kocore.h" |
51 | #endif | 52 | #endif |
52 | #include "koglobals.h" | 53 | #include "koglobals.h" |
53 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
54 | 55 | ||
55 | #include "komonthview.h" | 56 | #include "komonthview.h" |
56 | 57 | ||
57 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
58 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
59 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
60 | #endif | 61 | #endif |
61 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
62 | { | 63 | { |
63 | public: | 64 | public: |
64 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
65 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
66 | 67 | ||
67 | protected: | 68 | protected: |
68 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
69 | { | 70 | { |
70 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
71 | }; | 72 | }; |
72 | private: | 73 | private: |
73 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
74 | 75 | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
79 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
80 | { | 81 | { |
81 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
82 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
83 | #endif | 84 | #endif |
84 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
85 | } | 86 | } |
86 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
87 | { | 88 | { |
88 | 89 | ||
89 | } | 90 | } |
90 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
91 | { | 92 | { |
92 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
93 | if ( ! item ) { | 94 | if ( ! item ) { |
94 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
95 | } | 96 | } |
96 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
97 | } | 98 | } |
98 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 99 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
99 | { | 100 | { |
100 | 101 | ||
101 | switch(e->key()) { | 102 | switch(e->key()) { |
102 | case Key_Right: | 103 | case Key_Right: |
103 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 104 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
104 | { | 105 | { |
105 | e->ignore(); | 106 | e->ignore(); |
106 | return; | 107 | return; |
107 | } | 108 | } |
108 | scrollBy(10,0); | 109 | scrollBy(10,0); |
109 | break; | 110 | break; |
110 | case Key_Left: | 111 | case Key_Left: |
111 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 112 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
112 | { | 113 | { |
113 | e->ignore(); | 114 | e->ignore(); |
114 | return; | 115 | return; |
115 | } | 116 | } |
116 | scrollBy(-10,0); | 117 | scrollBy(-10,0); |
117 | break; | 118 | break; |
118 | case Key_Up: | 119 | case Key_Up: |
119 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 120 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
120 | e->ignore(); | 121 | e->ignore(); |
121 | break; | 122 | break; |
122 | } | 123 | } |
123 | setCurrentItem((currentItem()+count()-1)%count()); | 124 | setCurrentItem((currentItem()+count()-1)%count()); |
124 | if(!itemVisible(currentItem())) { | 125 | if(!itemVisible(currentItem())) { |
125 | if((unsigned int) currentItem() == (count()-1)) { | 126 | if((unsigned int) currentItem() == (count()-1)) { |
126 | setTopItem(currentItem()-numItemsVisible()+1); | 127 | setTopItem(currentItem()-numItemsVisible()+1); |
127 | } else { | 128 | } else { |
128 | setTopItem(topItem()-1); | 129 | setTopItem(topItem()-1); |
129 | } | 130 | } |
130 | } | 131 | } |
131 | break; | 132 | break; |
132 | case Key_Down: | 133 | case Key_Down: |
133 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 134 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
134 | e->ignore(); | 135 | e->ignore(); |
135 | break; | 136 | break; |
136 | } | 137 | } |
137 | setCurrentItem((currentItem()+1)%count()); | 138 | setCurrentItem((currentItem()+1)%count()); |
138 | if(!itemVisible(currentItem())) { | 139 | if(!itemVisible(currentItem())) { |
139 | if(currentItem() == 0) { | 140 | if(currentItem() == 0) { |
140 | setTopItem(0); | 141 | setTopItem(0); |
141 | } else { | 142 | } else { |
142 | setTopItem(topItem()+1); | 143 | setTopItem(topItem()+1); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | break; | 146 | break; |
146 | case Key_I: | 147 | case Key_I: |
147 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 148 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
148 | e->ignore(); | 149 | e->ignore(); |
149 | break; | 150 | break; |
150 | case Key_Shift: | 151 | case Key_Shift: |
151 | emit shiftDown(); | 152 | emit shiftDown(); |
152 | break; | 153 | break; |
153 | default: | 154 | default: |
154 | e->ignore(); | 155 | e->ignore(); |
155 | break; | 156 | break; |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
159 | void KNoScrollListBox::oneDown() | 160 | void KNoScrollListBox::oneDown() |
160 | { | 161 | { |
161 | setCurrentItem((currentItem()+1)%count()); | 162 | setCurrentItem((currentItem()+1)%count()); |
162 | if(!itemVisible(currentItem())) { | 163 | if(!itemVisible(currentItem())) { |
163 | if(currentItem() == 0) { | 164 | if(currentItem() == 0) { |
164 | setTopItem(0); | 165 | setTopItem(0); |
165 | } else { | 166 | } else { |
166 | setTopItem(topItem()+1); | 167 | setTopItem(topItem()+1); |
167 | } | 168 | } |
168 | } | 169 | } |
169 | } | 170 | } |
170 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
171 | { | 172 | { |
172 | switch(e->key()) { | 173 | switch(e->key()) { |
173 | case Key_Shift: | 174 | case Key_Shift: |
174 | emit shiftUp(); | 175 | emit shiftUp(); |
175 | break; | 176 | break; |
176 | default: | 177 | default: |
177 | break; | 178 | break; |
178 | } | 179 | } |
179 | } | 180 | } |
180 | 181 | ||
181 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
182 | { | 183 | { |
183 | QListBox::mousePressEvent(e); | 184 | QListBox::mousePressEvent(e); |
184 | 185 | ||
185 | if(e->button() == RightButton) { | 186 | if(e->button() == RightButton) { |
186 | emit rightClick(); | 187 | emit rightClick(); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
191 | : QListBoxItem() | 192 | : QListBoxItem() |
192 | { | 193 | { |
193 | setText( s ); | 194 | setText( s ); |
194 | 195 | ||
195 | mIncidence = incidence; | 196 | mIncidence = incidence; |
196 | mDate = qd; | 197 | mDate = qd; |
197 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
198 | mRecur = false; | 199 | mRecur = false; |
199 | mAlarm = false; | 200 | mAlarm = false; |
200 | mReply = false; | 201 | mReply = false; |
201 | mInfo = false; | 202 | mInfo = false; |
202 | } | 203 | } |
203 | 204 | ||
204 | void MonthViewItem::paint(QPainter *p) | 205 | void MonthViewItem::paint(QPainter *p) |
205 | { | 206 | { |
206 | #if QT_VERSION >= 0x030000 | 207 | #if QT_VERSION >= 0x030000 |
207 | bool sel = isSelected(); | 208 | bool sel = isSelected(); |
208 | #else | 209 | #else |
209 | bool sel = selected(); | 210 | bool sel = selected(); |
210 | #endif | 211 | #endif |
211 | 212 | ||
212 | 213 | ||
213 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
214 | { | 215 | { |
215 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
216 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
217 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
218 | } | 219 | } |
219 | int x = 1; | 220 | int x = 1; |
220 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 221 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
221 | int size = PIXMAP_SIZE; | 222 | int size = PIXMAP_SIZE; |
222 | if ( QApplication::desktop()->width() < 300 ) | 223 | if ( QApplication::desktop()->width() < 300 ) |
223 | size = 3; | 224 | size = 3; |
224 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 225 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
225 | if ( mInfo ) { | 226 | if ( mInfo ) { |
226 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
227 | x += size + 1; | 228 | x += size + 1; |
228 | } | 229 | } |
229 | if ( mRecur ) { | 230 | if ( mRecur ) { |
230 | p->fillRect ( x, y,size,size, Qt::blue ); | 231 | p->fillRect ( x, y,size,size, Qt::blue ); |
231 | x += size + 1; | 232 | x += size + 1; |
232 | } | 233 | } |
233 | if ( mAlarm ) { | 234 | if ( mAlarm ) { |
234 | p->fillRect ( x, y,size,size, Qt::red ); | 235 | p->fillRect ( x, y,size,size, Qt::red ); |
235 | x += size + 1; | 236 | x += size + 1; |
236 | } | 237 | } |
237 | if ( mReply ) { | 238 | if ( mReply ) { |
238 | p->fillRect ( x, y,size,size, Qt::yellow ); | 239 | p->fillRect ( x, y,size,size, Qt::yellow ); |
239 | x += size + 1; | 240 | x += size + 1; |
240 | } | 241 | } |
241 | } | 242 | } |
242 | QFontMetrics fm = p->fontMetrics(); | 243 | QFontMetrics fm = p->fontMetrics(); |
243 | int yPos; | 244 | int yPos; |
244 | int pmheight = size; | 245 | int pmheight = size; |
245 | if( pmheight < fm.height() ) | 246 | if( pmheight < fm.height() ) |
246 | yPos = fm.ascent() + fm.leading()/2; | 247 | yPos = fm.ascent() + fm.leading()/2; |
247 | else | 248 | else |
248 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
249 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 250 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
250 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
251 | p->drawText( x, yPos, text() ); | 252 | p->drawText( x, yPos, text() ); |
252 | if ( mIncidence->cancelled() ) { | 253 | if ( mIncidence->cancelled() ) { |
253 | int wid = fm.width( text() ); | 254 | int wid = fm.width( text() ); |
254 | 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); |
255 | } | 256 | } |
256 | 257 | ||
257 | } | 258 | } |
258 | 259 | ||
259 | int MonthViewItem::height(const QListBox *lb) const | 260 | int MonthViewItem::height(const QListBox *lb) const |
260 | { | 261 | { |
261 | return lb->fontMetrics().lineSpacing()+1; | 262 | return lb->fontMetrics().lineSpacing()+1; |
262 | } | 263 | } |
263 | 264 | ||
264 | int MonthViewItem::width(const QListBox *lb) const | 265 | int MonthViewItem::width(const QListBox *lb) const |
265 | { | 266 | { |
266 | int size = PIXMAP_SIZE; | 267 | int size = PIXMAP_SIZE; |
267 | if ( QApplication::desktop()->width() < 300 ) | 268 | if ( QApplication::desktop()->width() < 300 ) |
268 | size = 3; | 269 | size = 3; |
269 | int x = 1; | 270 | int x = 1; |
270 | if ( mInfo ) { | 271 | if ( mInfo ) { |
271 | x += size + 1; | 272 | x += size + 1; |
272 | } | 273 | } |
273 | if( mRecur ) { | 274 | if( mRecur ) { |
274 | x += size+1; | 275 | x += size+1; |
275 | } | 276 | } |
276 | if( mAlarm ) { | 277 | if( mAlarm ) { |
277 | x += size+1; | 278 | x += size+1; |
278 | } | 279 | } |
279 | if( mReply ) { | 280 | if( mReply ) { |
280 | x += size+1; | 281 | x += size+1; |
281 | } | 282 | } |
282 | 283 | ||
283 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 284 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
284 | } | 285 | } |
285 | 286 | ||
286 | 287 | ||
287 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
288 | : QWidget( par ), | 289 | : QWidget( par ), |
289 | mMonthView( parent ) | 290 | mMonthView( parent ) |
290 | { | 291 | { |
291 | 292 | ||
292 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
293 | 294 | ||
294 | // mLabel = new QLabel( this );QPushButton | 295 | // mLabel = new QLabel( this );QPushButton |
295 | mLabel = new QPushButton( this ); | 296 | mLabel = new QPushButton( this ); |
296 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
297 | //mLabel->setLineWidth( 1 ); | 298 | //mLabel->setLineWidth( 1 ); |
298 | //mLabel->setAlignment( AlignCenter ); | 299 | //mLabel->setAlignment( AlignCenter ); |
299 | mLabel->setFlat( true ); | 300 | mLabel->setFlat( true ); |
300 | mLabel->setFocusPolicy(NoFocus); | 301 | mLabel->setFocusPolicy(NoFocus); |
301 | mItemList = new KNoScrollListBox( this ); | 302 | mItemList = new KNoScrollListBox( this ); |
302 | mItemList->setMinimumSize( 10, 10 ); | 303 | mItemList->setMinimumSize( 10, 10 ); |
303 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
304 | mItemList->setLineWidth( 1 ); | 305 | mItemList->setLineWidth( 1 ); |
305 | topLayout->addWidget( mItemList ); | 306 | topLayout->addWidget( mItemList ); |
306 | mLabel->raise(); | 307 | mLabel->raise(); |
307 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
308 | mStandardPalette = palette(); | 309 | mStandardPalette = palette(); |
309 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
310 | 311 | ||
311 | enableScrollBars( false ); | 312 | enableScrollBars( false ); |
312 | updateConfig(); | 313 | updateConfig(); |
313 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
314 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
315 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
316 | SLOT( defaultAction( QListBoxItem * ) ) ); | 317 | SLOT( defaultAction( QListBoxItem * ) ) ); |
317 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
318 | const QPoint &) ), | 319 | const QPoint &) ), |
319 | SLOT( contextMenu( QListBoxItem * ) ) ); | 320 | SLOT( contextMenu( QListBoxItem * ) ) ); |
320 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
321 | SLOT( selection( QListBoxItem * ) ) ); | 322 | SLOT( selection( QListBoxItem * ) ) ); |
322 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
323 | SLOT( cellClicked( QListBoxItem * ) ) ); | 324 | SLOT( cellClicked( QListBoxItem * ) ) ); |
324 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
325 | SLOT( selection( QListBoxItem * ) ) ); | 326 | SLOT( selection( QListBoxItem * ) ) ); |
326 | } | 327 | } |
327 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
328 | QToolTipGroup *MonthViewCell::toolTipGroup() | 329 | QToolTipGroup *MonthViewCell::toolTipGroup() |
329 | { | 330 | { |
330 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
331 | return mToolTipGroup; | 332 | return mToolTipGroup; |
332 | } | 333 | } |
333 | #endif | 334 | #endif |
334 | 335 | ||
335 | void MonthViewCell::setDate( const QDate &date ) | 336 | void MonthViewCell::setDate( const QDate &date ) |
336 | { | 337 | { |
337 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
338 | mDate = date; | 339 | mDate = date; |
339 | 340 | ||
340 | 341 | ||
341 | 342 | ||
342 | //resizeEvent( 0 ); | 343 | //resizeEvent( 0 ); |
343 | } | 344 | } |
344 | 345 | ||
345 | QDate MonthViewCell::date() const | 346 | QDate MonthViewCell::date() const |
346 | { | 347 | { |
347 | return mDate; | 348 | return mDate; |
348 | } | 349 | } |
349 | 350 | ||
350 | void MonthViewCell::setPrimary( bool primary ) | 351 | void MonthViewCell::setPrimary( bool primary ) |
351 | { | 352 | { |
352 | mPrimary = primary; | 353 | mPrimary = primary; |
353 | //setMyPalette(); | 354 | //setMyPalette(); |
354 | } | 355 | } |
355 | void MonthViewCell::setMyPalette() | 356 | void MonthViewCell::setMyPalette() |
356 | { | 357 | { |
357 | 358 | ||
358 | if ( mHoliday) { | 359 | if ( mHoliday) { |
359 | setPalette( mHolidayPalette ); | 360 | setPalette( mHolidayPalette ); |
360 | } else { | 361 | } else { |
361 | if ( mPrimary ) { | 362 | if ( mPrimary ) { |
362 | setPalette( mPrimaryPalette ); | 363 | setPalette( mPrimaryPalette ); |
363 | } else { | 364 | } else { |
364 | setPalette( mNonPrimaryPalette ); | 365 | setPalette( mNonPrimaryPalette ); |
365 | } | 366 | } |
366 | } | 367 | } |
367 | QPalette pal = palette(); | 368 | QPalette pal = palette(); |
368 | 369 | ||
369 | 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 ) )); |
370 | } | 371 | } |
371 | QPalette MonthViewCell::getPalette () | 372 | QPalette MonthViewCell::getPalette () |
372 | { | 373 | { |
373 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
374 | return mStandardPalette; | 375 | return mStandardPalette; |
375 | if ( mHoliday) { | 376 | if ( mHoliday) { |
376 | return mHolidayPalette ; | 377 | return mHolidayPalette ; |
377 | } else { | 378 | } else { |
378 | if ( mPrimary ) { | 379 | if ( mPrimary ) { |
379 | return mPrimaryPalette ; | 380 | return mPrimaryPalette ; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | return mNonPrimaryPalette; | 383 | return mNonPrimaryPalette; |
383 | } | 384 | } |
384 | bool MonthViewCell::isPrimary() const | 385 | bool MonthViewCell::isPrimary() const |
385 | { | 386 | { |
386 | return mPrimary; | 387 | return mPrimary; |
387 | } | 388 | } |
388 | 389 | ||
389 | void MonthViewCell::setHoliday( bool holiday ) | 390 | void MonthViewCell::setHoliday( bool holiday ) |
390 | { | 391 | { |
391 | mHoliday = holiday; | 392 | mHoliday = holiday; |
392 | //setMyPalette(); | 393 | //setMyPalette(); |
393 | } | 394 | } |
394 | 395 | ||
395 | void MonthViewCell::setHoliday( const QString &holiday ) | 396 | void MonthViewCell::setHoliday( const QString &holiday ) |
396 | { | 397 | { |
397 | mHolidayString = holiday; | 398 | mHolidayString = holiday; |
398 | 399 | ||
399 | if ( !holiday.isEmpty() ) { | 400 | if ( !holiday.isEmpty() ) { |
400 | setHoliday( true ); | 401 | setHoliday( true ); |
401 | } | 402 | } |
402 | } | 403 | } |
403 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
404 | { | 405 | { |
405 | 406 | ||
406 | e->ignore(); | 407 | e->ignore(); |
407 | 408 | ||
408 | } | 409 | } |
409 | 410 | ||
410 | void MonthViewCell::startUpdateCell() | 411 | void MonthViewCell::startUpdateCell() |
411 | { | 412 | { |
412 | 413 | ||
413 | mItemList->setFocusPolicy(NoFocus); | 414 | mItemList->setFocusPolicy(NoFocus); |
414 | if ( !mMonthView->isUpdatePossible() ) | 415 | if ( !mMonthView->isUpdatePossible() ) |
415 | return; | 416 | return; |
416 | 417 | ||
417 | /* | 418 | /* |
418 | if ( !isVisible() ){ | 419 | if ( !isVisible() ){ |
419 | return; | 420 | return; |
420 | } | 421 | } |
421 | */ | 422 | */ |
422 | // qDebug("MonthViewCell::updateCell() "); | 423 | // qDebug("MonthViewCell::updateCell() "); |
423 | setPrimary( mDate.month()%2 ); | 424 | setPrimary( mDate.month()%2 ); |
424 | 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); |
425 | if ( mDate == QDate::currentDate() ) { | 426 | if ( mDate == QDate::currentDate() ) { |
426 | mItemList->setLineWidth( 3 ); | 427 | mItemList->setLineWidth( 3 ); |
427 | } else { | 428 | } else { |
428 | mItemList->setLineWidth( 1 ); | 429 | mItemList->setLineWidth( 1 ); |
429 | } | 430 | } |
430 | mItemList->clear(); | 431 | mItemList->clear(); |
431 | 432 | ||
432 | #ifdef DESKTOP_VERSION | 433 | #ifdef DESKTOP_VERSION |
433 | QToolTip::remove(this); | 434 | QToolTip::remove(this); |
434 | #endif | 435 | #endif |
435 | mToolTip = ""; | 436 | mToolTip = ""; |
436 | //qApp->processEvents(); | 437 | //qApp->processEvents(); |
437 | if ( !mHolidayString.isEmpty() ) { | 438 | if ( !mHolidayString.isEmpty() ) { |
438 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 439 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
439 | item->setPalette( mHolidayPalette ); | 440 | item->setPalette( mHolidayPalette ); |
440 | mItemList->insertItem( item ); | 441 | mItemList->insertItem( item ); |
441 | mToolTip += mHolidayString+"\n"; | 442 | mToolTip += mHolidayString+"\n"; |
442 | } | 443 | } |
443 | } | 444 | } |
444 | 445 | ||
445 | void MonthViewCell::insertEvent(Event *event) | 446 | void MonthViewCell::insertEvent(Event *event) |
446 | { | 447 | { |
447 | 448 | ||
448 | mItemList->setFocusPolicy(WheelFocus); | 449 | mItemList->setFocusPolicy(WheelFocus); |
449 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 450 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
450 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 451 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
451 | return; | 452 | return; |
452 | else | 453 | else |
453 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 454 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
454 | return; | 455 | return; |
455 | } | 456 | } |
456 | 457 | ||
457 | if ( event->categories().contains("Holiday") || | 458 | if ( event->categories().contains("Holiday") || |
458 | event->categories().contains(i18n("Holiday"))) { | 459 | event->categories().contains(i18n("Holiday"))) { |
459 | setHoliday( true ); | 460 | setHoliday( true ); |
460 | if ( mDate.dayOfWeek() == 7 ) | 461 | if ( mDate.dayOfWeek() == 7 ) |
461 | mItemList->setLineWidth( 3 ); | 462 | mItemList->setLineWidth( 3 ); |
462 | } | 463 | } |
463 | QString text; | 464 | QString text; |
464 | if (event->isMultiDay()) { | 465 | if (event->isMultiDay()) { |
465 | QString prefix = "<->"; | 466 | QString prefix = "<->"; |
466 | if ( event->doesRecur() ) { | 467 | if ( event->doesRecur() ) { |
467 | if ( event->recursOn( mDate) ) | 468 | if ( event->recursOn( mDate) ) |
468 | prefix ="->" ; | 469 | prefix ="->" ; |
469 | else { | 470 | else { |
470 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 471 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
471 | if ( event->recursOn( mDate.addDays( -days)) ) | 472 | if ( event->recursOn( mDate.addDays( -days)) ) |
472 | prefix ="<-" ; | 473 | prefix ="<-" ; |
473 | } | 474 | } |
474 | 475 | ||
475 | } else { | 476 | } else { |
476 | if (mDate == event->dtStart().date()) { | 477 | if (mDate == event->dtStart().date()) { |
477 | prefix ="->" ; | 478 | prefix ="->" ; |
478 | } else if (mDate == event->dtEnd().date()) { | 479 | } else if (mDate == event->dtEnd().date()) { |
479 | prefix ="<-" ; | 480 | prefix ="<-" ; |
480 | } | 481 | } |
481 | } | 482 | } |
482 | if ( !event->doesFloat() ) { | 483 | if ( !event->doesFloat() ) { |
483 | if ( mDate == event->dtStart().date () ) | 484 | if ( mDate == event->dtStart().date () ) |
484 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 485 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
485 | else if ( mDate == event->dtEnd().date () ) | 486 | else if ( mDate == event->dtEnd().date () ) |
486 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 487 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
487 | 488 | ||
488 | } | 489 | } |
489 | text = prefix + event->summary(); | 490 | text = prefix + event->summary(); |
490 | mToolTip += text; | 491 | mToolTip += text; |
491 | } else { | 492 | } else { |
492 | if (event->doesFloat()) { | 493 | if (event->doesFloat()) { |
493 | text = event->summary(); | 494 | text = event->summary(); |
494 | mToolTip += text; | 495 | mToolTip += text; |
495 | } | 496 | } |
496 | else { | 497 | else { |
497 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 498 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
498 | text += " " + event->summary(); | 499 | text += " " + event->summary(); |
499 | 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(); |
500 | } | 501 | } |
501 | } | 502 | } |
502 | 503 | ||
503 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 504 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
504 | QPalette pal; | 505 | QPalette pal; |
505 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
506 | QStringList categories = event->categories(); | 507 | QStringList categories = event->categories(); |
507 | QString cat = categories.first(); | 508 | QString cat = categories.first(); |
508 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
509 | pal = getPalette(); | 510 | pal = getPalette(); |
510 | if (cat.isEmpty()) { | 511 | if (cat.isEmpty()) { |
511 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
512 | } else { | 513 | } else { |
513 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
514 | } | 515 | } |
515 | 516 | ||
516 | } else { | 517 | } else { |
517 | if (cat.isEmpty()) { | 518 | if (cat.isEmpty()) { |
518 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
519 | } else { | 520 | } else { |
520 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
521 | } | 522 | } |
522 | } | 523 | } |
523 | 524 | ||
524 | } else { | 525 | } else { |
525 | pal = mStandardPalette ; | 526 | pal = mStandardPalette ; |
526 | } | 527 | } |
527 | item->setPalette( pal ); | 528 | item->setPalette( pal ); |
528 | item->setRecur( event->recurrence()->doesRecur() ); | 529 | item->setRecur( event->recurrence()->doesRecur() ); |
529 | item->setAlarm( event->isAlarmEnabled() ); | 530 | item->setAlarm( event->isAlarmEnabled() ); |
530 | item->setMoreInfo( event->description().length() > 0 ); | 531 | item->setMoreInfo( event->description().length() > 0 ); |
531 | #ifdef DESKTOP_VERSION | 532 | #ifdef DESKTOP_VERSION |
532 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 533 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
533 | KOPrefs::instance()->email()); | 534 | KOPrefs::instance()->email()); |
534 | if ( me != 0 ) { | 535 | if ( me != 0 ) { |
535 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 536 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
536 | item->setReply(true); | 537 | item->setReply(true); |
537 | else | 538 | else |
538 | item->setReply(false); | 539 | item->setReply(false); |
539 | } else | 540 | } else |
540 | item->setReply(false); | 541 | item->setReply(false); |
541 | #endif | 542 | #endif |