25 #include <tqsplitter.h>
26 #include <tqlistview.h>
29 #include <tqpushbutton.h>
31 #include <tdelocale.h>
34 #include <libkcal/event.h>
39 #include "timespanwidget.h"
40 #include "timespanwidget.moc"
42 TimeSpanWidget::TimeSpanWidget( TQWidget *parent,
const char *name ) :
43 TQWidget( parent, name )
45 TQBoxLayout *topLayout =
new TQVBoxLayout(
this );
47 mSplitter =
new TQSplitter(
this );
48 topLayout->addWidget( mSplitter );
50 mList =
new TQListView( mSplitter );
51 mList->addColumn( i18n(
"Summary") );
53 TQWidget *rightPane =
new TQWidget( mSplitter );
54 TQBoxLayout *rightPaneLayout =
new TQVBoxLayout( rightPane );
56 mTimeLine =
new TimeLine( rightPane );
57 mTimeLine->setFixedHeight( mList->header()->height() );
58 rightPaneLayout->addWidget( mTimeLine );
60 mLineView =
new LineView( rightPane );
61 rightPaneLayout->addWidget( mLineView );
63 TQBoxLayout *buttonLayout =
new TQHBoxLayout( rightPaneLayout );
65 TQPushButton *zoomInButton =
new TQPushButton( i18n(
"Zoom In"), rightPane );
66 connect( zoomInButton, TQ_SIGNAL( clicked() ), TQ_SLOT( zoomIn() ) );
67 buttonLayout->addWidget( zoomInButton );
69 TQPushButton *zoomOutButton =
new TQPushButton( i18n(
"Zoom Out"), rightPane );
70 connect( zoomOutButton, TQ_SIGNAL( clicked() ), TQ_SLOT( zoomOut() ) );
71 buttonLayout->addWidget( zoomOutButton );
73 TQPushButton *centerButton =
new TQPushButton( i18n(
"Center View"), rightPane );
74 connect( centerButton, TQ_SIGNAL( clicked() ), TQ_SLOT( centerView() ) );
75 buttonLayout->addWidget( centerButton );
77 connect(mLineView->horizontalScrollBar(),TQ_SIGNAL(valueChanged(
int)),
78 mTimeLine,TQ_SLOT(setContentsPos(
int)));
81 TimeSpanWidget::~TimeSpanWidget()
85 TQValueList<int> TimeSpanWidget::splitterSizes()
87 return mSplitter->sizes();
90 void TimeSpanWidget::setSplitterSizes( TQValueList<int> sizes )
92 mSplitter->setSizes( sizes );
97 new TQListViewItem( mList, event->
summary() );
99 TQDateTime startDt =
event->dtStart();
100 TQDateTime endDt =
event->dtEnd();
110 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel;
111 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel;
115 mLineView->addLine( startX, endX );
118 void TimeSpanWidget::clear()
124 void TimeSpanWidget::updateView()
126 mLineView->updateContents();
127 mTimeLine->updateContents();
130 void TimeSpanWidget::setDateRange(
const TQDateTime &start,
const TQDateTime &end )
135 mTimeLine->setDateRange( start, end );
137 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth();
140 TQDateTime TimeSpanWidget::startDateTime()
145 TQDateTime TimeSpanWidget::endDateTime()
150 void TimeSpanWidget::zoomIn()
152 int span = mStartDate.daysTo( mEndDate );
153 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) );
155 emit dateRangeChanged();
158 void TimeSpanWidget::zoomOut()
160 int span = mStartDate.daysTo( mEndDate );
161 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) );
163 emit dateRangeChanged();
166 void TimeSpanWidget::centerView()
168 TQScrollBar *scrollBar = mLineView->horizontalScrollBar();
169 int min = scrollBar->minValue();
170 int max = scrollBar->maxValue();
171 scrollBar->setValue( min + (max-min) / 2 );