author | umopapisdn <umopapisdn> | 2003-03-24 09:48:03 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-24 09:48:03 (UTC) |
commit | 1471e2c49d27b352682448e2653e59073b556abc (patch) (side-by-side diff) | |
tree | 28ba9126851cdb06fcf7e564c7ed7aa554eaee59 | |
parent | fea2436fef9e7096b31840e7170a23280f3d6e39 (diff) | |
download | opie-1471e2c49d27b352682448e2653e59073b556abc.zip opie-1471e2c49d27b352682448e2653e59073b556abc.tar.gz opie-1471e2c49d27b352682448e2653e59073b556abc.tar.bz2 |
New feature: (bug/feature request #0000227) In dayview, to icons have been added to navigate 1 week back and forward.
-rw-r--r-- | core/pim/datebook/datebookdayheader.cpp | 207 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayheader.h | 56 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayheaderimpl.cpp | 18 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayheaderimpl.h | 2 |
4 files changed, 283 insertions, 0 deletions
diff --git a/core/pim/datebook/datebookdayheader.cpp b/core/pim/datebook/datebookdayheader.cpp new file mode 100644 index 0000000..82a143f --- a/dev/null +++ b/core/pim/datebook/datebookdayheader.cpp @@ -0,0 +1,207 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'datebookdayheader.ui' +** +** Created: Mon Mar 24 10:42:07 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "datebookdayheader.h" + +#include <qbuttongroup.h> +#include <qpushbutton.h> +#include <qtoolbutton.h> +#include <qlayout.h> +#include <qvariant.h> +#include <qtooltip.h> +#include <qwhatsthis.h> +#include <qimage.h> +#include <qpixmap.h> + + +/* + * Constructs a DateBookDayHeaderBase which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DateBookDayHeaderBase::DateBookDayHeaderBase( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DateBookDayHeaderBase" ); + resize( 249, 26 ); + DateBookDayHeaderBaseLayout = new QHBoxLayout( this ); + DateBookDayHeaderBaseLayout->setSpacing( 0 ); + DateBookDayHeaderBaseLayout->setMargin( 0 ); + + backweek = new QToolButton( this, "backweek" ); + backweek->setText( tr( "" ) ); + backweek->setToggleButton( FALSE ); + backweek->setAutoRepeat( TRUE ); + backweek->setAutoRaise( TRUE ); + backweek->setToggleButton( FALSE ); + QToolTip::add( backweek, tr( "" ) ); + DateBookDayHeaderBaseLayout->addWidget( backweek ); + + back = new QToolButton( this, "back" ); + back->setText( tr( "" ) ); + back->setToggleButton( FALSE ); + back->setAutoRepeat( TRUE ); + back->setAutoRaise( TRUE ); + back->setToggleButton( FALSE ); + QToolTip::add( back, tr( "" ) ); + DateBookDayHeaderBaseLayout->addWidget( back ); + + date = new QToolButton( this, "date" ); + date->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, date->sizePolicy().hasHeightForWidth() ) ); + QFont date_font( date->font() ); + date_font.setBold( TRUE ); + date->setFont( date_font ); + date->setText( tr( "" ) ); + date->setAutoRepeat( FALSE ); + date->setAutoRaise( FALSE ); + DateBookDayHeaderBaseLayout->addWidget( date ); + + grpDays = new QButtonGroup( this, "grpDays" ); + grpDays->setFrameShape( QButtonGroup::NoFrame ); + grpDays->setFrameShadow( QButtonGroup::Plain ); + grpDays->setTitle( tr( "" ) ); + grpDays->setExclusive( TRUE ); + grpDays->setColumnLayout(0, Qt::Vertical ); + grpDays->layout()->setSpacing( 0 ); + grpDays->layout()->setMargin( 0 ); + grpDaysLayout = new QHBoxLayout( grpDays->layout() ); + grpDaysLayout->setAlignment( Qt::AlignTop ); + grpDaysLayout->setSpacing( 1 ); + grpDaysLayout->setMargin( 0 ); + + cmdDay1 = new QToolButton( grpDays, "cmdDay1" ); + cmdDay1->setText( tr( "M" ) ); + cmdDay1->setToggleButton( TRUE ); + cmdDay1->setAutoRaise( TRUE ); + cmdDay1->setToggleButton( TRUE ); + QToolTip::add( cmdDay1, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay1 ); + + cmdDay2 = new QToolButton( grpDays, "cmdDay2" ); + cmdDay2->setText( tr( "T" ) ); + cmdDay2->setToggleButton( TRUE ); + cmdDay2->setAutoRaise( TRUE ); + cmdDay2->setToggleButton( TRUE ); + QToolTip::add( cmdDay2, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay2 ); + + cmdDay3 = new QToolButton( grpDays, "cmdDay3" ); + cmdDay3->setText( tr( "W" ) ); + cmdDay3->setToggleButton( TRUE ); + cmdDay3->setAutoRaise( TRUE ); + cmdDay3->setToggleButton( TRUE ); + QToolTip::add( cmdDay3, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay3 ); + + cmdDay4 = new QToolButton( grpDays, "cmdDay4" ); + cmdDay4->setText( tr( "T" ) ); + cmdDay4->setToggleButton( TRUE ); + cmdDay4->setAutoRepeat( FALSE ); + cmdDay4->setAutoRaise( TRUE ); + cmdDay4->setToggleButton( TRUE ); + QToolTip::add( cmdDay4, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay4 ); + + cmdDay5 = new QToolButton( grpDays, "cmdDay5" ); + cmdDay5->setText( tr( "F" ) ); + cmdDay5->setToggleButton( TRUE ); + cmdDay5->setAutoRaise( TRUE ); + cmdDay5->setToggleButton( TRUE ); + QToolTip::add( cmdDay5, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay5 ); + + cmdDay6 = new QToolButton( grpDays, "cmdDay6" ); + cmdDay6->setText( tr( "S" ) ); + cmdDay6->setToggleButton( TRUE ); + cmdDay6->setAutoRaise( TRUE ); + cmdDay6->setToggleButton( TRUE ); + QToolTip::add( cmdDay6, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay6 ); + + cmdDay7 = new QToolButton( grpDays, "cmdDay7" ); + cmdDay7->setText( tr( "S" ) ); + cmdDay7->setToggleButton( TRUE ); + cmdDay7->setAutoRaise( TRUE ); + cmdDay7->setToggleButton( TRUE ); + QToolTip::add( cmdDay7, tr( "" ) ); + grpDaysLayout->addWidget( cmdDay7 ); + DateBookDayHeaderBaseLayout->addWidget( grpDays ); + + forward = new QToolButton( this, "forward" ); + forward->setText( tr( "" ) ); + forward->setAutoRepeat( TRUE ); + forward->setAutoRaise( TRUE ); + DateBookDayHeaderBaseLayout->addWidget( forward ); + + forwardweek = new QToolButton( this, "forwardweek" ); + forwardweek->setText( tr( "" ) ); + forwardweek->setAutoRepeat( TRUE ); + forwardweek->setAutoRaise( TRUE ); + DateBookDayHeaderBaseLayout->addWidget( forwardweek ); + + // signals and slots connections + connect( forwardweek, SIGNAL( clicked() ), this, SLOT( goForwardWeek() ) ); + connect( forward, SIGNAL( clicked() ), this, SLOT( goForward() ) ); + connect( back, SIGNAL( clicked() ), this, SLOT( goBack() ) ); + connect( backweek, SIGNAL( clicked() ), this, SLOT( goBackWeek() ) ); + connect( grpDays, SIGNAL( clicked(int) ), this, SLOT( setDay( int ) ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DateBookDayHeaderBase::~DateBookDayHeaderBase() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Main event handler. Reimplemented to handle application + * font changes + */ +bool DateBookDayHeaderBase::event( QEvent* ev ) +{ + bool ret = QWidget::event( ev ); + if ( ev->type() == QEvent::ApplicationFontChange ) { + QFont date_font( date->font() ); + date_font.setBold( TRUE ); + date->setFont( date_font ); + } + return ret; +} + +void DateBookDayHeaderBase::goBack() +{ + qWarning( "DateBookDayHeaderBase::goBack(): Not implemented yet!" ); +} + +void DateBookDayHeaderBase::goBackWeek() +{ + qWarning( "DateBookDayHeaderBase::goBackWeek(): Not implemented yet!" ); +} + +void DateBookDayHeaderBase::goForward() +{ + qWarning( "DateBookDayHeaderBase::goForward(): Not implemented yet!" ); +} + +void DateBookDayHeaderBase::goForwardWeek() +{ + qWarning( "DateBookDayHeaderBase::goForwardWeek(): Not implemented yet!" ); +} + +void DateBookDayHeaderBase::setDate( int, int, int ) +{ + qWarning( "DateBookDayHeaderBase::setDate( int, int, int ): Not implemented yet!" ); +} + +void DateBookDayHeaderBase::setDay( int ) +{ + qWarning( "DateBookDayHeaderBase::setDay( int ): Not implemented yet!" ); +} + diff --git a/core/pim/datebook/datebookdayheader.h b/core/pim/datebook/datebookdayheader.h new file mode 100644 index 0000000..12f6fcf --- a/dev/null +++ b/core/pim/datebook/datebookdayheader.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'datebookdayheader.ui' +** +** Created: Mon Mar 10 20:49:12 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DATEBOOKDAYHEADERBASE_H +#define DATEBOOKDAYHEADERBASE_H + +#include <qvariant.h> +#include <qwidget.h> +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QToolButton; + +class DateBookDayHeaderBase : public QWidget +{ + Q_OBJECT + +public: + DateBookDayHeaderBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DateBookDayHeaderBase(); + + QToolButton* backweek; + QToolButton* back; + QToolButton* date; + QButtonGroup* grpDays; + QToolButton* cmdDay1; + QToolButton* cmdDay2; + QToolButton* cmdDay3; + QToolButton* cmdDay4; + QToolButton* cmdDay5; + QToolButton* cmdDay6; + QToolButton* cmdDay7; + QToolButton* forward; + QToolButton* forwardweek; + +public slots: + virtual void goBackWeek(); + virtual void goBack(); + virtual void goForward(); + virtual void goForwardWeek(); + virtual void setDate( int, int, int ); + virtual void setDay( int ); + +protected: + QHBoxLayout* DateBookDayHeaderBaseLayout; + QHBoxLayout* grpDaysLayout; + bool event( QEvent* ); +}; + +#endif // DATEBOOKDAYHEADERBASE_H diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp index 7d77153..3e965f5 100644 --- a/core/pim/datebook/datebookdayheaderimpl.cpp +++ b/core/pim/datebook/datebookdayheaderimpl.cpp @@ -1,186 +1,204 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "datebookdayheaderimpl.h" #include <qpe/datebookmonth.h> #include <qpe/resource.h> #include <qpe/timestring.h> #include <qbuttongroup.h> #include <qpopupmenu.h> #include <qstringlist.h> #include <qtimer.h> #include <qtoolbutton.h> /* * Constructs a DateBookDayHeader which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ DateBookDayHeader::DateBookDayHeader( bool useMonday, QWidget* parent, const char* name ) : DateBookDayHeaderBase( parent, name ), bUseMonday( useMonday ) { connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); setupNames(); forward->setPixmap( Resource::loadPixmap( "forward" ) ); back->setPixmap( Resource::loadPixmap( "back" ) ); + forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); + backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); setBackgroundMode( PaletteButton ); grpDays->setBackgroundMode( PaletteButton ); } /* * Destroys the object and frees any allocated resources */ DateBookDayHeader::~DateBookDayHeader() { // no need to delete child widgets, Qt does it all for us } void DateBookDayHeader::setStartOfWeek( bool onMonday ) { bUseMonday = onMonday; setupNames(); setDate( currDate.year(), currDate.month(), currDate.day() ); } void DateBookDayHeader::setupNames() { if ( bUseMonday ) { cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); } else { cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); } } void DateBookDayHeader::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( currDate.year(), currDate.month(), currDate.day() ); m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); picker->setFocus(); } void DateBookDayHeader::gotHide() { // we have to redo the button... date->setDown( false ); } /* * public slot */ void DateBookDayHeader::goBack() { currDate = currDate.addDays( -1 ); setDate( currDate.year(), currDate.month(), currDate.day() ); } /* * public slot */ void DateBookDayHeader::goForward() { currDate = currDate.addDays( 1 ); setDate( currDate.year(), currDate.month(), currDate.day() ); } +/* + * public slot + */ +void DateBookDayHeader::goBackWeek() +{ + currDate = currDate.addDays( -7 ); + setDate( currDate.year(), currDate.month(), currDate.day() ); +} +/* + * public slot + */ +void DateBookDayHeader::goForwardWeek() +{ + currDate = currDate.addDays( 7 ); + setDate( currDate.year(), currDate.month(), currDate.day() ); +} /* * public slot */ void DateBookDayHeader::setDate( int y, int m, int d ) { currDate.setYMD( y, m, d ); date->setText( TimeString::shortDate( currDate ) ); int iDayOfWeek = currDate.dayOfWeek(); // cleverly adjust the day depending on how we start the week if ( bUseMonday ) iDayOfWeek--; else { if ( iDayOfWeek == 7 ) // Sunday iDayOfWeek = 0; } grpDays->setButton( iDayOfWeek ); emit dateChanged( y, m, d ); } /* * public slot */ void DateBookDayHeader::setDay( int day ) { int realDay; int dayOfWeek = currDate.dayOfWeek(); // a little adjustment is needed... if ( bUseMonday ) realDay = day + 1 ; else if ( !bUseMonday && day == 0 ) // sunday realDay = 7; else realDay = day; // special cases first... if ( realDay == 7 && !bUseMonday ) { while ( currDate.dayOfWeek() != realDay ) currDate = currDate.addDays( -1 ); } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { while ( currDate.dayOfWeek() != realDay ) currDate = currDate.addDays( 1 ); } else if ( dayOfWeek < realDay ) { while ( currDate.dayOfWeek() < realDay ) currDate = currDate.addDays( 1 ); } else if ( dayOfWeek > realDay ) { while ( currDate.dayOfWeek() > realDay ) currDate = currDate.addDays( -1 ); } // update the date... setDate( currDate.year(), currDate.month(), currDate.day() ); } diff --git a/core/pim/datebook/datebookdayheaderimpl.h b/core/pim/datebook/datebookdayheaderimpl.h index 43f3a93..a07bd67 100644 --- a/core/pim/datebook/datebookdayheaderimpl.h +++ b/core/pim/datebook/datebookdayheaderimpl.h @@ -1,57 +1,59 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DATEBOOKDAYHEADER_H #define DATEBOOKDAYHEADER_H #include "datebookdayheader.h" #include <qdatetime.h> class DateBookDayHeader : public DateBookDayHeaderBase { Q_OBJECT public: DateBookDayHeader( bool bUseMonday, QWidget* parent = 0, const char* name = 0 ); ~DateBookDayHeader(); void setStartOfWeek( bool onMonday ); public slots: void goBack(); void goForward(); + void goBackWeek(); + void goForwardWeek(); void setDate( int, int, int ); void setDay( int ); void gotHide(); signals: void dateChanged( int y, int m, int d ); private slots: void pickDate(); private: QDate currDate; bool bUseMonday; void setupNames(); }; #endif // DATEBOOKDAYHEADER_H |