25 #include <tqpainter.h> 30 #include "timeline.moc" 32 TimeLine::TimeLine( TQWidget *parent, const char *name ) : 33 TQScrollView( parent, name ) 37 resizeContents( mPixelWidth, 20 ); 39 viewport()->setBackgroundMode( PaletteBackground ); 41 setHScrollBarMode(AlwaysOff); 42 setVScrollBarMode(AlwaysOff); 49 void TimeLine::drawContents(TQPainter* p, int cx, int cy, int cw, int ch) 51 int spacingX = mDaySpacing; 52 int offsetX = mDayOffset; 56 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX ); 57 int x = cell * spacingX + ( spacingX - offsetX ); 61 p->drawLine(x,cy,x,cy+ch); 62 p->drawText( x + 5, 15, TQString::number( mStartDate.addDays( cell + 1 ).date().day() ) ); 69 void TimeLine::setDateRange( const TQDateTime &start, const TQDateTime &end ) 74 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth; 76 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel; 78 mDayOffset = TQDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel; 80 kdDebug(5850) << "TimeLines::setDateRange(): mDaySpacing: " << mDaySpacing << " mDayOffset: " 81 << mDayOffset << " mSecsPerPixel: " << mSecsPerPixel << endl; 84 void TimeLine::setContentsPos( int pos ) 86 TQScrollView::setContentsPos ( pos, 0 );
|