-rw-r--r-- | core/pim/datebook/datebook.cpp | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 1 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 177 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 23 |
4 files changed, 124 insertions, 84 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 4fbcb10..6dd8918 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -380,12 +380,19 @@ void DateBook::viewWeekLst() { | |||
380 | } | 380 | } |
381 | 381 | ||
382 | void DateBook::viewMonth() { | 382 | void DateBook::viewMonth() { |
383 | view(MONTH,currentDate()); | 383 | view(MONTH,currentDate()); |
384 | } | 384 | } |
385 | 385 | ||
386 | void DateBook::insertEvent( const Event &e ) | ||
387 | { | ||
388 | qWarning("Adding Event!"); | ||
389 | db->addEvent(e); | ||
390 | emit newEvent(); | ||
391 | } | ||
392 | |||
386 | void DateBook::duplicateEvent( const Event &e ) | 393 | void DateBook::duplicateEvent( const Event &e ) |
387 | { | 394 | { |
388 | qWarning("Hmmm..."); | 395 | qWarning("Hmmm..."); |
389 | // Alot of code duplication, as this is almost like editEvent(); | 396 | // Alot of code duplication, as this is almost like editEvent(); |
390 | if (syncing) { | 397 | if (syncing) { |
391 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 398 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 5216770..3f57d4a 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -85,12 +85,13 @@ private slots: | |||
85 | void viewWeek(); | 85 | void viewWeek(); |
86 | void viewWeekLst(); | 86 | void viewWeekLst(); |
87 | void viewMonth(); | 87 | void viewMonth(); |
88 | 88 | ||
89 | void showDay( int y, int m, int d ); | 89 | void showDay( int y, int m, int d ); |
90 | 90 | ||
91 | void insertEvent( const Event &e ); | ||
91 | void editEvent( const Event &e ); | 92 | void editEvent( const Event &e ); |
92 | void duplicateEvent( const Event &e ); | 93 | void duplicateEvent( const Event &e ); |
93 | void removeEvent( const Event &e ); | 94 | void removeEvent( const Event &e ); |
94 | 95 | ||
95 | void receive( const QCString &msg, const QByteArray &data ); | 96 | void receive( const QCString &msg, const QByteArray &data ); |
96 | void setDocument( const QString & ); | 97 | void setDocument( const QString & ); |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index db4c2fd..0a40ea9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -35,18 +35,18 @@ | |||
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qsimplerichtext.h> | 36 | #include <qsimplerichtext.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qtextcodec.h> | 38 | #include <qtextcodec.h> |
39 | #include <qpalette.h> | 39 | #include <qpalette.h> |
40 | 40 | ||
41 | #include <qlineedit.h> | ||
42 | |||
41 | #include <qtimer.h> | 43 | #include <qtimer.h> |
42 | 44 | ||
43 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | 45 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
44 | const char *name ) | 46 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
45 | : QTable( 24, 1, parent, name ), | ||
46 | ampm( whichClock ) | ||
47 | { | 47 | { |
48 | enableClipper(TRUE); | 48 | enableClipper(TRUE); |
49 | setTopMargin( 0 ); | 49 | setTopMargin( 0 ); |
50 | horizontalHeader()->hide(); | 50 | horizontalHeader()->hide(); |
51 | setLeftMargin(38); | 51 | setLeftMargin(38); |
52 | setColumnStretchable( 0, TRUE ); | 52 | setColumnStretchable( 0, TRUE ); |
@@ -60,15 +60,15 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | |||
60 | int row; | 60 | int row; |
61 | for ( row = 0; row < numRows(); row++ ) { | 61 | for ( row = 0; row < numRows(); row++ ) { |
62 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 62 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
63 | setItem( row, 0, tmp ); | 63 | setItem( row, 0, tmp ); |
64 | //setRowHeight( row, 40); | 64 | //setRowHeight( row, 40); |
65 | } | 65 | } |
66 | |||
66 | initHeader(); | 67 | initHeader(); |
67 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), | 68 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
68 | this, SLOT(slotChangeClock(bool)) ); | ||
69 | } | 69 | } |
70 | 70 | ||
71 | void DateBookDayView::initHeader() | 71 | void DateBookDayView::initHeader() |
72 | { | 72 | { |
73 | QString strTmp; | 73 | QString strTmp; |
74 | for ( int i = 0; i < 24; ++i ) { | 74 | for ( int i = 0; i < 24; ++i ) { |
@@ -90,12 +90,17 @@ void DateBookDayView::initHeader() | |||
90 | strTmp = strTmp.rightJustify( 6, ' ' ); | 90 | strTmp = strTmp.rightJustify( 6, ' ' ); |
91 | verticalHeader()->setLabel( i, strTmp ); | 91 | verticalHeader()->setLabel( i, strTmp ); |
92 | setRowStretchable( i, FALSE ); | 92 | setRowStretchable( i, FALSE ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | ||
97 | { | ||
98 | currDate.setYMD(y,m,d); | ||
99 | } | ||
100 | |||
96 | void DateBookDayView::slotChangeClock( bool newClock ) | 101 | void DateBookDayView::slotChangeClock( bool newClock ) |
97 | { | 102 | { |
98 | ampm = newClock; | 103 | ampm = newClock; |
99 | initHeader(); | 104 | initHeader(); |
100 | } | 105 | } |
101 | 106 | ||
@@ -136,13 +141,12 @@ void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | |||
136 | } | 141 | } |
137 | 142 | ||
138 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
139 | { | 144 | { |
140 | } | 145 | } |
141 | 146 | ||
142 | |||
143 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
144 | { | 148 | { |
145 | QTable::resizeEvent( e ); | 149 | QTable::resizeEvent( e ); |
146 | columnWidthChanged( 0 ); | 150 | columnWidthChanged( 0 ); |
147 | emit sigColWidthChanged(); | 151 | emit sigColWidthChanged(); |
148 | } | 152 | } |
@@ -165,40 +169,69 @@ void DateBookDayView::setRowStyle( int style ) | |||
165 | if (style<0) style = 0; | 169 | if (style<0) style = 0; |
166 | 170 | ||
167 | for (int i=0; i<numRows(); i++) | 171 | for (int i=0; i<numRows(); i++) |
168 | setRowHeight(i, style*10+20); | 172 | setRowHeight(i, style*10+20); |
169 | } | 173 | } |
170 | 174 | ||
175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | ||
176 | { | ||
177 | int y=e->y(); | ||
178 | int diff=y%(this->rowHeight(0)); | ||
179 | int hour=y/this->rowHeight(0); | ||
180 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit"); | ||
181 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | ||
182 | this->moveChild(quickLineEdit,0,y-diff); | ||
183 | quickLineEdit->setFocus(); | ||
184 | quickLineEdit->show(); | ||
185 | } | ||
186 | |||
171 | //=========================================================================== | 187 | //=========================================================================== |
172 | 188 | ||
173 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | 189 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) |
174 | DateBookDB *newDb, QWidget *parent, | 190 | { |
175 | const char *name ) | 191 | active=1; |
176 | : QVBox( parent, name ), | 192 | quickEvent.setStart(start); |
177 | currDate( QDate::currentDate() ), | 193 | quickEvent.setEnd(end); |
178 | db( newDb ), | 194 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
179 | startTime( 0 ) | 195 | } |
196 | |||
197 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | ||
198 | { | ||
199 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | ||
200 | quickEvent.setDescription(this->text()); | ||
201 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | ||
202 | emit(insertEvent(quickEvent)); | ||
203 | active=0; | ||
204 | } | ||
205 | this->close(true);// Close and also delete this widget | ||
206 | } | ||
207 | |||
208 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) | ||
209 | { | ||
210 | slotReturnPressed(); // Reuse code to add event and close this widget. | ||
211 | } | ||
212 | |||
213 | //=========================================================================== | ||
214 | |||
215 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | ||
216 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | ||
180 | { | 217 | { |
181 | widgetList.setAutoDelete( true ); | 218 | widgetList.setAutoDelete( true ); |
182 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 219 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
183 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 220 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
184 | view = new DateBookDayView( ampm, this, "day view" ); | 221 | view = new DateBookDayView( ampm, this, "day view" ); |
185 | 222 | ||
186 | connect( header, SIGNAL( dateChanged( int, int, int ) ), | 223 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); |
187 | this, SLOT( dateChanged( int, int, int ) ) ); | 224 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); |
188 | connect( view, SIGNAL( sigColWidthChanged() ), | 225 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
189 | this, SLOT( slotColWidthChanged() ) ); | 226 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
190 | connect( qApp, SIGNAL(weekChanged(bool)), | 227 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); |
191 | this, SLOT(slotWeekChanged(bool)) ); | ||
192 | connect( view, SIGNAL(sigCapturedKey(const QString &)), | ||
193 | this, SIGNAL(sigNewEvent(const QString&)) ); | ||
194 | 228 | ||
195 | QTimer *timer = new QTimer( this ); | 229 | QTimer *timer = new QTimer( this ); |
196 | 230 | ||
197 | connect( timer, SIGNAL(timeout()), | 231 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
198 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | ||
199 | timer->start( 1000*60*5, FALSE ); //update every 5min | 232 | timer->start( 1000*60*5, FALSE ); //update every 5min |
200 | 233 | ||
201 | selectedWidget = 0; | 234 | selectedWidget = 0; |
202 | 235 | ||
203 | timeMarker = new DateBookDayTimeMarker( this ); | 236 | timeMarker = new DateBookDayTimeMarker( this ); |
204 | timeMarker->setTime( QTime::currentTime() ); | 237 | timeMarker->setTime( QTime::currentTime() ); |
@@ -243,32 +276,31 @@ void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | |||
243 | 276 | ||
244 | for (int i=0; i<n; i++) { | 277 | for (int i=0; i<n; i++) { |
245 | QTableSelection sel = dayView()->selection( i ); | 278 | QTableSelection sel = dayView()->selection( i ); |
246 | sh = QMIN(sh,sel.topRow()); | 279 | sh = QMIN(sh,sel.topRow()); |
247 | eh = QMAX(sh,sel.bottomRow()+1); | 280 | eh = QMAX(sh,sel.bottomRow()+1); |
248 | } | 281 | } |
282 | |||
249 | if (sh > 23 || eh < 1) { | 283 | if (sh > 23 || eh < 1) { |
250 | sh=8; | 284 | sh=8; |
251 | eh=9; | 285 | eh=9; |
252 | } | 286 | } |
253 | 287 | ||
254 | start.setTime( QTime( sh, 0, 0 ) ); | 288 | start.setTime( QTime( sh, 0, 0 ) ); |
255 | end.setTime( QTime( eh, 0, 0 ) ); | 289 | end.setTime( QTime( eh, 0, 0 ) ); |
256 | } | 290 | } |
257 | 291 | ||
258 | void DateBookDay::setDate( int y, int m, int d ) | 292 | void DateBookDay::setDate( int y, int m, int d ) |
259 | { | 293 | { |
260 | header->setDate( y, m, d ); | 294 | header->setDate( y, m, d ); |
261 | |||
262 | selectedWidget = 0; | 295 | selectedWidget = 0; |
263 | } | 296 | } |
264 | 297 | ||
265 | void DateBookDay::setDate( QDate d) | 298 | void DateBookDay::setDate( QDate d) |
266 | { | 299 | { |
267 | header->setDate( d.year(), d.month(), d.day() ); | 300 | header->setDate( d.year(), d.month(), d.day() ); |
268 | |||
269 | selectedWidget = 0; | 301 | selectedWidget = 0; |
270 | } | 302 | } |
271 | 303 | ||
272 | void DateBookDay::dateChanged( int y, int m, int d ) | 304 | void DateBookDay::dateChanged( int y, int m, int d ) |
273 | { | 305 | { |
274 | QDate date( y, m, d ); | 306 | QDate date( y, m, d ); |
@@ -280,22 +312,19 @@ void DateBookDay::dateChanged( int y, int m, int d ) | |||
280 | QTableSelection ts; | 312 | QTableSelection ts; |
281 | 313 | ||
282 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 314 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
283 | { | 315 | { |
284 | ts.init( QTime::currentTime().hour(), 0); | 316 | ts.init( QTime::currentTime().hour(), 0); |
285 | ts.expandTo( QTime::currentTime().hour(), 0); | 317 | ts.expandTo( QTime::currentTime().hour(), 0); |
286 | } else | 318 | } else { |
287 | { | ||
288 | ts.init( startTime, 0 ); | 319 | ts.init( startTime, 0 ); |
289 | ts.expandTo( startTime, 0 ); | 320 | ts.expandTo( startTime, 0 ); |
290 | } | 321 | } |
291 | 322 | ||
292 | dayView()->addSelection( ts ); | 323 | dayView()->addSelection( ts ); |
293 | |||
294 | selectedWidget = 0; | 324 | selectedWidget = 0; |
295 | |||
296 | } | 325 | } |
297 | 326 | ||
298 | void DateBookDay::redraw() | 327 | void DateBookDay::redraw() |
299 | { | 328 | { |
300 | if ( isUpdatesEnabled() ) | 329 | if ( isUpdatesEnabled() ) |
301 | relayoutPage(); | 330 | relayoutPage(); |
@@ -308,24 +337,19 @@ void DateBookDay::getEvents() | |||
308 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 337 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
309 | QValueListIterator<EffectiveEvent> it; | 338 | QValueListIterator<EffectiveEvent> it; |
310 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 339 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
311 | EffectiveEvent ev=*it; | 340 | EffectiveEvent ev=*it; |
312 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 341 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
313 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 342 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
314 | connect( w, SIGNAL( deleteMe( const Event & ) ), | 343 | connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); |
315 | this, SIGNAL( removeEvent( const Event & ) ) ); | 344 | connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); |
316 | connect( w, SIGNAL( duplicateMe( const Event & ) ), | 345 | connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); |
317 | this, SIGNAL( duplicateEvent( const Event & ) ) ); | 346 | connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); |
318 | connect( w, SIGNAL( editMe( const Event & ) ), | ||
319 | this, SIGNAL( editEvent( const Event & ) ) ); | ||
320 | connect( w, SIGNAL( beamMe( const Event & ) ), | ||
321 | this, SIGNAL( beamEvent( const Event & ) ) ); | ||
322 | widgetList.append( w ); | 347 | widgetList.append( w ); |
323 | } | 348 | } |
324 | } | 349 | } |
325 | |||
326 | } | 350 | } |
327 | 351 | ||
328 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 352 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
329 | { | 353 | { |
330 | int place = 0; | 354 | int place = 0; |
331 | int start = item->event().start().hour(); | 355 | int start = item->event().start().hour(); |
@@ -342,13 +366,14 @@ static int place( const DateBookDayWidget *item, bool *used, int maxn ) | |||
342 | if ( used[10*s+place] ) { | 366 | if ( used[10*s+place] ) { |
343 | free = FALSE; | 367 | free = FALSE; |
344 | break; | 368 | break; |
345 | } | 369 | } |
346 | s++; | 370 | s++; |
347 | } | 371 | } |
348 | if ( free ) break; | 372 | if ( free ) |
373 | break; | ||
349 | place++; | 374 | place++; |
350 | } | 375 | } |
351 | if ( place == maxn ) { | 376 | if ( place == maxn ) { |
352 | return -1; | 377 | return -1; |
353 | } | 378 | } |
354 | while( start <= end ) { | 379 | while( start <= end ) { |
@@ -380,68 +405,60 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
380 | 405 | ||
381 | if ( wCount < 20 ) { | 406 | if ( wCount < 20 ) { |
382 | 407 | ||
383 | QArray<QRect> geometries(wCount); | 408 | QArray<QRect> geometries(wCount); |
384 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 409 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
385 | 410 | ||
386 | for ( int i = 0; i < wCount; i++) | 411 | for ( int i = 0; i < wCount; i++) { |
387 | { | ||
388 | QValueList<int> intersectedWidgets; | 412 | QValueList<int> intersectedWidgets; |
389 | 413 | ||
390 | //find all widgets intersecting with widgetList.at(i) | 414 | //find all widgets intersecting with widgetList.at(i) |
391 | for ( int j = 0; j < wCount; j++) | 415 | for ( int j = 0; j < wCount; j++) { |
392 | if (i != j) | 416 | if (i != j) |
393 | if (geometries[j].intersects(geometries[i])) | 417 | if (geometries[j].intersects(geometries[i])) |
394 | intersectedWidgets.append(j); | 418 | intersectedWidgets.append(j); |
419 | } | ||
395 | 420 | ||
396 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 421 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
397 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 422 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
398 | { | 423 | { |
399 | QArray<int> inter(wCount); | 424 | QArray<int> inter(wCount); |
400 | inter[j]=1; | 425 | inter[j]=1; |
401 | 426 | ||
402 | if (intersectedWidgets[j] != -1) | 427 | if (intersectedWidgets[j] != -1) |
403 | for ( uint k = j; k < intersectedWidgets.count(); k++) | 428 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
404 | if (j != k && intersectedWidgets[k] != -1) | 429 | if (j != k && intersectedWidgets[k] != -1) |
405 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) | 430 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
406 | { | ||
407 | inter[j]++; | 431 | inter[j]++; |
408 | intersectedWidgets[k] = -1; | 432 | intersectedWidgets[k] = -1; |
409 | } | 433 | } |
410 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 434 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
411 | } | 435 | } |
412 | 436 | } | |
413 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 437 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
414 | } | 438 | } |
415 | 439 | ||
416 | 440 | ||
417 | for ( int i = 0; i < wCount; i++) { | 441 | for ( int i = 0; i < wCount; i++) { |
418 | DateBookDayWidget *w = widgetList.at(i); | 442 | DateBookDayWidget *w = widgetList.at(i); |
419 | QRect geom = w->geometry(); | 443 | QRect geom = w->geometry(); |
420 | |||
421 | geom.setX( 0 ); | 444 | geom.setX( 0 ); |
422 | |||
423 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 445 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
424 | |||
425 | geom.setWidth( wd ); | 446 | geom.setWidth( wd ); |
426 | |||
427 | while ( intersects( w, geom ) ) { | 447 | while ( intersects( w, geom ) ) { |
428 | geom.moveBy( wd + 2 + 1, 0 ); | 448 | geom.moveBy( wd + 2 + 1, 0 ); |
429 | } | 449 | } |
430 | w->setGeometry( geom ); | 450 | w->setGeometry( geom ); |
431 | } | 451 | } |
432 | 452 | ||
433 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 453 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
434 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 454 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
435 | else | 455 | } else { |
436 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 456 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
437 | 457 | } | |
438 | |||
439 | } else { | 458 | } else { |
440 | |||
441 | |||
442 | int hours[24]; | 459 | int hours[24]; |
443 | memset( hours, 0, 24*sizeof( int ) ); | 460 | memset( hours, 0, 24*sizeof( int ) ); |
444 | bool overFlow = FALSE; | 461 | bool overFlow = FALSE; |
445 | for ( int i = 0; i < wCount; i++ ) { | 462 | for ( int i = 0; i < wCount; i++ ) { |
446 | DateBookDayWidget *w = widgetList.at(i); | 463 | DateBookDayWidget *w = widgetList.at(i); |
447 | int start = w->event().start().hour(); | 464 | int start = w->event().start().hour(); |
@@ -476,17 +493,18 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
476 | geom.setX( xp*(wid+2) ); | 493 | geom.setX( xp*(wid+2) ); |
477 | geom.setWidth( wid ); | 494 | geom.setWidth( wid ); |
478 | w->setGeometry( geom ); | 495 | w->setGeometry( geom ); |
479 | } | 496 | } |
480 | } | 497 | } |
481 | 498 | ||
482 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 499 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
483 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 500 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
484 | else | 501 | } else { |
485 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 502 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
486 | } | 503 | } |
504 | } | ||
487 | 505 | ||
488 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 506 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
489 | timeMarker->raise(); //on top of all widgets | 507 | timeMarker->raise(); //on top of all widgets |
490 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | 508 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day |
491 | timeMarker->show(); else timeMarker->hide(); | 509 | timeMarker->show(); else timeMarker->hide(); |
492 | 510 | ||
@@ -518,18 +536,16 @@ QDate DateBookDay::date() const | |||
518 | void DateBookDay::setStartViewTime( int startHere ) | 536 | void DateBookDay::setStartViewTime( int startHere ) |
519 | { | 537 | { |
520 | startTime = startHere; | 538 | startTime = startHere; |
521 | dayView()->clearSelection(); | 539 | dayView()->clearSelection(); |
522 | QTableSelection ts; | 540 | QTableSelection ts; |
523 | 541 | ||
524 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? | 542 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
525 | { | ||
526 | ts.init( QTime::currentTime().hour(), 0); | 543 | ts.init( QTime::currentTime().hour(), 0); |
527 | ts.expandTo( QTime::currentTime().hour(), 0); | 544 | ts.expandTo( QTime::currentTime().hour(), 0); |
528 | } else | 545 | } else { |
529 | { | ||
530 | ts.init( startTime, 0 ); | 546 | ts.init( startTime, 0 ); |
531 | ts.expandTo( startTime, 0 ); | 547 | ts.expandTo( startTime, 0 ); |
532 | } | 548 | } |
533 | 549 | ||
534 | dayView()->addSelection( ts ); | 550 | dayView()->addSelection( ts ); |
535 | } | 551 | } |
@@ -564,18 +580,15 @@ void DateBookDay::keyPressEvent(QKeyEvent *e) | |||
564 | e->ignore(); | 580 | e->ignore(); |
565 | } | 581 | } |
566 | } | 582 | } |
567 | 583 | ||
568 | //=========================================================================== | 584 | //=========================================================================== |
569 | 585 | ||
570 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | 586 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
571 | DateBookDay *db ) | ||
572 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 587 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
573 | { | 588 | { |
574 | |||
575 | |||
576 | // why would someone use "<"? Oh well, fix it up... | 589 | // why would someone use "<"? Oh well, fix it up... |
577 | // I wonder what other things may be messed up... | 590 | // I wonder what other things may be messed up... |
578 | QString strDesc = ev.description(); | 591 | QString strDesc = ev.description(); |
579 | int where = strDesc.find( "<" ); | 592 | int where = strDesc.find( "<" ); |
580 | while ( where != -1 ) { | 593 | while ( where != -1 ) { |
581 | strDesc.remove( where, 1 ); | 594 | strDesc.remove( where, 1 ); |
@@ -602,16 +615,17 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
602 | } | 615 | } |
603 | 616 | ||
604 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 617 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
605 | if ( !strCat.isEmpty() ) { | 618 | if ( !strCat.isEmpty() ) { |
606 | text += strCat + "</i><br>"; | 619 | text += strCat + "</i><br>"; |
607 | } | 620 | } |
608 | if (ev.event().type() == Event::Normal ) | 621 | if (ev.event().type() == Event::Normal ) { |
609 | setEventText( text ); | 622 | setEventText( text ); |
610 | else | 623 | } else { |
611 | setAllDayText( text ); | 624 | setAllDayText( text ); |
625 | } | ||
612 | 626 | ||
613 | text += "<br><br>" + strNote; | 627 | text += "<br><br>" + strNote; |
614 | 628 | ||
615 | setBackgroundMode( PaletteBase ); | 629 | setBackgroundMode( PaletteBase ); |
616 | 630 | ||
617 | QTime start = ev.start(); | 631 | QTime start = ev.start(); |
@@ -627,15 +641,17 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
627 | geom.setY( y ); | 641 | geom.setY( y ); |
628 | geom.setHeight( h ); | 642 | geom.setHeight( h ); |
629 | geom.setX( 0 ); | 643 | geom.setX( 0 ); |
630 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 644 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
631 | 645 | ||
632 | } | 646 | } |
647 | |||
633 | void DateBookDayWidget::setAllDayText( QString &text ) { | 648 | void DateBookDayWidget::setAllDayText( QString &text ) { |
634 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 649 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
635 | } | 650 | } |
651 | |||
636 | void DateBookDayWidget::setEventText( QString& text ) { | 652 | void DateBookDayWidget::setEventText( QString& text ) { |
637 | bool whichClock = dateBook->dayView()->whichClock(); | 653 | bool whichClock = dateBook->dayView()->whichClock(); |
638 | if ( ev.startDate() != ev.endDate() ) { | 654 | if ( ev.startDate() != ev.endDate() ) { |
639 | text += "<b>" + tr("Start") + "</b>: "; | 655 | text += "<b>" + tr("Start") + "</b>: "; |
640 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 656 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
641 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 657 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
@@ -655,35 +671,27 @@ DateBookDayWidget::~DateBookDayWidget() | |||
655 | } | 671 | } |
656 | 672 | ||
657 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 673 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
658 | { | 674 | { |
659 | QPainter p( this ); | 675 | QPainter p( this ); |
660 | 676 | ||
661 | if (dateBook->getSelectedWidget() == this) | 677 | if (dateBook->getSelectedWidget() == this) { |
662 | { | ||
663 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 678 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
664 | } else | 679 | } else { |
665 | { | 680 | if (dateBook->date() == QDate::currentDate()) { |
666 | if (dateBook->date() == QDate::currentDate()) | ||
667 | { | ||
668 | QTime curTime = QTime::currentTime(); | 681 | QTime curTime = QTime::currentTime(); |
669 | 682 | if (ev.end() < curTime) { | |
670 | if (ev.end() < curTime) | ||
671 | { | ||
672 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 683 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
673 | } else | 684 | } else { |
674 | { | ||
675 | //change color in dependence of the time till the event starts | 685 | //change color in dependence of the time till the event starts |
676 | int duration = curTime.secsTo(ev.start()); | 686 | int duration = curTime.secsTo(ev.start()); |
677 | if (duration < 0) duration = 0; | 687 | if (duration < 0) duration = 0; |
678 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 688 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
679 | |||
680 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 689 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
681 | } | 690 | } |
682 | } else | 691 | } else { |
683 | { | ||
684 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 692 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
685 | //perhaps make a distinction between future/past dates | 693 | //perhaps make a distinction between future/past dates |
686 | } | 694 | } |
687 | } | 695 | } |
688 | 696 | ||
689 | p.setPen( QColor(100, 100, 100) ); | 697 | p.setPen( QColor(100, 100, 100) ); |
@@ -713,13 +721,14 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
713 | 721 | ||
714 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 722 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
715 | { | 723 | { |
716 | DateBookDayWidget *item; | 724 | DateBookDayWidget *item; |
717 | 725 | ||
718 | item = dateBook->getSelectedWidget(); | 726 | item = dateBook->getSelectedWidget(); |
719 | if (item) item->update(); | 727 | if (item) |
728 | item->update(); | ||
720 | 729 | ||
721 | dateBook->setSelectedWidget(this); | 730 | dateBook->setSelectedWidget(this); |
722 | update(); | 731 | update(); |
723 | dateBook->repaint(); | 732 | dateBook->repaint(); |
724 | 733 | ||
725 | QPopupMenu m; | 734 | QPopupMenu m; |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 2faf24e..961f60f 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -24,46 +24,69 @@ | |||
24 | 24 | ||
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qtable.h> | 26 | #include <qtable.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | 29 | ||
30 | #include "datebook.h" | ||
31 | #include <qlineedit.h> | ||
32 | |||
30 | class DateBookDayHeader; | 33 | class DateBookDayHeader; |
31 | class DateBookDB; | 34 | class DateBookDB; |
32 | class QDateTime; | 35 | class QDateTime; |
33 | class QMouseEvent; | 36 | class QMouseEvent; |
34 | class QPaintEvent; | 37 | class QPaintEvent; |
35 | class QResizeEvent; | 38 | class QResizeEvent; |
36 | 39 | ||
40 | class DateBookDayViewQuickLineEdit : public QLineEdit | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); | ||
45 | protected: | ||
46 | Event quickEvent; | ||
47 | int active; | ||
48 | void focusOutEvent( QFocusEvent *e ); | ||
49 | protected slots: | ||
50 | void slotReturnPressed(void); | ||
51 | signals: | ||
52 | void insertEvent(const Event &e); | ||
53 | }; | ||
54 | |||
55 | |||
37 | class DateBookDayView : public QTable | 56 | class DateBookDayView : public QTable |
38 | { | 57 | { |
39 | Q_OBJECT | 58 | Q_OBJECT |
40 | public: | 59 | public: |
41 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); | 60 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); |
42 | bool whichClock() const; | 61 | bool whichClock() const; |
43 | 62 | ||
44 | void setRowStyle( int style ); | 63 | void setRowStyle( int style ); |
45 | 64 | ||
46 | public slots: | 65 | public slots: |
47 | void moveUp(); | 66 | void moveUp(); |
48 | void moveDown(); | 67 | void moveDown(); |
68 | void slotDateChanged( int year, int month, int day ); | ||
49 | 69 | ||
50 | signals: | 70 | signals: |
51 | void sigColWidthChanged(); | 71 | void sigColWidthChanged(); |
52 | void sigCapturedKey( const QString &txt ); | 72 | void sigCapturedKey( const QString &txt ); |
53 | protected slots: | 73 | protected slots: |
54 | void slotChangeClock( bool ); | 74 | void slotChangeClock( bool ); |
55 | protected: | 75 | protected: |
56 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 76 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
57 | virtual void paintFocus( QPainter *p, const QRect &cr ); | 77 | virtual void paintFocus( QPainter *p, const QRect &cr ); |
58 | 78 | ||
59 | virtual void resizeEvent( QResizeEvent *e ); | 79 | virtual void resizeEvent( QResizeEvent *e ); |
60 | void keyPressEvent( QKeyEvent *e ); | 80 | void keyPressEvent( QKeyEvent *e ); |
81 | void contentsMouseReleaseEvent( QMouseEvent *e ); | ||
61 | void initHeader(); | 82 | void initHeader(); |
62 | private: | 83 | private: |
63 | bool ampm; | 84 | bool ampm; |
85 | QDate currDate; | ||
86 | DateBookDayViewQuickLineEdit *quickLineEdit; | ||
64 | }; | 87 | }; |
65 | 88 | ||
66 | class DateBookDay; | 89 | class DateBookDay; |
67 | class DateBookDayWidget : public QWidget | 90 | class DateBookDayWidget : public QWidget |
68 | { | 91 | { |
69 | Q_OBJECT | 92 | Q_OBJECT |