summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index af98e06..db4c2fd 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -468,311 +468,311 @@ void DateBookDay::relayoutPage( bool fromResize )
bool used[24*10];
memset( used, FALSE, 24*10*sizeof( bool ) );
for ( int i = 0; i < wCount; i++ ) {
DateBookDayWidget *w = widgetList.at(i);
int xp = place( w, used, n );
if ( xp != -1 ) {
QRect geom = w->geometry();
geom.setX( xp*(wid+2) );
geom.setWidth( wid );
w->setGeometry( geom );
}
}
if (jumpToCurTime && this->date() == QDate::currentDate())
view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour
else
view->setContentsPos( 0, startTime * view->rowHeight(0) );
}
timeMarker->setTime( QTime::currentTime() ); //display timeMarker
timeMarker->raise(); //on top of all widgets
if (this->date() == QDate::currentDate()) //only show timeMarker on current day
timeMarker->show(); else timeMarker->hide();
setUpdatesEnabled( TRUE );
return;
}
DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom )
{
int i = 0;
DateBookDayWidget *w = widgetList.at(i);
int wCount = widgetList.count();
while ( i < wCount && w != item ) {
if ( w->geometry().intersects( geom ) ) {
return w;
}
w = widgetList.at(++i);
}
return 0;
}
QDate DateBookDay::date() const
{
return currDate;
}
void DateBookDay::setStartViewTime( int startHere )
{
startTime = startHere;
dayView()->clearSelection();
QTableSelection ts;
if (jumpToCurTime && this->date() == QDate::currentDate()) //this should probably be in datebook.cpp where it's called?
{
ts.init( QTime::currentTime().hour(), 0);
ts.expandTo( QTime::currentTime().hour(), 0);
} else
{
ts.init( startTime, 0 );
ts.expandTo( startTime, 0 );
}
dayView()->addSelection( ts );
}
int DateBookDay::startViewTime() const
{
return startTime;
}
void DateBookDay::slotWeekChanged( bool bStartOnMonday )
{
header->setStartOfWeek( bStartOnMonday );
// redraw();
}
void DateBookDay::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Up:
view->moveUp();
break;
case Key_Down:
view->moveDown();
break;
case Key_Left:
setDate(QDate(currDate).addDays(-1));
break;
case Key_Right:
setDate(QDate(currDate).addDays(1));
break;
default:
e->ignore();
}
}
//===========================================================================
DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e,
DateBookDay *db )
: QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db )
{
// why would someone use "<"? Oh well, fix it up...
// I wonder what other things may be messed up...
QString strDesc = ev.description();
int where = strDesc.find( "<" );
while ( where != -1 ) {
strDesc.remove( where, 1 );
strDesc.insert( where, "&#60;" );
where = strDesc.find( "<", where );
}
QString strCat;
// ### Fix later...
// QString strCat = ev.category();
// where = strCat.find( "<" );
// while ( where != -1 ) {
// strCat.remove( where, 1 );
// strCat.insert( where, "&#60;" );
// where = strCat.find( "<", where );
// }
- QString strNote = ev.notes();
- where = strNote.find( "<" );
- while ( where != -1 ) {
- strNote.remove( where, 1 );
- strNote.insert( where, "&#60;" );
- where = strNote.find( "<", where );
- }
+ QString strNote = ev.notes();
+ where = strNote.find( "<" );
+ while ( where != -1 ) {
+ strNote.remove( where, 1 );
+ strNote.insert( where, "&#60;" );
+ where = strNote.find( "<", where );
+ }
- text = "<b>" + strDesc + "</b><br>" + "<i>";
- if ( !strCat.isEmpty() ) {
- text += strCat + "</i><br>";
- }
- if (ev.event().type() == Event::Normal )
- setEventText( text );
- else
- setAllDayText( text );
+ text = "<b>" + strDesc + "</b><br>" + "<i>";
+ if ( !strCat.isEmpty() ) {
+ text += strCat + "</i><br>";
+ }
+ if (ev.event().type() == Event::Normal )
+ setEventText( text );
+ else
+ setAllDayText( text );
text += "<br><br>" + strNote;
setBackgroundMode( PaletteBase );
- QTime start = ev.start();
- QTime end = ev.end();
- int y = start.hour()*60+start.minute();
- int h = end.hour()*60+end.minute()-y;
- int rh = dateBook->dayView()->rowHeight(0);
- y = y*rh/60;
- h = h*rh/60;
- if ( h < 3 ) {
- h = 3;
- }
- geom.setY( y );
- geom.setHeight( h );
- geom.setX( 0 );
- geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
+ QTime start = ev.start();
+ QTime end = ev.end();
+ int y = start.hour()*60+start.minute();
+ int h = end.hour()*60+end.minute()-y;
+ int rh = dateBook->dayView()->rowHeight(0);
+ y = y*rh/60;
+ h = h*rh/60;
+
+ 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.
+ if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview.
+ geom.setY( y );
+ geom.setHeight( h );
+ geom.setX( 0 );
+ geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
}
void DateBookDayWidget::setAllDayText( QString &text ) {
- text += "<b>" + tr("This is an all day event.") + "</b><br>";
+ text += "<b>" + tr("This is an all day event.") + "</b>";
}
void DateBookDayWidget::setEventText( QString& text ) {
- bool whichClock = dateBook->dayView()->whichClock();
- if ( ev.startDate() != ev.endDate() ) {
- text += "<b>" + tr("Start") + "</b>: ";
- text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
- text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
- text += "<b>" + tr("End") + "</b>: ";
- text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
- text += " - " + TimeString::longDateString( ev.endDate() ) + "<br>";
- } else {
- text += "<b>" + tr("Time") + "</b>: ";
- text += TimeString::timeString( ev.start(), whichClock, FALSE );
- text += "<b>" + tr(" - ") + "</b>";
- text += TimeString::timeString( ev.end(), whichClock, FALSE );
- }
+ bool whichClock = dateBook->dayView()->whichClock();
+ if ( ev.startDate() != ev.endDate() ) {
+ text += "<b>" + tr("Start") + "</b>: ";
+ text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE );
+ text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>";
+ text += "<b>" + tr("End") + "</b>: ";
+ text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE );
+ text += " - " + TimeString::longDateString( ev.endDate() );
+ } else {
+ text += "<b>" + tr("Time") + "</b>: ";
+ text += TimeString::timeString( ev.start(), whichClock, FALSE );
+ text += "<b>" + tr(" - ") + "</b>";
+ text += TimeString::timeString( ev.end(), whichClock, FALSE );
+ }
}
DateBookDayWidget::~DateBookDayWidget()
{
}
void DateBookDayWidget::paintEvent( QPaintEvent *e )
{
QPainter p( this );
if (dateBook->getSelectedWidget() == this)
{
p.setBrush( QColor( 155, 240, 230 ) ); // selected item
} else
{
if (dateBook->date() == QDate::currentDate())
{
QTime curTime = QTime::currentTime();
if (ev.end() < curTime)
{
p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
} else
{
//change color in dependence of the time till the event starts
int duration = curTime.secsTo(ev.start());
if (duration < 0) duration = 0;
int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
}
} else
{
p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
//perhaps make a distinction between future/past dates
}
}
p.setPen( QColor(100, 100, 100) );
p.drawRect(rect());
// p.drawRect(0,0, 5, height());
int y = 0;
int d = 0;
if ( ev.event().hasAlarm() ) {
p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
y = 20;
d = 20;
}
if ( ev.event().hasRepeat() ) {
p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
d = 20;
y += 20;
}
QSimpleRichText rt( text, font() );
rt.setWidth( geom.width() - d - 6 );
rt.draw( &p, 7, 0, e->region(), colorGroup() );
}
void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
{
DateBookDayWidget *item;
item = dateBook->getSelectedWidget();
if (item) item->update();
dateBook->setSelectedWidget(this);
update();
dateBook->repaint();
QPopupMenu m;
m.insertItem( tr( "Edit" ), 1 );
m.insertItem( tr( "Duplicate" ), 4 );
m.insertItem( tr( "Delete" ), 2 );
if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
int r = m.exec( e->globalPos() );
if ( r == 1 ) {
emit editMe( ev.event() );
} else if ( r == 2 ) {
emit deleteMe( ev.event() );
} else if ( r == 3 ) {
emit beamMe( ev.event() );
} else if ( r == 4 ) {
emit duplicateMe( ev.event() );
}
}
void DateBookDayWidget::setGeometry( const QRect &r )
{
geom = r;
setFixedSize( r.width()+1, r.height()+1 );
dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
show();
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
: QWidget( db->dayView()->viewport() ), dateBook( db )
{
setBackgroundMode( PaletteBase );
}
DateBookDayTimeMarker::~DateBookDayTimeMarker()
{
}
void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
{
QPainter p( this );
p.setBrush( QColor( 255, 0, 0 ) );
QPen pen;
pen.setStyle(NoPen);
p.setPen( pen );
p.drawRect(rect());
}
void DateBookDayTimeMarker::setTime( const QTime &t )
{