summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-04-13 22:25:35 (UTC)
committer umopapisdn <umopapisdn>2003-04-13 22:25:35 (UTC)
commit053c38bb48ae8e7563293bc029f3c9d029b947f7 (patch) (side-by-side diff)
tree4277c6ba37ceed2233df07bf8ead89b049977f2f
parent1745c6565e18506d5cb5631ae13cfc5fab060fee (diff)
downloadopie-053c38bb48ae8e7563293bc029f3c9d029b947f7.zip
opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.gz
opie-053c38bb48ae8e7563293bc029f3c9d029b947f7.tar.bz2
New Feature: Quick entries now honors the duration selected.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp19
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
@@ -129,102 +129,111 @@ void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
int x2 = w - 1;
int y2 = h - 1;
QPen pen( p->pen() );
p->setPen( colorGroup().dark() );
p->drawLine( x2, 0, x2, y2 );
p->drawLine( 0, y2, x2, y2 );
p->setPen( colorGroup().midlight() );
p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
p->setPen( pen );
}
}
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.
}
//===========================================================================
DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
: QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
{
widgetList.setAutoDelete( true );
header = new DateBookDayHeader( startOnMonday, this, "day header" );
header->setDate( currDate.year(), currDate.month(), currDate.day() );
view = new DateBookDayView( ampm, this, "day view" );
connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) );
connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) );
connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) );
QTimer *timer = new QTimer( this );