summaryrefslogtreecommitdiffabout
path: root/korganizer/timeline.cpp
Unidiff
Diffstat (limited to 'korganizer/timeline.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/timeline.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/timeline.cpp b/korganizer/timeline.cpp
index 6f9c8dd..11be432 100644
--- a/korganizer/timeline.cpp
+++ b/korganizer/timeline.cpp
@@ -1,54 +1,53 @@
1#include <qpainter.h> 1#include <qpainter.h>
2 2
3#include <kdebug.h> 3#include <kdebug.h>
4 4
5#include "timeline.h" 5#include "timeline.h"
6#include "timeline.moc"
7 6
8TimeLine::TimeLine( QWidget *parent, const char *name ) : 7TimeLine::TimeLine( QWidget *parent, const char *name ) :
9 QScrollView( parent, name ) 8 QScrollView( parent, name )
10{ 9{
11 mPixelWidth = 1000; 10 mPixelWidth = 1000;
12 11
13 resizeContents( mPixelWidth, 20 ); 12 resizeContents( mPixelWidth, 20 );
14 13
15 viewport()->setBackgroundMode( PaletteBackground ); 14 viewport()->setBackgroundMode( PaletteBackground );
16 15
17 setHScrollBarMode(AlwaysOff); 16 setHScrollBarMode(AlwaysOff);
18 setVScrollBarMode(AlwaysOff); 17 setVScrollBarMode(AlwaysOff);
19} 18}
20 19
21TimeLine::~TimeLine() 20TimeLine::~TimeLine()
22{ 21{
23} 22}
24 23
25void TimeLine::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 24void TimeLine::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
26{ 25{
27 int spacingX = mDaySpacing; 26 int spacingX = mDaySpacing;
28 int offsetX = mDayOffset; 27 int offsetX = mDayOffset;
29 28
30 // Draw vertical lines of grid 29 // Draw vertical lines of grid
31// kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl; 30// kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl;
32 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX ); 31 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX );
33 int x = cell * spacingX + ( spacingX - offsetX ); 32 int x = cell * spacingX + ( spacingX - offsetX );
34// kdDebug() << " x: " << x << endl; 33// kdDebug() << " x: " << x << endl;
35 while (x < cx + cw) { 34 while (x < cx + cw) {
36// kdDebug() << " x: " << x << endl; 35// kdDebug() << " x: " << x << endl;
37 p->drawLine(x,cy,x,cy+ch); 36 p->drawLine(x,cy,x,cy+ch);
38 p->drawText( x + 5, 15, QString::number( mStartDate.addDays( cell + 1 ).date().day() ) ); 37 p->drawText( x + 5, 15, QString::number( mStartDate.addDays( cell + 1 ).date().day() ) );
39 38
40 x += spacingX; 39 x += spacingX;
41 cell++; 40 cell++;
42 } 41 }
43} 42}
44 43
45void TimeLine::setDateRange( const QDateTime &start, const QDateTime &end ) 44void TimeLine::setDateRange( const QDateTime &start, const QDateTime &end )
46{ 45{
47 mStartDate = start; 46 mStartDate = start;
48 mEndDate = end; 47 mEndDate = end;
49 48
50 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth; 49 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth;
51 50
52 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel; 51 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel;
53 52
54 mDayOffset = QDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel; 53 mDayOffset = QDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel;