author | zautrix <zautrix> | 2005-02-04 22:22:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-04 22:22:10 (UTC) |
commit | 936b4b2aa37e699052a2517dc2d928d717398cf6 (patch) (unidiff) | |
tree | 964ac33783c2126ecbaea0a2ee72b83ae6475b52 /korganizer/komonthview.cpp | |
parent | 4659ee80518c7d5108c21ba04a12a25eab783113 (diff) | |
download | kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.zip kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.gz kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.bz2 |
fifi
-rw-r--r-- | korganizer/komonthview.cpp | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index dfa89e2..df5e060 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -55,148 +55,163 @@ | |||
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 ) | 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(4,0); | 108 | scrollBy(10,0); |
109 | break; | 109 | break; |
110 | case Key_Left: | 110 | case Key_Left: |
111 | // if ( e->state() == Qt::ControlButton ) | 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(-4,0); | 116 | scrollBy(-10,0); |
117 | break; | 117 | break; |
118 | case Key_Up: | 118 | case Key_Up: |
119 | if(count() < 2) { | 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(count() < 2) { | 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: | ||
147 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | ||
148 | e->ignore(); | ||
149 | break; | ||
146 | case Key_Shift: | 150 | case Key_Shift: |
147 | emit shiftDown(); | 151 | emit shiftDown(); |
148 | break; | 152 | break; |
149 | default: | 153 | default: |
150 | e->ignore(); | 154 | e->ignore(); |
151 | break; | 155 | break; |
152 | } | 156 | } |
153 | } | 157 | } |
154 | 158 | ||
159 | void KNoScrollListBox::oneDown() | ||
160 | { | ||
161 | setCurrentItem((currentItem()+1)%count()); | ||
162 | if(!itemVisible(currentItem())) { | ||
163 | if(currentItem() == 0) { | ||
164 | setTopItem(0); | ||
165 | } else { | ||
166 | setTopItem(topItem()+1); | ||
167 | } | ||
168 | } | ||
169 | } | ||
155 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 170 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
156 | { | 171 | { |
157 | switch(e->key()) { | 172 | switch(e->key()) { |
158 | case Key_Shift: | 173 | case Key_Shift: |
159 | emit shiftUp(); | 174 | emit shiftUp(); |
160 | break; | 175 | break; |
161 | default: | 176 | default: |
162 | break; | 177 | break; |
163 | } | 178 | } |
164 | } | 179 | } |
165 | 180 | ||
166 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 181 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
167 | { | 182 | { |
168 | QListBox::mousePressEvent(e); | 183 | QListBox::mousePressEvent(e); |
169 | 184 | ||
170 | if(e->button() == RightButton) { | 185 | if(e->button() == RightButton) { |
171 | emit rightClick(); | 186 | emit rightClick(); |
172 | } | 187 | } |
173 | } | 188 | } |
174 | 189 | ||
175 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 190 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
176 | : QListBoxItem() | 191 | : QListBoxItem() |
177 | { | 192 | { |
178 | setText( s ); | 193 | setText( s ); |
179 | 194 | ||
180 | mIncidence = incidence; | 195 | mIncidence = incidence; |
181 | mDate = qd; | 196 | mDate = qd; |
182 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 197 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
183 | mRecur = false; | 198 | mRecur = false; |
184 | mAlarm = false; | 199 | mAlarm = false; |
185 | mReply = false; | 200 | mReply = false; |
186 | mInfo = false; | 201 | mInfo = false; |
187 | } | 202 | } |
188 | 203 | ||
189 | void MonthViewItem::paint(QPainter *p) | 204 | void MonthViewItem::paint(QPainter *p) |
190 | { | 205 | { |
191 | #if QT_VERSION >= 0x030000 | 206 | #if QT_VERSION >= 0x030000 |
192 | bool sel = isSelected(); | 207 | bool sel = isSelected(); |
193 | #else | 208 | #else |
194 | bool sel = selected(); | 209 | bool sel = selected(); |
195 | #endif | 210 | #endif |
196 | 211 | ||
197 | 212 | ||
198 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 213 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
199 | { | 214 | { |
200 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 215 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
201 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 216 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
202 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 217 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
@@ -237,96 +252,97 @@ void MonthViewItem::paint(QPainter *p) | |||
237 | if ( mIncidence->cancelled() ) { | 252 | if ( mIncidence->cancelled() ) { |
238 | int wid = fm.width( text() ); | 253 | int wid = fm.width( text() ); |
239 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 254 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
240 | } | 255 | } |
241 | 256 | ||
242 | } | 257 | } |
243 | 258 | ||
244 | int MonthViewItem::height(const QListBox *lb) const | 259 | int MonthViewItem::height(const QListBox *lb) const |
245 | { | 260 | { |
246 | return lb->fontMetrics().lineSpacing()+1; | 261 | return lb->fontMetrics().lineSpacing()+1; |
247 | } | 262 | } |
248 | 263 | ||
249 | int MonthViewItem::width(const QListBox *lb) const | 264 | int MonthViewItem::width(const QListBox *lb) const |
250 | { | 265 | { |
251 | int size = PIXMAP_SIZE; | 266 | int size = PIXMAP_SIZE; |
252 | if ( QApplication::desktop()->width() < 300 ) | 267 | if ( QApplication::desktop()->width() < 300 ) |
253 | size = 3; | 268 | size = 3; |
254 | int x = 1; | 269 | int x = 1; |
255 | if ( mInfo ) { | 270 | if ( mInfo ) { |
256 | x += size + 1; | 271 | x += size + 1; |
257 | } | 272 | } |
258 | if( mRecur ) { | 273 | if( mRecur ) { |
259 | x += size+1; | 274 | x += size+1; |
260 | } | 275 | } |
261 | if( mAlarm ) { | 276 | if( mAlarm ) { |
262 | x += size+1; | 277 | x += size+1; |
263 | } | 278 | } |
264 | if( mReply ) { | 279 | if( mReply ) { |
265 | x += size+1; | 280 | x += size+1; |
266 | } | 281 | } |
267 | 282 | ||
268 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 283 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
269 | } | 284 | } |
270 | 285 | ||
271 | 286 | ||
272 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 287 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
273 | : QWidget( par ), | 288 | : QWidget( par ), |
274 | mMonthView( parent ) | 289 | mMonthView( parent ) |
275 | { | 290 | { |
276 | 291 | ||
277 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 292 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
278 | 293 | ||
279 | // mLabel = new QLabel( this );QPushButton | 294 | // mLabel = new QLabel( this );QPushButton |
280 | mLabel = new QPushButton( this ); | 295 | mLabel = new QPushButton( this ); |
281 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 296 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
282 | //mLabel->setLineWidth( 1 ); | 297 | //mLabel->setLineWidth( 1 ); |
283 | //mLabel->setAlignment( AlignCenter ); | 298 | //mLabel->setAlignment( AlignCenter ); |
284 | mLabel->setFlat( true ); | 299 | mLabel->setFlat( true ); |
300 | mLabel->setFocusPolicy(NoFocus); | ||
285 | mItemList = new KNoScrollListBox( this ); | 301 | mItemList = new KNoScrollListBox( this ); |
286 | mItemList->setMinimumSize( 10, 10 ); | 302 | mItemList->setMinimumSize( 10, 10 ); |
287 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 303 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
288 | mItemList->setLineWidth( 1 ); | 304 | mItemList->setLineWidth( 1 ); |
289 | topLayout->addWidget( mItemList ); | 305 | topLayout->addWidget( mItemList ); |
290 | mLabel->raise(); | 306 | mLabel->raise(); |
291 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 307 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
292 | mStandardPalette = palette(); | 308 | mStandardPalette = palette(); |
293 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 309 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
294 | 310 | ||
295 | enableScrollBars( false ); | 311 | enableScrollBars( false ); |
296 | updateConfig(); | 312 | updateConfig(); |
297 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 313 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
298 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 314 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
299 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 315 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
300 | SLOT( defaultAction( QListBoxItem * ) ) ); | 316 | SLOT( defaultAction( QListBoxItem * ) ) ); |
301 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 317 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
302 | const QPoint &) ), | 318 | const QPoint &) ), |
303 | SLOT( contextMenu( QListBoxItem * ) ) ); | 319 | SLOT( contextMenu( QListBoxItem * ) ) ); |
304 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 320 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
305 | SLOT( selection( QListBoxItem * ) ) ); | 321 | SLOT( selection( QListBoxItem * ) ) ); |
306 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 322 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
307 | SLOT( cellClicked( QListBoxItem * ) ) ); | 323 | SLOT( cellClicked( QListBoxItem * ) ) ); |
308 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 324 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
309 | SLOT( selection( QListBoxItem * ) ) ); | 325 | SLOT( selection( QListBoxItem * ) ) ); |
310 | } | 326 | } |
311 | #ifdef DESKTOP_VERSION | 327 | #ifdef DESKTOP_VERSION |
312 | QToolTipGroup *MonthViewCell::toolTipGroup() | 328 | QToolTipGroup *MonthViewCell::toolTipGroup() |
313 | { | 329 | { |
314 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 330 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
315 | return mToolTipGroup; | 331 | return mToolTipGroup; |
316 | } | 332 | } |
317 | #endif | 333 | #endif |
318 | 334 | ||
319 | void MonthViewCell::setDate( const QDate &date ) | 335 | void MonthViewCell::setDate( const QDate &date ) |
320 | { | 336 | { |
321 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 337 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
322 | mDate = date; | 338 | mDate = date; |
323 | 339 | ||
324 | 340 | ||
325 | 341 | ||
326 | //resizeEvent( 0 ); | 342 | //resizeEvent( 0 ); |
327 | } | 343 | } |
328 | 344 | ||
329 | QDate MonthViewCell::date() const | 345 | QDate MonthViewCell::date() const |
330 | { | 346 | { |
331 | return mDate; | 347 | return mDate; |
332 | } | 348 | } |
@@ -356,128 +372,132 @@ QPalette MonthViewCell::getPalette () | |||
356 | { | 372 | { |
357 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 373 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
358 | return mStandardPalette; | 374 | return mStandardPalette; |
359 | if ( mHoliday) { | 375 | if ( mHoliday) { |
360 | return mHolidayPalette ; | 376 | return mHolidayPalette ; |
361 | } else { | 377 | } else { |
362 | if ( mPrimary ) { | 378 | if ( mPrimary ) { |
363 | return mPrimaryPalette ; | 379 | return mPrimaryPalette ; |
364 | } | 380 | } |
365 | } | 381 | } |
366 | return mNonPrimaryPalette; | 382 | return mNonPrimaryPalette; |
367 | } | 383 | } |
368 | bool MonthViewCell::isPrimary() const | 384 | bool MonthViewCell::isPrimary() const |
369 | { | 385 | { |
370 | return mPrimary; | 386 | return mPrimary; |
371 | } | 387 | } |
372 | 388 | ||
373 | void MonthViewCell::setHoliday( bool holiday ) | 389 | void MonthViewCell::setHoliday( bool holiday ) |
374 | { | 390 | { |
375 | mHoliday = holiday; | 391 | mHoliday = holiday; |
376 | //setMyPalette(); | 392 | //setMyPalette(); |
377 | } | 393 | } |
378 | 394 | ||
379 | void MonthViewCell::setHoliday( const QString &holiday ) | 395 | void MonthViewCell::setHoliday( const QString &holiday ) |
380 | { | 396 | { |
381 | mHolidayString = holiday; | 397 | mHolidayString = holiday; |
382 | 398 | ||
383 | if ( !holiday.isEmpty() ) { | 399 | if ( !holiday.isEmpty() ) { |
384 | setHoliday( true ); | 400 | setHoliday( true ); |
385 | } | 401 | } |
386 | } | 402 | } |
387 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 403 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
388 | { | 404 | { |
389 | 405 | ||
390 | e->ignore(); | 406 | e->ignore(); |
391 | 407 | ||
392 | } | 408 | } |
393 | void MonthViewCell::clear() | 409 | void MonthViewCell::clear() |
394 | { | 410 | { |
395 | mItemList->clear(); | 411 | mItemList->clear(); |
396 | QApplication::removePostedEvents ( mItemList ); | 412 | QApplication::removePostedEvents ( mItemList ); |
397 | QApplication::removePostedEvents ( mLabel ); | 413 | QApplication::removePostedEvents ( mLabel ); |
398 | QApplication::removePostedEvents ( this ); | 414 | QApplication::removePostedEvents ( this ); |
399 | } | 415 | } |
400 | 416 | ||
401 | void MonthViewCell::startUpdateCell() | 417 | void MonthViewCell::startUpdateCell() |
402 | { | 418 | { |
403 | 419 | ||
420 | mItemList->setFocusPolicy(NoFocus); | ||
404 | if ( !mMonthView->isUpdatePossible() ) | 421 | if ( !mMonthView->isUpdatePossible() ) |
405 | return; | 422 | return; |
423 | |||
406 | /* | 424 | /* |
407 | if ( !isVisible() ){ | 425 | if ( !isVisible() ){ |
408 | return; | 426 | return; |
409 | } | 427 | } |
410 | */ | 428 | */ |
411 | // qDebug("MonthViewCell::updateCell() "); | 429 | // qDebug("MonthViewCell::updateCell() "); |
412 | setPrimary( mDate.month()%2 ); | 430 | setPrimary( mDate.month()%2 ); |
413 | 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); |
414 | if ( mDate == QDate::currentDate() ) { | 432 | if ( mDate == QDate::currentDate() ) { |
415 | mItemList->setLineWidth( 3 ); | 433 | mItemList->setLineWidth( 3 ); |
416 | } else { | 434 | } else { |
417 | mItemList->setLineWidth( 1 ); | 435 | mItemList->setLineWidth( 1 ); |
418 | } | 436 | } |
419 | mItemList->clear(); | 437 | mItemList->clear(); |
420 | 438 | ||
421 | #ifdef DESKTOP_VERSION | 439 | #ifdef DESKTOP_VERSION |
422 | QToolTip::remove(this); | 440 | QToolTip::remove(this); |
423 | #endif | 441 | #endif |
424 | mToolTip = ""; | 442 | mToolTip = ""; |
425 | //qApp->processEvents(); | 443 | //qApp->processEvents(); |
426 | if ( !mHolidayString.isEmpty() ) { | 444 | if ( !mHolidayString.isEmpty() ) { |
427 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 445 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
428 | item->setPalette( mHolidayPalette ); | 446 | item->setPalette( mHolidayPalette ); |
429 | mItemList->insertItem( item ); | 447 | mItemList->insertItem( item ); |
430 | mToolTip += mHolidayString+"\n"; | 448 | mToolTip += mHolidayString+"\n"; |
431 | } | 449 | } |
432 | } | 450 | } |
433 | 451 | ||
434 | void MonthViewCell::insertEvent(Event *event) | 452 | void MonthViewCell::insertEvent(Event *event) |
435 | { | 453 | { |
454 | |||
455 | mItemList->setFocusPolicy(WheelFocus); | ||
436 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 456 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
437 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 457 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
438 | return; | 458 | return; |
439 | else | 459 | else |
440 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 460 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
441 | return; | 461 | return; |
442 | } | 462 | } |
443 | 463 | ||
444 | if ( event->categories().contains("Holiday") || | 464 | if ( event->categories().contains("Holiday") || |
445 | event->categories().contains(i18n("Holiday"))) { | 465 | event->categories().contains(i18n("Holiday"))) { |
446 | setHoliday( true ); | 466 | setHoliday( true ); |
447 | if ( mDate.dayOfWeek() == 7 ) | 467 | if ( mDate.dayOfWeek() == 7 ) |
448 | mItemList->setLineWidth( 3 ); | 468 | mItemList->setLineWidth( 3 ); |
449 | } | 469 | } |
450 | QString text; | 470 | QString text; |
451 | if (event->isMultiDay()) { | 471 | if (event->isMultiDay()) { |
452 | QString prefix = "<->"; | 472 | QString prefix = "<->"; |
453 | if ( event->doesRecur() ) { | 473 | if ( event->doesRecur() ) { |
454 | if ( event->recursOn( mDate) ) | 474 | if ( event->recursOn( mDate) ) |
455 | prefix ="->" ; | 475 | prefix ="->" ; |
456 | else { | 476 | else { |
457 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 477 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
458 | if ( event->recursOn( mDate.addDays( -days)) ) | 478 | if ( event->recursOn( mDate.addDays( -days)) ) |
459 | prefix ="<-" ; | 479 | prefix ="<-" ; |
460 | } | 480 | } |
461 | 481 | ||
462 | } else { | 482 | } else { |
463 | if (mDate == event->dtStart().date()) { | 483 | if (mDate == event->dtStart().date()) { |
464 | prefix ="->" ; | 484 | prefix ="->" ; |
465 | } else if (mDate == event->dtEnd().date()) { | 485 | } else if (mDate == event->dtEnd().date()) { |
466 | prefix ="<-" ; | 486 | prefix ="<-" ; |
467 | } | 487 | } |
468 | } | 488 | } |
469 | if ( !event->doesFloat() ) { | 489 | if ( !event->doesFloat() ) { |
470 | if ( mDate == event->dtStart().date () ) | 490 | if ( mDate == event->dtStart().date () ) |
471 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 491 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
472 | else if ( mDate == event->dtEnd().date () ) | 492 | else if ( mDate == event->dtEnd().date () ) |
473 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 493 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
474 | 494 | ||
475 | } | 495 | } |
476 | text = prefix + event->summary(); | 496 | text = prefix + event->summary(); |
477 | mToolTip += text; | 497 | mToolTip += text; |
478 | } else { | 498 | } else { |
479 | if (event->doesFloat()) { | 499 | if (event->doesFloat()) { |
480 | text = event->summary(); | 500 | text = event->summary(); |
481 | mToolTip += text; | 501 | mToolTip += text; |
482 | } | 502 | } |
483 | else { | 503 | else { |
@@ -493,97 +513,97 @@ void MonthViewCell::insertEvent(Event *event) | |||
493 | QStringList categories = event->categories(); | 513 | QStringList categories = event->categories(); |
494 | QString cat = categories.first(); | 514 | QString cat = categories.first(); |
495 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 515 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
496 | pal = getPalette(); | 516 | pal = getPalette(); |
497 | if (cat.isEmpty()) { | 517 | if (cat.isEmpty()) { |
498 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 518 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
499 | } else { | 519 | } else { |
500 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 520 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
501 | } | 521 | } |
502 | 522 | ||
503 | } else { | 523 | } else { |
504 | if (cat.isEmpty()) { | 524 | if (cat.isEmpty()) { |
505 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 525 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
506 | } else { | 526 | } else { |
507 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 527 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
508 | } | 528 | } |
509 | } | 529 | } |
510 | 530 | ||
511 | } else { | 531 | } else { |
512 | pal = mStandardPalette ; | 532 | pal = mStandardPalette ; |
513 | } | 533 | } |
514 | item->setPalette( pal ); | 534 | item->setPalette( pal ); |
515 | item->setRecur( event->recurrence()->doesRecur() ); | 535 | item->setRecur( event->recurrence()->doesRecur() ); |
516 | item->setAlarm( event->isAlarmEnabled() ); | 536 | item->setAlarm( event->isAlarmEnabled() ); |
517 | item->setMoreInfo( event->description().length() > 0 ); | 537 | item->setMoreInfo( event->description().length() > 0 ); |
518 | #ifdef DESKTOP_VERSION | 538 | #ifdef DESKTOP_VERSION |
519 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 539 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
520 | KOPrefs::instance()->email()); | 540 | KOPrefs::instance()->email()); |
521 | if ( me != 0 ) { | 541 | if ( me != 0 ) { |
522 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 542 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
523 | item->setReply(true); | 543 | item->setReply(true); |
524 | else | 544 | else |
525 | item->setReply(false); | 545 | item->setReply(false); |
526 | } else | 546 | } else |
527 | item->setReply(false); | 547 | item->setReply(false); |
528 | #endif | 548 | #endif |
529 | mItemList->insertItem( item ); | 549 | mItemList->insertItem( item ); |
530 | mToolTip += "\n"; | 550 | mToolTip += "\n"; |
531 | } | 551 | } |
532 | void MonthViewCell::insertTodo(Todo *todo) | 552 | void MonthViewCell::insertTodo(Todo *todo) |
533 | { | 553 | { |
534 | QString text; | 554 | QString text; |
535 | if (todo->hasDueDate()) { | 555 | if (todo->hasDueDate()) { |
536 | if (!todo->doesFloat()) { | 556 | if (!todo->doesFloat()) { |
537 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 557 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
538 | text += " "; | 558 | text += " "; |
539 | } | 559 | } |
540 | } | 560 | } |
541 | text += i18n("To-Do: %1").arg(todo->summary()); | 561 | text += i18n("Td: %1").arg(todo->summary()); |
542 | 562 | ||
543 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 563 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
544 | //item->setPalette( mStandardPalette ); | 564 | //item->setPalette( mStandardPalette ); |
545 | QPalette pal; | 565 | QPalette pal; |
546 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 566 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
547 | QStringList categories = todo->categories(); | 567 | QStringList categories = todo->categories(); |
548 | QString cat = categories.first(); | 568 | QString cat = categories.first(); |
549 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 569 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
550 | pal = getPalette(); | 570 | pal = getPalette(); |
551 | if (cat.isEmpty()) { | 571 | if (cat.isEmpty()) { |
552 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 572 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
553 | } else { | 573 | } else { |
554 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 574 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
555 | } | 575 | } |
556 | 576 | ||
557 | } else { | 577 | } else { |
558 | if (cat.isEmpty()) { | 578 | if (cat.isEmpty()) { |
559 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 579 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
560 | } else { | 580 | } else { |
561 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 581 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
562 | } | 582 | } |
563 | } | 583 | } |
564 | 584 | ||
565 | } else { | 585 | } else { |
566 | pal = mStandardPalette ; | 586 | pal = mStandardPalette ; |
567 | } | 587 | } |
568 | item->setPalette( pal ); | 588 | item->setPalette( pal ); |
569 | mItemList->insertItem( item ); | 589 | mItemList->insertItem( item ); |
570 | mToolTip += text+"\n"; | 590 | mToolTip += text+"\n"; |
571 | } | 591 | } |
572 | void MonthViewCell::finishUpdateCell() | 592 | void MonthViewCell::finishUpdateCell() |
573 | { | 593 | { |
574 | #ifdef DESKTOP_VERSION | 594 | #ifdef DESKTOP_VERSION |
575 | if (mToolTip != "") | 595 | if (mToolTip != "") |
576 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 596 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
577 | #endif | 597 | #endif |
578 | mItemList->sort(); | 598 | mItemList->sort(); |
579 | //setMyPalette(); | 599 | //setMyPalette(); |
580 | setMyPalette(); | 600 | setMyPalette(); |
581 | QString text; | 601 | QString text; |
582 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 602 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
583 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 603 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
584 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 604 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
585 | mLabel->resize( mLabelBigSize ); | 605 | mLabel->resize( mLabelBigSize ); |
586 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 606 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
587 | } else { | 607 | } else { |
588 | mLabel->resize( mLabelSize ); | 608 | mLabel->resize( mLabelSize ); |
589 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 609 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
@@ -781,183 +801,188 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
781 | mWidStack = new QWidgetStack( this ); | 801 | mWidStack = new QWidgetStack( this ); |
782 | QHBoxLayout* hb = new QHBoxLayout( this ); | 802 | QHBoxLayout* hb = new QHBoxLayout( this ); |
783 | mMonthView = new QWidget( mWidStack ); | 803 | mMonthView = new QWidget( mWidStack ); |
784 | mWeekView = new QWidget( mWidStack ); | 804 | mWeekView = new QWidget( mWidStack ); |
785 | #if QT_VERSION >= 0x030000 | 805 | #if QT_VERSION >= 0x030000 |
786 | mWidStack->addWidget(mMonthView ); | 806 | mWidStack->addWidget(mMonthView ); |
787 | mWidStack->addWidget(mWeekView ); | 807 | mWidStack->addWidget(mWeekView ); |
788 | #else | 808 | #else |
789 | mWidStack->addWidget( mMonthView, 1 ); | 809 | mWidStack->addWidget( mMonthView, 1 ); |
790 | mWidStack->addWidget( mWeekView , 1 ); | 810 | mWidStack->addWidget( mWeekView , 1 ); |
791 | #endif | 811 | #endif |
792 | hb->addWidget( mWidStack ); | 812 | hb->addWidget( mWidStack ); |
793 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
794 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
795 | if ( mShowWeekView ) | 815 | if ( mShowWeekView ) |
796 | mWeekStartsMonday = true; | 816 | mWeekStartsMonday = true; |
797 | updatePossible = false; | 817 | updatePossible = false; |
798 | mCells.setAutoDelete( true ); | 818 | mCells.setAutoDelete( true ); |
799 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 819 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
800 | mDayLabels.resize( mDaysPerWeek ); | 820 | mDayLabels.resize( mDaysPerWeek ); |
801 | mDayLabelsW.resize( mDaysPerWeek ); | 821 | mDayLabelsW.resize( mDaysPerWeek ); |
802 | QFont bfont = font(); | 822 | QFont bfont = font(); |
803 | if ( QApplication::desktop()->width() < 650 ) { | 823 | if ( QApplication::desktop()->width() < 650 ) { |
804 | bfont.setPointSize( bfont.pointSize() - 2 ); | 824 | bfont.setPointSize( bfont.pointSize() - 2 ); |
805 | } | 825 | } |
806 | bfont.setBold( true ); | 826 | bfont.setBold( true ); |
807 | int i; | 827 | int i; |
808 | 828 | ||
809 | for( i = 0; i < mDaysPerWeek; i++ ) { | 829 | for( i = 0; i < mDaysPerWeek; i++ ) { |
810 | QLabel *label = new QLabel( mMonthView ); | 830 | QLabel *label = new QLabel( mMonthView ); |
811 | label->setFont(bfont); | 831 | label->setFont(bfont); |
812 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 832 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
813 | label->setLineWidth(1); | 833 | label->setLineWidth(1); |
814 | label->setAlignment(AlignCenter); | 834 | label->setAlignment(AlignCenter); |
815 | mDayLabels.insert( i, label ); | 835 | mDayLabels.insert( i, label ); |
816 | label = new QLabel( mWeekView ); | 836 | label = new QLabel( mWeekView ); |
817 | label->setFont(bfont); | 837 | label->setFont(bfont); |
818 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 838 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
819 | label->setLineWidth(1); | 839 | label->setLineWidth(1); |
820 | label->setAlignment(AlignCenter); | 840 | label->setAlignment(AlignCenter); |
821 | mDayLabelsW.insert( i, label ); | 841 | mDayLabelsW.insert( i, label ); |
822 | } | 842 | } |
823 | 843 | ||
824 | bfont.setBold( false ); | 844 | bfont.setBold( false ); |
825 | mWeekLabels.resize( mNumWeeks+1 ); | 845 | mWeekLabels.resize( mNumWeeks+1 ); |
826 | mWeekLabelsW.resize( 2 ); | 846 | mWeekLabelsW.resize( 2 ); |
827 | for( i = 0; i < mNumWeeks+1; i++ ) { | 847 | for( i = 0; i < mNumWeeks+1; i++ ) { |
828 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 848 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
849 | label->setFocusPolicy(NoFocus); | ||
829 | label->setFont(bfont); | 850 | label->setFont(bfont); |
830 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 851 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
831 | label->setFlat(true); | 852 | label->setFlat(true); |
832 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 853 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
833 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 854 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
834 | //label->setLineWidth(1); | 855 | //label->setLineWidth(1); |
835 | //label->setAlignment(AlignCenter); | 856 | //label->setAlignment(AlignCenter); |
836 | mWeekLabels.insert( i, label ); | 857 | mWeekLabels.insert( i, label ); |
837 | } | 858 | } |
838 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 859 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
839 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 860 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
840 | 861 | ||
841 | for( i = 0; i < 1+1; i++ ) { | 862 | for( i = 0; i < 1+1; i++ ) { |
842 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 863 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
864 | label->setFocusPolicy(NoFocus); | ||
843 | label->setFont(bfont); | 865 | label->setFont(bfont); |
844 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 866 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
845 | label->setFlat(true); | 867 | label->setFlat(true); |
846 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 868 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
847 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 869 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
848 | //label->setLineWidth(1); | 870 | //label->setLineWidth(1); |
849 | //label->setAlignment(AlignCenter); | 871 | //label->setAlignment(AlignCenter); |
850 | mWeekLabelsW.insert( i, label ); | 872 | mWeekLabelsW.insert( i, label ); |
851 | } | 873 | } |
852 | mWeekLabelsW[1]->setText( i18n("W")); | 874 | mWeekLabelsW[1]->setText( i18n("W")); |
853 | 875 | ||
854 | 876 | ||
855 | int row, col; | 877 | int row, col; |
856 | mCells.resize( mNumCells ); | 878 | mCells.resize( mNumCells ); |
857 | for( row = 0; row < mNumWeeks; ++row ) { | 879 | for( row = 0; row < mNumWeeks; ++row ) { |
858 | for( col = 0; col < mDaysPerWeek; ++col ) { | 880 | for( col = 0; col < mDaysPerWeek; ++col ) { |
859 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 881 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
860 | mCells.insert( row * mDaysPerWeek + col, cell ); | 882 | mCells.insert( row * mDaysPerWeek + col, cell ); |
861 | 883 | ||
862 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 884 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
863 | SLOT( defaultAction( Incidence * ) ) ); | 885 | SLOT( defaultAction( Incidence * ) ) ); |
864 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 886 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
865 | SIGNAL( newEventSignal( QDateTime ) ) ); | 887 | SIGNAL( newEventSignal( QDateTime ) ) ); |
866 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 888 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
867 | SIGNAL( showDaySignal( QDate ) ) ); | 889 | SIGNAL( showDaySignal( QDate ) ) ); |
868 | } | 890 | } |
869 | } | 891 | } |
870 | mCellsW.resize( mDaysPerWeek ); | 892 | mCellsW.resize( mDaysPerWeek ); |
871 | for( col = 0; col < mDaysPerWeek; ++col ) { | 893 | for( col = 0; col < mDaysPerWeek; ++col ) { |
872 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 894 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
873 | mCellsW.insert( col, cell ); | 895 | mCellsW.insert( col, cell ); |
874 | 896 | ||
875 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 897 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
876 | SLOT( defaultAction( Incidence * ) ) ); | 898 | SLOT( defaultAction( Incidence * ) ) ); |
877 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 899 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
878 | SIGNAL( newEventSignal( QDateTime ) ) ); | 900 | SIGNAL( newEventSignal( QDateTime ) ) ); |
879 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 901 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
880 | SIGNAL( showDaySignal( QDate ) ) ); | 902 | SIGNAL( showDaySignal( QDate ) ) ); |
881 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 903 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
882 | } | 904 | } |
883 | 905 | ||
884 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 906 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
885 | mContextMenu = eventPopup(); | 907 | mContextMenu = eventPopup(); |
886 | // updateConfig(); //useless here | 908 | // updateConfig(); //useless here |
887 | 909 | ||
888 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 910 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
889 | #if 0 | 911 | #if 0 |
890 | mWidStack = new QWidgetStack( this ); | 912 | mWidStack = new QWidgetStack( this ); |
891 | mMonthView = new QWidget( mWidStack ); | 913 | mMonthView = new QWidget( mWidStack ); |
892 | mWeekView = new QWidget( mWidStack ); | 914 | mWeekView = new QWidget( mWidStack ); |
893 | #endif | 915 | #endif |
894 | if ( mShowWeekView ) | 916 | if ( mShowWeekView ) |
895 | mWidStack->raiseWidget( mWeekView ); | 917 | mWidStack->raiseWidget( mWeekView ); |
896 | else | 918 | else |
897 | mWidStack->raiseWidget( mMonthView ); | 919 | mWidStack->raiseWidget( mMonthView ); |
898 | 920 | ||
899 | emit incidenceSelected( 0 ); | 921 | emit incidenceSelected( 0 ); |
900 | } | 922 | } |
901 | 923 | ||
902 | KOMonthView::~KOMonthView() | 924 | KOMonthView::~KOMonthView() |
903 | { | 925 | { |
904 | delete mContextMenu; | 926 | delete mContextMenu; |
905 | } | 927 | } |
906 | void KOMonthView::selectDateWeekNum ( int ) | ||
907 | { | ||
908 | 928 | ||
909 | } | ||
910 | void KOMonthView::selectInternalWeekNum ( int n ) | 929 | void KOMonthView::selectInternalWeekNum ( int n ) |
911 | { | 930 | { |
912 | switchView(); | 931 | switchView(); |
913 | emit selectWeekNum ( n ); | 932 | emit selectWeekNum ( n ); |
914 | } | 933 | } |
915 | 934 | ||
935 | int KOMonthView::currentWeek() | ||
936 | { | ||
937 | if ( mShowWeekView ) | ||
938 | return mWeekLabelsW[0]->getWeekNum(); | ||
939 | return mWeekLabels[0]->getWeekNum(); | ||
940 | } | ||
916 | void KOMonthView::switchView() | 941 | void KOMonthView::switchView() |
917 | { | 942 | { |
918 | 943 | ||
919 | if ( selectedCell( ) ) | 944 | if ( selectedCell( ) ) |
920 | selectedCell()->deselect(); | 945 | selectedCell()->deselect(); |
921 | mShowWeekView = !mShowWeekView; | 946 | mShowWeekView = !mShowWeekView; |
922 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 947 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
923 | //emit showNavigator( !mShowWeekView ); | 948 | //emit showNavigator( !mShowWeekView ); |
924 | if ( clPending ) { | 949 | if ( clPending ) { |
925 | computeLayout(); | 950 | computeLayout(); |
926 | updateConfig(); | 951 | updateConfig(); |
927 | } | 952 | } |
928 | if ( mShowWeekView ) | 953 | if ( mShowWeekView ) |
929 | mWidStack->raiseWidget( mWeekView ); | 954 | mWidStack->raiseWidget( mWeekView ); |
930 | else | 955 | else |
931 | mWidStack->raiseWidget( mMonthView ); | 956 | mWidStack->raiseWidget( mMonthView ); |
932 | clPending = false; | 957 | clPending = false; |
933 | } | 958 | } |
934 | 959 | ||
935 | int KOMonthView::maxDatesHint() | 960 | int KOMonthView::maxDatesHint() |
936 | { | 961 | { |
937 | return mNumCells; | 962 | return mNumCells; |
938 | } | 963 | } |
939 | 964 | ||
940 | int KOMonthView::currentDateCount() | 965 | int KOMonthView::currentDateCount() |
941 | { | 966 | { |
942 | return mNumCells; | 967 | return mNumCells; |
943 | } | 968 | } |
944 | 969 | ||
945 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 970 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
946 | { | 971 | { |
947 | QPtrList<Incidence> selected; | 972 | QPtrList<Incidence> selected; |
948 | 973 | ||
949 | if ( mSelectedCell ) { | 974 | if ( mSelectedCell ) { |
950 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 975 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
951 | if ( incidence ) selected.append( incidence ); | 976 | if ( incidence ) selected.append( incidence ); |
952 | } | 977 | } |
953 | 978 | ||
954 | return selected; | 979 | return selected; |
955 | } | 980 | } |
956 | 981 | ||
957 | DateList KOMonthView::selectedDates() | 982 | DateList KOMonthView::selectedDates() |
958 | { | 983 | { |
959 | DateList selected; | 984 | DateList selected; |
960 | 985 | ||
961 | if ( mSelectedCell ) { | 986 | if ( mSelectedCell ) { |
962 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 987 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
963 | if ( qd.isValid() ) selected.append( qd ); | 988 | if ( qd.isValid() ) selected.append( qd ); |
@@ -1494,53 +1519,60 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell ) | |||
1494 | mSelectedCell = cell; | 1519 | mSelectedCell = cell; |
1495 | mvc->deselect(); | 1520 | mvc->deselect(); |
1496 | } else | 1521 | } else |
1497 | mSelectedCell = cell; | 1522 | mSelectedCell = cell; |
1498 | // if ( mSelectedCell ) | 1523 | // if ( mSelectedCell ) |
1499 | // mSelectedCell->select(); | 1524 | // mSelectedCell->select(); |
1500 | if ( !mSelectedCell ) | 1525 | if ( !mSelectedCell ) |
1501 | emit incidenceSelected( 0 ); | 1526 | emit incidenceSelected( 0 ); |
1502 | else | 1527 | else |
1503 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1528 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1504 | } | 1529 | } |
1505 | 1530 | ||
1506 | void KOMonthView::processSelectionChange() | 1531 | void KOMonthView::processSelectionChange() |
1507 | { | 1532 | { |
1508 | QPtrList<Incidence> incidences = selectedIncidences(); | 1533 | QPtrList<Incidence> incidences = selectedIncidences(); |
1509 | if (incidences.count() > 0) { | 1534 | if (incidences.count() > 0) { |
1510 | emit incidenceSelected( incidences.first() ); | 1535 | emit incidenceSelected( incidences.first() ); |
1511 | } else { | 1536 | } else { |
1512 | emit incidenceSelected( 0 ); | 1537 | emit incidenceSelected( 0 ); |
1513 | } | 1538 | } |
1514 | } | 1539 | } |
1515 | 1540 | ||
1516 | void KOMonthView::clearSelection() | 1541 | void KOMonthView::clearSelection() |
1517 | { | 1542 | { |
1518 | if ( mSelectedCell ) { | 1543 | if ( mSelectedCell ) { |
1519 | mSelectedCell->deselect(); | 1544 | mSelectedCell->deselect(); |
1520 | mSelectedCell = 0; | 1545 | mSelectedCell = 0; |
1521 | } | 1546 | } |
1522 | } | 1547 | } |
1523 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1548 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1524 | { | 1549 | { |
1525 | //qDebug("KOMonthView::keyPressEvent "); | 1550 | //qDebug("KOMonthView::keyPressEvent "); |
1526 | switch(e->key()) { | 1551 | switch(e->key()) { |
1527 | case Key_Up: | 1552 | case Key_Up: |
1528 | { | 1553 | { |
1529 | emit prevMonth(); | 1554 | emit prevMonth(); |
1530 | mCells[0]->setFocus(); | 1555 | mCells[0]->setFocus(); |
1531 | } | 1556 | } |
1532 | e->accept(); | 1557 | e->accept(); |
1533 | break; | 1558 | break; |
1534 | case Key_Down: | 1559 | case Key_Down: |
1535 | { | 1560 | { |
1536 | emit nextMonth(); | 1561 | emit nextMonth(); |
1537 | mCells[0]->setFocus(); | 1562 | mCells[0]->setFocus(); |
1538 | 1563 | ||
1539 | } | 1564 | } |
1540 | e->accept(); | 1565 | e->accept(); |
1541 | break; | 1566 | break; |
1567 | case Key_Return: | ||
1568 | case Key_Enter: | ||
1569 | { | ||
1570 | selectInternalWeekNum ( currentWeek() ); | ||
1571 | } | ||
1572 | e->accept(); | ||
1573 | break; | ||
1542 | default: | 1574 | default: |
1543 | e->ignore(); | 1575 | e->ignore(); |
1544 | break; | 1576 | break; |
1545 | } | 1577 | } |
1546 | } | 1578 | } |