-rw-r--r-- | korganizer/timespanview.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp index df8ff88..0908056 100644 --- a/korganizer/timespanview.cpp +++ b/korganizer/timespanview.cpp | |||
@@ -1,157 +1,161 @@ | |||
1 | 1 | ||
2 | #ifndef DESKTOP_VERSION | 2 | #ifndef DESKTOP_VERSION |
3 | #include <qksplitter.h> | 3 | #include <qksplitter.h> |
4 | #else | 4 | #else |
5 | #include <qsplitter.h> | 5 | #include <qsplitter.h> |
6 | #endif | 6 | #endif |
7 | #include <qlistview.h> | 7 | #include <q3listview.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qheader.h> | 9 | #include <q3header.h> |
10 | #include <qpushbutton.h> | 10 | #include <qpushbutton.h> |
11 | //Added by qt3to4: | ||
12 | #include <Q3HBoxLayout> | ||
13 | #include <Q3VBoxLayout> | ||
14 | #include <Q3ValueList> | ||
11 | 15 | ||
12 | #include <klocale.h> | 16 | #include <klocale.h> |
13 | #include <kdebug.h> | 17 | #include <kdebug.h> |
14 | 18 | ||
15 | #include "lineview.h" | 19 | #include "lineview.h" |
16 | #include "timeline.h" | 20 | #include "timeline.h" |
17 | 21 | ||
18 | #include "timespanview.h" | 22 | #include "timespanview.h" |
19 | 23 | ||
20 | 24 | ||
21 | TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : | 25 | TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : |
22 | QWidget( parent, name ) | 26 | QWidget( parent, name ) |
23 | { | 27 | { |
24 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 28 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
25 | #ifndef DESKTOP_VERSION | 29 | #ifndef DESKTOP_VERSION |
26 | mSplitter = new QKSplitter( this ); | 30 | mSplitter = new QKSplitter( this ); |
27 | #else | 31 | #else |
28 | mSplitter = new QSplitter( this ); | 32 | mSplitter = new QSplitter( this ); |
29 | #endif | 33 | #endif |
30 | topLayout->addWidget( mSplitter ); | 34 | topLayout->addWidget( mSplitter ); |
31 | 35 | ||
32 | mList = new QListView( mSplitter ); | 36 | mList = new Q3ListView( mSplitter ); |
33 | mList->addColumn( i18n("Summary") ); | 37 | mList->addColumn( i18n("Summary") ); |
34 | 38 | ||
35 | QWidget *rightPane = new QWidget( mSplitter ); | 39 | QWidget *rightPane = new QWidget( mSplitter ); |
36 | QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane ); | 40 | Q3BoxLayout *rightPaneLayout = new Q3VBoxLayout( rightPane ); |
37 | 41 | ||
38 | mTimeLine = new TimeLine( rightPane ); | 42 | mTimeLine = new TimeLine( rightPane ); |
39 | mTimeLine->setFixedHeight( mList->header()->height() ); | 43 | mTimeLine->setFixedHeight( mList->header()->height() ); |
40 | rightPaneLayout->addWidget( mTimeLine ); | 44 | rightPaneLayout->addWidget( mTimeLine ); |
41 | 45 | ||
42 | mLineView = new LineView( rightPane ); | 46 | mLineView = new LineView( rightPane ); |
43 | rightPaneLayout->addWidget( mLineView ); | 47 | rightPaneLayout->addWidget( mLineView ); |
44 | 48 | ||
45 | QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout ); | 49 | Q3BoxLayout *buttonLayout = new Q3HBoxLayout( rightPaneLayout ); |
46 | 50 | ||
47 | QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); | 51 | QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); |
48 | connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); | 52 | connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); |
49 | buttonLayout->addWidget( zoomInButton ); | 53 | buttonLayout->addWidget( zoomInButton ); |
50 | 54 | ||
51 | QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); | 55 | QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); |
52 | connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); | 56 | connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); |
53 | buttonLayout->addWidget( zoomOutButton ); | 57 | buttonLayout->addWidget( zoomOutButton ); |
54 | 58 | ||
55 | QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); | 59 | QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); |
56 | connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); | 60 | connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); |
57 | buttonLayout->addWidget( centerButton ); | 61 | buttonLayout->addWidget( centerButton ); |
58 | 62 | ||
59 | connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), | 63 | connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), |
60 | mTimeLine,SLOT(setContentsPos(int))); | 64 | mTimeLine,SLOT(setContentsPos(int))); |
61 | } | 65 | } |
62 | 66 | ||
63 | TimeSpanView::~TimeSpanView() | 67 | TimeSpanView::~TimeSpanView() |
64 | { | 68 | { |
65 | } | 69 | } |
66 | 70 | ||
67 | QValueList<int> TimeSpanView::splitterSizes() | 71 | Q3ValueList<int> TimeSpanView::splitterSizes() |
68 | { | 72 | { |
69 | return mSplitter->sizes(); | 73 | return mSplitter->sizes(); |
70 | } | 74 | } |
71 | 75 | ||
72 | void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) | 76 | void TimeSpanView::setSplitterSizes( Q3ValueList<int> sizes ) |
73 | { | 77 | { |
74 | mSplitter->setSizes( sizes ); | 78 | mSplitter->setSizes( sizes ); |
75 | } | 79 | } |
76 | 80 | ||
77 | void TimeSpanView::addItem( KCal::Event *event ) | 81 | void TimeSpanView::addItem( KCal::Event *event ) |
78 | { | 82 | { |
79 | new QListViewItem( mList, event->summary() ); | 83 | new Q3ListViewItem( mList, event->summary() ); |
80 | 84 | ||
81 | QDateTime startDt = event->dtStart(); | 85 | QDateTime startDt = event->dtStart(); |
82 | QDateTime endDt = event->dtEnd(); | 86 | QDateTime endDt = event->dtEnd(); |
83 | 87 | ||
84 | // kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() | 88 | // kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() |
85 | // << " end: " << endDt.toString() << endl; | 89 | // << " end: " << endDt.toString() << endl; |
86 | 90 | ||
87 | int startSecs = mStartDate.secsTo( startDt ); | 91 | int startSecs = mStartDate.secsTo( startDt ); |
88 | int durationSecs = startDt.secsTo( endDt ); | 92 | int durationSecs = startDt.secsTo( endDt ); |
89 | 93 | ||
90 | // kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; | 94 | // kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; |
91 | 95 | ||
92 | int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; | 96 | int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; |
93 | int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; | 97 | int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; |
94 | 98 | ||
95 | // kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; | 99 | // kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; |
96 | 100 | ||
97 | mLineView->addLine( startX, endX ); | 101 | mLineView->addLine( startX, endX ); |
98 | } | 102 | } |
99 | 103 | ||
100 | void TimeSpanView::clear() | 104 | void TimeSpanView::clear() |
101 | { | 105 | { |
102 | mList->clear(); | 106 | mList->clear(); |
103 | mLineView->clear(); | 107 | mLineView->clear(); |
104 | } | 108 | } |
105 | 109 | ||
106 | void TimeSpanView::updateView() | 110 | void TimeSpanView::updateView() |
107 | { | 111 | { |
108 | #if QT_VERSION >= 0x030000 | 112 | #if QT_VERSION >= 0x030000 |
109 | mLineView->updateContents(); | 113 | mLineView->updateContents(); |
110 | mTimeLine->updateContents(); | 114 | mTimeLine->updateContents(); |
111 | #else | 115 | #else |
112 | #endif | 116 | #endif |
113 | } | 117 | } |
114 | 118 | ||
115 | void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) | 119 | void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) |
116 | { | 120 | { |
117 | mStartDate = start; | 121 | mStartDate = start; |
118 | mEndDate = end; | 122 | mEndDate = end; |
119 | 123 | ||
120 | mTimeLine->setDateRange( start, end ); | 124 | mTimeLine->setDateRange( start, end ); |
121 | 125 | ||
122 | mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); | 126 | mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); |
123 | } | 127 | } |
124 | 128 | ||
125 | QDateTime TimeSpanView::startDateTime() | 129 | QDateTime TimeSpanView::startDateTime() |
126 | { | 130 | { |
127 | return mStartDate; | 131 | return mStartDate; |
128 | } | 132 | } |
129 | 133 | ||
130 | QDateTime TimeSpanView::endDateTime() | 134 | QDateTime TimeSpanView::endDateTime() |
131 | { | 135 | { |
132 | return mEndDate; | 136 | return mEndDate; |
133 | } | 137 | } |
134 | 138 | ||
135 | void TimeSpanView::zoomIn() | 139 | void TimeSpanView::zoomIn() |
136 | { | 140 | { |
137 | int span = mStartDate.daysTo( mEndDate ); | 141 | int span = mStartDate.daysTo( mEndDate ); |
138 | setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); | 142 | setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); |
139 | 143 | ||
140 | emit dateRangeChanged(); | 144 | emit dateRangeChanged(); |
141 | } | 145 | } |
142 | 146 | ||
143 | void TimeSpanView::zoomOut() | 147 | void TimeSpanView::zoomOut() |
144 | { | 148 | { |
145 | int span = mStartDate.daysTo( mEndDate ); | 149 | int span = mStartDate.daysTo( mEndDate ); |
146 | setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); | 150 | setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); |
147 | 151 | ||
148 | emit dateRangeChanged(); | 152 | emit dateRangeChanged(); |
149 | } | 153 | } |
150 | 154 | ||
151 | void TimeSpanView::centerView() | 155 | void TimeSpanView::centerView() |
152 | { | 156 | { |
153 | QScrollBar *scrollBar = mLineView->horizontalScrollBar(); | 157 | QScrollBar *scrollBar = mLineView->horizontalScrollBar(); |
154 | int min = scrollBar->minValue(); | 158 | int min = scrollBar->minValue(); |
155 | int max = scrollBar->maxValue(); | 159 | int max = scrollBar->maxValue(); |
156 | scrollBar->setValue( min + (max-min) / 2 ); | 160 | scrollBar->setValue( min + (max-min) / 2 ); |
157 | } | 161 | } |