author | zautrix <zautrix> | 2005-04-05 19:42:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 19:42:46 (UTC) |
commit | 6add774cf9841377f32613c7aa23161a823aa1da (patch) (unidiff) | |
tree | 43631d25bdfff4eb9d9934bc604609c38717b000 | |
parent | 8734ae4789ed411cb546edd304816a77c431a2bf (diff) | |
download | kdepimpi-6add774cf9841377f32613c7aa23161a823aa1da.zip kdepimpi-6add774cf9841377f32613c7aa23161a823aa1da.tar.gz kdepimpi-6add774cf9841377f32613c7aa23161a823aa1da.tar.bz2 |
fix
-rw-r--r-- | korganizer/komonthview.cpp | 146 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 90 insertions, 61 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index e66ddce..4dfb9df 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -95,36 +95,40 @@ KNoScrollListBox::~KNoScrollListBox() | |||
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 (); |
@@ -171,15 +175,19 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
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; |
@@ -187,15 +195,19 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
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; |
@@ -224,16 +236,20 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
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 | } |
@@ -472,12 +488,13 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | |||
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 | { |
@@ -988,8 +1005,9 @@ void MonthViewCell::resizeEvent ( QResizeEvent * 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; |
@@ -1009,24 +1027,15 @@ void MonthViewCell::newEvent() | |||
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 | { |
@@ -1150,8 +1159,12 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
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 ) { |
@@ -1163,8 +1176,12 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
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() ) ); |
@@ -1973,4 +1990,13 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) | |||
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 | } | ||
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e39eeb0..c6b6b5e 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -82,8 +82,10 @@ class KNoScrollListBox: public QListBox | |||
82 | signals: | 82 | signals: |
83 | void shiftDown(); | 83 | void shiftDown(); |
84 | void shiftUp(); | 84 | void shiftUp(); |
85 | void rightClick(); | 85 | void rightClick(); |
86 | void nextCell(); | ||
87 | void prevCell(); | ||
86 | 88 | ||
87 | protected slots: | 89 | protected slots: |
88 | void oneDown(); | 90 | void oneDown(); |
89 | void keyPressEvent(QKeyEvent *); | 91 | void keyPressEvent(QKeyEvent *); |
@@ -187,9 +189,8 @@ class MonthViewCell : public KNoScrollListBox | |||
187 | protected: | 189 | protected: |
188 | QStringList mToolTip; | 190 | QStringList mToolTip; |
189 | void resizeEvent( QResizeEvent * ); | 191 | void resizeEvent( QResizeEvent * ); |
190 | 192 | ||
191 | |||
192 | public slots: | 193 | public slots: |
193 | void showDay(); | 194 | void showDay(); |
194 | 195 | ||
195 | protected slots: | 196 | protected slots: |
@@ -255,8 +256,10 @@ class KOMonthView: public KOEventView | |||
255 | MonthViewCell * selectedCell(); | 256 | MonthViewCell * selectedCell(); |
256 | bool skipResize; | 257 | bool skipResize; |
257 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 258 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
258 | public slots: | 259 | public slots: |
260 | void nextCell(); | ||
261 | void prevCell(); | ||
259 | virtual void updateView(); | 262 | virtual void updateView(); |
260 | virtual void updateConfig(); | 263 | virtual void updateConfig(); |
261 | virtual void showDates(const QDate &start, const QDate &end); | 264 | virtual void showDates(const QDate &start, const QDate &end); |
262 | virtual void showEvents(QPtrList<Event> eventList); | 265 | virtual void showEvents(QPtrList<Event> eventList); |