summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index e49ed28..2ad7aa9 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -31,163 +31,163 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qspinbox.h>
#include <qstyle.h>
//-----------------------------------------------------------------
DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
: ev( e )
{
// with the current implementation change the color for all day events
if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
c = Qt::green;
} else {
c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
}
}
void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
{
r.setRect( x, y, w, h );
}
//------------------=---------------------------------------------
DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
QWidget *parent, const char *name )
: QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
showingEvent( false )
{
items.setAutoDelete( true );
viewport()->setBackgroundMode( PaletteBase );
header = new QHeader( this );
header->addLabel( "" );
header->setMovingEnabled( false );
header->setResizeEnabled( false );
header->setClickEnabled( false, 0 );
initNames();
connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
QObject::connect(qApp, SIGNAL(clockChanged(bool)),
this, SLOT(slotChangeClock(bool)));
QFontMetrics fm( font() );
rowHeight = fm.height()+2;
resizeContents( width(), 24*rowHeight );
}
void DateBookWeekView::initNames()
{
static bool bFirst = true;
if ( bFirst ) {
if ( bOnMonday ) {
- header->addLabel( tr("M", "Monday" ) );
- header->addLabel( tr("T", "Tuesday") );
- header->addLabel( tr("W", "Wednesday" ) );
- header->addLabel( tr("T", "Thursday" ) );
- header->addLabel( tr("F", "Friday" ) );
- header->addLabel( tr("S", "Saturday" ) );
- header->addLabel( tr("S", "Sunday" ) );
+ header->addLabel( tr("Mo", "Monday" ) );
+ header->addLabel( tr("Tu", "Tuesday") );
+ header->addLabel( tr("We", "Wednesday" ) );
+ header->addLabel( tr("Th", "Thursday" ) );
+ header->addLabel( tr("Fr", "Friday" ) );
+ header->addLabel( tr("Sa", "Saturday" ) );
+ header->addLabel( tr("Su", "Sunday" ) );
} else {
- header->addLabel( tr("S", "Sunday" ) );
- header->addLabel( tr("M", "Monday") );
- header->addLabel( tr("T", "Tuesday") );
- header->addLabel( tr("W", "Wednesday" ) );
- header->addLabel( tr("T", "Thursday" ) );
- header->addLabel( tr("F", "Friday" ) );
- header->addLabel( tr("S", "Saturday" ) );
+ header->addLabel( tr("Su", "Sunday" ) );
+ header->addLabel( tr("Mo", "Monday") );
+ header->addLabel( tr("Tu", "Tuesday") );
+ header->addLabel( tr("We", "Wednesday" ) );
+ header->addLabel( tr("Th", "Thursday" ) );
+ header->addLabel( tr("Fr", "Friday" ) );
+ header->addLabel( tr("Sa", "Saturday" ) );
}
bFirst = false;
} else {
// we are change things...
if ( bOnMonday ) {
- header->setLabel( 1, tr("M", "Monday") );
- header->setLabel( 2, tr("T", "Tuesday") );
- header->setLabel( 3, tr("W", "Wednesday" ) );
- header->setLabel( 4, tr("T", "Thursday" ) );
- header->setLabel( 5, tr("F", "Friday" ) );
- header->setLabel( 6, tr("S", "Saturday" ) );
- header->setLabel( 7, tr("S", "Sunday" ) );
+ header->setLabel( 1, tr("Mo", "Monday") );
+ header->setLabel( 2, tr("Tu", "Tuesday") );
+ header->setLabel( 3, tr("We", "Wednesday" ) );
+ header->setLabel( 4, tr("Th", "Thursday" ) );
+ header->setLabel( 5, tr("Fr", "Friday" ) );
+ header->setLabel( 6, tr("Sa", "Saturday" ) );
+ header->setLabel( 7, tr("Su", "Sunday" ) );
} else {
- header->setLabel( 1, tr("S", "Sunday" ) );
- header->setLabel( 2, tr("M", "Monday") );
- header->setLabel( 3, tr("T", "Tuesday") );
- header->setLabel( 4, tr("W", "Wednesday" ) );
- header->setLabel( 5, tr("T", "Thursday" ) );
- header->setLabel( 6, tr("F", "Friday" ) );
- header->setLabel( 7, tr("S", "Saturday" ) );
+ header->setLabel( 1, tr("Su", "Sunday" ) );
+ header->setLabel( 2, tr("Mo", "Monday") );
+ header->setLabel( 3, tr("Tu", "Tuesday") );
+ header->setLabel( 4, tr("We", "Wednesday" ) );
+ header->setLabel( 5, tr("Th", "Thursday" ) );
+ header->setLabel( 6, tr("Fr", "Friday" ) );
+ header->setLabel( 7, tr("Sa", "Saturday" ) );
}
}
}
void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
{
items.clear();
QValueListIterator<EffectiveEvent> it;
for ( it = ev.begin(); it != ev.end(); ++it ) {
DateBookWeekItem *i = new DateBookWeekItem( *it );
if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day.
positionItem( i );
items.append( i );
}
}
viewport()->update();
}
void DateBookWeekView::moveToHour( int h )
{
int offset = h*rowHeight;
setContentsPos( 0, offset );
}
void DateBookWeekView::keyPressEvent( QKeyEvent *e )
{
e->ignore();
}
void DateBookWeekView::slotChangeClock( bool c )
{
ampm = c;
viewport()->update();
}
static inline int db_round30min( int m )
{
if ( m < 15 )
m = 0;
else if ( m < 45 )
m = 1;
else
m = 2;
return m;
}
void DateBookWeekView::alterDay( int day )
{
if ( !bOnMonday ) {
day--;
}
emit showDay( day );
}
void DateBookWeekView::positionItem( DateBookWeekItem *i )
{
const int Width = 8;
const EffectiveEvent ev = i->event();
// 30 minute intervals
int y = ev.start().hour() * 2;