-rw-r--r-- | korganizer/koagendaview.cpp | 72 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 62 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 7 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 39 |
5 files changed, 71 insertions, 110 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 36c66ea..0d36946 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -427,32 +427,3 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : mAllDayAgenda->setFocusPolicy(NoFocus); - QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); - - mDummyAllDayRightL = new QLabel ( dummyAllDayRight ); - QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); - new QLabel ( dummyAllDayRight ); - mDummyAllDayRightL->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,QSizePolicy::Fixed ) ); - dummyAllDayRightB->setFlat( true ); - dummyAllDayRightB->setFocusPolicy(NoFocus); - dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 ); - - QPopupMenu * wpo = new QPopupMenu (this); - QPopupMenu * all = new QPopupMenu (this); - //wpo->insertItem( i18n("W#"), 0 ); - int first = 1; - int i; - for ( i = 1; i < 50; ++i ) { - if ( !(i%10) ) { - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); - first = i; - wpo = new QPopupMenu (this); - } - wpo->insertItem( QString::number(i), i ); - } - for ( i = 50; i < 53; ++i ) { - wpo->insertItem( QString::number(i), i); - } - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - dummyAllDayRightB->setPopup( all ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); + QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); @@ -589,16 +560,3 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : - QFont dlf = KOPrefs::instance()->mTimeLabelsFont; - QFontMetrics fm ( dlf ); - QString dayTest = "30"; - int wid = fm.width( dayTest ); - int maxWid = dummyAllDayRight->width()-2; - int fontPoint = dlf.pointSize(); - while ( wid > maxWid ) { - --fontPoint; - dlf.setPointSize( fontPoint ); - QFontMetrics f( dlf ); - wid = f.width( dayTest ); - } - mDummyAllDayRightL->setFont( dlf ); - mDummyAllDayRightL->setAlignment( AlignHCenter ); + } @@ -1110,28 +1068,2 @@ void KOAgendaView::fillAgenda() - int weekNum = 0; - QDate seda = mSelectedDates.first(); - QDate d = QDate ( seda.year(), 1,1); - seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday - if ( seda.addDays(6).year() != seda.year() ) { - if ( seda.year() != d.year() ) { - if ( d.dayOfWeek() > 4 ) - d = QDate ( seda.year(), 1,1); - else - weekNum = 1; - } else { - QDate dd( seda.year()+1, 1,1); - if ( dd.dayOfWeek() <= 4 ) - weekNum = 1; - } - } - if ( weekNum == 0 ){ - int dow = d.dayOfWeek(); - if ( dow <= 4 ) - d = d.addDays( 1-dow ); - else // 5,6,7 - d = d.addDays( 8-dow ); - // we have the first week of the year.we are on monday - weekNum = d.daysTo( seda ) / 7 +1; - } - mDummyAllDayRightL->setText( QString::number( weekNum) ); mAllDayAgenda->changeColumns(mSelectedDates.count()); diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index ba9bc93..4a058ce 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -218,3 +218,2 @@ class KOAgendaView : public KOEventView { protected: - QLabel * mDummyAllDayRightL; KOAgendaButton* getNewDaylabel(); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9e32c18..1c74307 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -286,3 +286,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : #endif - + updateWeek( mView->startDate() ); + connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), + SLOT( updateWeekNum( const KCal::DateList & ) ) ); mBRdisabled = false; @@ -556,2 +558,26 @@ void MainWindow::initActions() + menuBarWeek = new QPEMenuBar( iconToolBar ); + QPopupMenu * wpo = new QPopupMenu (this); + QPopupMenu * all = new QPopupMenu (this); + //wpo->insertItem( i18n("W#"), 0 ); + int first = 1; + int i; + for ( i = 1; i < 50; ++i ) { + if ( !(i%10) ) { + all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); + connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); + first = i; + wpo = new QPopupMenu (this); + } + wpo->insertItem( QString::number(i), i ); + } + for ( i = 50; i < 53; ++i ) { + wpo->insertItem( QString::number(i), i); + } + all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); + connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); + menuBarWeek->insertItem( "00",all,1); + menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( )); + + connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); // ****************** @@ -1318,5 +1344,39 @@ QString MainWindow::syncFileName() } +void MainWindow::updateWeek(QDate seda) +{ + int weekNum = 0; + QDate d = QDate ( seda.year(), 1,1); + seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday + if ( seda.addDays(6).year() != seda.year() ) { + if ( seda.year() != d.year() ) { + if ( d.dayOfWeek() > 4 ) + d = QDate ( seda.year(), 1,1); + else + weekNum = 1; + } else { + QDate dd( seda.year()+1, 1,1); + if ( dd.dayOfWeek() <= 4 ) + weekNum = 1; + } + } + if ( weekNum == 0 ){ + int dow = d.dayOfWeek(); + if ( dow <= 4 ) + d = d.addDays( 1-dow ); + else // 5,6,7 + d = d.addDays( 8-dow ); + // we have the first week of the year.we are on monday + weekNum = d.daysTo( seda ) / 7 +1; + } + //qDebug("weeknum %s ", QString::number( weekNum).latin1()); + menuBarWeek-> changeItem(1, QString::number( weekNum) ); +} +void MainWindow::updateWeekNum(const DateList &selectedDates) +{ + updateWeek( selectedDates.first() ); +} void MainWindow::processIncidenceSelection( Incidence *incidence ) { + if ( !incidence ) { diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 8dd55ac..076ab94 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -25,2 +25,3 @@ class KSyncProfile; class QPEToolBar; +class QPEMenuBar; @@ -44,2 +45,4 @@ class MainWindow : public QMainWindow public slots: + void updateWeekNum(const KCal::DateList &); + void updateWeek(QDate); virtual void showMaximized (); @@ -86,3 +89,4 @@ class MainWindow : public QMainWindow void disableBR(bool); - + signals: + void selectWeek ( int ); private slots: @@ -118,2 +122,3 @@ class MainWindow : public QMainWindow QAction *mNewSubTodoAction; + QPEMenuBar *menuBarWeek; diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 24de01f..657f98d 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp @@ -74,4 +74,3 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam #endif - bool insertWeek = (QString ( name ) == QString("useBigPixmaps")) ; - if ( insertWeek && QApplication::desktop()->width() > 320 ) + if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) isDesktop = true; @@ -91,9 +90,2 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam - QPushButton * selWeek = 0; - if ( insertWeek ) { - selWeek = new QPushButton( mCtrlFrame ); - QToolTip::add( selWeek, i18n("Select Week") ); - selWeek->setFocusPolicy(NoFocus); - } - mNextYear = new QPushButton( mCtrlFrame ); @@ -113,5 +105,3 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam mPrevYear->setFlat( true); - mPrevMonth->setFlat( true); - if ( insertWeek ) - selWeek->setFlat( true); + mPrevMonth->setFlat( true); } @@ -137,25 +127,2 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam - if ( insertWeek ) { - QPopupMenu * wpo = new QPopupMenu (this); - QPopupMenu * all = new QPopupMenu (this); - //wpo->insertItem( i18n("W#"), 0 ); - int first = 1; - for ( i = 1; i < 50; ++i ) { - if ( !(i%10) ) { - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); - first = i; - wpo = new QPopupMenu (this); - } - wpo->insertItem( QString::number(i), i ); - } - for ( i = 50; i < 53; ++i ) { - wpo->insertItem( QString::number(i), i); - } - all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); - selWeek->setPopup( all ); - selWeek->setFixedWidth( (size/5)*4 ); - selWeek->setFixedHeight( size ); - connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); - } mSelectMonth->setFixedWidth( maxwidth ); @@ -178,4 +145,2 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam ctrlLayout->addWidget( mNextYear, 3 ); - if ( insertWeek ) - ctrlLayout->addWidget( selWeek ); |