summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/koagendaview.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b5596d9..05216a7 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -144,146 +144,148 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
144 fullTime = hour + suffix; 144 fullTime = hour + suffix;
145 145
146 // center and draw the time label 146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i"); 147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth; 148 int offset = this->width() - timeWidth;
149 int borderWidth = 5; 149 int borderWidth = 5;
150 int timeHeight = fm.height(); 150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153 153
154 // increment indices 154 // increment indices
155 y += mCellHeight; 155 y += mCellHeight;
156 cell++; 156 cell++;
157 } 157 }
158} 158}
159 159
160/** 160/**
161 Calculates the minimum width. 161 Calculates the minimum width.
162*/ 162*/
163int TimeLabels::minimumWidth() const 163int TimeLabels::minimumWidth() const
164{ 164{
165 QFontMetrics fm = fontMetrics(); 165 QFontMetrics fm = fontMetrics();
166 166
167 //TODO: calculate this value 167 //TODO: calculate this value
168 int borderWidth = 4; 168 int borderWidth = 4;
169 169
170 // the maximum width possible 170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth; 171 int width = fm.width("88:88x") + borderWidth;
172 172
173 return width; 173 return width;
174} 174}
175 175
176/** updates widget's internal state */ 176/** updates widget's internal state */
177void TimeLabels::updateConfig() 177void TimeLabels::updateConfig()
178{ 178{
179 // set the font 179 // set the font
180 // config->setGroup("Fonts"); 180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font"); 181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont); 182 setFont(KOPrefs::instance()->mTimeBarFont);
183 183
184 // update geometry restrictions based on new settings 184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204 204
205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
206{ 206{
207 mMouseDownY = e->pos().y(); 207 mMouseDownY = e->pos().y();
208 mOrgCap = topLevelWidget()->caption();
208} 209}
209 210
210void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 211void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
211{ 212{
212 int diff = mMouseDownY - e->pos().y(); 213 int diff = mMouseDownY - e->pos().y();
213 if ( diff < 10 && diff > -10 ) 214 if ( diff < 10 && diff > -10 )
214 return; 215 return;
215 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 216 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
216 if ( tSize < 4 ) 217 if ( tSize < 4 )
217 tSize = 4; 218 tSize = 4;
218 if ( tSize > 18 ) 219 if ( tSize > 18 )
219 tSize = 18; 220 tSize = 18;
220 tSize = (tSize-2)/2; 221 tSize = (tSize-2)/2;
221 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 222 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
222 223
223} 224}
224void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 225void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
225{ 226{
227 topLevelWidget()->setCaption( mOrgCap );
226 int diff = mMouseDownY - e->pos().y(); 228 int diff = mMouseDownY - e->pos().y();
227 if ( diff < 10 && diff > -10 ) 229 if ( diff < 10 && diff > -10 )
228 return; 230 return;
229 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 231 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
230 if ( tSize < 4 ) 232 if ( tSize < 4 )
231 tSize = 4; 233 tSize = 4;
232 if ( tSize > 18 ) 234 if ( tSize > 18 )
233 tSize = 18; 235 tSize = 18;
234 tSize = (tSize/2)*2; 236 tSize = (tSize/2)*2;
235 if ( tSize == KOPrefs::instance()->mHourSize ) 237 if ( tSize == KOPrefs::instance()->mHourSize )
236 return; 238 return;
237 KOPrefs::instance()->mHourSize = tSize; 239 KOPrefs::instance()->mHourSize = tSize;
238 emit scaleChanged(); 240 emit scaleChanged();
239} 241}
240 242
241/** This is called in response to repaint() */ 243/** This is called in response to repaint() */
242void TimeLabels::paintEvent(QPaintEvent*) 244void TimeLabels::paintEvent(QPaintEvent*)
243{ 245{
244 246
245 // kdDebug() << "paintevent..." << endl; 247 // kdDebug() << "paintevent..." << endl;
246 // this is another hack! 248 // this is another hack!
247 // QPainter painter(this); 249 // QPainter painter(this);
248 //QString c 250 //QString c
249 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
250} 252}
251 253
252//////////////////////////////////////////////////////////////////////////// 254////////////////////////////////////////////////////////////////////////////
253 255
254EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
255 : QFrame(parent,name) 257 : QFrame(parent,name)
256{ 258{
257 mColumns = 1; 259 mColumns = 1;
258 mTopBox = 0; 260 mTopBox = 0;
259 mLocation = loc; 261 mLocation = loc;
260 mTopLayout = 0; 262 mTopLayout = 0;
261 mPaintWidget = 0; 263 mPaintWidget = 0;
262 mXOffset = 0; 264 mXOffset = 0;
263 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
264 else mPixmap = SmallIcon("1downarrow"); 266 else mPixmap = SmallIcon("1downarrow");
265 mEnabled.resize(mColumns); 267 mEnabled.resize(mColumns);
266 if (mLocation == Top) 268 if (mLocation == Top)
267 setMaximumHeight(0); 269 setMaximumHeight(0);
268 else 270 else
269 setMinimumHeight(mPixmap.height()); 271 setMinimumHeight(mPixmap.height());
270} 272}
271 273
272EventIndicator::~EventIndicator() 274EventIndicator::~EventIndicator()
273{ 275{
274} 276}
275 277
276void EventIndicator::drawContents(QPainter *p) 278void EventIndicator::drawContents(QPainter *p)
277{ 279{
278 280
279 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
280 KDGanttSplitterHandle* han = 0; 282 KDGanttSplitterHandle* han = 0;
281 if ( mPaintWidget ) 283 if ( mPaintWidget )
282 han = mPaintWidget->firstHandle(); 284 han = mPaintWidget->firstHandle();
283 if ( ! han ) { 285 if ( ! han ) {
284 int i; 286 int i;
285 for(i=0;i<mColumns;++i) { 287 for(i=0;i<mColumns;++i) {
286 if (mEnabled[i]) { 288 if (mEnabled[i]) {
287 int cellWidth = contentsRect().right()/mColumns; 289 int cellWidth = contentsRect().right()/mColumns;
288 int xOffset = KOGlobals::self()->reverseLayout() ? 290 int xOffset = KOGlobals::self()->reverseLayout() ?
289 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 221b0ea..3cf938f 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -16,128 +16,129 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 30#include <qksplitter.h>
31#else 31#else
32#include <qsplitter.h> 32#include <qsplitter.h>
33#endif 33#endif
34#include <qmemarray.h> 34#include <qmemarray.h>
35 35
36#include "koeventview.h" 36#include "koeventview.h"
37 37
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48class TimeLabels : public QScrollView { 48class TimeLabels : public QScrollView {
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 52
53 void setCellHeight(int height); 53 void setCellHeight(int height);
54 54
55 /** Calculates the minimum width */ 55 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 56 virtual int minimumWidth() const;
57 57
58 /** updates widget's internal state */ 58 /** updates widget's internal state */
59 void updateConfig(); 59 void updateConfig();
60 60
61 /** */ 61 /** */
62 void setAgenda(KOAgenda* agenda); 62 void setAgenda(KOAgenda* agenda);
63 63
64 /** */ 64 /** */
65 virtual void paintEvent(QPaintEvent* e); 65 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ; 66 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * ); 67 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * ); 68 void contentsMouseMoveEvent ( QMouseEvent * );
69 69
70 public slots: 70 public slots:
71 /** update time label positions */ 71 /** update time label positions */
72 void positionChanged(); 72 void positionChanged();
73 signals: 73 signals:
74 void scaleChanged(); 74 void scaleChanged();
75 protected: 75 protected:
76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
77 77
78 private: 78 private:
79 int mMouseDownY; 79 int mMouseDownY;
80 QString mOrgCap;
80 int mRows; 81 int mRows;
81 int mCellHeight; 82 int mCellHeight;
82 83
83 /** */ 84 /** */
84 KOAgenda* mAgenda; 85 KOAgenda* mAgenda;
85}; 86};
86 87
87class EventIndicator : public QFrame { 88class EventIndicator : public QFrame {
88 Q_OBJECT 89 Q_OBJECT
89 public: 90 public:
90 enum Location { Top, Bottom }; 91 enum Location { Top, Bottom };
91 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
92 virtual ~EventIndicator(); 93 virtual ~EventIndicator();
93 94
94 void changeColumns(int columns); 95 void changeColumns(int columns);
95 void setPaintWidget( KDGanttMinimizeSplitter* ); 96 void setPaintWidget( KDGanttMinimizeSplitter* );
96 void setXOffset( int ); 97 void setXOffset( int );
97 void enableColumn(int column, bool enable); 98 void enableColumn(int column, bool enable);
98 99
99 protected: 100 protected:
100 void drawContents(QPainter *); 101 void drawContents(QPainter *);
101 102
102 private: 103 private:
103 int mXOffset; 104 int mXOffset;
104 KDGanttMinimizeSplitter* mPaintWidget; 105 KDGanttMinimizeSplitter* mPaintWidget;
105 int mColumns; 106 int mColumns;
106 QHBox *mTopBox; 107 QHBox *mTopBox;
107 QBoxLayout *mTopLayout; 108 QBoxLayout *mTopLayout;
108 Location mLocation; 109 Location mLocation;
109 QPixmap mPixmap; 110 QPixmap mPixmap;
110 QMemArray<bool> mEnabled; 111 QMemArray<bool> mEnabled;
111}; 112};
112 113
113/** 114/**
114 KOAgendaView is the agenda-like view used to display events in an one or 115 KOAgendaView is the agenda-like view used to display events in an one or
115 multi-day view. 116 multi-day view.
116*/ 117*/
117class KOAgendaView : public KOEventView { 118class KOAgendaView : public KOEventView {
118 Q_OBJECT 119 Q_OBJECT
119 public: 120 public:
120 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
121 virtual ~KOAgendaView(); 122 virtual ~KOAgendaView();
122 void setStartHour( int ); 123 void setStartHour( int );
123 void toggleAllDay(); 124 void toggleAllDay();
124 125
125 126
126 /** Returns maximum number of days supported by the koagendaview */ 127 /** Returns maximum number of days supported by the koagendaview */
127 virtual int maxDatesHint(); 128 virtual int maxDatesHint();
128 129
129 /** Returns number of currently shown dates. */ 130 /** Returns number of currently shown dates. */
130 virtual int currentDateCount(); 131 virtual int currentDateCount();
131 132
132 /** returns the currently selected events */ 133 /** returns the currently selected events */
133 virtual QPtrList<Incidence> selectedIncidences(); 134 virtual QPtrList<Incidence> selectedIncidences();
134 135
135 /** returns the currently selected events */ 136 /** returns the currently selected events */
136 virtual DateList selectedDates(); 137 virtual DateList selectedDates();
137 138
138 /** Remove all events from view */ 139 /** Remove all events from view */
139 void clearView(); 140 void clearView();
140 KOAgenda *agenda() { return mAgenda;} 141 KOAgenda *agenda() { return mAgenda;}
141 virtual void printPreview(CalPrinter *calPrinter, 142 virtual void printPreview(CalPrinter *calPrinter,
142 const QDate &, const QDate &); 143 const QDate &, const QDate &);
143 144