summaryrefslogtreecommitdiff
path: root/core
Side-by-side diff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 12f57a0..e49ed28 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -315,193 +315,192 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
QListIterator<DateBookWeekItem> it(items);
for ( ; it.current(); ++it ) {
DateBookWeekItem *i = it.current();
if ( i->geometry().intersects( ur ) ) {
p->setBrush( i->color() );
p->drawRect( i->geometry() );
}
}
}
void DateBookWeekView::resizeEvent( QResizeEvent *e )
{
const int hourWidth = 20;
QScrollView::resizeEvent( e );
int avail = width()-qApp->style().scrollBarExtent().width()-1;
header->setGeometry( 0, 0, avail, header->sizeHint().height() );
setMargins( 0, header->height(), 0, 0 );
header->resizeSection( 0, hourWidth );
int sw = (avail - hourWidth) / 7;
for ( int i = 1; i < 7; i++ )
header->resizeSection( i, sw );
header->resizeSection( 7, avail - hourWidth - sw*6 );
}
void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
{
bOnMonday = bStartOnMonday;
initNames();
}
//-------------------------------------------------------------------
DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
QWidget *parent, const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday( startOnMonday )
{
setFocusPolicy(StrongFocus);
QVBoxLayout *vb = new QVBoxLayout( this );
header = new DateBookWeekHeader( bStartOnMonday, this );
view = new DateBookWeekView( ampm, startOnMonday, this );
vb->addWidget( header );
vb->addWidget( view );
lblDesc = new QLabel( this, "event label" );
lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
lblDesc->setBackgroundColor( yellow );
lblDesc->hide();
tHide = new QTimer( this );
connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) );
connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
setDate(QDate::currentDate());
}
void DateBookWeek::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Up:
view->scrollBy(0, -20);
break;
case Key_Down:
view->scrollBy(0, 20);
break;
case Key_Left:
setDate(date().addDays(-7));
break;
case Key_Right:
setDate(date().addDays(7));
break;
default:
e->ignore();
}
}
void DateBookWeek::showDay( int day )
{
QDate d=bdate;
// Calculate offset to first day of week.
int dayoffset=d.dayOfWeek();
if(bStartOnMonday) dayoffset--;
day--;
d=d.addDays(day-dayoffset);
emit showDate( d.year(), d.month(), d.day() );
- qDebug("%4d-%02d-%02d / Day %d\n",d.year(),d.month(),d.day(),day);
}
void DateBookWeek::setDate( int y, int m, int d )
{
setDate(QDate(y, m, d));
}
void DateBookWeek::setDate(QDate newdate)
{
bdate=newdate;
dow = newdate.dayOfWeek();
header->setDate( newdate );
}
void DateBookWeek::dateChanged( QDate &newdate )
{
bdate=newdate;
getEvents();
}
QDate DateBookWeek::date() const
{
return bdate;
}
void DateBookWeek::getEvents()
{
QDate startWeek = weekDate();
QDate endWeek = startWeek.addDays( 6 );
QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
view->showEvents( eventList );
view->moveToHour( startTime );
}
void DateBookWeek::generateAllDayTooltext( QString& text ) {
text += "<b>" + tr("This is an all day event.") + "</b><br>";
}
void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
str += "<b>" + QObject::tr("Start") + "</b>: ";
str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
if( ev.startDate()!=ev.endDate() ) {
str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
}
str += "<br>";
str += "<b>" + QObject::tr("End") + "</b>: ";
str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
if( ev.startDate()!=ev.endDate() ) {
str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
}
}
void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
{
if ( tHide->isActive() )
tHide->stop();
// 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 strLocation = ev.location();
while ( where != -1 ) {
strLocation.remove( where, 1 );
strLocation.insert( where, "&#60;" );
where = strLocation.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 str = "<b>" + strDesc + "</b><br>"
+ strLocation + "<br>"
+ "<i>" + strCat + "</i>"