summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9e32c18..1c74307 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -284,7 +284,9 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
#ifndef DESKTOP_VERSION
infrared = 0;
#endif
-
+ updateWeek( mView->startDate() );
+ connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
+ SLOT( updateWeekNum( const KCal::DateList & ) ) );
mBRdisabled = false;
//toggleBeamReceive();
}
@@ -554,6 +556,30 @@ void MainWindow::initActions()
connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
+ 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 ) ) );
// ******************
QAction *action;
QIconSet icon;
@@ -1316,9 +1342,43 @@ QString MainWindow::syncFileName()
return QString( "/tmp/synccalendar.ics" );
#endif
}
+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 ) {
enableIncidenceActions( false );