author | umopapisdn <umopapisdn> | 2003-04-13 22:25:35 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-13 22:25:35 (UTC) |
commit | 053c38bb48ae8e7563293bc029f3c9d029b947f7 (patch) (side-by-side diff) | |
tree | 4277c6ba37ceed2233df07bf8ead89b049977f2f | |
parent | 1745c6565e18506d5cb5631ae13cfc5fab060fee (diff) | |
download | opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.zip opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.gz opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.bz2 |
New Feature: Quick entries now honors the duration selected.
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 0a40ea9..e212807 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -145,70 +145,79 @@ void DateBookDayView::paintFocus( QPainter *, const QRect & ) } void DateBookDayView::resizeEvent( QResizeEvent *e ) { QTable::resizeEvent( e ); columnWidthChanged( 0 ); emit sigColWidthChanged(); } void DateBookDayView::keyPressEvent( QKeyEvent *e ) { QString txt = e->text(); if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { // we this is some sort of thing we know about... e->accept(); emit sigCapturedKey( txt ); } else { // I don't know what this key is, do you? e->ignore(); } } void DateBookDayView::setRowStyle( int style ) { if (style<0) style = 0; for (int i=0; i<numRows(); i++) setRowHeight(i, style*10+20); } void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) { - int y=e->y(); - int diff=y%(this->rowHeight(0)); - int hour=y/this->rowHeight(0); - quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit"); + int sh=99,eh=-1; + + for(int i=0;i<this->numSelections();i++) { + QTableSelection sel = this->selection( i ); + sh = QMIN(sh,sel.topRow()); + eh = QMAX(sh,sel.bottomRow()+1); + } + if (sh > 23 || eh < 1) { + sh=8; + eh=9; + } + + quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); - this->moveChild(quickLineEdit,0,y-diff); + this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); quickLineEdit->setFocus(); quickLineEdit->show(); } //=========================================================================== DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) { active=1; quickEvent.setStart(start); quickEvent.setEnd(end); connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); } void DateBookDayViewQuickLineEdit::slotReturnPressed() { if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times. quickEvent.setDescription(this->text()); connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); emit(insertEvent(quickEvent)); active=0; } this->close(true); // Close and also delete this widget } void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) { slotReturnPressed(); // Reuse code to add event and close this widget. } //=========================================================================== |