summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-04 16:26:39 (UTC)
committer zautrix <zautrix>2005-02-04 16:26:39 (UTC)
commitb7c502a598566264e6e7129524104b6e39438f03 (patch) (side-by-side diff)
tree9be2449e9607b7bb73f94f85ae3abb27412fe682
parent76e6ad6cc6a3be8df896a3e7cf8375234b3212a9 (diff)
downloadkdepimpi-b7c502a598566264e6e7129524104b6e39438f03.zip
kdepimpi-b7c502a598566264e6e7129524104b6e39438f03.tar.gz
kdepimpi-b7c502a598566264e6e7129524104b6e39438f03.tar.bz2
mv faster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/komonthview.cpp207
-rw-r--r--korganizer/komonthview.h10
3 files changed, 168 insertions, 51 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index e24ee43..3ba0841 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -12,2 +12,4 @@ all attendees or all selected (with RSVP) attendees.
+Made the week-month mode changing in month view faster.
+
********** VERSION 2.0.2 ************
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9c1e4c3..daa37fd 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -25,2 +25,3 @@
#include <qvbox.h>
+#include <qwidgetstack.h>
#include <qpushbutton.h>
@@ -270,4 +271,4 @@ int MonthViewItem::width(const QListBox *lb) const
-MonthViewCell::MonthViewCell( KOMonthView *parent)
- : QWidget( parent ),
+MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
+ : QWidget( par ),
mMonthView( parent )
@@ -768,2 +769,16 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
{
+
+ clPending = true;
+ mWidStack = new QWidgetStack( this );
+ QHBoxLayout* hb = new QHBoxLayout( this );
+ mMonthView = new QWidget( mWidStack );
+ mWeekView = new QWidget( mWidStack );
+#if QT_VERSION >= 0x030000
+ mWidStack->addWidget(mMonthView );
+ mWidStack->addWidget(mWeekView );
+#else
+ mWidStack->addWidget( mMonthView, 1 );
+ mWidStack->addWidget( mWeekView , 1 );
+#endif
+ hb->addWidget( mWidStack );
mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
@@ -775,6 +790,4 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
- // mDayLayout = new QGridLayout( this );
- // create the day of the week labels (Sun, Mon, etc) and add them to
- // the layout.
mDayLabels.resize( mDaysPerWeek );
+ mDayLabelsW.resize( mDaysPerWeek );
QFont bfont = font();
@@ -787,3 +800,3 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
for( i = 0; i < mDaysPerWeek; i++ ) {
- QLabel *label = new QLabel( this );
+ QLabel *label = new QLabel( mMonthView );
label->setFont(bfont);
@@ -793,2 +806,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mDayLabels.insert( i, label );
+ label = new QLabel( mWeekView );
+ label->setFont(bfont);
+ label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ label->setLineWidth(1);
+ label->setAlignment(AlignCenter);
+ mDayLabelsW.insert( i, label );
}
@@ -797,4 +816,5 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mWeekLabels.resize( mNumWeeks+1 );
+ mWeekLabelsW.resize( 2 );
for( i = 0; i < mNumWeeks+1; i++ ) {
- KOWeekButton *label = new KOWeekButton( this );
+ KOWeekButton *label = new KOWeekButton( mMonthView );
label->setFont(bfont);
@@ -808,4 +828,19 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
}
- mWeekLabels[mNumWeeks]->setText( i18n(""));
+ mWeekLabels[mNumWeeks]->setText( i18n("W"));
QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
+
+ for( i = 0; i < 1+1; i++ ) {
+ KOWeekButton *label = new KOWeekButton( mWeekView );
+ label->setFont(bfont);
+ connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
+ label->setFlat(true);
+ QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
+ //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ //label->setLineWidth(1);
+ //label->setAlignment(AlignCenter);
+ mWeekLabelsW.insert( i, label );
+ }
+ mWeekLabelsW[1]->setText( i18n("W"));
+
+
int row, col;
@@ -814,3 +849,3 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
for( col = 0; col < mDaysPerWeek; ++col ) {
- MonthViewCell *cell = new MonthViewCell( this );
+ MonthViewCell *cell = new MonthViewCell( this, mMonthView );
mCells.insert( row * mDaysPerWeek + col, cell );
@@ -825,2 +860,14 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
}
+ mCellsW.resize( mDaysPerWeek );
+ for( col = 0; col < mDaysPerWeek; ++col ) {
+ MonthViewCell *cell = new MonthViewCell( this, mWeekView );
+ mCellsW.insert( col, cell );
+
+ connect( cell, SIGNAL( defaultAction( Incidence * ) ),
+ SLOT( defaultAction( Incidence * ) ) );
+ connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
+ SIGNAL( newEventSignal( QDateTime ) ) );
+ connect( cell, SIGNAL( showDaySignal( QDate ) ),
+ SIGNAL( showDaySignal( QDate ) ) );
+ }
@@ -830,3 +877,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
- mWeekLabels[mNumWeeks]->setText( i18n("W"));
+ //mWeekLabels[mNumWeeks]->setText( i18n("W"));
+#if 0
+ mWidStack = new QWidgetStack( this );
+ mMonthView = new QWidget( mWidStack );
+ mWeekView = new QWidget( mWidStack );
+#endif
+ if ( mShowWeekView )
+ mWidStack->raiseWidget( mWeekView );
+ else
+ mWidStack->raiseWidget( mMonthView );
+
emit incidenceSelected( 0 );
@@ -844,4 +901,4 @@ void KOMonthView::selectInternalWeekNum ( int n )
{
- emit selectWeekNum ( n );
switchView();
+ emit selectWeekNum ( n );
}
@@ -850,2 +907,3 @@ void KOMonthView::switchView()
{
+
if ( selectedCell( ) )
@@ -855,4 +913,11 @@ void KOMonthView::switchView()
//emit showNavigator( !mShowWeekView );
- computeLayout();
- updateConfig();
+ if ( clPending ) {
+ computeLayout();
+ updateConfig();
+ }
+ if ( mShowWeekView )
+ mWidStack->raiseWidget( mWeekView );
+ else
+ mWidStack->raiseWidget( mMonthView );
+ clPending = false;
}
@@ -908,3 +973,3 @@ void KOMonthView::updateConfig()
mWeekStartsMonday = true;
- }
+ }
QFontMetrics fontmetric(mDayLabels[0]->font());
@@ -938,2 +1003,24 @@ void KOMonthView::updateDayLabels()
+ QPtrVector<QLabel> *mDayLabelsT;
+#if 0
+ if (mShowWeekView )
+ mDayLabelsT = &mDayLabelsW;
+ else
+ mDayLabelsT = &mDayLabels;
+#endif
+
+ mDayLabelsT = &mDayLabelsW;
+ for (int i = 0; i < 7; i++) {
+ if (mWeekStartsMonday) {
+ bool show = mShortDayLabels;
+ if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
+ show = true;
+ (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
+ } else {
+ if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
+ else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
+
+ }
+ }
+ mDayLabelsT = &mDayLabels;
for (int i = 0; i < 7; i++) {
@@ -941,8 +1028,8 @@ void KOMonthView::updateDayLabels()
bool show = mShortDayLabels;
- if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
+ if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
show = true;
- mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
+ (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
} else {
- if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
- else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
+ if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
+ else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
@@ -950,2 +1037,3 @@ void KOMonthView::updateDayLabels()
}
+
}
@@ -956,2 +1044,16 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
+ QPtrVector<MonthViewCell> *cells;
+ QPtrVector<QLabel> *dayLabels;
+ QPtrVector<KOWeekButton> *weekLabels;
+ int weekNum = 6;
+ if ( mShowWeekView ) {
+ weekNum = 1;
+ cells = &mCellsW;
+ dayLabels = &mDayLabelsW;
+ weekLabels = &mWeekLabelsW;
+ } else {
+ cells = &mCells;
+ dayLabels = &mDayLabels;
+ weekLabels = &mWeekLabels;
+ }
@@ -967,5 +1069,5 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
uint i;
- for( i = 0; i < mCells.size(); ++i ) {
+ for( i = 0; i < (*cells).size(); ++i ) {
QDate date = mStartDate.addDays( i );
- mCells[i]->setDate( date );
+ (*cells)[i]->setDate( date );
@@ -974,3 +1076,3 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
QString hstring(KOCore::self()->holiday(date));
- mCells[i]->setHoliday( hstring );
+ (*cells)[i]->setHoliday( hstring );
#endif
@@ -979,3 +1081,3 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
- for( i = 0; i < 6; ++i ) {
+ for( i = 0; i < weekNum; ++i ) {
int wno;
@@ -989,3 +1091,3 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
wno =dayOfYear / 7;
- mWeekLabels[i]->setWeekNum( wno );
+ (*weekLabels)[i]->setWeekNum( wno );
date = date.addDays( 7 );
@@ -1014,5 +1116,11 @@ void KOMonthView::updateView()
//ti.start();
+ QPtrVector<MonthViewCell> *cells;
+ if ( mShowWeekView ) {
+ cells = &mCellsW;
+ } else {
+ cells = &mCells;
+ }
#if 1
int i;
- int timeSpan = mCells.size()-1;
+ int timeSpan = (*cells).size()-1;
if ( KOPrefs::instance()->mMonthViewWeek )
@@ -1020,3 +1128,3 @@ void KOMonthView::updateView()
for( i = 0; i < timeSpan + 1; ++i ) {
- mCells[i]->startUpdateCell();
+ (*cells)[i]->startUpdateCell();
}
@@ -1049,3 +1157,3 @@ void KOMonthView::updateView()
for ( iii = st;iii<= end;++iii)
- mCells[iii]->insertEvent( event );
+ (*cells)[iii]->insertEvent( event );
}
@@ -1079,3 +1187,3 @@ void KOMonthView::updateView()
for ( iii = st;iii<= end;++iii)
- mCells[iii]->insertEvent( event );
+ (*cells)[iii]->insertEvent( event );
}
@@ -1092,3 +1200,3 @@ void KOMonthView::updateView()
if ( day >= 0 && day < timeSpan + 1) {
- mCells[day]->insertTodo( todo );
+ (*cells)[day]->insertTodo( todo );
}
@@ -1098,6 +1206,6 @@ void KOMonthView::updateView()
for( i = 0; i < timeSpan+1; ++i ) {
- mCells[i]->finishUpdateCell();
+ (*cells)[i]->finishUpdateCell();
}
processSelectionChange();
- mCells[0]->setFocus();
+ (*cells)[0]->setFocus();
@@ -1108,4 +1216,4 @@ void KOMonthView::updateView()
int i;
- for( i = 0; i < mCells.count(); ++i ) {
- mCells[i]->updateCell();
+ for( i = 0; i < (*cells).count(); ++i ) {
+ (*cells)[i]->updateCell();
}
@@ -1115,3 +1223,3 @@ void KOMonthView::updateView()
// qDebug("---------------------------------------------------------------------+ ");
- mCells[0]->setFocus();
+ (*cells)[0]->setFocus();
#endif
@@ -1124,3 +1232,7 @@ void KOMonthView::resizeEvent(QResizeEvent * e)
computeLayout();
- mCells[0]->setFocus();
+ clPending = true;
+ if ( mShowWeekView )
+ mCellsW[0]->setFocus();
+ else
+ mCells[0]->setFocus();
}
@@ -1158,3 +1270,3 @@ void KOMonthView::computeLayoutWeek()
int lastCol = wid - ( colWid*6 );
- int dayLabelHei = mDayLabels[0]->sizeHint().height();
+ int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
@@ -1179,3 +1291,3 @@ void KOMonthView::computeLayoutWeek()
if ( i >= 5 ) {
- mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
+ mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
x -= (w/2 );
@@ -1183,3 +1295,3 @@ void KOMonthView::computeLayoutWeek()
else
- mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
+ mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
x += w;
@@ -1190,5 +1302,5 @@ void KOMonthView::computeLayoutWeek()
h = cellHei;
- for ( i = 0; i < mCells.count(); ++i) {
+ for ( i = 0; i < mCellsW.count(); ++i) {
if ( i > 6 ) {
- mCells[i]->hide();
+ mCellsW[i]->hide();
continue;
@@ -1205,3 +1317,3 @@ void KOMonthView::computeLayoutWeek()
if ( i ==5 ) {
- mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
+ mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
x -= w ;y += h/2;
@@ -1211,3 +1323,3 @@ void KOMonthView::computeLayoutWeek()
}
- mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
+ mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
y -= h/2;
@@ -1215,3 +1327,3 @@ void KOMonthView::computeLayoutWeek()
} else
- mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
+ mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
@@ -1226,10 +1338,7 @@ void KOMonthView::computeLayoutWeek()
h = cellHei ;
- mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
- for ( i = 1; i < 6; i++) {
- mWeekLabels[i]->hide();
- }
- mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
+ mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
+ mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
// qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
//qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
- mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
+ mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
updateDayLabels();
@@ -1302,3 +1411,2 @@ void KOMonthView::computeLayout()
for ( i = 0; i < mCells.count(); ++i) {
- mCells[i]->show();
w = colWid;
@@ -1333,3 +1441,2 @@ void KOMonthView::computeLayout()
for ( i = 0; i < 6; i++) {
- mWeekLabels[i]->show();
if ( i == (6-rowModulo))
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 1ed200b..b89b2bc 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -27,2 +27,3 @@
#include <qpoint.h>
+#include <qwidgetstack.h>
#include <qlayout.h>
@@ -127,3 +128,3 @@ class MonthViewCell : public QWidget
public:
- MonthViewCell( KOMonthView * );
+ MonthViewCell(KOMonthView *,QWidget* );
@@ -258,2 +259,6 @@ class KOMonthView: public KOEventView
private:
+ bool clPending;
+ QWidgetStack * mWidStack;
+ QWidget* mMonthView;
+ QWidget* mWeekView;
bool mShowWeekView;
@@ -271,2 +276,5 @@ class KOMonthView: public KOEventView
QPtrVector<KOWeekButton> mWeekLabels;
+ QPtrVector<MonthViewCell> mCellsW;
+ QPtrVector<QLabel> mDayLabelsW;
+ QPtrVector<KOWeekButton> mWeekLabelsW;