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