summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
committer umopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
commit3b193b852133a82b5c1708b68a7e460c63629768 (patch) (side-by-side diff)
tree8cd0ff3adc14f0b937d24ab99fca327fb3f16875
parent12a700f8903eedeba03d3aba7990b9d660410045 (diff)
downloadopie-3b193b852133a82b5c1708b68a7e460c63629768.zip
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.gz
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.bz2
UI and code cleanup. Both UI and code is now more consistent. Also removed menus in favor of toolbuttons. (why were they even available as menus in the first place?)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp276
-rw-r--r--core/pim/datebook/datebookweek.cpp179
-rw-r--r--core/pim/datebook/datebookweek.h2
-rw-r--r--core/pim/datebook/datebookweekheader.ui62
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp137
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h19
-rw-r--r--core/pim/datebook/datebookweeklst.cpp212
-rw-r--r--core/pim/datebook/datebookweeklst.h41
-rw-r--r--core/pim/datebook/datebookweeklstheader.ui127
9 files changed, 453 insertions, 602 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index cf1eeca..b7e89b0 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -78,119 +78,122 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
rowStyle( 0 ),
bJumpToCurTime(FALSE),
syncing(FALSE),
inSearch(FALSE),
alarmCounter(0)
{
- bool needEvilHack= false; // if we need an Evil Hack
- QTime t;
- t.start();
- db = new DateBookDBHack;
- qDebug("loading db t=%d", t.elapsed() );
- loadSettings();
- setCaption( tr("Calendar") );
- setIcon( Resource::loadPixmap( "datebook_icon" ) );
-
- setToolBarsMovable( FALSE );
-
- views = new QWidgetStack( this );
- setCentralWidget( views );
-
- dayView = 0;
- weekView = 0;
- weekLstView = 0;
- monthView = 0;
-
- QPEToolBar *bar = new QPEToolBar( this );
- bar->setHorizontalStretchable( TRUE );
-
- QPEMenuBar *mb = new QPEMenuBar( bar );
- mb->setMargin( 0 );
-
- QPEToolBar *sub_bar = new QPEToolBar(this);
-
- QPopupMenu *view = new QPopupMenu( this );
- QPopupMenu *settings = new QPopupMenu( this );
-
- mb->insertItem( tr( "View" ), view );
- mb->insertItem( tr( "Settings" ), settings );
-
- QActionGroup *g = new QActionGroup( this );
- g->setExclusive( TRUE );
-
- QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
- QString::null, 0, this, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
- a->addTo( sub_bar );
-
- a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
- a->addTo( sub_bar );
- a->addTo( view );
-
- a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
- a->addTo( sub_bar );
- a->addTo( view );
- a->setToggleAction( TRUE );
- a->setOn( TRUE );
- dayAction = a;
-
- a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
- a->addTo( sub_bar );
- a->addTo( view );
- a->setToggleAction( TRUE );
- weekAction = a;
-
- a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
- a->addTo( sub_bar );
- a->addTo( view );
- a->setToggleAction( TRUE );
- weekLstAction = a;
-
- a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
- a->addTo( sub_bar );
- a->addTo( view );
- a->setToggleAction( TRUE );
- monthAction = a;
-
- a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 );
- connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
- a->addTo( sub_bar );
-
- a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
- a->addTo( settings );
+ bool needEvilHack= false; // if we need an Evil Hack
+ QTime t;
+ t.start();
+ db = new DateBookDBHack;
+ qDebug("loading db t=%d", t.elapsed() );
+ loadSettings();
+ setCaption( tr("Calendar") );
+ setIcon( Resource::loadPixmap( "datebook_icon" ) );
+
+ setToolBarsMovable( FALSE );
+
+ views = new QWidgetStack( this );
+ setCentralWidget( views );
+
+ dayView = 0;
+ weekView = 0;
+ weekLstView = 0;
+ monthView = 0;
+
+// QPEToolBar *bar = new QPEToolBar( this );
+// bar->setHorizontalStretchable( TRUE );
+
+// QPEMenuBar *mb = new QPEMenuBar( bar );
+// mb->setMargin( 0 );
+
+// QPopupMenu *view = new QPopupMenu( this );
+// mb->insertItem( tr( "View" ), view );
+
+ QPEToolBar *sub_bar = new QPEToolBar(this);
+ sub_bar->setHorizontalStretchable(TRUE);
+
+ QActionGroup *g = new QActionGroup( this );
+ g->setExclusive( TRUE );
+
+ QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
+ a->addTo( sub_bar );
+
+ sub_bar->addSeparator();
+
+ a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
+ a->addTo( sub_bar );
+// a->addTo( view );
+
+ sub_bar->addSeparator();
+
+ a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
+ a->addTo( sub_bar );
+// a->addTo( view );
+ a->setToggleAction( TRUE );
+ a->setOn( TRUE );
+ dayAction = a;
+
+ a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
+ a->addTo( sub_bar );
+// a->addTo( view );
+ a->setToggleAction( TRUE );
+ weekAction = a;
+
+ a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
+ a->addTo( sub_bar );
+// a->addTo( view );
+ a->setToggleAction( TRUE );
+ weekLstAction = a;
+
+ a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
+ a->addTo( sub_bar );
+// a->addTo( view );
+ a->setToggleAction( TRUE );
+ monthAction = a;
+
+ sub_bar->addSeparator();
+
+ a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
+ a->addTo( sub_bar );
+
+ a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
+ a->addTo( sub_bar );
if(defaultView==DAY) viewDay();
if(defaultView==WEEK) needEvilHack=true; // viewWeek();
if(defaultView==WEEKLST) viewWeekLst();
if(defaultView==MONTH) viewMonth();
connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
- connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
+ connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
- connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
+ connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
#endif
// listen on QPE/System
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
- QCopChannel *channel = new QCopChannel( "QPE/System", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
- channel = new QCopChannel( "QPE/Datebook", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
- qDebug("olle\n");
+ QCopChannel *channel = new QCopChannel( "QPE/System", this );
+ connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
+ channel = new QCopChannel( "QPE/Datebook", this );
+ connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
+ qDebug("olle\n");
#endif
#endif
- qDebug("done t=%d", t.elapsed() );
+ qDebug("done t=%d", t.elapsed() );
/*
* Here is a problem description:
* When Weekview is the default view
* a DateBookWeekView get's created
* redraw() get's called. So what?
@@ -370,36 +373,29 @@ void DateBook::view(int v, const QDate &d) {
views->raiseWidget( monthView );
monthView->redraw();
}
}
void DateBook::viewDefault(const QDate &d) {
-/*
- Config config("DateBook");
- config.setGroup("Main");
- int current=config.readNumEntry("defaultview", DAY);
-
- view(current,d);
-*/
view(defaultView,d);
}
void DateBook::viewDay() {
- view(DAY,currentDate());
+ view(DAY,currentDate());
}
void DateBook::viewWeek() {
- view(WEEK,currentDate());
+ view(WEEK,currentDate());
}
void DateBook::viewWeekLst() {
- view(WEEKLST,currentDate());
+ view(WEEKLST,currentDate());
}
void DateBook::viewMonth() {
- view(MONTH,currentDate());
+ view(MONTH,currentDate());
}
void DateBook::insertEvent( const Event &e )
{
Event dupEvent=e;
dupEvent.setLocation(defaultLocation);
@@ -523,39 +519,30 @@ void DateBook::initDay()
if ( !dayView ) {
dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
views->addWidget( dayView, DAY );
dayView->setStartViewTime( startTime );
dayView->setJumpToCurTime( bJumpToCurTime );
dayView->setRowStyle( rowStyle );
- connect( this, SIGNAL( newEvent() ),
- dayView, SLOT( redraw() ) );
- connect( dayView, SIGNAL( newEvent() ),
- this, SLOT( fileNew() ) );
- connect( dayView, SIGNAL( removeEvent( const Event & ) ),
- this, SLOT( removeEvent( const Event & ) ) );
- connect( dayView, SIGNAL( editEvent( const Event & ) ),
- this, SLOT( editEvent( const Event & ) ) );
- connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
- this, SLOT( duplicateEvent( const Event & ) ) );
- connect( dayView, SIGNAL( beamEvent( const Event & ) ),
- this, SLOT( beamEvent( const Event & ) ) );
- connect( dayView, SIGNAL(sigNewEvent(const QString &)),
- this, SLOT(slotNewEventFromKey(const QString &)) );
- }
+ connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
+ connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
+ connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
+ connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
+ connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
+ connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
+ connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
+ }
}
void DateBook::initWeek()
{
if ( !weekView ) {
weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
weekView->setStartViewTime( startTime );
views->addWidget( weekView, WEEK );
- connect( weekView, SIGNAL( showDate( int, int, int ) ),
- this, SLOT( showDay( int, int, int ) ) );
- connect( this, SIGNAL( newEvent() ),
- weekView, SLOT( redraw() ) );
+ connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
+ connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
}
//But also get it right: the year that we display can be different
//from the year of the current date. So, first find the year
//number of the current week.
int yearNumber, totWeeks;
@@ -565,50 +552,38 @@ void DateBook::initWeek()
calcWeek( d, totWeeks, yearNumber, onMonday );
while ( totWeeks == 1 ) {
d = d.addDays( -1 );
calcWeek( d, totWeeks, yearNumber, onMonday );
}
- if ( totWeeks != weekView->totalWeeks() )
- weekView->setTotalWeeks( totWeeks );
}
void DateBook::initWeekLst() {
- if ( !weekLstView ) {
- weekLstView = new DateBookWeekLst( ampm, onMonday, db,
- views, "weeklst view" );
- views->addWidget( weekLstView, WEEKLST );
-
- //weekLstView->setStartViewTime( startTime );
- connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
- this, SLOT( showDay( int, int, int ) ) );
- connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
- const QDateTime &,
- const QString & , const QString &) ),
- this, SLOT( slotNewEntry( const QDateTime &,
- const QDateTime &,
- const QString & , const QString &) ) );
- connect( this, SIGNAL( newEvent() ),
- weekLstView, SLOT( redraw() ) );
- connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
- this, SLOT( editEvent( const Event & ) ) );
- }
+ if ( !weekLstView ) {
+ weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
+ views->addWidget( weekLstView, WEEKLST );
+
+ //weekLstView->setStartViewTime( startTime );
+ connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
+ connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ),
+ this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) );
+ connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
+ connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
+ }
}
void DateBook::initMonth()
{
- if ( !monthView ) {
- monthView = new DateBookMonth( views, "month view", FALSE, db );
- views->addWidget( monthView, MONTH );
- connect( monthView, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( showDay( int, int, int ) ) );
- connect( this, SIGNAL( newEvent() ),
- monthView, SLOT( redraw() ) );
- qApp->processEvents();
- }
+ if ( !monthView ) {
+ monthView = new DateBookMonth( views, "month view", FALSE, db );
+ views->addWidget( monthView, MONTH );
+ connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
+ connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
+ qApp->processEvents();
+ }
}
void DateBook::loadSettings()
{
Config qpeconfig( "qpe" );
qpeconfig.setGroup("Time");
@@ -626,12 +601,13 @@ void DateBook::loadSettings()
weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
defaultLocation=config.readEntry("defaultLocation");
QString tmpString=config.readEntry("defaultCategories");
QStringList tmpStringList=QStringList::split(",",tmpString);
defaultCategories.truncate(0);
+
for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
defaultCategories.resize(defaultCategories.count()+1);
defaultCategories[defaultCategories.count()-1]=(*i).toInt();
}
}
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 8241655..3ae4610 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -350,44 +350,34 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
: 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( int, int ) ),
- this, SLOT( dateChanged( int, int ) ) );
- connect( tHide, SIGNAL( timeout() ),
- lblDesc, SLOT( hide() ) );
- connect( header->spinYear, SIGNAL(valueChanged(int)),
- this, SLOT(slotYearChanged(int)) );
- connect( qApp, SIGNAL(weekChanged(bool)),
- this, SLOT(slotWeekChanged(bool)) );
- connect( qApp, SIGNAL(clockChanged(bool)),
- this, SLOT(slotClockChanged(bool)));
- setDate(QDate::currentDate());
-
+ 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( int, int ) ), this, SLOT( dateChanged( int, int ) ) );
+ 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:
@@ -406,84 +396,80 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e)
e->ignore();
}
}
void DateBookWeek::showDay( int day )
{
- QDate d;
- d = dateFromWeek( _week, year, bStartOnMonday );
- day--;
- d = d.addDays( day );
- emit showDate( d.year(), d.month(), d.day() );
+ QDate d;
+ d = dateFromWeek( _week, year, bStartOnMonday );
+ day--;
+ d = d.addDays( day );
+ emit showDate( d.year(), d.month(), d.day() );
}
void DateBookWeek::setDate( int y, int m, int d )
{
- QDate date;
- date.setYMD( y, m, d );
- setDate(QDate(y, m, d));
+ setDate(QDate(y, m, d));
}
void DateBookWeek::setDate(QDate date)
{
- dow = date.dayOfWeek();
- int w, y;
- calcWeek( date, w, y, bStartOnMonday );
- header->setDate( y, w );
+ dow = date.dayOfWeek();
+ int w, y;
+ calcWeek( date, w, y, bStartOnMonday );
+ header->setDate( date );
}
void DateBookWeek::dateChanged( int y, int w )
{
- year = y;
- _week = w;
- getEvents();
+ year = y;
+ _week = w;
+ getEvents();
}
QDate DateBookWeek::date() const
{
- QDate d;
- d = dateFromWeek( _week - 1, year, bStartOnMonday );
- if ( bStartOnMonday )
- d = d.addDays( 7 + dow - 1 );
- else {
- if ( dow == 7 )
- d = d.addDays( dow );
- else
- d = d.addDays( 7 + dow );
- }
- return d;
+ QDate d;
+ d = dateFromWeek( _week - 1, year, bStartOnMonday );
+ if ( bStartOnMonday )
+ d = d.addDays( 7 + dow - 1 );
+ else {
+ if ( dow == 7 )
+ d = d.addDays( dow );
+ else
+ d = d.addDays( 7 + dow );
+ }
+ return d;
}
void DateBookWeek::getEvents()
{
- QDate startWeek = weekDate();
+ QDate startWeek = weekDate();
- QDate endWeek = startWeek.addDays( 6 );
- QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek,
- endWeek);
- view->showEvents( eventList );
- view->moveToHour( startTime );
+ 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>";
+ 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::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();
@@ -563,46 +549,33 @@ void DateBookWeek::redraw()
{
getEvents();
}
void DateBookWeek::slotYearChanged( int y )
{
- int totWeek;
- QDate d( y, 12, 31 );
- int throwAway;
- calcWeek( d, totWeek, throwAway, bStartOnMonday );
- while ( totWeek == 1 ) {
- d = d.addDays( -1 );
+ int totWeek;
+ QDate d( y, 12, 31 );
+ int throwAway;
calcWeek( d, totWeek, throwAway, bStartOnMonday );
- }
- if ( totWeek != totalWeeks() )
- setTotalWeeks( totWeek );
-}
-
-
-void DateBookWeek::setTotalWeeks( int numWeeks )
-{
- header->spinWeek->setMaxValue( numWeeks );
-}
-
-int DateBookWeek::totalWeeks() const
-{
- return header->spinWeek->maxValue();
+ while ( totWeek == 1 ) {
+ d = d.addDays( -1 );
+ calcWeek( d, totWeek, throwAway, bStartOnMonday );
+ }
}
void DateBookWeek::slotWeekChanged( bool onMonday )
{
- bStartOnMonday = onMonday;
- view->setStartOfWeek( bStartOnMonday );
- header->setStartOfWeek( bStartOnMonday );
- redraw();
+ bStartOnMonday = onMonday;
+ view->setStartOfWeek( bStartOnMonday );
+ header->setStartOfWeek( bStartOnMonday );
+ redraw();
}
void DateBookWeek::slotClockChanged( bool ap )
{
- ampm = ap;
+ ampm = ap;
}
// return the date at the beginning of the week...
QDate DateBookWeek::weekDate() const
{
return dateFromWeek( _week, year, bStartOnMonday );
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index acbc2c7..8c5e06d 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -106,14 +106,12 @@ public:
void setDate( QDate d );
QDate date() const;
DateBookWeekView *weekView() const { return view; }
void setStartViewTime( int startHere );
int startViewTime() const;
int week() const { return _week; };
- void setTotalWeeks( int totalWeeks );
- int totalWeeks() const;
QDate weekDate() const;
public slots:
void redraw();
void slotWeekChanged( bool bStartOnMonday );
void slotClockChanged( bool a );
diff --git a/core/pim/datebook/datebookweekheader.ui b/core/pim/datebook/datebookweekheader.ui
index 591b625..b2e0e36 100644
--- a/core/pim/datebook/datebookweekheader.ui
+++ b/core/pim/datebook/datebookweekheader.ui
@@ -116,72 +116,12 @@
</property>
<property>
<name>toolTip</name>
<string></string>
</property>
</widget>
- <widget>
- <class>QSpinBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>spinYear</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
- </property>
- <property stdset="1">
- <name>prefix</name>
- <string>Y: </string>
- </property>
- <property stdset="1">
- <name>maxValue</name>
- <number>2037</number>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1970</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>2002</number>
- </property>
- </widget>
- <widget>
- <class>QSpinBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>spinWeek</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
- </property>
- <property stdset="1">
- <name>prefix</name>
- <string>W: </string>
- </property>
- <property stdset="1">
- <name>maxValue</name>
- <number>52</number>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>1</number>
- </property>
- </widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer1_1</cstring>
</property>
<property stdset="1">
@@ -327,9 +267,9 @@
<slot access="public">yearChanged( int )</slot>
<slot access="public">nextWeek()</slot>
<slot access="public">prevWeek()</slot>
<slot access="public">weekChanged( int )</slot>
<slot access="public">nextMonth()</slot>
<slot access="public">prevMonth()</slot>
- <slot access="public">pickDate()</slot>
+ <slot access="public">pickDate()</slot>
</connections>
</UI>
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 5f555d5..fd792e2 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -29,26 +29,22 @@
#include <qtoolbutton.h>
/*
* Constructs a DateBookWeekHeader which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
-DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
- const char* name, WFlags fl )
+DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
: DateBookWeekHeaderBase( parent, name, fl ),
bStartOnMonday( startOnMonday )
{
- setBackgroundMode( PaletteButton );
- labelDate->setBackgroundMode( PaletteButton );
-
- backmonth->setPixmap( Resource::loadPixmap("fastback") );
- backweek->setPixmap( Resource::loadPixmap("back") );
- forwardweek->setPixmap( Resource::loadPixmap("forward") );
- forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
- spinYear->hide();
- spinWeek->hide();
+ setBackgroundMode( PaletteButton );
+ labelDate->setBackgroundMode( PaletteButton );
+ backmonth->setPixmap( Resource::loadPixmap("fastback") );
+ backweek->setPixmap( Resource::loadPixmap("back") );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
}
/*
* Destroys the object and frees any allocated resources
*/
DateBookWeekHeader::~DateBookWeekHeader()
@@ -57,124 +53,87 @@ DateBookWeekHeader::~DateBookWeekHeader()
}
void DateBookWeekHeader::pickDate()
{
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
- QDate currDate = dateFromWeek( week, year, bStartOnMonday );
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
- connect( picker, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( setDate( int, int, int ) ) );
-// connect( m1, SIGNAL( aboutToHide() ),
-// this, SLOT( gotHide() ) );
+ connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) );
+// connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
}
- picker->setDate( currDate.year(), currDate.month(), currDate.day() );
+ picker->setDate( date.year(), date.month(), date.day() );
m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
picker->setFocus();
}
-/*
- * public slot
- */
-void DateBookWeekHeader::yearChanged( int y )
-{
- setDate( y, week );
-}
+
void DateBookWeekHeader::nextMonth()
{
- QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
- calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks.
- setDate( year, week ); // update view
+ setDate(date.addDays(28));
}
void DateBookWeekHeader::prevMonth()
{
- QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
- calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks
- setDate( year, week ); // update view
+ setDate(date.addDays(-28));
}
-/*
- * public slot
- */
void DateBookWeekHeader::nextWeek()
{
- QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
- calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week
-// if ( week < 52 )
-// week++;
- setDate( year, week );
+ setDate(date.addDays(7));
}
-/*
- * public slot
- */
void DateBookWeekHeader::prevWeek()
{
- QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
- calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week
-// if ( week > 1 )
-// week--;
- setDate( year, week );
-}
-/*
- * public slot
- */
-void DateBookWeekHeader::weekChanged( int w )
-{
- setDate( year, w );
+ setDate(date.addDays(-7));
}
void DateBookWeekHeader::setDate( int y, int m, int d )
{
- calcWeek( QDate(y,m,d), week, year, bStartOnMonday );
- setDate( year, week );
+ setDate(QDate(y,m,d));
}
-void DateBookWeekHeader::setDate( int y, int w )
-{
- year = y;
- week = w;
- spinYear->setValue( y );
- spinWeek->setValue( w );
-
- QDate d = dateFromWeek( week, year, bStartOnMonday );
-
- QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() )
- + "-";
- d = d.addDays( 6 );
- s += QString::number( d.day() ) + ". " + d.monthName( d.month() );
- s += " ("+tr("week")+":"+QString::number( w )+")";
- labelDate->setText( s );
+void DateBookWeekHeader::setDate(const QDate &d) {
+ int year,week,dayofweek;
+ date=d;
+ dayofweek=d.dayOfWeek();
+ if(bStartOnMonday) dayofweek--;
+ date=date.addDays(-dayofweek);
- emit dateChanged( y, w );
+ calcWeek(date,week,year,bStartOnMonday);
+ QDate start=date;
+ QDate stop=start.addDays(6);
+ labelDate->setText( QString::number(start.day()) + "." +
+ start.monthName(start.month()) + "-" +
+ QString::number(stop.day()) + "." +
+ start.monthName(stop.month()) +" ("+
+ tr("w")+":"+QString::number( week ) +")");
+ emit dateChanged(year,week);
}
void DateBookWeekHeader::setStartOfWeek( bool onMonday )
{
- bStartOnMonday = onMonday;
- setDate( year, week );
+ bStartOnMonday = onMonday;
+ setDate( date );
}
// dateFromWeek
// compute the date from the week in the year
-
QDate dateFromWeek( int week, int year, bool startOnMonday )
{
- QDate d;
- d.setYMD( year, 1, 1 );
- int dayOfWeek = d.dayOfWeek();
- if ( startOnMonday ) {
- if ( dayOfWeek <= 4 ) {
- d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
- } else {
- d = d.addDays( (week) * 7 - dayOfWeek + 1 );
- }
- } else {
- if ( dayOfWeek <= 4 || dayOfWeek == 7) {
- d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
+ QDate d;
+ d.setYMD( year, 1, 1 );
+ int dayOfWeek = d.dayOfWeek();
+ if ( startOnMonday ) {
+ if ( dayOfWeek <= 4 ) {
+ d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
+ } else {
+ d = d.addDays( (week) * 7 - dayOfWeek + 1 );
+ }
} else {
- d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
+ if ( dayOfWeek <= 4 || dayOfWeek == 7) {
+ d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
+ } else {
+ d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
+ }
}
- }
- return d;
+ return d;
}
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index 2e5a6ca..1ab1d52 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -29,38 +29,31 @@ class DateBookWeekHeader : public DateBookWeekHeaderBase
public:
DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
const char* name = 0, WFlags fl = 0 );
~DateBookWeekHeader();
- void setDate( int y, int w );
- void setStartOfWeek( bool onMonday );
+ void setDate(const QDate &d);
+ void setStartOfWeek( bool onMonday );
signals:
- void dateChanged( int y, int w );
+ void dateChanged( int y, int w );
public slots:
void pickDate();
- void yearChanged( int );
void nextMonth();
void prevMonth();
void nextWeek();
void prevWeek();
- void weekChanged( int );
void setDate( int y, int m, int d);
protected slots:
- void keyPressEvent(QKeyEvent *e)
- {
- e->ignore();
- }
+ void keyPressEvent(QKeyEvent *e) { e->ignore(); }
private:
- int year,
- week;
- bool bStartOnMonday;
-
+ QDate date;
+ bool bStartOnMonday;
};
QDate dateFromWeek( int week, int year, bool startOnMonday );
#endif // DATEBOOKDAYHEADER_H
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 3c8fc89..a39ff40 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -24,121 +24,133 @@
#include <qtoolbutton.h>
#include <qvbox.h>
#include <qsizepolicy.h>
#include <qabstractlayout.h>
#include <qtl.h>
-bool calcWeek(const QDate &d, int &week, int &year,
- bool startOnMonday = false);
+bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
-DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
- const char* name, WFlags fl)
+DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
: DateBookWeekLstHeaderBase(parent, name, fl)
{
- setBackgroundMode( PaletteButton );
- labelDate->setBackgroundMode( PaletteButton );
- labelWeek->setBackgroundMode( PaletteButton );
- forward->setBackgroundMode( PaletteButton );
- forward->setPixmap( Resource::loadPixmap("forward") );
- back->setBackgroundMode( PaletteButton );
- back->setPixmap( Resource::loadPixmap("back") );
- DateBookWeekLstHeaderBaseLayout->setSpacing(0);
- DateBookWeekLstHeaderBaseLayout->setMargin(0);
- //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
- setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
-
- connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
- connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
- connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
- connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
- onMonday=onM;
+ setBackgroundMode( PaletteButton );
+ labelDate->setBackgroundMode( PaletteButton );
+ forwardweek->setBackgroundMode( PaletteButton );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setBackgroundMode( PaletteButton );
+ forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
+ backweek->setBackgroundMode( PaletteButton );
+ backweek->setPixmap( Resource::loadPixmap("back") );
+ backmonth->setBackgroundMode( PaletteButton );
+ backmonth->setPixmap( Resource::loadPixmap("fastback") );
+ DateBookWeekLstHeaderBaseLayout->setSpacing(0);
+ DateBookWeekLstHeaderBaseLayout->setMargin(0);
+ //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
+
+ connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
+ connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
+ connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
+ connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
+ connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
+ connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
+ bStartOnMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
+
void DateBookWeekLstHeader::setDate(const QDate &d) {
- date=d;
-
- int year,week;
- calcWeek(d,week,year,onMonday);
- labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) );
-
- QDate start=date;
- QDate stop=start.addDays(6);
- labelDate->setText( QString::number(start.day()) + " " +
- start.monthName(start.month()) + " - " +
- QString::number(stop.day()) + " " +
- start.monthName(stop.month()) );
- emit dateChanged(year,week);
+ int year,week,dayofweek;
+ date=d;
+ dayofweek=d.dayOfWeek();
+ if(bStartOnMonday) dayofweek--;
+ date=date.addDays(-dayofweek);
+
+ calcWeek(date,week,year,bStartOnMonday);
+ QDate start=date;
+ QDate stop=start.addDays(6);
+ labelDate->setText( QString::number(start.day()) + "." +
+ start.monthName(start.month()) + "-" +
+ QString::number(stop.day()) + "." +
+ start.monthName(stop.month()) +" ("+
+ tr("w")+":"+QString::number( week ) +")");
+ emit dateChanged(year,week);
}
+
void DateBookWeekLstHeader::pickDate() {
- static QPopupMenu *m1 = 0;
- static DateBookMonth *picker = 0;
- if ( !m1 ) {
- m1 = new QPopupMenu( this );
- picker = new DateBookMonth( m1, 0, TRUE );
- m1->insertItem( picker );
- connect( picker, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( setDate( int, int, int ) ) );
- //connect( m1, SIGNAL( aboutToHide() ),
- //this, SLOT( gotHide() ) );
- }
- picker->setDate( date.year(), date.month(), date.day() );
- m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
- picker->setFocus();
+ static QPopupMenu *m1 = 0;
+ static DateBookMonth *picker = 0;
+ if ( !m1 ) {
+ m1 = new QPopupMenu( this );
+ picker = new DateBookMonth( m1, 0, TRUE );
+ m1->insertItem( picker );
+ connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
+ //connect( m1, SIGNAL( aboutToHide() ),
+ //this, SLOT( gotHide() ) );
+ }
+ picker->setDate( date.year(), date.month(), date.day() );
+ m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
+ picker->setFocus();
}
void DateBookWeekLstHeader::setDate(int y, int m, int d) {
- QDate new_date(y,m,d);
- setDate(new_date);
+ setDate(QDate(y,m,d));
}
void DateBookWeekLstHeader::nextWeek() {
- setDate(date.addDays(7));
+ setDate(date.addDays(7));
}
void DateBookWeekLstHeader::prevWeek() {
- setDate(date.addDays(-7));
+ setDate(date.addDays(-7));
+}
+void DateBookWeekLstHeader::nextMonth()
+{
+ setDate(date.addDays(28));
+}
+void DateBookWeekLstHeader::prevMonth()
+{
+ setDate(date.addDays(-28));
}
DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
QWidget* parent,
const char* name,
WFlags fl )
: DateBookWeekLstDayHdrBase(parent, name, fl) {
- date=d;
-
- static const char *wdays={"MTWTFSS"};
- char day=wdays[d.dayOfWeek()-1];
-
- label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +
- QString::number(d.day()) );
- add->setText("+");
-
- if (d == QDate::currentDate()) {
- QPalette pal=label->palette();
- pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
- label->setPalette(pal);
-
- /*
- QFont f=label->font();
- f.setItalic(true);
- label->setFont(f);
- label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
- */
- } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
- QPalette pal=label->palette();
- pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
- label->setPalette(pal);
- }
-
+ date=d;
+
+ static const char *wdays={"MTWTFSS"};
+ char day=wdays[d.dayOfWeek()-1];
+
+ label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
+ add->setText("+");
+
+ if (d == QDate::currentDate()) {
+ QPalette pal=label->palette();
+ pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
+ label->setPalette(pal);
+
+ /*
+ QFont f=label->font();
+ f.setItalic(true);
+ label->setFont(f);
+ label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
+ */
+ } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
+ QPalette pal=label->palette();
+ pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
+ label->setPalette(pal);
+ }
- connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
- connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
+ connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
+ connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
}
void DateBookWeekLstDayHdr::showDay() {
- emit showDate(date.year(), date.month(), date.day());
+ emit showDate(date.year(), date.month(), date.day());
}
+
void DateBookWeekLstDayHdr::newEvent() {
QDateTime start, stop;
start=stop=date;
start.setTime(QTime(10,0));
stop.setTime(QTime(12,0));
@@ -201,35 +213,34 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
{
Config config("DateBook");
config.setGroup("Main");
int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
- onMonday=onM;
+ bStartOnMonday=onM;
setPalette(white);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
QVBoxLayout *layout = new QVBoxLayout( this );
qBubbleSort(ev);
QValueListIterator<EffectiveEvent> it;
it=ev.begin();
int dayOrder[7];
- if (onMonday) {
+ if (bStartOnMonday) {
for (int d=0; d<7; d++) dayOrder[d]=d+1;
} else {
for (int d=0; d<7; d++) dayOrder[d]=d;
dayOrder[0]=7;
}
for (int i=0; i<7; i++) {
// Header
- DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this);
- connect(hdr, SIGNAL(showDate(int,int,int)),
- this, SIGNAL(showDate(int,int,int)));
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this);
+ connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
layout->addWidget(hdr);
// Events
while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
@@ -276,26 +287,24 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
QWidget *parent,
const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
- onMonday(onM)
+ bStartOnMonday(onM)
{
- setFocusPolicy(StrongFocus);
- layout = new QVBoxLayout( this );
- layout->setMargin(0);
+ setFocusPolicy(StrongFocus);
+ layout = new QVBoxLayout( this );
+ layout->setMargin(0);
- header=new DateBookWeekLstHeader(onM, this);
- layout->addWidget( header );
- connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
- connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
+ header=new DateBookWeekLstHeader(onM, this);
+ layout->addWidget( header );
+ connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
+ connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
scroll=new QScrollView(this);
- //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
- //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
scroll->setResizePolicy(QScrollView::AutoOneFit);
layout->addWidget(scroll);
view=NULL;
Config config("DateBook");
config.setGroup("Main");
@@ -307,13 +316,13 @@ DateBookWeekLst::~DateBookWeekLst(){
config.setGroup("Main");
config.writeEntry("weeklst_dbl", dbl);
}
void DateBookWeekLst::setDate(const QDate &d) {
int w,y;
- calcWeek(d,w,y,onMonday);
+ calcWeek(d,w,y,bStartOnMonday);
year=y;
_week=w;
header->setDate(date());
}
void DateBookWeekLst::setDbl(bool on) {
dbl=on;
@@ -323,13 +332,13 @@ void DateBookWeekLst::redraw() {getEvents();}
QDate DateBookWeekLst::date() const {
QDate d;
d.setYMD(year,1,1);
int dow= d.dayOfWeek();
- if (!onMonday)
+ if (!bStartOnMonday)
if (dow==7) {
dow=1;
} else {
dow++;
}
@@ -344,15 +353,15 @@ void DateBookWeekLst::getEvents() {
if (view) delete view;
if (dbl) {
QDate start2=start.addDays(7);
stop=start2.addDays(6);
QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
- view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
+ view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
} else {
- view=new DateBookWeekLstView(el,start,onMonday,scroll);
+ view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
}
connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
@@ -383,8 +392,7 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
case Key_Right:
header->nextWeek();
break;
default:
e->ignore();
}
-}
-
+} \ No newline at end of file
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 17dc01f..f858c4f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -22,22 +22,25 @@ public:
DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstHeader();
void setDate(const QDate &d);
public slots:
- void nextWeek();
- void prevWeek();
- void pickDate();
- void setDate(int y, int m, int d);
+ void nextWeek();
+ void prevWeek();
+ void nextMonth();
+ void prevMonth();
+ void pickDate();
+ void setDate(int y, int m, int d);
signals:
- void dateChanged(int y, int w);
- void setDbl(bool on);
+ void dateChanged(int y, int w);
+ void setDbl(bool on);
private:
- QDate date;
- bool onMonday;
+ QDate date;
+// bool onMonday;
+ bool bStartOnMonday;
};
class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
{
Q_OBJECT
public:
@@ -76,20 +79,20 @@ class DateBookWeekLstView: public QWidget
public:
DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstView();
signals:
- void editEvent(const Event &e);
- void showDate(int y, int m, int d);
- void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
+ void editEvent(const Event &e);
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
private:
- bool onMonday;
+ bool bStartOnMonday;
protected slots:
- void keyPressEvent(QKeyEvent *);
+ void keyPressEvent(QKeyEvent *);
};
class DateBookWeekLstDblView: public QWidget {
Q_OBJECT
public:
DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
@@ -124,22 +127,22 @@ public slots:
protected slots:
void keyPressEvent(QKeyEvent *);
void setDbl(bool on);
signals:
- void showDate(int y, int m, int d);
- void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
- void editEvent(const Event &e);
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
+ void editEvent(const Event &e);
private:
DateBookDB *db;
int startTime;
bool ampm;
- bool onMonday;
+ bool bStartOnMonday;
bool dbl;
int year, _week;
DateBookWeekLstHeader *header;
QWidget *view;
QVBoxLayout *layout;
QScrollView *scroll;
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui
index c71e046..e925ec3 100644
--- a/core/pim/datebook/datebookweeklstheader.ui
+++ b/core/pim/datebook/datebookweeklstheader.ui
@@ -38,13 +38,48 @@
<number>6</number>
</property>
<widget>
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
- <cstring>back</cstring>
+ <cstring>backmonth</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap></pixmap>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>backweek</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
@@ -76,13 +111,13 @@
</property>
<property>
<name>toolTip</name>
<string></string>
</property>
</widget>
- <spacer>
+ <spacer>
<property>
<name>name</name>
<cstring>Spacer1_3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
@@ -101,13 +136,13 @@
</property>
</spacer>
<widget>
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
- <cstring>labelWeek</cstring>
+ <cstring>labelDate</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
@@ -137,33 +172,12 @@
</property>
<property>
<name>toolTip</name>
<string></string>
</property>
</widget>
- <spacer>
- <property>
- <name>name</name>
- <cstring>Spacer1</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
- </property>
- <property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
<widget>
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
<cstring>dbl</cstring>
</property>
@@ -220,86 +234,73 @@
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
- <class>QLabel</class>
+ <class>QToolButton</class>
<property stdset="1">
<name>name</name>
- <cstring>labelDate</cstring>
+ <cstring>forwardweek</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>7</vsizetype>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
- <name>font</name>
- <font>
- <bold>1</bold>
- </font>
- </property>
- <property stdset="1">
<name>text</name>
- <string>00 Jan-00 Jan</string>
- </property>
- <property>
- <name>hAlign</name>
- </property>
- </widget>
- <spacer>
- <property>
- <name>name</name>
- <cstring>Spacer1_2</cstring>
+ <string></string>
</property>
<property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
+ <name>pixmap</name>
+ <pixmap></pixmap>
</property>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
+ <name>autoRepeat</name>
+ <bool>true</bool>
</property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
</property>
- </spacer>
+ </widget>
<widget>
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
- <cstring>forward</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
+ <cstring>forwardmonth</cstring>
</property>
<property stdset="1">
<name>text</name>
<string></string>
</property>
<property stdset="1">
<name>pixmap</name>
<pixmap></pixmap>
</property>
<property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
<name>autoRepeat</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>autoRaise</name>
<bool>true</bool>
</property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string></string>
+ </property>
</widget>
</hbox>
</widget>
</UI>