-rw-r--r-- | korganizer/komonthview.cpp | 27 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 29 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ab9a4b6..9f7db69 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -70,37 +70,59 @@ protected: | |||
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 | } | 87 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 88 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 89 | { |
89 | 90 | ||
90 | } | 91 | } |
92 | |||
93 | |||
94 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | ||
95 | { | ||
96 | QListBox::focusInEvent ( e ); | ||
97 | QListBoxItem * i = item ( 0 ); | ||
98 | if ( i && resetOnFocusIn ) { | ||
99 | setCurrentItem( i ); | ||
100 | setSelected ( 0, true ); | ||
101 | } | ||
102 | resetOnFocusIn = true; | ||
103 | } | ||
104 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | ||
105 | { | ||
106 | int i = currentItem (); | ||
107 | if ( i >= 0 ) { | ||
108 | setSelected ( i, false ); | ||
109 | } | ||
110 | QListBox::focusOutEvent ( e ); | ||
111 | } | ||
112 | |||
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 113 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 114 | { |
93 | QListBoxItem* item = itemAt ( p ); | 115 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 116 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 117 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 118 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 119 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | 120 | KOPrefs::instance()->mWTshowDetails, |
99 | KOPrefs::instance()->mWTshowCreated, | 121 | KOPrefs::instance()->mWTshowCreated, |
100 | KOPrefs::instance()->mWTshowChanged); | 122 | KOPrefs::instance()->mWTshowChanged); |
101 | } | 123 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 124 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
103 | { | 125 | { |
104 | //qDebug("KNoScrollListBox::keyPressEvent "); | 126 | //qDebug("KNoScrollListBox::keyPressEvent "); |
105 | switch(e->key()) { | 127 | switch(e->key()) { |
106 | case Key_Right: | 128 | case Key_Right: |
@@ -139,58 +161,59 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
139 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 161 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
140 | e->ignore(); | 162 | e->ignore(); |
141 | break; | 163 | break; |
142 | } | 164 | } |
143 | if ( count () ) { | 165 | if ( count () ) { |
144 | setCurrentItem((currentItem()+1)%count()); | 166 | setCurrentItem((currentItem()+1)%count()); |
145 | if(!itemVisible(currentItem())) { | 167 | if(!itemVisible(currentItem())) { |
146 | if(currentItem() == 0) { | 168 | if(currentItem() == 0) { |
147 | setTopItem(0); | 169 | setTopItem(0); |
148 | } else { | 170 | } else { |
149 | setTopItem(topItem()+1); | 171 | setTopItem(topItem()+1); |
150 | } | 172 | } |
151 | } | 173 | } |
152 | } | 174 | } |
153 | break; | 175 | break; |
154 | case Key_I: | 176 | case Key_I: |
155 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 177 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
156 | e->ignore(); | 178 | e->ignore(); |
157 | break; | 179 | break; |
158 | case Key_Return: | 180 | case Key_Return: |
159 | case Key_Enter: | 181 | case Key_Enter: |
160 | { | 182 | { |
161 | if ( currentItem() >= 0 ) { | 183 | if ( currentItem() >= 0 ) { |
162 | emit doubleClicked( item( currentItem() ) ); | 184 | emit doubleClicked( item( currentItem() ) ); |
163 | e->accept(); | 185 | e->accept(); |
164 | } else { | 186 | } else { |
165 | e->ignore(); | 187 | e->ignore(); |
166 | } | 188 | } |
167 | } | 189 | } |
168 | break; | 190 | break; |
169 | case Key_Shift: | 191 | case Key_Shift: |
170 | emit shiftDown(); | 192 | emit shiftDown(); |
171 | break; | 193 | break; |
172 | default: | 194 | default: |
173 | e->ignore(); | 195 | e->ignore(); |
174 | break; | 196 | break; |
175 | } | 197 | } |
176 | } | 198 | } |
177 | 199 | ||
178 | void KNoScrollListBox::oneDown() | 200 | void KNoScrollListBox::oneDown() |
179 | { | 201 | { |
180 | if ( count () ) { | 202 | if ( count () ) { |
203 | resetOnFocusIn = false; | ||
181 | setCurrentItem((currentItem()+1)%count()); | 204 | setCurrentItem((currentItem()+1)%count()); |
182 | if(!itemVisible(currentItem())) { | 205 | if(!itemVisible(currentItem())) { |
183 | if(currentItem() == 0) { | 206 | if(currentItem() == 0) { |
184 | setTopItem(0); | 207 | setTopItem(0); |
185 | } else { | 208 | } else { |
186 | setTopItem(topItem()+1); | 209 | setTopItem(topItem()+1); |
187 | } | 210 | } |
188 | } | 211 | } |
189 | } | 212 | } |
190 | } | 213 | } |
191 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 214 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
192 | { | 215 | { |
193 | switch(e->key()) { | 216 | switch(e->key()) { |
194 | case Key_Shift: | 217 | case Key_Shift: |
195 | emit shiftUp(); | 218 | emit shiftUp(); |
196 | break; | 219 | break; |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 88050fe..e04cdf5 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -74,35 +74,38 @@ class KNoScrollListBox: public QListBox | |||
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 77 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
78 | ~KNoScrollListBox(); | 78 | ~KNoScrollListBox(); |
79 | QString getWhatsThisText(QPoint p) ; | 79 | QString getWhatsThisText(QPoint p) ; |
80 | 80 | ||
81 | signals: | 81 | signals: |
82 | void shiftDown(); | 82 | void shiftDown(); |
83 | void shiftUp(); | 83 | void shiftUp(); |
84 | void rightClick(); | 84 | void rightClick(); |
85 | 85 | ||
86 | protected slots: | 86 | protected slots: |
87 | void oneDown(); | 87 | void oneDown(); |
88 | void keyPressEvent(QKeyEvent *); | 88 | void keyPressEvent(QKeyEvent *); |
89 | void keyReleaseEvent(QKeyEvent *); | 89 | void keyReleaseEvent(QKeyEvent *); |
90 | void mousePressEvent(QMouseEvent *); | 90 | void mousePressEvent(QMouseEvent *); |
91 | void focusInEvent ( QFocusEvent * ); | ||
92 | void focusOutEvent ( QFocusEvent * ); | ||
91 | 93 | ||
92 | private: | 94 | private: |
95 | bool resetOnFocusIn; | ||
93 | KNOWhatsThis * mWT; | 96 | KNOWhatsThis * mWT; |
94 | }; | 97 | }; |
95 | 98 | ||
96 | 99 | ||
97 | class MonthViewItem: public QListBoxItem | 100 | class MonthViewItem: public QListBoxItem |
98 | { | 101 | { |
99 | public: | 102 | public: |
100 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 103 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
101 | void recycle( Incidence *incidence, QDate qd, const QString & s); | 104 | void recycle( Incidence *incidence, QDate qd, const QString & s); |
102 | void setRecur(bool on) { mRecur = on; } | 105 | void setRecur(bool on) { mRecur = on; } |
103 | void setAlarm(bool on) { mAlarm = on; } | 106 | void setAlarm(bool on) { mAlarm = on; } |
104 | void setReply(bool on) { mReply = on; } | 107 | void setReply(bool on) { mReply = on; } |
105 | void setMoreInfo(bool on) { mInfo = on; } | 108 | void setMoreInfo(bool on) { mInfo = on; } |
106 | void setMultiDay(int type) { mMultiday = type; } | 109 | void setMultiDay(int type) { mMultiday = type; } |
107 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 110 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
108 | 111 | ||