summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-04 13:27:55 (UTC)
committer zautrix <zautrix>2005-04-04 13:27:55 (UTC)
commit13fa1e5e1d5e4663bbbc79e0c68caf725ad2e31b (patch) (unidiff)
tree956518730f29846d70544142b6875636713a8b9b
parent919f1060a9ef41e6c865f28132cf9e82c3f67409 (diff)
downloadkdepimpi-13fa1e5e1d5e4663bbbc79e0c68caf725ad2e31b.zip
kdepimpi-13fa1e5e1d5e4663bbbc79e0c68caf725ad2e31b.tar.gz
kdepimpi-13fa1e5e1d5e4663bbbc79e0c68caf725ad2e31b.tar.bz2
monthview fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp27
-rw-r--r--korganizer/komonthview.h5
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
@@ -38,191 +38,214 @@
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
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
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
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
68protected: 68protected:
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 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::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}
87KNoScrollListBox::~KNoScrollListBox() 88KNoScrollListBox::~KNoScrollListBox()
88{ 89{
89 90
90} 91}
92
93
94void 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}
104void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
105{
106 int i = currentItem ();
107 if ( i >= 0 ) {
108 setSelected ( i, false );
109 }
110 QListBox::focusOutEvent ( e );
111}
112
91QString KNoScrollListBox::getWhatsThisText(QPoint p) 113QString 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}
102void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 124void 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:
107 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 129 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
108 { 130 {
109 e->ignore(); 131 e->ignore();
110 return; 132 return;
111 } 133 }
112 scrollBy(10,0); 134 scrollBy(10,0);
113 break; 135 break;
114 case Key_Left: 136 case Key_Left:
115 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 137 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
116 { 138 {
117 e->ignore(); 139 e->ignore();
118 return; 140 return;
119 } 141 }
120 scrollBy(-10,0); 142 scrollBy(-10,0);
121 break; 143 break;
122 case Key_Up: 144 case Key_Up:
123 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 145 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
124 e->ignore(); 146 e->ignore();
125 break; 147 break;
126 } 148 }
127 if ( count() ) { 149 if ( count() ) {
128 setCurrentItem((currentItem()+count()-1)%count()); 150 setCurrentItem((currentItem()+count()-1)%count());
129 if(!itemVisible(currentItem())) { 151 if(!itemVisible(currentItem())) {
130 if((unsigned int) currentItem() == (count()-1)) { 152 if((unsigned int) currentItem() == (count()-1)) {
131 setTopItem(currentItem()-numItemsVisible()+1); 153 setTopItem(currentItem()-numItemsVisible()+1);
132 } else { 154 } else {
133 setTopItem(topItem()-1); 155 setTopItem(topItem()-1);
134 } 156 }
135 } 157 }
136 } 158 }
137 break; 159 break;
138 case Key_Down: 160 case Key_Down:
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
178void KNoScrollListBox::oneDown() 200void 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}
191void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 214void 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;
197 default: 220 default:
198 break; 221 break;
199 } 222 }
200} 223}
201 224
202void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 225void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
203{ 226{
204 QListBox::mousePressEvent(e); 227 QListBox::mousePressEvent(e);
205 228
206 if(e->button() == RightButton) { 229 if(e->button() == RightButton) {
207 emit rightClick(); 230 emit rightClick();
208 } 231 }
209} 232}
210 233
211MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 234MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
212 : QListBoxItem() 235 : QListBoxItem()
213{ 236{
214 mblockRepaint = true; 237 mblockRepaint = true;
215 setText( s ); 238 setText( s );
216 mMultiday = 0; 239 mMultiday = 0;
217 mIncidence = incidence; 240 mIncidence = incidence;
218 mDate = qd; 241 mDate = qd;
219 mRecur = false; 242 mRecur = false;
220 mAlarm = false; 243 mAlarm = false;
221 mReply = false; 244 mReply = false;
222 mInfo = false; 245 mInfo = false;
223 //qDebug("NEWWWWWWWWWWWWW "); 246 //qDebug("NEWWWWWWWWWWWWW ");
224} 247}
225void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 248void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
226{ 249{
227 setText( s ); 250 setText( s );
228 mMultiday = 0; 251 mMultiday = 0;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 88050fe..e04cdf5 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -42,99 +42,102 @@
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class KOWeekButton : public QPushButton 47class KOWeekButton : public QPushButton
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 51 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
52 QPushButton( parent, name) 52 QPushButton( parent, name)
53 { 53 {
54 connect( this, SIGNAL( clicked() ), 54 connect( this, SIGNAL( clicked() ),
55 SLOT( bottonClicked() )); 55 SLOT( bottonClicked() ));
56 mNumber = -1; 56 mNumber = -1;
57 } 57 }
58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
59 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
60 signals: 60 signals:
61 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
62private: 62private:
63 int mNumber; 63 int mNumber;
64 void keyPressEvent ( QKeyEvent * e ) 64 void keyPressEvent ( QKeyEvent * e )
65 { 65 {
66 e->ignore(); 66 e->ignore();
67 } 67 }
68 68
69private slots : 69private slots :
70 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 70 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
71}; 71};
72 72
73class KNoScrollListBox: public QListBox 73class 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
97class MonthViewItem: public QListBoxItem 100class 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
109 112
110 void setPalette(const QPalette &p) { mPalette = p; } 113 void setPalette(const QPalette &p) { mPalette = p; }
111 QPalette palette() const { return mPalette; } 114 QPalette palette() const { return mPalette; }
112 115
113 Incidence *incidence() const { return mIncidence; } 116 Incidence *incidence() const { return mIncidence; }
114 QDate incidenceDate() { return mDate; } 117 QDate incidenceDate() { return mDate; }
115 118
116 protected: 119 protected:
117 virtual void paint(QPainter *); 120 virtual void paint(QPainter *);
118 virtual int height(const QListBox *) const; 121 virtual int height(const QListBox *) const;
119 virtual int width(const QListBox *) const; 122 virtual int width(const QListBox *) const;
120 123
121 private: 124 private:
122 bool mblockRepaint; 125 bool mblockRepaint;
123 int mMultiday; 126 int mMultiday;
124 bool mRecur; 127 bool mRecur;
125 bool mAlarm; 128 bool mAlarm;
126 bool mReply; 129 bool mReply;
127 bool mInfo; 130 bool mInfo;
128 131
129 QPalette mPalette; 132 QPalette mPalette;
130 QDate mDate; 133 QDate mDate;
131 134
132 Incidence *mIncidence; 135 Incidence *mIncidence;
133}; 136};
134 137
135 138
136class KOMonthView; 139class KOMonthView;
137 140
138class MonthViewCell : public KNoScrollListBox 141class MonthViewCell : public KNoScrollListBox
139{ 142{
140 Q_OBJECT 143 Q_OBJECT