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
@@ -263,49 +263,51 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
mSyncManager->setDefaultFileName( defaultFileName());
connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
mSyncManager->fillSyncMenu();
mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
if ( showWarning ) {
KMessageBox::information( this,
"You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
qApp->processEvents();
mView->dialogManager()->showSyncOptions();
}
//US listen for result adressed from Ka/Pi
#ifndef DESKTOP_VERSION
connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
#endif
#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();
}
MainWindow::~MainWindow()
{
//qDebug("MainWindow::~MainWindow() ");
//save toolbar location
delete mCalendar;
delete mSyncManager;
#ifndef DESKTOP_VERSION
if ( infrared )
delete infrared;
#endif
}
void MainWindow::disableBR(bool b)
{
#ifndef DESKTOP_VERSION
if ( b ) {
if ( infrared ) {
toggleBeamReceive();
mBRdisabled = true;
@@ -533,48 +535,72 @@ void MainWindow::initActions()
menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
#endif
//menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
menuBar1->insertItem( i18n("Help"), helpMenu );
} else {
QPEMenuBar *menuBar1;
menuBar1 = new QPEMenuBar( iconToolBar );
QPopupMenu *menuBar = new QPopupMenu( this );
menuBar1->insertItem( i18n("ME"), menuBar);
menuBar->insertItem( i18n("File"), importMenu );
menuBar->insertItem( i18n("View"), viewMenu );
menuBar->insertItem( i18n("Actions"), actionMenu );
menuBar->insertItem( i18n("Synchronize"), syncMenu );
menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
menuBar->insertItem( i18n("Filter"),selectFilterMenu );
menuBar->insertItem( i18n("Help"), helpMenu );
//menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
menuBar1->setMaximumSize( menuBar1->sizeHint( ));
}
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;
// QPopupMenu *configureMenu= new QPopupMenu( menuBar );
configureToolBarMenu->setCheckable( true );
QString pathString = "";
if ( !p->mToolBarMiniIcons ) {
if ( QApplication::desktop()->width() < 480 )
pathString += "icons16/";
} else
pathString += "iconsmini/";
configureAgendaMenu->setCheckable( true );
int iii ;
for ( iii = 1;iii<= 10 ;++iii ){
configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
}
//configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
connect( configureAgendaMenu, SIGNAL( aboutToShow()),
this, SLOT( showConfigureAgenda( ) ) );
icon = loadPixmap( pathString + "configure" );
action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
@@ -1295,51 +1321,85 @@ void MainWindow::aboutKnownBugs()
i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
i18n("\nor report them in the bugtracker on\n") +
i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
QMessageBox::NoIcon,
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton);
msg->exec();
delete msg;
}
QString MainWindow::defaultFileName()
{
return locateLocal( "data", "korganizer/mycalendar.ics" );
}
QString MainWindow::syncFileName()
{
#ifdef DESKTOP_VERSION
return locateLocal( "tmp", "synccalendar.ics" );
#else
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 );
mNewSubTodoAction->setEnabled( false );
setCaptionToDates();
return;
}
//KGlobal::locale()->formatDateTime(nextA, true);
QString startString = "";
if ( incidence->type() != "Todo" ) {
if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
if ( incidence->doesFloat() ) {
startString += ": "+incidence->dtStartDateStr( true );
startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
} else {
startString = ": "+incidence->dtStartStr(true);
startString += " --- "+((Event*)incidence)->dtEndStr(true);
}
} else {