From f0e656b51a2dcee1dec594636cbc1ba8d4b11eef Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 23 Jun 2002 18:18:27 +0000 Subject: Patch by to configure the size of the row of the dayview Adds an option to jump to the current time in the dayview and some small fixes ( zecke ) --- diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index c0d45c9..7dd93a6 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -80,6 +80,8 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) aPreset( FALSE ), presetTime( -1 ), startTime( 8 ), // an acceptable default + rowStyle( 0 ), + bJumpToCurTime(FALSE), syncing(FALSE), inSearch(FALSE), alarmCounter(0) @@ -249,6 +251,8 @@ void DateBook::slotSettings() DateBookSettings frmSettings( ampm, this ); frmSettings.setStartTime( startTime ); frmSettings.setAlarmPreset( aPreset, presetTime ); + frmSettings.setJumpToCurTime( bJumpToCurTime ); + frmSettings.setRowStyle( rowStyle ); #if defined (Q_WS_QWS) || defined(_WS_QWS_) frmSettings.showMaximized(); #endif @@ -257,8 +261,12 @@ void DateBook::slotSettings() aPreset = frmSettings.alarmPreset(); presetTime = frmSettings.presetTime(); startTime = frmSettings.startTime(); + bJumpToCurTime = frmSettings.jumpToCurTime(); + rowStyle = frmSettings.rowStyle(); if ( dayView ) dayView->setStartViewTime( startTime ); + dayView->setJumpToCurTime( bJumpToCurTime ); + dayView->setRowStyle( rowStyle ); if ( weekView ) weekView->setStartViewTime( startTime ); saveSettings(); @@ -453,6 +461,8 @@ void DateBook::initDay() 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() ), @@ -547,6 +557,8 @@ void DateBook::loadSettings() startTime = config.readNumEntry("startviewtime", 8); aPreset = config.readBoolEntry("alarmpreset"); presetTime = config.readNumEntry("presettime"); + bJumpToCurTime = config.readBoolEntry("jumptocurtime"); + rowStyle = config.readNumEntry("rowstyle"); } } @@ -558,6 +570,8 @@ void DateBook::saveSettings() configDB.writeEntry("startviewtime",startTime); configDB.writeEntry("alarmpreset",aPreset); configDB.writeEntry("presettime",presetTime); + configDB.writeEntry("jumptocurtime", bJumpToCurTime); + configDB.writeEntry("rowstyle", rowStyle); } void DateBook::newDefaultView(QAction *a) { diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index e7be0dd..ba8f97e 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h @@ -114,6 +114,8 @@ private: bool aPreset; // have everything set to alarm? int presetTime; // the standard time for the alarm int startTime; + int rowStyle; + bool bJumpToCurTime; //should jump to current time in dayview? bool ampm; bool onMonday; diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 609b7dc..1db3e3a 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro @@ -7,6 +7,7 @@ HEADERS = datebookday.h \ dateentryimpl.h \ datebookdayheaderimpl.h \ datebooksettings.h \ + datebooksettingsbase.h \ datebookweek.h \ datebookweeklst.h \ datebookweekheaderimpl.h \ @@ -20,6 +21,7 @@ SOURCES = main.cpp \ datebook.cpp \ dateentryimpl.cpp \ datebookdayheaderimpl.cpp \ + datebooksettingsbase.cpp \ datebooksettings.cpp \ datebookweek.cpp \ datebookweeklst.cpp \ @@ -31,7 +33,6 @@ SOURCES = main.cpp \ INTERFACES = dateentry.ui \ datebookdayheader.ui \ - datebooksettingsbase.ui \ datebookweekheader.ui \ datebookweeklstheader.ui \ datebookweeklstdayhdr.ui \ diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index c15ccef..9cc5fcd 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -60,7 +60,7 @@ DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, for ( row = 0; row < numRows(); row++ ) { tmp = new QTableItem( this, QTableItem::Never, QString::null); setItem( row, 0, tmp ); - setRowHeight( row, 40); + //setRowHeight( row, 40); } initHeader(); QObject::connect( qApp, SIGNAL(clockChanged(bool)), @@ -159,6 +159,13 @@ void DateBookDayView::keyPressEvent( QKeyEvent *e ) } } +void DateBookDayView::setRowStyle( int style ) +{ + if (style<0) style = 0; + + for (int i=0; isetDate( currDate.year(), currDate.month(), currDate.day() ); view = new DateBookDayView( ampm, this, "day view" ); + connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); connect( view, SIGNAL( sigColWidthChanged() ), @@ -193,6 +201,18 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, timeMarker = new DateBookDayTimeMarker( this ); timeMarker->setTime( QTime::currentTime() ); + rowStyle = -1; // initialize with bogus values +} + +void DateBookDay::setJumpToCurTime( bool bJump ) +{ + jumpToCurTime = bJump; +} + +void DateBookDay::setRowStyle( int style ) +{ + if (rowStyle != style) view->setRowStyle( style ); + rowStyle = style; } void DateBookDay::updateView( void ) @@ -257,15 +277,21 @@ void DateBookDay::dateChanged( int y, int m, int d ) relayoutPage(); dayView()->clearSelection(); QTableSelection ts; - ts.init( startTime, 0 ); - ts.expandTo( startTime, 0 ); + + if (jumpToCurTime && this->date() == QDate::currentDate()) + { + ts.init( QTime::currentTime().hour(), 0); + ts.expandTo( QTime::currentTime().hour(), 0); + } else + { + ts.init( startTime, 0 ); + ts.expandTo( startTime, 0 ); + } + dayView()->addSelection( ts ); selectedWidget = 0; - if (this->date() == QDate::currentDate()) - timeMarker->show(); else timeMarker->hide(); - } void DateBookDay::redraw() @@ -399,7 +425,10 @@ void DateBookDay::relayoutPage( bool fromResize ) w->setGeometry( geom ); } - view->setContentsPos( 0, startTime * view->rowHeight(0) ); + 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) ); } else { @@ -444,11 +473,18 @@ void DateBookDay::relayoutPage( bool fromResize ) w->setGeometry( geom ); } } - view->setContentsPos( 0, startTime * view->rowHeight(0) ); + + 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; } @@ -479,8 +515,17 @@ void DateBookDay::setStartViewTime( int startHere ) startTime = startHere; dayView()->clearSelection(); QTableSelection ts; - ts.init( startTime, 0 ); - ts.expandTo( startTime, 0 ); + + 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 ); } diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index db0f3b6..be7cc45 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h @@ -40,6 +40,8 @@ class DateBookDayView : public QTable public: DateBookDayView( bool hourClock, QWidget *parent, const char *name ); bool whichClock() const; + + void setRowStyle( int style ); public slots: void moveUp(); @@ -149,6 +151,8 @@ public: int startViewTime() const; void setSelectedWidget( DateBookDayWidget * ); DateBookDayWidget * getSelectedWidget( void ); + void setJumpToCurTime( bool bJump ); + void setRowStyle( int style ); public slots: void setDate( int y, int m, int d ); @@ -181,6 +185,8 @@ private: DateBookDB *db; WidgetListClass widgetList; //reimplemented QList for sorting widgets by height int startTime; + bool jumpToCurTime; //should we jump to current time in dayview? + int rowStyle; DateBookDayWidget *selectedWidget; //actual selected widget (obviously) DateBookDayTimeMarker *timeMarker; //marker for current time }; diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index c5d8ac1..49fcd17 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp @@ -133,3 +133,23 @@ void DateBookSettings::slotChangeClock( bool whichClock ) init(); setStartTime( saveMe ); } + +void DateBookSettings::setJumpToCurTime( bool bJump ) +{ + chkJumpToCurTime->setChecked( bJump ); +} + +bool DateBookSettings::jumpToCurTime() const +{ + return chkJumpToCurTime->isChecked(); +} + +void DateBookSettings::setRowStyle( int style ) +{ + comboRowStyle->setCurrentItem( style ); +} + +int DateBookSettings::rowStyle() const +{ + return comboRowStyle->currentItem(); +} diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h index ee9f39c..90a07f9 100644 --- a/core/pim/datebook/datebooksettings.h +++ b/core/pim/datebook/datebooksettings.h @@ -35,7 +35,12 @@ public: int presetTime() const; void setAlarmType( int alarmType ); int alarmType() const; - + + void setJumpToCurTime( bool bJump ); + bool jumpToCurTime() const; + void setRowStyle( int style ); + int rowStyle() const; + private slots: void slot12Hour( int ); void slotChangeClock( bool ); diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui index 0f40773..816a441 100644 --- a/core/pim/datebook/datebooksettingsbase.ui +++ b/core/pim/datebook/datebooksettingsbase.ui @@ -32,7 +32,7 @@ 0 0 - 232 + 220 290 @@ -46,16 +46,16 @@ layoutSpacing - + margin - 5 + 11 spacing - 1 + 6 - + QGroupBox name @@ -73,65 +73,102 @@ title Start viewing events - + + QLayoutWidget - margin - 11 + name + Layout6 - spacing - 6 + geometry + + 3 + 21 + 210 + 53 + - - QLayoutWidget + - name - Layout1 + margin + 0 - + + spacing + 6 + + + + name + Spacer1 + - margin - 0 + orientation + Vertical - spacing - 6 + sizeType + Expanding - - QLabel - - name - lblStartTime - - - text - Start Time: - - - - QSpinBox - - name - spinStart - - - suffix - :00 - + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout1 + + - wrapping - true + margin + 0 - maxValue - 23 + spacing + 6 - - - - + + QLabel + + name + lblStartTime + + + text + Start Time: + + + + QSpinBox + + name + spinStart + + + suffix + :00 + + + wrapping + true + + + maxValue + 23 + + + + + + - + QGroupBox name @@ -141,77 +178,207 @@ title Alarm Settings - + + QLayoutWidget - margin - 11 + name + Layout4 - spacing - 6 + geometry + + 10 + 20 + 200 + 53 + - - QLayoutWidget + + + margin + 0 + - name - Layout6 + spacing + 6 - + + + name + Spacer2 + - margin - 0 + orientation + Vertical - spacing - 6 + sizeType + Expanding - - QCheckBox - - name - chkAlarmPreset - - - text - Alarm Preset - - - - QSpinBox - - name - spinPreset - - - enabled - false - + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout6 + + - suffix - minutes + margin + 0 - maxValue - 180 + spacing + 6 - - minValue - 0 + + QCheckBox + + name + chkAlarmPreset + + + text + Alarm Preset + + + + QSpinBox + + name + spinPreset + + + enabled + false + + + suffix + minutes + + + maxValue + 180 + + + minValue + 0 + + + lineStep + 5 + + + value + 5 + + + + + + + + + QGroupBox + + name + fraMisc + + + title + Misc + + + QLayoutWidget + + name + Layout5 + + + geometry + + 10 + 40 + 170 + 24 + + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Row style: + + + + QComboBox + + + text + Default - - lineStep - 5 + + + + text + Medium - - value - 5 + + + + text + Large - - - - + + + name + comboRowStyle + + + + + + QCheckBox + + name + chkJumpToCurTime + + + geometry + + 10 + 20 + 200 + 20 + + + + text + Jump to current time (dayview) + + - + diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 8e88377..58a9c53 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -20,14 +20,14 @@ #include #include #include -#include -#include +#include +#include #include bool calcWeek(const QDate &d, int &week, int &year, bool startOnMonday = false); -DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, +DateBookWeekLstHeader::DateBookWeekLstHeader(bool /*onM*/, QWidget* parent, const char* name, WFlags fl) : DateBookWeekLstHeaderBase(parent, name, fl) { @@ -54,12 +54,12 @@ void DateBookWeekLstHeader::setDate(const QDate &d) { int year,week; calcWeek(d,week,year,onMonday); labelWeek->setText("W: " + QString::number(week)); - + QDate start=date; QDate stop=start.addDays(6); - labelDate->setText( QString::number(start.day()) + " " + + labelDate->setText( QString::number(start.day()) + " " + start.monthName(start.month()) + " - " + - QString::number(stop.day()) + " " + + QString::number(stop.day()) + " " + start.monthName(stop.month()) ); emit dateChanged(year,week); } @@ -92,9 +92,9 @@ void DateBookWeekLstHeader::prevWeek() { } DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, - QWidget* parent, - const char* name, - WFlags fl ) + QWidget* parent, + const char* name, + WFlags fl ) : DateBookWeekLstDayHdrBase(parent, name, fl) { date=d; @@ -102,7 +102,7 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, static const char *wdays="MTWTFSS"; char day=wdays[d.dayOfWeek()-1]; - label->setText( QString(QChar(day)) + " " + + label->setText( QString(QChar(day)) + " " + QString::number(d.day()) ); add->setText("+"); @@ -110,7 +110,7 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); label->setPalette(pal); - + /* QFont f=label->font(); f.setItalic(true); @@ -139,9 +139,9 @@ void DateBookWeekLstDayHdr::newEvent() { emit addEvent(start,stop,""); } -DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, - QWidget* parent, - const char* name, +DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, + QWidget* parent, + const char* name, WFlags fl) : OClickableLabel(parent,name,fl), event(ev) @@ -165,9 +165,9 @@ void DateBookWeekLstEvent::editMe() { } -DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, +DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, const QDate &d, bool onM, - QWidget* parent, + QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { @@ -176,13 +176,13 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); QVBoxLayout *layout = new QVBoxLayout( this ); - + qBubbleSort(ev); QValueListIterator it; it=ev.begin(); int dayOrder[7]; - if (onMonday) + if (onMonday) for (int d=0; d<7; d++) dayOrder[d]=d+1; else { for (int d=0; d<7; d++) dayOrder[d]=d; @@ -193,16 +193,16 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, // Header DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); - connect(hdr, SIGNAL(showDate(int,int,int)), + connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect(hdr, SIGNAL(addEvent(const QDateTime &, + connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &)), - this, SIGNAL(addEvent(const QDateTime &, + const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &))); layout->addWidget(hdr); - + // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); @@ -211,17 +211,17 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, this, SIGNAL(editEvent(const Event &))); it++; } - + layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} -DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList &ev1, - QValueList &ev2, +DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList &ev1, + QValueList &ev2, QDate &d, bool onM, - QWidget* parent, + QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { @@ -251,8 +251,8 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList &ev1, const QString &))); } -DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, - QWidget *parent, +DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, + QWidget *parent, const char *name ) : QWidget( parent, name ), db( newDB ), @@ -266,10 +266,10 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(int,int)), + connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); connect(header, SIGNAL(setDbl(bool)), - this, SLOT(setDbl(bool))); + this, SLOT(setDbl(bool))); scroll=new QScrollView(this); //scroll->setVScrollBarMode(QScrollView::AlwaysOn); @@ -310,7 +310,7 @@ QDate DateBookWeekLst::date() const { if (!onMonday) if (dow==7) dow=1; else dow++; - + d=d.addDays( (_week-1)*7 - dow + 1 ); return d; } -- cgit v0.9.0.2