author | waspe <waspe> | 2003-11-04 16:37:14 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-04 16:37:14 (UTC) |
commit | efcd8d6a743261194b55df3afeec956fde9886d4 (patch) (unidiff) | |
tree | 7bf7232a92c40c8236813fc06aac18b4f8d16d1d | |
parent | d2c52ff34d0ef37d055f74bb9fd957c6ffc583a9 (diff) | |
download | opie-efcd8d6a743261194b55df3afeec956fde9886d4.zip opie-efcd8d6a743261194b55df3afeec956fde9886d4.tar.gz opie-efcd8d6a743261194b55df3afeec956fde9886d4.tar.bz2 |
remove merge conflict
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index f4008e9..4d64099 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -1,933 +1,933 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | ||
21 | 20 | ||
22 | #include "datebookday.h" | 21 | #include "datebookday.h" |
23 | #include "datebookdayheaderimpl.h" | 22 | #include "datebookdayheaderimpl.h" |
24 | #include "datebookdayallday.h" | 23 | #include "datebookdayallday.h" |
25 | 24 | ||
26 | #include <qpe/datebookdb.h> | ||
27 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
28 | #include <qpe/event.h> | ||
29 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/timestring.h> | ||
31 | #include <qpe/qpedebug.h> | ||
32 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
33 | 28 | ||
34 | #include <qheader.h> | ||
35 | #include <qdatetime.h> | ||
36 | #include <qpainter.h> | ||
37 | #include <qsimplerichtext.h> | 29 | #include <qsimplerichtext.h> |
38 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
39 | #include <qtextcodec.h> | ||
40 | #include <qpalette.h> | ||
41 | 31 | ||
42 | #include <qlineedit.h> | ||
43 | 32 | ||
44 | #include <qtimer.h> | 33 | #include <qtimer.h> |
45 | 34 | ||
46 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) | 35 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
47 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) | 36 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
48 | { | 37 | { |
49 | enableClipper(TRUE); | 38 | enableClipper(TRUE); |
50 | setTopMargin( 0 ); | 39 | setTopMargin( 0 ); |
51 | horizontalHeader()->hide(); | 40 | horizontalHeader()->hide(); |
52 | setLeftMargin(38); | 41 | setLeftMargin(38); |
53 | setColumnStretchable( 0, TRUE ); | 42 | setColumnStretchable( 0, TRUE ); |
54 | setHScrollBarMode( QScrollView::AlwaysOff ); | 43 | setHScrollBarMode( QScrollView::AlwaysOff ); |
55 | verticalHeader()->setPalette(white); | 44 | verticalHeader()->setPalette(white); |
56 | verticalHeader()->setResizeEnabled(FALSE); | 45 | verticalHeader()->setResizeEnabled(FALSE); |
57 | setSelectionMode( Single ); | 46 | setSelectionMode( Single ); |
58 | 47 | ||
59 | // get rid of being able to edit things... | 48 | // get rid of being able to edit things... |
60 | QTableItem *tmp; | 49 | QTableItem *tmp; |
61 | int row; | 50 | int row; |
62 | for ( row = 0; row < numRows(); row++ ) { | 51 | for ( row = 0; row < numRows(); row++ ) { |
63 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 52 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
64 | setItem( row, 0, tmp ); | 53 | setItem( row, 0, tmp ); |
65 | //setRowHeight( row, 40); | 54 | //setRowHeight( row, 40); |
66 | } | 55 | } |
67 | 56 | ||
68 | initHeader(); | 57 | initHeader(); |
69 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); | 58 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
70 | } | 59 | } |
71 | 60 | ||
72 | void DateBookDayView::initHeader() | 61 | void DateBookDayView::initHeader() |
73 | { | 62 | { |
74 | QString strTmp; | 63 | QString strTmp; |
64 | int preferredWidth = 0; | ||
75 | for ( int i = 0; i < 24; ++i ) { | 65 | for ( int i = 0; i < 24; ++i ) { |
76 | if ( ampm ) { | 66 | if ( ampm ) { |
77 | if ( i == 0 ) | 67 | if ( i == 0 ) |
78 | strTmp = QString::number(12) + ":00"; | 68 | strTmp = QString::number(12) + ":00"; |
79 | else if ( i == 12 ) | 69 | else if ( i == 12 ) |
80 | strTmp = QString::number(12) + tr(":00p"); | 70 | strTmp = QString::number(12) + tr(":00p"); |
81 | else if ( i > 12 ) | 71 | else if ( i > 12 ) |
82 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 72 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
83 | else | 73 | else |
84 | strTmp = QString::number(i) + ":00"; | 74 | strTmp = QString::number(i) + ":00"; |
85 | } else { | 75 | } else { |
86 | if ( i < 10 ) | 76 | if ( i < 10 ) |
87 | strTmp = "0" + QString::number(i) + ":00"; | 77 | strTmp = "0" + QString::number(i) + ":00"; |
88 | else | 78 | else |
89 | strTmp = QString::number(i) + ":00"; | 79 | strTmp = QString::number(i) + ":00"; |
90 | } | 80 | } |
91 | strTmp = strTmp.rightJustify( 6, ' ' ); | 81 | strTmp = strTmp.rightJustify( 6, ' ' ); |
92 | verticalHeader()->setLabel( i, strTmp ); | 82 | verticalHeader()->setLabel( i, strTmp ); |
83 | |||
84 | // Compute correct width for current Font (Add some space right) | ||
85 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); | ||
86 | if ( preferredWidth < actWidth ) | ||
87 | preferredWidth = actWidth; | ||
93 | setRowStretchable( i, FALSE ); | 88 | setRowStretchable( i, FALSE ); |
94 | } | 89 | } |
90 | |||
91 | // It seems as if the header has a bug. It does not resize | ||
92 | // correct horizontally if it is used vertical.. | ||
93 | // Thus, we do it manually.. | ||
94 | setLeftMargin( preferredWidth ); | ||
95 | } | 95 | } |
96 | 96 | ||
97 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | 97 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
98 | { | 98 | { |
99 | currDate.setYMD(y,m,d); | 99 | currDate.setYMD(y,m,d); |
100 | } | 100 | } |
101 | 101 | ||
102 | void DateBookDayView::slotChangeClock( bool newClock ) | 102 | void DateBookDayView::slotChangeClock( bool newClock ) |
103 | { | 103 | { |
104 | ampm = newClock; | 104 | ampm = newClock; |
105 | initHeader(); | 105 | initHeader(); |
106 | } | 106 | } |
107 | 107 | ||
108 | bool DateBookDayView::whichClock() const | 108 | bool DateBookDayView::whichClock() const |
109 | { | 109 | { |
110 | return ampm; | 110 | return ampm; |
111 | } | 111 | } |
112 | 112 | ||
113 | void DateBookDayView::moveUp() | 113 | void DateBookDayView::moveUp() |
114 | { | 114 | { |
115 | scrollBy(0, -20); | 115 | scrollBy(0, -20); |
116 | } | 116 | } |
117 | 117 | ||
118 | void DateBookDayView::moveDown() | 118 | void DateBookDayView::moveDown() |
119 | { | 119 | { |
120 | scrollBy(0, 20); | 120 | scrollBy(0, 20); |
121 | } | 121 | } |
122 | 122 | ||
123 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 123 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
124 | { | 124 | { |
125 | int w = cr.width(); | 125 | int w = cr.width(); |
126 | int h = cr.height(); | 126 | int h = cr.height(); |
127 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 127 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
128 | if ( showGrid() ) { | 128 | if ( showGrid() ) { |
129 | // Draw our lines | 129 | // Draw our lines |
130 | int x2 = w - 1; | 130 | int x2 = w - 1; |
131 | int y2 = h - 1; | 131 | int y2 = h - 1; |
132 | QPen pen( p->pen() ); | 132 | QPen pen( p->pen() ); |
133 | p->setPen( colorGroup().dark() ); | 133 | p->setPen( colorGroup().dark() ); |
134 | p->drawLine( x2, 0, x2, y2 ); | 134 | p->drawLine( x2, 0, x2, y2 ); |
135 | p->drawLine( 0, y2, x2, y2 ); | 135 | p->drawLine( 0, y2, x2, y2 ); |
136 | 136 | ||
137 | p->setPen( colorGroup().midlight() ); | 137 | p->setPen( colorGroup().midlight() ); |
138 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 138 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
139 | 139 | ||
140 | p->setPen( pen ); | 140 | p->setPen( pen ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 144 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
145 | { | 145 | { |
146 | } | 146 | } |
147 | 147 | ||
148 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 148 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
149 | { | 149 | { |
150 | QTable::resizeEvent( e ); | 150 | QTable::resizeEvent( e ); |
151 | columnWidthChanged( 0 ); | 151 | columnWidthChanged( 0 ); |
152 | emit sigColWidthChanged(); | 152 | emit sigColWidthChanged(); |
153 | } | 153 | } |
154 | 154 | ||
155 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 155 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
156 | { | 156 | { |
157 | QString txt = e->text(); | 157 | QString txt = e->text(); |
158 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 158 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
159 | // we this is some sort of thing we know about... | 159 | // we this is some sort of thing we know about... |
160 | e->accept(); | 160 | e->accept(); |
161 | emit sigCapturedKey( txt ); | 161 | emit sigCapturedKey( txt ); |
162 | } else { | 162 | } else { |
163 | // I don't know what this key is, do you? | 163 | // I don't know what this key is, do you? |
164 | e->ignore(); | 164 | e->ignore(); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void DateBookDayView::setRowStyle( int style ) | 168 | void DateBookDayView::setRowStyle( int style ) |
169 | { | 169 | { |
170 | if (style<0) style = 0; | 170 | if (style<0) style = 0; |
171 | 171 | ||
172 | for (int i=0; i<numRows(); i++) | 172 | for (int i=0; i<numRows(); i++) |
173 | setRowHeight(i, style*10+20); | 173 | setRowHeight(i, style*10+20); |
174 | } | 174 | } |
175 | 175 | ||
176 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | 176 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) |
177 | { | 177 | { |
178 | int sh=99,eh=-1; | 178 | int sh=99,eh=-1; |
179 | 179 | ||
180 | for(int i=0;i<this->numSelections();i++) { | 180 | for(int i=0;i<this->numSelections();i++) { |
181 | QTableSelection sel = this->selection( i ); | 181 | QTableSelection sel = this->selection( i ); |
182 | sh = QMIN(sh,sel.topRow()); | 182 | sh = QMIN(sh,sel.topRow()); |
183 | eh = QMAX(sh,sel.bottomRow()+1); | 183 | eh = QMAX(sh,sel.bottomRow()+1); |
184 | } | 184 | } |
185 | if (sh > 23 || eh < 1) { | 185 | if (sh > 23 || eh < 1) { |
186 | sh=8; | 186 | sh=8; |
187 | eh=9; | 187 | eh=9; |
188 | } | 188 | } |
189 | 189 | ||
190 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | 190 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); |
191 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 191 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
192 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); | 192 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
193 | quickLineEdit->setFocus(); | 193 | quickLineEdit->setFocus(); |
194 | quickLineEdit->show(); | 194 | quickLineEdit->show(); |
195 | } | 195 | } |
196 | 196 | ||
197 | //=========================================================================== | 197 | //=========================================================================== |
198 | 198 | ||
199 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) | 199 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) |
200 | { | 200 | { |
201 | active=1; | 201 | active=1; |
202 | quickEvent.setStart(start); | 202 | quickEvent.setStart(start); |
203 | quickEvent.setEnd(end); | 203 | quickEvent.setEnd(end); |
204 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 204 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
205 | } | 205 | } |
206 | 206 | ||
207 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 207 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
208 | { | 208 | { |
209 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | 209 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. |
210 | quickEvent.setDescription(this->text()); | 210 | quickEvent.setDescription(this->text()); |
211 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | 211 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); |
212 | emit(insertEvent(quickEvent)); | 212 | emit(insertEvent(quickEvent)); |
213 | active=0; | 213 | active=0; |
214 | } | 214 | } |
215 | /* we need to return to this object.. */ | 215 | /* we need to return to this object.. */ |
216 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget | 216 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget |
217 | } | 217 | } |
218 | void DateBookDayViewQuickLineEdit::finallyCallClose() { | 218 | void DateBookDayViewQuickLineEdit::finallyCallClose() { |
219 | close(true); // also deletes this widget... | 219 | close(true); // also deletes this widget... |
220 | } | 220 | } |
221 | 221 | ||
222 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) | 222 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) |
223 | { | 223 | { |
224 | slotReturnPressed(); // Reuse code to add event and close this widget. | 224 | slotReturnPressed(); // Reuse code to add event and close this widget. |
225 | } | 225 | } |
226 | 226 | ||
227 | //=========================================================================== | 227 | //=========================================================================== |
228 | 228 | ||
229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) |
230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
231 | { | 231 | { |
232 | widgetList.setAutoDelete( true ); | 232 | widgetList.setAutoDelete( true ); |
233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
235 | 235 | ||
236 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); | 236 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); |
237 | m_allDays->hide(); | 237 | m_allDays->hide(); |
238 | 238 | ||
239 | view = new DateBookDayView( ampm, this, "day view" ); | 239 | view = new DateBookDayView( ampm, this, "day view" ); |
240 | 240 | ||
241 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); | 241 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); |
242 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); | 242 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); |
243 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | 243 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
244 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 244 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
245 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); | 245 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); |
246 | 246 | ||
247 | QTimer *timer = new QTimer( this ); | 247 | QTimer *timer = new QTimer( this ); |
248 | 248 | ||
249 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 249 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
250 | timer->start( 1000*60*5, FALSE ); //update every 5min | 250 | timer->start( 1000*60*5, FALSE ); //update every 5min |
251 | 251 | ||
252 | selectedWidget = 0; | 252 | selectedWidget = 0; |
253 | 253 | ||
254 | timeMarker = new DateBookDayTimeMarker( this ); | 254 | timeMarker = new DateBookDayTimeMarker( this ); |
255 | timeMarker->setTime( QTime::currentTime() ); | 255 | timeMarker->setTime( QTime::currentTime() ); |
256 | rowStyle = -1; // initialize with bogus values | 256 | rowStyle = -1; // initialize with bogus values |
257 | jumpToCurTime = false; | 257 | jumpToCurTime = false; |
258 | } | 258 | } |
259 | 259 | ||
260 | void DateBookDay::setJumpToCurTime( bool bJump ) | 260 | void DateBookDay::setJumpToCurTime( bool bJump ) |
261 | { | 261 | { |
262 | jumpToCurTime = bJump; | 262 | jumpToCurTime = bJump; |
263 | } | 263 | } |
264 | 264 | ||
265 | void DateBookDay::setRowStyle( int style ) | 265 | void DateBookDay::setRowStyle( int style ) |
266 | { | 266 | { |
267 | if (rowStyle != style) view->setRowStyle( style ); | 267 | if (rowStyle != style) view->setRowStyle( style ); |
268 | rowStyle = style; | 268 | rowStyle = style; |
269 | } | 269 | } |
270 | 270 | ||
271 | void DateBookDay::updateView( void ) | 271 | void DateBookDay::updateView( void ) |
272 | { | 272 | { |
273 | timeMarker->setTime( QTime::currentTime() ); | 273 | timeMarker->setTime( QTime::currentTime() ); |
274 | //need to find a way to update all DateBookDayWidgets | 274 | //need to find a way to update all DateBookDayWidgets |
275 | } | 275 | } |
276 | 276 | ||
277 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 277 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
278 | { | 278 | { |
279 | selectedWidget = w; | 279 | selectedWidget = w; |
280 | } | 280 | } |
281 | 281 | ||
282 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 282 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
283 | { | 283 | { |
284 | return selectedWidget; | 284 | return selectedWidget; |
285 | } | 285 | } |
286 | 286 | ||
287 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 287 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
288 | { | 288 | { |
289 | start.setDate( currDate ); | 289 | start.setDate( currDate ); |
290 | end.setDate( currDate ); | 290 | end.setDate( currDate ); |
291 | 291 | ||
292 | int sh=99,eh=-1; | 292 | int sh=99,eh=-1; |
293 | 293 | ||
294 | int n = dayView()->numSelections(); | 294 | int n = dayView()->numSelections(); |
295 | 295 | ||
296 | for (int i=0; i<n; i++) { | 296 | for (int i=0; i<n; i++) { |
297 | QTableSelection sel = dayView()->selection( i ); | 297 | QTableSelection sel = dayView()->selection( i ); |
298 | sh = QMIN(sh,sel.topRow()); | 298 | sh = QMIN(sh,sel.topRow()); |
299 | eh = QMAX(sh,sel.bottomRow()+1); | 299 | eh = QMAX(sh,sel.bottomRow()+1); |
300 | } | 300 | } |
301 | 301 | ||
302 | if (sh > 23 || eh < 1) { | 302 | if (sh > 23 || eh < 1) { |
303 | sh=8; | 303 | sh=8; |
304 | eh=9; | 304 | eh=9; |
305 | } | 305 | } |
306 | 306 | ||
307 | start.setTime( QTime( sh, 0, 0 ) ); | 307 | start.setTime( QTime( sh, 0, 0 ) ); |
308 | end.setTime( QTime( eh, 0, 0 ) ); | 308 | end.setTime( QTime( eh, 0, 0 ) ); |
309 | } | 309 | } |
310 | 310 | ||
311 | void DateBookDay::setDate( int y, int m, int d ) | 311 | void DateBookDay::setDate( int y, int m, int d ) |
312 | { | 312 | { |
313 | header->setDate( y, m, d ); | 313 | header->setDate( y, m, d ); |
314 | selectedWidget = 0; | 314 | selectedWidget = 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | void DateBookDay::setDate( QDate d) | 317 | void DateBookDay::setDate( QDate d) |
318 | { | 318 | { |
319 | header->setDate( d.year(), d.month(), d.day() ); | 319 | header->setDate( d.year(), d.month(), d.day() ); |
320 | selectedWidget = 0; | 320 | selectedWidget = 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | void DateBookDay::dateChanged( int y, int m, int d ) | 323 | void DateBookDay::dateChanged( int y, int m, int d ) |
324 | { | 324 | { |
325 | QDate date( y, m, d ); | 325 | QDate date( y, m, d ); |
326 | if ( currDate == date ) | 326 | if ( currDate == date ) |
327 | return; | 327 | return; |
328 | currDate.setYMD( y, m, d ); | 328 | currDate.setYMD( y, m, d ); |
329 | relayoutPage(); | 329 | relayoutPage(); |
330 | dayView()->clearSelection(); | 330 | dayView()->clearSelection(); |
331 | QTableSelection ts; | 331 | QTableSelection ts; |
332 | 332 | ||
333 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 333 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
334 | { | 334 | { |
335 | ts.init( QTime::currentTime().hour(), 0); | 335 | ts.init( QTime::currentTime().hour(), 0); |
336 | ts.expandTo( QTime::currentTime().hour(), 0); | 336 | ts.expandTo( QTime::currentTime().hour(), 0); |
337 | } else { | 337 | } else { |
338 | ts.init( startTime, 0 ); | 338 | ts.init( startTime, 0 ); |
339 | ts.expandTo( startTime, 0 ); | 339 | ts.expandTo( startTime, 0 ); |
340 | } | 340 | } |
341 | 341 | ||
342 | dayView()->addSelection( ts ); | 342 | dayView()->addSelection( ts ); |
343 | selectedWidget = 0; | 343 | selectedWidget = 0; |
344 | } | 344 | } |
345 | 345 | ||
346 | void DateBookDay::redraw() | 346 | void DateBookDay::redraw() |
347 | { | 347 | { |
348 | if ( isUpdatesEnabled() ) | 348 | if ( isUpdatesEnabled() ) |
349 | relayoutPage(); | 349 | relayoutPage(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void DateBookDay::getEvents() | 352 | void DateBookDay::getEvents() |
353 | { | 353 | { |
354 | widgetList.clear(); | 354 | widgetList.clear(); |
355 | 355 | ||
356 | /* clear the AllDay List */ | 356 | /* clear the AllDay List */ |
357 | m_allDays->hide(); // just in case | 357 | m_allDays->hide(); // just in case |
358 | m_allDays->removeAllEvents(); | 358 | m_allDays->removeAllEvents(); |
359 | 359 | ||
360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
361 | QValueListIterator<EffectiveEvent> it; | 361 | QValueListIterator<EffectiveEvent> it; |
362 | QObject* object = 0; | 362 | QObject* object = 0; |
363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
364 | EffectiveEvent ev=*it; | 364 | EffectiveEvent ev=*it; |
365 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 365 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
366 | if (ev.event().type() == Event::AllDay ) { | 366 | if (ev.event().type() == Event::AllDay ) { |
367 | object = m_allDays->addEvent( ev ); | 367 | object = m_allDays->addEvent( ev ); |
368 | if (!object) | 368 | if (!object) |
369 | continue; | 369 | continue; |
370 | }else { | 370 | }else { |
371 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 371 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
372 | widgetList.append( w ); | 372 | widgetList.append( w ); |
373 | object = w; | 373 | object = w; |
374 | } | 374 | } |
375 | 375 | ||
376 | connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); | 376 | connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); |
377 | connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); | 377 | connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); |
378 | connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); | 378 | connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); |
379 | connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); | 379 | connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); |
380 | 380 | ||
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 385 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
386 | { | 386 | { |
387 | int place = 0; | 387 | int place = 0; |
388 | int start = item->event().start().hour(); | 388 | int start = item->event().start().hour(); |
389 | QTime e = item->event().end(); | 389 | QTime e = item->event().end(); |
390 | int end = e.hour(); | 390 | int end = e.hour(); |
391 | if ( e.minute() < 5 ) | 391 | if ( e.minute() < 5 ) |
392 | end--; | 392 | end--; |
393 | if ( end < start ) | 393 | if ( end < start ) |
394 | end = start; | 394 | end = start; |
395 | while ( place < maxn ) { | 395 | while ( place < maxn ) { |
396 | bool free = TRUE; | 396 | bool free = TRUE; |
397 | int s = start; | 397 | int s = start; |
398 | while( s <= end ) { | 398 | while( s <= end ) { |
399 | if ( used[10*s+place] ) { | 399 | if ( used[10*s+place] ) { |
400 | free = FALSE; | 400 | free = FALSE; |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | s++; | 403 | s++; |
404 | } | 404 | } |
405 | if ( free ) | 405 | if ( free ) |
406 | break; | 406 | break; |
407 | place++; | 407 | place++; |
408 | } | 408 | } |
409 | if ( place == maxn ) { | 409 | if ( place == maxn ) { |
410 | return -1; | 410 | return -1; |
411 | } | 411 | } |
412 | while( start <= end ) { | 412 | while( start <= end ) { |
413 | used[10*start+place] = TRUE; | 413 | used[10*start+place] = TRUE; |
414 | start++; | 414 | start++; |
415 | } | 415 | } |
416 | return place; | 416 | return place; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void DateBookDay::relayoutPage( bool fromResize ) | 420 | void DateBookDay::relayoutPage( bool fromResize ) |
421 | { | 421 | { |
422 | setUpdatesEnabled( FALSE ); | 422 | setUpdatesEnabled( FALSE ); |
423 | if ( !fromResize ) { | 423 | if ( !fromResize ) { |
424 | getEvents(); // no need we already have them! | 424 | getEvents(); // no need we already have them! |
425 | 425 | ||
426 | if (m_allDays->items() > 0 ) | 426 | if (m_allDays->items() > 0 ) |
427 | m_allDays->show(); | 427 | m_allDays->show(); |
428 | /* | 428 | /* |
429 | * else if ( m_allDays->items() == 0 ) already hide in getEvents | 429 | * else if ( m_allDays->items() == 0 ) already hide in getEvents |
430 | */ | 430 | */ |
431 | } | 431 | } |
432 | 432 | ||
433 | widgetList.sort(); | 433 | widgetList.sort(); |
434 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | 434 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning |
435 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | 435 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view |
436 | 436 | ||
437 | int wCount = widgetList.count(); | 437 | int wCount = widgetList.count(); |
438 | int wid = view->columnWidth(0)-1; | 438 | int wid = view->columnWidth(0)-1; |
439 | int wd; | 439 | int wd; |
440 | int n = 1; | 440 | int n = 1; |
441 | 441 | ||
442 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | 442 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget |
443 | 443 | ||
444 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | 444 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); |
445 | 445 | ||
446 | if ( wCount < 20 ) { | 446 | if ( wCount < 20 ) { |
447 | 447 | ||
448 | QArray<QRect> geometries(wCount); | 448 | QArray<QRect> geometries(wCount); |
449 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 449 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
450 | 450 | ||
451 | for ( int i = 0; i < wCount; i++) { | 451 | for ( int i = 0; i < wCount; i++) { |
452 | QValueList<int> intersectedWidgets; | 452 | QValueList<int> intersectedWidgets; |
453 | 453 | ||
454 | //find all widgets intersecting with widgetList.at(i) | 454 | //find all widgets intersecting with widgetList.at(i) |
455 | for ( int j = 0; j < wCount; j++) { | 455 | for ( int j = 0; j < wCount; j++) { |
456 | if (i != j) | 456 | if (i != j) |
457 | if (geometries[j].intersects(geometries[i])) | 457 | if (geometries[j].intersects(geometries[i])) |
458 | intersectedWidgets.append(j); | 458 | intersectedWidgets.append(j); |
459 | } | 459 | } |
460 | 460 | ||
461 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 461 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
462 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 462 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
463 | { | 463 | { |
464 | QArray<int> inter(wCount); | 464 | QArray<int> inter(wCount); |
465 | inter[j]=1; | 465 | inter[j]=1; |
466 | 466 | ||
467 | if (intersectedWidgets[j] != -1) | 467 | if (intersectedWidgets[j] != -1) |
468 | for ( uint k = j; k < intersectedWidgets.count(); k++) { | 468 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
469 | if (j != k && intersectedWidgets[k] != -1) | 469 | if (j != k && intersectedWidgets[k] != -1) |
470 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { | 470 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
471 | inter[j]++; | 471 | inter[j]++; |
472 | intersectedWidgets[k] = -1; | 472 | intersectedWidgets[k] = -1; |
473 | } | 473 | } |
474 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 474 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 477 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | for ( int i = 0; i < wCount; i++) { | 481 | for ( int i = 0; i < wCount; i++) { |
482 | DateBookDayWidget *w = widgetList.at(i); | 482 | DateBookDayWidget *w = widgetList.at(i); |
483 | QRect geom = w->geometry(); | 483 | QRect geom = w->geometry(); |
484 | geom.setX( 0 ); | 484 | geom.setX( 0 ); |
485 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 485 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
486 | geom.setWidth( wd ); | 486 | geom.setWidth( wd ); |
487 | while ( intersects( w, geom ) ) { | 487 | while ( intersects( w, geom ) ) { |
488 | geom.moveBy( wd + 2 + 1, 0 ); | 488 | geom.moveBy( wd + 2 + 1, 0 ); |
489 | } | 489 | } |
490 | w->setGeometry( geom ); | 490 | w->setGeometry( geom ); |
491 | } | 491 | } |
492 | 492 | ||
493 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 493 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
494 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 494 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
495 | } else { | 495 | } else { |
496 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 496 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
497 | } | 497 | } |
498 | } else { | 498 | } else { |
499 | int hours[24]; | 499 | int hours[24]; |
500 | memset( hours, 0, 24*sizeof( int ) ); | 500 | memset( hours, 0, 24*sizeof( int ) ); |
501 | bool overFlow = FALSE; | 501 | bool overFlow = FALSE; |
502 | for ( int i = 0; i < wCount; i++ ) { | 502 | for ( int i = 0; i < wCount; i++ ) { |
503 | DateBookDayWidget *w = widgetList.at(i); | 503 | DateBookDayWidget *w = widgetList.at(i); |
504 | int start = w->event().start().hour(); | 504 | int start = w->event().start().hour(); |
505 | QTime e = w->event().end(); | 505 | QTime e = w->event().end(); |
506 | int end = e.hour(); | 506 | int end = e.hour(); |
507 | if ( e.minute() < 5 ) | 507 | if ( e.minute() < 5 ) |
508 | end--; | 508 | end--; |
509 | if ( end < start ) | 509 | if ( end < start ) |
510 | end = start; | 510 | end = start; |
511 | while( start <= end ) { | 511 | while( start <= end ) { |
512 | hours[start]++; | 512 | hours[start]++; |
513 | if ( hours[start] >= 10 ) | 513 | if ( hours[start] >= 10 ) |
514 | overFlow = TRUE; | 514 | overFlow = TRUE; |
515 | ++start; | 515 | ++start; |
516 | } | 516 | } |
517 | if ( overFlow ) | 517 | if ( overFlow ) |
518 | break; | 518 | break; |
519 | } | 519 | } |
520 | for ( int i = 0; i < 24; i++ ) { | 520 | for ( int i = 0; i < 24; i++ ) { |
521 | n = QMAX( n, hours[i] ); | 521 | n = QMAX( n, hours[i] ); |
522 | } | 522 | } |
523 | wid = ( view->columnWidth(0)-1 ) / n; | 523 | wid = ( view->columnWidth(0)-1 ) / n; |
524 | 524 | ||
525 | bool used[24*10]; | 525 | bool used[24*10]; |
526 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 526 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
527 | 527 | ||
528 | for ( int i = 0; i < wCount; i++ ) { | 528 | for ( int i = 0; i < wCount; i++ ) { |
529 | DateBookDayWidget *w = widgetList.at(i); | 529 | DateBookDayWidget *w = widgetList.at(i); |
530 | int xp = place( w, used, n ); | 530 | int xp = place( w, used, n ); |
531 | if ( xp != -1 ) { | 531 | if ( xp != -1 ) { |
532 | QRect geom = w->geometry(); | 532 | QRect geom = w->geometry(); |
533 | geom.setX( xp*(wid+2) ); | 533 | geom.setX( xp*(wid+2) ); |
534 | geom.setWidth( wid ); | 534 | geom.setWidth( wid ); |
535 | w->setGeometry( geom ); | 535 | w->setGeometry( geom ); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 539 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
540 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 540 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
541 | } else { | 541 | } else { |
542 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 542 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | 545 | ||
546 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 546 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
547 | timeMarker->raise(); //on top of all widgets | 547 | timeMarker->raise(); //on top of all widgets |
548 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day | 548 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day |
549 | timeMarker->show(); | 549 | timeMarker->show(); |
550 | } else { | 550 | } else { |
551 | timeMarker->hide(); | 551 | timeMarker->hide(); |
552 | } | 552 | } |
553 | setUpdatesEnabled( TRUE ); | 553 | setUpdatesEnabled( TRUE ); |
554 | return; | 554 | return; |
555 | } | 555 | } |
556 | 556 | ||
557 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 557 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
558 | { | 558 | { |
559 | int i = 0; | 559 | int i = 0; |
560 | DateBookDayWidget *w = widgetList.at(i); | 560 | DateBookDayWidget *w = widgetList.at(i); |
561 | int wCount = widgetList.count(); | 561 | int wCount = widgetList.count(); |
562 | while ( i < wCount && w != item ) { | 562 | while ( i < wCount && w != item ) { |
563 | if ( w->geometry().intersects( geom ) ) { | 563 | if ( w->geometry().intersects( geom ) ) { |
564 | return w; | 564 | return w; |
565 | } | 565 | } |
566 | w = widgetList.at(++i); | 566 | w = widgetList.at(++i); |
567 | } | 567 | } |
568 | 568 | ||
569 | return 0; | 569 | return 0; |
570 | } | 570 | } |
571 | 571 | ||
572 | 572 | ||
573 | QDate DateBookDay::date() const | 573 | QDate DateBookDay::date() const |
574 | { | 574 | { |
575 | return currDate; | 575 | return currDate; |
576 | } | 576 | } |
577 | 577 | ||
578 | void DateBookDay::setStartViewTime( int startHere ) | 578 | void DateBookDay::setStartViewTime( int startHere ) |
579 | { | 579 | { |
580 | startTime = startHere; | 580 | startTime = startHere; |
581 | dayView()->clearSelection(); | 581 | dayView()->clearSelection(); |
582 | QTableSelection ts; | 582 | QTableSelection ts; |
583 | 583 | ||
584 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? | 584 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
585 | ts.init( QTime::currentTime().hour(), 0); | 585 | ts.init( QTime::currentTime().hour(), 0); |
586 | ts.expandTo( QTime::currentTime().hour(), 0); | 586 | ts.expandTo( QTime::currentTime().hour(), 0); |
587 | } else { | 587 | } else { |
588 | ts.init( startTime, 0 ); | 588 | ts.init( startTime, 0 ); |
589 | ts.expandTo( startTime, 0 ); | 589 | ts.expandTo( startTime, 0 ); |
590 | } | 590 | } |
591 | 591 | ||
592 | dayView()->addSelection( ts ); | 592 | dayView()->addSelection( ts ); |
593 | } | 593 | } |
594 | 594 | ||
595 | int DateBookDay::startViewTime() const | 595 | int DateBookDay::startViewTime() const |
596 | { | 596 | { |
597 | return startTime; | 597 | return startTime; |
598 | } | 598 | } |
599 | 599 | ||
600 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 600 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
601 | { | 601 | { |
602 | header->setStartOfWeek( bStartOnMonday ); | 602 | header->setStartOfWeek( bStartOnMonday ); |
603 | //redraw(); | 603 | //redraw(); |
604 | } | 604 | } |
605 | 605 | ||
606 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 606 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
607 | { | 607 | { |
608 | switch(e->key()) { | 608 | switch(e->key()) { |
609 | case Key_Up: | 609 | case Key_Up: |
610 | view->moveUp(); | 610 | view->moveUp(); |
611 | break; | 611 | break; |
612 | case Key_Down: | 612 | case Key_Down: |
613 | view->moveDown(); | 613 | view->moveDown(); |
614 | break; | 614 | break; |
615 | case Key_Left: | 615 | case Key_Left: |
616 | setDate(QDate(currDate).addDays(-1)); | 616 | setDate(QDate(currDate).addDays(-1)); |
617 | break; | 617 | break; |
618 | case Key_Right: | 618 | case Key_Right: |
619 | setDate(QDate(currDate).addDays(1)); | 619 | setDate(QDate(currDate).addDays(1)); |
620 | break; | 620 | break; |
621 | default: | 621 | default: |
622 | e->ignore(); | 622 | e->ignore(); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | 625 | ||
626 | //=========================================================================== | 626 | //=========================================================================== |
627 | 627 | ||
628 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) | 628 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
629 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 629 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
630 | { | 630 | { |
631 | // why would someone use "<"? Oh well, fix it up... | 631 | // why would someone use "<"? Oh well, fix it up... |
632 | // I wonder what other things may be messed up... | 632 | // I wonder what other things may be messed up... |
633 | QString strDesc = ev.description(); | 633 | QString strDesc = ev.description(); |
634 | int where = strDesc.find( "<" ); | 634 | int where = strDesc.find( "<" ); |
635 | while ( where != -1 ) { | 635 | while ( where != -1 ) { |
636 | strDesc.remove( where, 1 ); | 636 | strDesc.remove( where, 1 ); |
637 | strDesc.insert( where, "<" ); | 637 | strDesc.insert( where, "<" ); |
638 | where = strDesc.find( "<", where ); | 638 | where = strDesc.find( "<", where ); |
639 | } | 639 | } |
640 | 640 | ||
641 | QString strCat; | 641 | QString strCat; |
642 | // ### Fix later... | 642 | // ### Fix later... |
643 | // QString strCat = ev.category(); | 643 | // QString strCat = ev.category(); |
644 | // where = strCat.find( "<" ); | 644 | // where = strCat.find( "<" ); |
645 | // while ( where != -1 ) { | 645 | // while ( where != -1 ) { |
646 | // strCat.remove( where, 1 ); | 646 | // strCat.remove( where, 1 ); |
647 | // strCat.insert( where, "<" ); | 647 | // strCat.insert( where, "<" ); |
648 | // where = strCat.find( "<", where ); | 648 | // where = strCat.find( "<", where ); |
649 | // } | 649 | // } |
650 | 650 | ||
651 | QString strNote = ev.notes(); | 651 | QString strNote = ev.notes(); |
652 | where = strNote.find( "<" ); | 652 | where = strNote.find( "<" ); |
653 | while ( where != -1 ) { | 653 | while ( where != -1 ) { |
654 | strNote.remove( where, 1 ); | 654 | strNote.remove( where, 1 ); |
655 | strNote.insert( where, "<" ); | 655 | strNote.insert( where, "<" ); |
656 | where = strNote.find( "<", where ); | 656 | where = strNote.find( "<", where ); |
657 | } | 657 | } |
658 | 658 | ||
659 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 659 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
660 | if ( !strCat.isEmpty() ) { | 660 | if ( !strCat.isEmpty() ) { |
661 | text += strCat + "</i><br>"; | 661 | text += strCat + "</i><br>"; |
662 | } | 662 | } |
663 | if (ev.event().type() == Event::Normal ) { | 663 | if (ev.event().type() == Event::Normal ) { |
664 | setEventText( text ); | 664 | setEventText( text ); |
665 | } else { | 665 | } else { |
666 | setAllDayText( text ); | 666 | setAllDayText( text ); |
667 | } | 667 | } |
668 | 668 | ||
669 | text += "<br><br>" + strNote; | 669 | text += "<br><br>" + strNote; |
670 | 670 | ||
671 | setBackgroundMode( PaletteBase ); | 671 | setBackgroundMode( PaletteBase ); |
672 | 672 | ||
673 | QTime start = ev.start(); | 673 | QTime start = ev.start(); |
674 | QTime end = ev.end(); | 674 | QTime end = ev.end(); |
675 | int y = start.hour()*60+start.minute(); | 675 | int y = start.hour()*60+start.minute(); |
676 | int h = end.hour()*60+end.minute()-y; | 676 | int h = end.hour()*60+end.minute()-y; |
677 | int rh = dateBook->dayView()->rowHeight(0); | 677 | int rh = dateBook->dayView()->rowHeight(0); |
678 | y = y*rh/60; | 678 | y = y*rh/60; |
679 | h = h*rh/60; | 679 | h = h*rh/60; |
680 | 680 | ||
681 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. | 681 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. |
682 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. | 682 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. |
683 | geom.setY( y ); | 683 | geom.setY( y ); |
684 | geom.setHeight( h ); | 684 | geom.setHeight( h ); |
685 | geom.setX( 0 ); | 685 | geom.setX( 0 ); |
686 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 686 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
687 | 687 | ||
688 | } | 688 | } |
689 | 689 | ||
690 | void DateBookDayWidget::setAllDayText( QString &text ) { | 690 | void DateBookDayWidget::setAllDayText( QString &text ) { |
691 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 691 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
692 | } | 692 | } |
693 | 693 | ||
694 | void DateBookDayWidget::setEventText( QString& text ) { | 694 | void DateBookDayWidget::setEventText( QString& text ) { |
695 | bool whichClock = dateBook->dayView()->whichClock(); | 695 | bool whichClock = dateBook->dayView()->whichClock(); |
696 | if ( ev.startDate() != ev.endDate() ) { | 696 | if ( ev.startDate() != ev.endDate() ) { |
697 | text += "<b>" + tr("Start") + "</b>: "; | 697 | text += "<b>" + tr("Start") + "</b>: "; |
698 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 698 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
699 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 699 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
700 | text += "<b>" + tr("End") + "</b>: "; | 700 | text += "<b>" + tr("End") + "</b>: "; |
701 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | 701 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); |
702 | text += " - " + TimeString::longDateString( ev.endDate() ); | 702 | text += " - " + TimeString::longDateString( ev.endDate() ); |
703 | } else { | 703 | } else { |
704 | text += "<b>" + tr("Time") + "</b>: "; | 704 | text += "<b>" + tr("Time") + "</b>: "; |
705 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 705 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
706 | text += "<b>" + tr(" - ") + "</b>"; | 706 | text += "<b>" + tr(" - ") + "</b>"; |
707 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 707 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
708 | } | 708 | } |
709 | } | 709 | } |
710 | 710 | ||
711 | DateBookDayWidget::~DateBookDayWidget() | 711 | DateBookDayWidget::~DateBookDayWidget() |
712 | { | 712 | { |
713 | } | 713 | } |
714 | 714 | ||
715 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 715 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
716 | { | 716 | { |
717 | QPainter p( this ); | 717 | QPainter p( this ); |
718 | 718 | ||
719 | if (dateBook->getSelectedWidget() == this) { | 719 | if (dateBook->getSelectedWidget() == this) { |
720 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 720 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
721 | } else { | 721 | } else { |
722 | if (dateBook->date() == QDate::currentDate()) { | 722 | if (dateBook->date() == QDate::currentDate()) { |
723 | QTime curTime = QTime::currentTime(); | 723 | QTime curTime = QTime::currentTime(); |
724 | if (ev.end() < curTime) { | 724 | if (ev.end() < curTime) { |
725 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 725 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
726 | } else { | 726 | } else { |
727 | //change color in dependence of the time till the event starts | 727 | //change color in dependence of the time till the event starts |
728 | int duration = curTime.secsTo(ev.start()); | 728 | int duration = curTime.secsTo(ev.start()); |
729 | if (duration < 0) duration = 0; | 729 | if (duration < 0) duration = 0; |
730 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 730 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
731 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 731 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
732 | } | 732 | } |
733 | } else { | 733 | } else { |
734 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 734 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
735 | //perhaps make a distinction between future/past dates | 735 | //perhaps make a distinction between future/past dates |
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | p.setPen( QColor(100, 100, 100) ); | 739 | p.setPen( QColor(100, 100, 100) ); |
740 | p.drawRect(rect()); | 740 | p.drawRect(rect()); |
741 | 741 | ||
742 | // p.drawRect(0,0, 5, height()); | 742 | // p.drawRect(0,0, 5, height()); |
743 | 743 | ||
744 | int y = 0; | 744 | int y = 0; |
745 | int d = 0; | 745 | int d = 0; |
746 | 746 | ||
747 | if ( ev.event().hasAlarm() ) { | 747 | if ( ev.event().hasAlarm() ) { |
748 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 748 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
749 | y = 20; | 749 | y = 20; |
750 | d = 20; | 750 | d = 20; |
751 | } | 751 | } |
752 | 752 | ||
753 | if ( ev.event().hasRepeat() ) { | 753 | if ( ev.event().hasRepeat() ) { |
754 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 754 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
755 | d = 20; | 755 | d = 20; |
756 | y += 20; | 756 | y += 20; |
757 | } | 757 | } |
758 | 758 | ||
759 | QSimpleRichText rt( text, font() ); | 759 | QSimpleRichText rt( text, font() ); |
760 | rt.setWidth( geom.width() - d - 6 ); | 760 | rt.setWidth( geom.width() - d - 6 ); |
761 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 761 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
762 | } | 762 | } |
763 | 763 | ||
764 | /* | 764 | /* |
765 | * we need to find the real start date for a uid | 765 | * we need to find the real start date for a uid |
766 | * we need to check from one day to another... | 766 | * we need to check from one day to another... |
767 | */ | 767 | */ |
768 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { | 768 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { |
769 | QDate dt( isIncluded ); | 769 | QDate dt( isIncluded ); |
770 | QDate fnd = dt; | 770 | QDate fnd = dt; |
771 | 771 | ||
772 | bool doAgain = true; | 772 | bool doAgain = true; |
773 | do{ | 773 | do{ |
774 | dt = dt.addDays( -1 ); | 774 | dt = dt.addDays( -1 ); |
775 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); | 775 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); |
776 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { | 776 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { |
777 | EffectiveEvent ev = (*it); | 777 | EffectiveEvent ev = (*it); |
778 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) | 778 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) |
779 | return ev.date(); | 779 | return ev.date(); |
780 | } | 780 | } |
781 | }while (doAgain ); | 781 | }while (doAgain ); |
782 | 782 | ||
783 | return fnd; | 783 | return fnd; |
784 | } | 784 | } |
785 | 785 | ||
786 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 786 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
787 | { | 787 | { |
788 | DateBookDayWidget *item; | 788 | DateBookDayWidget *item; |
789 | 789 | ||
790 | item = dateBook->getSelectedWidget(); | 790 | item = dateBook->getSelectedWidget(); |
791 | if (item) | 791 | if (item) |
792 | item->update(); | 792 | item->update(); |
793 | 793 | ||
794 | dateBook->setSelectedWidget(this); | 794 | dateBook->setSelectedWidget(this); |
795 | update(); | 795 | update(); |
796 | dateBook->repaint(); | 796 | dateBook->repaint(); |
797 | 797 | ||
798 | QPopupMenu m; | 798 | QPopupMenu m; |
799 | m.insertItem( tr( "Edit" ), 1 ); | 799 | m.insertItem( tr( "Edit" ), 1 ); |
800 | m.insertItem( tr( "Duplicate" ), 4 ); | 800 | m.insertItem( tr( "Duplicate" ), 4 ); |
801 | m.insertItem( tr( "Delete" ), 2 ); | 801 | m.insertItem( tr( "Delete" ), 2 ); |
802 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 802 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
803 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); | 803 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); |
804 | int r = m.exec( e->globalPos() ); | 804 | int r = m.exec( e->globalPos() ); |
805 | if ( r == 1 ) { | 805 | if ( r == 1 ) { |
806 | emit editMe( ev.event() ); | 806 | emit editMe( ev.event() ); |
807 | } else if ( r == 2 ) { | 807 | } else if ( r == 2 ) { |
808 | emit deleteMe( ev.event() ); | 808 | emit deleteMe( ev.event() ); |
809 | } else if ( r == 3 ) { | 809 | } else if ( r == 3 ) { |
810 | emit beamMe( ev.event() ); | 810 | emit beamMe( ev.event() ); |
811 | } else if ( r == 4 ) { | 811 | } else if ( r == 4 ) { |
812 | emit duplicateMe( ev.event() ); | 812 | emit duplicateMe( ev.event() ); |
813 | } else if ( r == 5 ) { | 813 | } else if ( r == 5 ) { |
814 | // create an Event and beam it... | 814 | // create an Event and beam it... |
815 | /* | 815 | /* |
816 | * Start with the easy stuff. If start and end date is the same we can just use | 816 | * Start with the easy stuff. If start and end date is the same we can just use |
817 | * the values of effective events | 817 | * the values of effective events |
818 | * If it is a multi day event we need to find the real start and end date... | 818 | * If it is a multi day event we need to find the real start and end date... |
819 | */ | 819 | */ |
820 | if ( ev.event().start().date() == ev.event().end().date() ) { | 820 | if ( ev.event().start().date() == ev.event().end().date() ) { |
821 | Event event( ev.event() ); | 821 | Event event( ev.event() ); |
822 | 822 | ||
823 | QDateTime dt( ev.date(), ev.start() ); | 823 | QDateTime dt( ev.date(), ev.start() ); |
824 | event.setStart( dt ); | 824 | event.setStart( dt ); |
825 | 825 | ||
826 | dt.setTime( ev.end() ); | 826 | dt.setTime( ev.end() ); |
827 | event.setEnd( dt ); | 827 | event.setEnd( dt ); |
828 | emit beamMe( event ); | 828 | emit beamMe( event ); |
829 | }else { | 829 | }else { |
830 | /* | 830 | /* |
831 | * at least the the Times are right now | 831 | * at least the the Times are right now |
832 | */ | 832 | */ |
833 | QDateTime start( ev.event().start() ); | 833 | QDateTime start( ev.event().start() ); |
834 | QDateTime end ( ev.event().end () ); | 834 | QDateTime end ( ev.event().end () ); |
835 | 835 | ||
836 | 836 | ||
837 | /* | 837 | /* |
838 | * ok we know the start date or we need to find it | 838 | * ok we know the start date or we need to find it |
839 | */ | 839 | */ |
840 | if ( ev.start() != QTime( 0, 0, 0 ) ) { | 840 | if ( ev.start() != QTime( 0, 0, 0 ) ) { |
841 | start.setDate( ev.date() ); | 841 | start.setDate( ev.date() ); |
842 | }else { | 842 | }else { |
843 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); | 843 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); |
844 | start.setDate( dt ); | 844 | start.setDate( dt ); |
845 | } | 845 | } |
846 | 846 | ||
847 | 847 | ||
848 | /* | 848 | /* |
849 | * ok we know now the end date... | 849 | * ok we know now the end date... |
850 | * else | 850 | * else |
851 | * get to know the offset btw the real start and real end | 851 | * get to know the offset btw the real start and real end |
852 | * and then add it to the new start date... | 852 | * and then add it to the new start date... |
853 | */ | 853 | */ |
854 | if ( ev.end() != QTime(23, 59, 59 ) ) { | 854 | if ( ev.end() != QTime(23, 59, 59 ) ) { |
855 | end.setDate( ev.date() ); | 855 | end.setDate( ev.date() ); |
856 | }else{ | 856 | }else{ |
857 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); | 857 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); |
858 | end.setDate( start.date().addDays( days ) ); | 858 | end.setDate( start.date().addDays( days ) ); |
859 | } | 859 | } |
860 | 860 | ||
861 | 861 | ||
862 | 862 | ||
863 | Event event( ev.event() ); | 863 | Event event( ev.event() ); |
864 | event.setStart( start ); | 864 | event.setStart( start ); |
865 | event.setEnd ( end ); | 865 | event.setEnd ( end ); |
866 | 866 | ||
867 | 867 | ||
868 | emit beamMe( event ); | 868 | emit beamMe( event ); |
869 | } | 869 | } |
870 | } | 870 | } |
871 | } | 871 | } |
872 | 872 | ||
873 | void DateBookDayWidget::setGeometry( const QRect &r ) | 873 | void DateBookDayWidget::setGeometry( const QRect &r ) |
874 | { | 874 | { |
875 | geom = r; | 875 | geom = r; |
876 | setFixedSize( r.width()+1, r.height()+1 ); | 876 | setFixedSize( r.width()+1, r.height()+1 ); |
877 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 877 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
878 | show(); | 878 | show(); |
879 | } | 879 | } |
880 | 880 | ||
881 | 881 | ||
882 | //--------------------------------------------------------------------------------------------- | 882 | //--------------------------------------------------------------------------------------------- |
883 | //--------------------------------------------------------------------------------------------- | 883 | //--------------------------------------------------------------------------------------------- |
884 | 884 | ||
885 | 885 | ||
886 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 886 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
887 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 887 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
888 | { | 888 | { |
889 | setBackgroundMode( PaletteBase ); | 889 | setBackgroundMode( PaletteBase ); |
890 | } | 890 | } |
891 | 891 | ||
892 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 892 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
893 | { | 893 | { |
894 | } | 894 | } |
895 | 895 | ||
896 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 896 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
897 | { | 897 | { |
898 | QPainter p( this ); | 898 | QPainter p( this ); |
899 | p.setBrush( QColor( 255, 0, 0 ) ); | 899 | p.setBrush( QColor( 255, 0, 0 ) ); |
900 | 900 | ||
901 | QPen pen; | 901 | QPen pen; |
902 | pen.setStyle(NoPen); | 902 | pen.setStyle(NoPen); |
903 | 903 | ||
904 | p.setPen( pen ); | 904 | p.setPen( pen ); |
905 | p.drawRect(rect()); | 905 | p.drawRect(rect()); |
906 | } | 906 | } |
907 | 907 | ||
908 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 908 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
909 | { | 909 | { |
910 | int y = t.hour()*60+t.minute(); | 910 | int y = t.hour()*60+t.minute(); |
911 | int rh = dateBook->dayView()->rowHeight(0); | 911 | int rh = dateBook->dayView()->rowHeight(0); |
912 | y = y*rh/60; | 912 | y = y*rh/60; |
913 | 913 | ||
914 | geom.setX( 0 ); | 914 | geom.setX( 0 ); |
915 | 915 | ||
916 | int x = dateBook->dayView()->columnWidth(0)-1; | 916 | int x = dateBook->dayView()->columnWidth(0)-1; |
917 | geom.setWidth( x ); | 917 | geom.setWidth( x ); |
918 | 918 | ||
919 | geom.setY( y ); | 919 | geom.setY( y ); |
920 | geom.setHeight( 1 ); | 920 | geom.setHeight( 1 ); |
921 | 921 | ||
922 | setGeometry( geom ); | 922 | setGeometry( geom ); |
923 | 923 | ||
924 | time = t; | 924 | time = t; |
925 | } | 925 | } |
926 | 926 | ||
927 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 927 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
928 | { | 928 | { |
929 | geom = r; | 929 | geom = r; |
930 | setFixedSize( r.width()+1, r.height()+1 ); | 930 | setFixedSize( r.width()+1, r.height()+1 ); |
931 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 931 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
932 | show(); | 932 | show(); |
933 | } | 933 | } |