-rw-r--r-- | korganizer/komonthview.cpp | 146 |
1 files changed, 86 insertions, 60 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index e66ddce..4dfb9df 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -51,233 +51,249 @@ | |||
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | 92 | ||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 96 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
97 | { | 97 | { |
98 | QListBox::focusInEvent ( e ); | 98 | QListBox::focusInEvent ( e ); |
99 | QListBoxItem * i = item ( 0 ); | 99 | if ( count() ){ |
100 | if ( i && resetOnFocusIn ) { | 100 | int ci = currentItem(); |
101 | setCurrentItem( i ); | 101 | if ( ci < 0 ) ci = 0; |
102 | setSelected ( 0, true ); | 102 | |
103 | } | 103 | setCurrentItem( ci ); |
104 | resetOnFocusIn = true; | 104 | setSelected ( ci, true ); |
105 | 105 | emit highlighted( item ( ci ) ); | |
106 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 106 | |
107 | QListBoxItem *fi = firstItem (); | 107 | resetOnFocusIn = true; |
108 | if (fi ) { | 108 | |
109 | int ihei = fi->height( this ); | 109 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
110 | int hei = numRows () * ihei; | 110 | QListBoxItem *fi = firstItem (); |
111 | if ( hei < height() - horizontalScrollBar()->height () ) { | 111 | if (fi ) { |
112 | setVScrollBarMode(QScrollView::AlwaysOff); | 112 | int ihei = fi->height( this ); |
113 | } | 113 | int hei = numRows () * ihei; |
114 | else | 114 | if ( hei < height() - horizontalScrollBar()->height () ) { |
115 | setVScrollBarMode(QScrollView::AlwaysOff); | ||
116 | } | ||
117 | else | ||
118 | setVScrollBarMode(QScrollView::Auto); | ||
119 | if ( ihei *3 > height() ) { | ||
120 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
121 | } | ||
122 | else { | ||
123 | setHScrollBarMode(QScrollView::Auto); | ||
124 | } | ||
125 | } else { | ||
115 | setVScrollBarMode(QScrollView::Auto); | 126 | setVScrollBarMode(QScrollView::Auto); |
116 | if ( ihei *3 > height() ) { | ||
117 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
118 | } | ||
119 | else { | ||
120 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
121 | } | 128 | } |
122 | } else { | 129 | } |
123 | setVScrollBarMode(QScrollView::Auto); | 130 | } |
124 | setHScrollBarMode(QScrollView::Auto); | ||
125 | } | ||
126 | } | ||
127 | } | 131 | } |
128 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 132 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
129 | { | 133 | { |
130 | int i = currentItem (); | 134 | int i = currentItem (); |
131 | if ( i >= 0 ) { | 135 | if ( i >= 0 ) { |
132 | setSelected ( i, false ); | 136 | setSelected ( i, false ); |
133 | } | 137 | } |
134 | QListBox::focusOutEvent ( e ); | 138 | QListBox::focusOutEvent ( e ); |
135 | setVScrollBarMode(QScrollView::AlwaysOff); | 139 | setVScrollBarMode(QScrollView::AlwaysOff); |
136 | setHScrollBarMode(QScrollView::AlwaysOff); | 140 | setHScrollBarMode(QScrollView::AlwaysOff); |
137 | } | 141 | } |
138 | 142 | ||
139 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 143 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
140 | { | 144 | { |
141 | QListBoxItem* item = itemAt ( p ); | 145 | QListBoxItem* item = itemAt ( p ); |
142 | if ( ! item ) { | 146 | if ( ! item ) { |
143 | return i18n("Click in the cell\nto add an event!"); | 147 | return i18n("Click in the cell\nto add an event!"); |
144 | } | 148 | } |
145 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 149 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
146 | KOPrefs::instance()->mWTshowDetails, | 150 | KOPrefs::instance()->mWTshowDetails, |
147 | KOPrefs::instance()->mWTshowCreated, | 151 | KOPrefs::instance()->mWTshowCreated, |
148 | KOPrefs::instance()->mWTshowChanged); | 152 | KOPrefs::instance()->mWTshowChanged); |
149 | } | 153 | } |
150 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
151 | { | 155 | { |
152 | //qDebug("KNoScrollListBox::keyPressEvent "); | 156 | //qDebug("KNoScrollListBox::keyPressEvent "); |
153 | switch(e->key()) { | 157 | switch(e->key()) { |
154 | case Key_Right: | 158 | case Key_Right: |
155 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 159 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
156 | { | 160 | { |
157 | e->ignore(); | 161 | e->ignore(); |
158 | return; | 162 | return; |
159 | } | 163 | } |
160 | scrollBy(10,0); | 164 | scrollBy(10,0); |
161 | break; | 165 | break; |
162 | case Key_Left: | 166 | case Key_Left: |
163 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 167 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
164 | { | 168 | { |
165 | e->ignore(); | 169 | e->ignore(); |
166 | return; | 170 | return; |
167 | } | 171 | } |
168 | scrollBy(-10,0); | 172 | scrollBy(-10,0); |
169 | break; | 173 | break; |
170 | case Key_Up: | 174 | case Key_Up: |
171 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 175 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
172 | e->ignore(); | 176 | e->ignore(); |
173 | break; | 177 | break; |
174 | } | 178 | } |
175 | if ( count() ) { | 179 | if ( count() ) { |
176 | setCurrentItem((currentItem()+count()-1)%count()); | 180 | if ( currentItem() == 0 ) { |
177 | if(!itemVisible(currentItem())) { | 181 | emit prevCell(); |
178 | if((unsigned int) currentItem() == (count()-1)) { | 182 | } else { |
179 | setTopItem(currentItem()-numItemsVisible()+1); | 183 | setCurrentItem((currentItem()+count()-1)%count()); |
180 | } else { | 184 | if(!itemVisible(currentItem())) { |
181 | setTopItem(topItem()-1); | 185 | if((unsigned int) currentItem() == (count()-1)) { |
186 | setTopItem(currentItem()-numItemsVisible()+1); | ||
187 | } else { | ||
188 | setTopItem(topItem()-1); | ||
189 | } | ||
182 | } | 190 | } |
183 | } | 191 | } |
184 | } | 192 | } |
185 | break; | 193 | break; |
186 | case Key_Down: | 194 | case Key_Down: |
187 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 195 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
188 | e->ignore(); | 196 | e->ignore(); |
189 | break; | 197 | break; |
190 | } | 198 | } |
191 | if ( count () ) { | 199 | if ( count () ) { |
192 | setCurrentItem((currentItem()+1)%count()); | 200 | if ( currentItem()+1 == count () ) { |
193 | if(!itemVisible(currentItem())) { | 201 | emit nextCell(); |
194 | if(currentItem() == 0) { | 202 | } else { |
195 | setTopItem(0); | 203 | setCurrentItem((currentItem()+1)%count()); |
196 | } else { | 204 | if(!itemVisible(currentItem())) { |
197 | setTopItem(topItem()+1); | 205 | if(currentItem() == 0) { |
206 | setTopItem(0); | ||
207 | } else { | ||
208 | setTopItem(topItem()+1); | ||
209 | } | ||
198 | } | 210 | } |
199 | } | 211 | } |
200 | } | 212 | } |
201 | break; | 213 | break; |
202 | case Key_I: | 214 | case Key_I: |
203 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 215 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
204 | e->ignore(); | 216 | e->ignore(); |
205 | break; | 217 | break; |
206 | case Key_Return: | 218 | case Key_Return: |
207 | case Key_Enter: | 219 | case Key_Enter: |
208 | { | 220 | { |
209 | if ( currentItem() >= 0 ) { | 221 | if ( currentItem() >= 0 ) { |
210 | emit doubleClicked( item( currentItem() ) ); | 222 | emit doubleClicked( item( currentItem() ) ); |
211 | e->accept(); | 223 | e->accept(); |
212 | } else { | 224 | } else { |
213 | e->ignore(); | 225 | e->ignore(); |
214 | } | 226 | } |
215 | } | 227 | } |
216 | break; | 228 | break; |
217 | case Key_Shift: | 229 | case Key_Shift: |
218 | emit shiftDown(); | 230 | emit shiftDown(); |
219 | break; | 231 | break; |
220 | default: | 232 | default: |
221 | e->ignore(); | 233 | e->ignore(); |
222 | break; | 234 | break; |
223 | } | 235 | } |
224 | } | 236 | } |
225 | 237 | ||
226 | void KNoScrollListBox::oneDown() | 238 | void KNoScrollListBox::oneDown() |
227 | { | 239 | { |
228 | if ( count () ) { | 240 | if ( count () ) { |
229 | resetOnFocusIn = false; | 241 | if ( currentItem()+1 == count () ) { |
230 | setCurrentItem((currentItem()+1)%count()); | 242 | emit nextCell(); |
231 | if(!itemVisible(currentItem())) { | 243 | } else { |
232 | if(currentItem() == 0) { | 244 | resetOnFocusIn = false; |
233 | setTopItem(0); | 245 | setCurrentItem((currentItem()+1)%count()); |
234 | } else { | 246 | if(!itemVisible(currentItem())) { |
235 | setTopItem(topItem()+1); | 247 | if(currentItem() == 0) { |
248 | setTopItem(0); | ||
249 | } else { | ||
250 | setTopItem(topItem()+1); | ||
251 | } | ||
236 | } | 252 | } |
237 | } | 253 | } |
238 | } | 254 | } |
239 | } | 255 | } |
240 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 256 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
241 | { | 257 | { |
242 | switch(e->key()) { | 258 | switch(e->key()) { |
243 | case Key_Shift: | 259 | case Key_Shift: |
244 | emit shiftUp(); | 260 | emit shiftUp(); |
245 | break; | 261 | break; |
246 | default: | 262 | default: |
247 | break; | 263 | break; |
248 | } | 264 | } |
249 | } | 265 | } |
250 | 266 | ||
251 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 267 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
252 | { | 268 | { |
253 | QListBox::mousePressEvent(e); | 269 | QListBox::mousePressEvent(e); |
254 | 270 | ||
255 | if(e->button() == RightButton) { | 271 | if(e->button() == RightButton) { |
256 | emit rightClick(); | 272 | emit rightClick(); |
257 | } | 273 | } |
258 | } | 274 | } |
259 | 275 | ||
260 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 276 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
261 | : QListBoxItem() | 277 | : QListBoxItem() |
262 | { | 278 | { |
263 | mblockRepaint = true; | 279 | mblockRepaint = true; |
264 | setText( s ); | 280 | setText( s ); |
265 | mMultiday = 0; | 281 | mMultiday = 0; |
266 | mIncidence = incidence; | 282 | mIncidence = incidence; |
267 | mDate = qd; | 283 | mDate = qd; |
268 | mRecur = false; | 284 | mRecur = false; |
269 | mAlarm = false; | 285 | mAlarm = false; |
270 | mReply = false; | 286 | mReply = false; |
271 | mInfo = false; | 287 | mInfo = false; |
272 | mdayPos = 0; | 288 | mdayPos = 0; |
273 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 289 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
274 | //qDebug("NEWWWWWWWWWWWWW "); | 290 | //qDebug("NEWWWWWWWWWWWWW "); |
275 | } | 291 | } |
276 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 292 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
277 | { | 293 | { |
278 | setText( s ); | 294 | setText( s ); |
279 | mMultiday = 0; | 295 | mMultiday = 0; |
280 | mIncidence = incidence; | 296 | mIncidence = incidence; |
281 | mDate = qd; | 297 | mDate = qd; |
282 | mRecur = false; | 298 | mRecur = false; |
283 | mAlarm = false; | 299 | mAlarm = false; |
@@ -428,100 +444,101 @@ int MonthViewItem::width(const QListBox *lb) const | |||
428 | } | 444 | } |
429 | } | 445 | } |
430 | if( mMultiday ) { | 446 | if( mMultiday ) { |
431 | x += size+1+2+size/2; | 447 | x += size+1+2+size/2; |
432 | } | 448 | } |
433 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 449 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
434 | } | 450 | } |
435 | if ( ! lb ) | 451 | if ( ! lb ) |
436 | return 10; | 452 | return 10; |
437 | //qDebug("ret wid %d ", lb->width()); | 453 | //qDebug("ret wid %d ", lb->width()); |
438 | return lb->width(); | 454 | return lb->width(); |
439 | } | 455 | } |
440 | 456 | ||
441 | 457 | ||
442 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 458 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
443 | : KNoScrollListBox( par ), | 459 | : KNoScrollListBox( par ), |
444 | mMonthView( parent ) | 460 | mMonthView( parent ) |
445 | { | 461 | { |
446 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 462 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
447 | currentPalette = 0; | 463 | currentPalette = 0; |
448 | // mLabel = new QLabel( this );QPushButton | 464 | // mLabel = new QLabel( this );QPushButton |
449 | mLabel = new QPushButton( this ); | 465 | mLabel = new QPushButton( this ); |
450 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 466 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
451 | //mLabel->setLineWidth( 1 ); | 467 | //mLabel->setLineWidth( 1 ); |
452 | //mLabel->setAlignment( AlignCenter ); | 468 | //mLabel->setAlignment( AlignCenter ); |
453 | mLabel->setFlat( true ); | 469 | mLabel->setFlat( true ); |
454 | mLabel->setFocusPolicy(NoFocus); | 470 | mLabel->setFocusPolicy(NoFocus); |
455 | //mItemList = new KNoScrollListBox( this ); | 471 | //mItemList = new KNoScrollListBox( this ); |
456 | setMinimumSize( 10, 10 ); | 472 | setMinimumSize( 10, 10 ); |
457 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 473 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
458 | setLineWidth( 1 ); | 474 | setLineWidth( 1 ); |
459 | //topLayout->addWidget( mItemList ); | 475 | //topLayout->addWidget( mItemList ); |
460 | mLabel->raise(); | 476 | mLabel->raise(); |
461 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 477 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
462 | mStandardPalette = palette(); | 478 | mStandardPalette = palette(); |
463 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 479 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
464 | 480 | ||
465 | enableScrollBars( false ); | 481 | enableScrollBars( false ); |
466 | updateConfig(); | 482 | updateConfig(); |
467 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 483 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
468 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 484 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
469 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 485 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
470 | SLOT( defaultAction( QListBoxItem * ) ) ); | 486 | SLOT( defaultAction( QListBoxItem * ) ) ); |
471 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 487 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
472 | const QPoint &) ), | 488 | const QPoint &) ), |
473 | SLOT( contextMenu( QListBoxItem * ) ) ); | 489 | SLOT( contextMenu( QListBoxItem * ) ) ); |
474 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 490 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
475 | SLOT( selection( QListBoxItem * ) ) ); | 491 | SLOT( selection( QListBoxItem * ) ) ); |
476 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 492 | |
477 | SLOT( cellClicked( QListBoxItem * ) ) ); | 493 | /* |
478 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 494 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
479 | SLOT( selection( QListBoxItem * ) ) ); | 495 | SLOT( selection( QListBoxItem * ) ) ); |
496 | */ | ||
480 | } | 497 | } |
481 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
482 | QToolTipGroup *MonthViewCell::toolTipGroup() | 499 | QToolTipGroup *MonthViewCell::toolTipGroup() |
483 | { | 500 | { |
484 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 501 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
485 | return mToolTipGroup; | 502 | return mToolTipGroup; |
486 | } | 503 | } |
487 | #endif | 504 | #endif |
488 | 505 | ||
489 | void MonthViewCell::setDate( const QDate &date ) | 506 | void MonthViewCell::setDate( const QDate &date ) |
490 | { | 507 | { |
491 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 508 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
492 | mDate = date; | 509 | mDate = date; |
493 | 510 | ||
494 | 511 | ||
495 | 512 | ||
496 | //resizeEvent( 0 ); | 513 | //resizeEvent( 0 ); |
497 | } | 514 | } |
498 | 515 | ||
499 | QDate MonthViewCell::date() const | 516 | QDate MonthViewCell::date() const |
500 | { | 517 | { |
501 | return mDate; | 518 | return mDate; |
502 | } | 519 | } |
503 | 520 | ||
504 | void MonthViewCell::setPrimary( bool primary ) | 521 | void MonthViewCell::setPrimary( bool primary ) |
505 | { | 522 | { |
506 | mPrimary = primary; | 523 | mPrimary = primary; |
507 | //setMyPalette(); | 524 | //setMyPalette(); |
508 | } | 525 | } |
509 | void MonthViewCell::setMyPalette() | 526 | void MonthViewCell::setMyPalette() |
510 | { | 527 | { |
511 | 528 | ||
512 | if ( mHoliday) { | 529 | if ( mHoliday) { |
513 | if ( currentPalette == 1 ) return; | 530 | if ( currentPalette == 1 ) return; |
514 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 531 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
515 | setPalette( mHolidayPalette ); | 532 | setPalette( mHolidayPalette ); |
516 | //mLabel->setPalette( mHolidayPalette ); | 533 | //mLabel->setPalette( mHolidayPalette ); |
517 | currentPalette = 1; | 534 | currentPalette = 1; |
518 | 535 | ||
519 | } else { | 536 | } else { |
520 | if ( mPrimary ) { | 537 | if ( mPrimary ) { |
521 | if ( currentPalette == 2 ) return; | 538 | if ( currentPalette == 2 ) return; |
522 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 539 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
523 | //mLabel->setPalette( mPrimaryPalette ); | 540 | //mLabel->setPalette( mPrimaryPalette ); |
524 | setPalette( mPrimaryPalette ); | 541 | setPalette( mPrimaryPalette ); |
525 | currentPalette = 2; | 542 | currentPalette = 2; |
526 | 543 | ||
527 | } else { | 544 | } else { |
@@ -944,133 +961,125 @@ QDate MonthViewCell::selectedIncidenceDate() | |||
944 | void MonthViewCell::deselect() | 961 | void MonthViewCell::deselect() |
945 | { | 962 | { |
946 | clearSelection(); | 963 | clearSelection(); |
947 | enableScrollBars( false ); | 964 | enableScrollBars( false ); |
948 | // updateCell(); | 965 | // updateCell(); |
949 | } | 966 | } |
950 | void MonthViewCell::select() | 967 | void MonthViewCell::select() |
951 | { | 968 | { |
952 | ;// updateCell(); | 969 | ;// updateCell(); |
953 | } | 970 | } |
954 | 971 | ||
955 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 972 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
956 | { | 973 | { |
957 | if ( !mMonthView->isUpdatePossible() ) | 974 | if ( !mMonthView->isUpdatePossible() ) |
958 | return; | 975 | return; |
959 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 976 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
960 | deselect(); | 977 | deselect(); |
961 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 978 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
962 | 979 | ||
963 | QString text; | 980 | QString text; |
964 | mLabel->setText( text ); | 981 | mLabel->setText( text ); |
965 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 982 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
966 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 983 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
967 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 984 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
968 | mLabel->resize( mLabelBigSize ); | 985 | mLabel->resize( mLabelBigSize ); |
969 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 986 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
970 | } else { | 987 | } else { |
971 | mLabel->resize( mLabelSize ); | 988 | mLabel->resize( mLabelSize ); |
972 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 989 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
973 | } | 990 | } |
974 | mLabel->setText( text ); | 991 | mLabel->setText( text ); |
975 | 992 | ||
976 | int size = height() - mLabel->height() - lineWidth()-1; | 993 | int size = height() - mLabel->height() - lineWidth()-1; |
977 | //qDebug("LW %d ", lineWidth()); | 994 | //qDebug("LW %d ", lineWidth()); |
978 | if ( size > 0 ) | 995 | if ( size > 0 ) |
979 | verticalScrollBar()->setMaximumHeight( size ); | 996 | verticalScrollBar()->setMaximumHeight( size ); |
980 | size = width() - mLabel->width() -lineWidth()-1; | 997 | size = width() - mLabel->width() -lineWidth()-1; |
981 | if ( size > 0 ) | 998 | if ( size > 0 ) |
982 | horizontalScrollBar()->setMaximumWidth( size ); | 999 | horizontalScrollBar()->setMaximumWidth( size ); |
983 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1000 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
984 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1001 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
985 | // mItemList->resize ( width(), height () ); | 1002 | // mItemList->resize ( width(), height () ); |
986 | if ( e ) | 1003 | if ( e ) |
987 | KNoScrollListBox::resizeEvent ( e ); | 1004 | KNoScrollListBox::resizeEvent ( e ); |
988 | } | 1005 | } |
989 | 1006 | ||
990 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1007 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
991 | { | 1008 | { |
1009 | |||
992 | if ( !item ) { | 1010 | if ( !item ) { |
993 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1011 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
994 | emit newEventSignal( dt ); | 1012 | emit newEventSignal( dt ); |
995 | return; | 1013 | return; |
996 | } | 1014 | } |
997 | 1015 | ||
998 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1016 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
999 | Incidence *incidence = eventItem->incidence(); | 1017 | Incidence *incidence = eventItem->incidence(); |
1000 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1018 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1001 | } | 1019 | } |
1002 | void MonthViewCell::showDay() | 1020 | void MonthViewCell::showDay() |
1003 | { | 1021 | { |
1004 | emit showDaySignal( date() ); | 1022 | emit showDaySignal( date() ); |
1005 | } | 1023 | } |
1006 | void MonthViewCell::newEvent() | 1024 | void MonthViewCell::newEvent() |
1007 | { | 1025 | { |
1008 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1026 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1009 | emit newEventSignal( dt ); | 1027 | emit newEventSignal( dt ); |
1010 | } | 1028 | } |
1011 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1029 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1012 | { | 1030 | { |
1031 | qDebug("CELL "); | ||
1013 | if ( item == 0 ) { | 1032 | if ( item == 0 ) { |
1014 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1033 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1015 | emit newEventSignal( dt ); | 1034 | emit newEventSignal( dt ); |
1016 | return; | 1035 | return; |
1017 | } | 1036 | } |
1018 | /* | 1037 | |
1019 | if ( lastClicked ) | ||
1020 | if ( ! item ) { | ||
1021 | if ( lastClicked->listBox() != item->listBox() ) | ||
1022 | lastClicked->listBox()->clearSelection(); | ||
1023 | } | ||
1024 | */ | ||
1025 | |||
1026 | mMonthView->setSelectedCell( this ); | ||
1027 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | ||
1028 | select(); | ||
1029 | } | 1038 | } |
1030 | 1039 | ||
1031 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1040 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1032 | { | 1041 | { |
1033 | if ( !item ) return; | 1042 | if ( !item ) return; |
1034 | 1043 | ||
1035 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1044 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1036 | Incidence *incidence = eventItem->incidence(); | 1045 | Incidence *incidence = eventItem->incidence(); |
1037 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1046 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1038 | } | 1047 | } |
1039 | 1048 | ||
1040 | void MonthViewCell::selection( QListBoxItem *item ) | 1049 | void MonthViewCell::selection( QListBoxItem *item ) |
1041 | { | 1050 | { |
1042 | if ( !item ) return; | 1051 | if ( !item ) return; |
1043 | 1052 | ||
1044 | mMonthView->setSelectedCell( this ); | 1053 | mMonthView->setSelectedCell( this ); |
1045 | } | 1054 | } |
1046 | 1055 | ||
1047 | 1056 | ||
1048 | // ******************************************************************************* | 1057 | // ******************************************************************************* |
1049 | // ******************************************************************************* | 1058 | // ******************************************************************************* |
1050 | // ******************************************************************************* | 1059 | // ******************************************************************************* |
1051 | 1060 | ||
1052 | 1061 | ||
1053 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1062 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1054 | : KOEventView( calendar, parent, name ), | 1063 | : KOEventView( calendar, parent, name ), |
1055 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1064 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1056 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1065 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1057 | { | 1066 | { |
1058 | mFlagKeyPressed = false; | 1067 | mFlagKeyPressed = false; |
1059 | mShortDayLabelsM = false; | 1068 | mShortDayLabelsM = false; |
1060 | mShortDayLabelsW = false; | 1069 | mShortDayLabelsW = false; |
1061 | skipResize = false; | 1070 | skipResize = false; |
1062 | clPending = true; | 1071 | clPending = true; |
1063 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1072 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1064 | mWidStack = new QWidgetStack( this ); | 1073 | mWidStack = new QWidgetStack( this ); |
1065 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1074 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1066 | mMonthView = new QWidget( mWidStack ); | 1075 | mMonthView = new QWidget( mWidStack ); |
1067 | mWeekView = new QWidget( mWidStack ); | 1076 | mWeekView = new QWidget( mWidStack ); |
1068 | #if QT_VERSION >= 0x030000 | 1077 | #if QT_VERSION >= 0x030000 |
1069 | mWidStack->addWidget(mMonthView ); | 1078 | mWidStack->addWidget(mMonthView ); |
1070 | mWidStack->addWidget(mWeekView ); | 1079 | mWidStack->addWidget(mWeekView ); |
1071 | #else | 1080 | #else |
1072 | mWidStack->addWidget( mMonthView, 1 ); | 1081 | mWidStack->addWidget( mMonthView, 1 ); |
1073 | mWidStack->addWidget( mWeekView , 1 ); | 1082 | mWidStack->addWidget( mWeekView , 1 ); |
1074 | #endif | 1083 | #endif |
1075 | hb->addWidget( mNavigatorBar ); | 1084 | hb->addWidget( mNavigatorBar ); |
1076 | hb->addWidget( mWidStack ); | 1085 | hb->addWidget( mWidStack ); |
@@ -1106,109 +1115,117 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1106 | bfont.setBold( false ); | 1115 | bfont.setBold( false ); |
1107 | mWeekLabels.resize( mNumWeeks+1 ); | 1116 | mWeekLabels.resize( mNumWeeks+1 ); |
1108 | mWeekLabelsW.resize( 2 ); | 1117 | mWeekLabelsW.resize( 2 ); |
1109 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1118 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1110 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1119 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1111 | label->setFocusPolicy(NoFocus); | 1120 | label->setFocusPolicy(NoFocus); |
1112 | label->setFont(bfont); | 1121 | label->setFont(bfont); |
1113 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1122 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1114 | label->setFlat(true); | 1123 | label->setFlat(true); |
1115 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1124 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1116 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1125 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1117 | //label->setLineWidth(1); | 1126 | //label->setLineWidth(1); |
1118 | //label->setAlignment(AlignCenter); | 1127 | //label->setAlignment(AlignCenter); |
1119 | mWeekLabels.insert( i, label ); | 1128 | mWeekLabels.insert( i, label ); |
1120 | } | 1129 | } |
1121 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1130 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1122 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1131 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1123 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1132 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1124 | 1133 | ||
1125 | for( i = 0; i < 1+1; i++ ) { | 1134 | for( i = 0; i < 1+1; i++ ) { |
1126 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1135 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1127 | label->setFocusPolicy(NoFocus); | 1136 | label->setFocusPolicy(NoFocus); |
1128 | label->setFont(bfont); | 1137 | label->setFont(bfont); |
1129 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1138 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1130 | label->setFlat(true); | 1139 | label->setFlat(true); |
1131 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1140 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1132 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1141 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1133 | //label->setLineWidth(1); | 1142 | //label->setLineWidth(1); |
1134 | //label->setAlignment(AlignCenter); | 1143 | //label->setAlignment(AlignCenter); |
1135 | mWeekLabelsW.insert( i, label ); | 1144 | mWeekLabelsW.insert( i, label ); |
1136 | } | 1145 | } |
1137 | mWeekLabelsW[1]->setText( i18n("W")); | 1146 | mWeekLabelsW[1]->setText( i18n("W")); |
1138 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1147 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1139 | 1148 | ||
1140 | 1149 | ||
1141 | int row, col; | 1150 | int row, col; |
1142 | mCells.resize( mNumCells ); | 1151 | mCells.resize( mNumCells ); |
1143 | for( row = 0; row < mNumWeeks; ++row ) { | 1152 | for( row = 0; row < mNumWeeks; ++row ) { |
1144 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1153 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1145 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1154 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1146 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1155 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1147 | 1156 | ||
1148 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1157 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1149 | SLOT( defaultAction( Incidence * ) ) ); | 1158 | SLOT( defaultAction( Incidence * ) ) ); |
1150 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1159 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1151 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1160 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1152 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1161 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1153 | SIGNAL( showDaySignal( QDate ) ) ); | 1162 | SIGNAL( showDaySignal( QDate ) ) ); |
1163 | connect( cell, SIGNAL( nextCell() ), | ||
1164 | SLOT( nextCell() ) ); | ||
1165 | connect( cell, SIGNAL( prevCell() ), | ||
1166 | SLOT( prevCell() ) ); | ||
1154 | } | 1167 | } |
1155 | } | 1168 | } |
1156 | mCellsW.resize( mDaysPerWeek ); | 1169 | mCellsW.resize( mDaysPerWeek ); |
1157 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1170 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1158 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1171 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1159 | mCellsW.insert( col, cell ); | 1172 | mCellsW.insert( col, cell ); |
1160 | 1173 | ||
1161 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1174 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1162 | SLOT( defaultAction( Incidence * ) ) ); | 1175 | SLOT( defaultAction( Incidence * ) ) ); |
1163 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1176 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1164 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1177 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1165 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1178 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1166 | SIGNAL( showDaySignal( QDate ) ) ); | 1179 | SIGNAL( showDaySignal( QDate ) ) ); |
1180 | connect( cell, SIGNAL( nextCell() ), | ||
1181 | SLOT( nextCell() ) ); | ||
1182 | connect( cell, SIGNAL( prevCell() ), | ||
1183 | SLOT( prevCell() ) ); | ||
1167 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1184 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1168 | } | 1185 | } |
1169 | 1186 | ||
1170 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1187 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1171 | mContextMenu = eventPopup(); | 1188 | mContextMenu = eventPopup(); |
1172 | // updateConfig(); //useless here... | 1189 | // updateConfig(); //useless here... |
1173 | // ... but we need mWidthLongDayLabel computed | 1190 | // ... but we need mWidthLongDayLabel computed |
1174 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1191 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1175 | mWidthLongDayLabel = 0; | 1192 | mWidthLongDayLabel = 0; |
1176 | for (int i = 0; i < 7; i++) { | 1193 | for (int i = 0; i < 7; i++) { |
1177 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1194 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1178 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1195 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1179 | } | 1196 | } |
1180 | 1197 | ||
1181 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1198 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1182 | 1199 | ||
1183 | #if 0 | 1200 | #if 0 |
1184 | if ( mShowWeekView ) | 1201 | if ( mShowWeekView ) |
1185 | mWidStack->raiseWidget( mWeekView ); | 1202 | mWidStack->raiseWidget( mWeekView ); |
1186 | else | 1203 | else |
1187 | mWidStack->raiseWidget( mMonthView ); | 1204 | mWidStack->raiseWidget( mMonthView ); |
1188 | #endif | 1205 | #endif |
1189 | 1206 | ||
1190 | emit incidenceSelected( 0 ); | 1207 | emit incidenceSelected( 0 ); |
1191 | 1208 | ||
1192 | mComputeLayoutTimer = new QTimer( this ); | 1209 | mComputeLayoutTimer = new QTimer( this ); |
1193 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1210 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1194 | 1211 | ||
1195 | 1212 | ||
1196 | #ifndef DESKTOP_VERSION | 1213 | #ifndef DESKTOP_VERSION |
1197 | resize( QApplication::desktop()->size() ); | 1214 | resize( QApplication::desktop()->size() ); |
1198 | #else | 1215 | #else |
1199 | resize(640, 480 ); | 1216 | resize(640, 480 ); |
1200 | updatePossible = true; | 1217 | updatePossible = true; |
1201 | #endif | 1218 | #endif |
1202 | computeLayout(); | 1219 | computeLayout(); |
1203 | 1220 | ||
1204 | if ( mShowWeekView ) | 1221 | if ( mShowWeekView ) |
1205 | mWidStack->raiseWidget( mWeekView ); | 1222 | mWidStack->raiseWidget( mWeekView ); |
1206 | else | 1223 | else |
1207 | mWidStack->raiseWidget( mMonthView ); | 1224 | mWidStack->raiseWidget( mMonthView ); |
1208 | } | 1225 | } |
1209 | 1226 | ||
1210 | KOMonthView::~KOMonthView() | 1227 | KOMonthView::~KOMonthView() |
1211 | { | 1228 | { |
1212 | delete mContextMenu; | 1229 | delete mContextMenu; |
1213 | } | 1230 | } |
1214 | 1231 | ||
@@ -1929,48 +1946,57 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) | |||
1929 | return; | 1946 | return; |
1930 | } | 1947 | } |
1931 | if (! e->isAutoRepeat() ) | 1948 | if (! e->isAutoRepeat() ) |
1932 | mFlagKeyPressed = true; | 1949 | mFlagKeyPressed = true; |
1933 | switch(e->key()) { | 1950 | switch(e->key()) { |
1934 | case Key_Up: | 1951 | case Key_Up: |
1935 | { | 1952 | { |
1936 | if ( mShowWeekView ) { | 1953 | if ( mShowWeekView ) { |
1937 | emit selectWeekNum ( currentWeek() - 1 ); | 1954 | emit selectWeekNum ( currentWeek() - 1 ); |
1938 | } | 1955 | } |
1939 | else { | 1956 | else { |
1940 | emit prevMonth(); | 1957 | emit prevMonth(); |
1941 | } | 1958 | } |
1942 | } | 1959 | } |
1943 | e->accept(); | 1960 | e->accept(); |
1944 | break; | 1961 | break; |
1945 | case Key_Down: | 1962 | case Key_Down: |
1946 | { | 1963 | { |
1947 | if ( mShowWeekView ) { | 1964 | if ( mShowWeekView ) { |
1948 | emit selectWeekNum ( currentWeek() +1); | 1965 | emit selectWeekNum ( currentWeek() +1); |
1949 | } | 1966 | } |
1950 | else { | 1967 | else { |
1951 | emit nextMonth(); | 1968 | emit nextMonth(); |
1952 | } | 1969 | } |
1953 | 1970 | ||
1954 | } | 1971 | } |
1955 | e->accept(); | 1972 | e->accept(); |
1956 | break; | 1973 | break; |
1957 | case Key_Return: | 1974 | case Key_Return: |
1958 | case Key_Enter: | 1975 | case Key_Enter: |
1959 | { | 1976 | { |
1960 | selectInternalWeekNum ( currentWeek() ); | 1977 | selectInternalWeekNum ( currentWeek() ); |
1961 | } | 1978 | } |
1962 | e->accept(); | 1979 | e->accept(); |
1963 | break; | 1980 | break; |
1964 | case Key_D: | 1981 | case Key_D: |
1965 | if ( mSelectedCell ) { | 1982 | if ( mSelectedCell ) { |
1966 | mSelectedCell->showDay(); | 1983 | mSelectedCell->showDay(); |
1967 | e->accept(); | 1984 | e->accept(); |
1968 | } else { | 1985 | } else { |
1969 | e->ignore(); | 1986 | e->ignore(); |
1970 | } | 1987 | } |
1971 | break; | 1988 | break; |
1972 | default: | 1989 | default: |
1973 | e->ignore(); | 1990 | e->ignore(); |
1974 | break; | 1991 | break; |
1975 | } | 1992 | } |
1976 | } | 1993 | } |
1994 | |||
1995 | void KOMonthView::nextCell() | ||
1996 | { | ||
1997 | bool res = focusNextPrevChild ( true ); | ||
1998 | } | ||
1999 | void KOMonthView::prevCell() | ||
2000 | { | ||
2001 | focusNextPrevChild ( false ); | ||
2002 | } | ||