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
@@ -191,193 +191,195 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
//qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
int vh = height() ;
int vw = width();
//qDebug("Toolbar hei %d ",iconToolBar->height() );
if ( iconToolBar->orientation () == Qt:: Horizontal ) {
vh -= iconToolBar->height();
} else {
vw -= iconToolBar->height();
}
//mView->setMaximumSize( splash->size() );
//mView->resize( splash->size() );
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
mView->readSettings();
bool newFile = false;
if( !QFile::exists( defaultFileName() ) ) {
QFileInfo finfo ( defaultFileName() );
QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
qDebug("oldfile %s ", oldFile.latin1());
QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
} else {
oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
}
}
mView->saveCalendar( defaultFileName() );
newFile = true;
}
QTime neededSaveTime = QDateTime::currentDateTime().time();
mView->openCalendar( defaultFileName() );
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Calendar loading time: %d ms",msNeeded );
if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
KOPrefs::instance()->setCategoryDefaults();
int count = mView->addCategories();
}
processIncidenceSelection( 0 );
connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
SLOT( processIncidenceSelection( Incidence * ) ) );
connect( mView, SIGNAL( modifiedChanged( bool ) ),
SLOT( slotModifiedChanged( bool ) ) );
connect( mView, SIGNAL( tempDisableBR(bool) ),
SLOT( disableBR(bool) ) );
connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
mView->setModified( false );
mBlockAtStartup = false;
mView->setModified( false );
setCentralWidget( mView );
globalFlagBlockStartup = 0;
mView->show();
delete splash;
if ( newFile )
mView->updateConfig();
// qApp->processEvents();
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
//fillSyncMenu();
connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
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;
}
mBRdisabled = true;
} else {
if ( mBRdisabled ) {
mBRdisabled = false;
//makes no sense,because other cal ap is probably running
// toggleBeamReceive();
}
}
#endif
}
bool MainWindow::beamReceiveEnabled()
{
#ifndef DESKTOP_VERSION
return ( infrared != 0 );
#endif
return false;
}
void MainWindow::toggleBeamReceive()
{
if ( mBRdisabled )
return;
#ifndef DESKTOP_VERSION
if ( infrared ) {
qDebug("disable BeamReceive ");
delete infrared;
infrared = 0;
brAction->setOn(false);
return;
}
qDebug("enable BeamReceive ");
brAction->setOn(true);
infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
#endif
}
void MainWindow::showMaximized ()
{
#ifndef DESKTOP_VERSION
if ( ! globalFlagBlockStartup )
if ( mClosed )
mView->goToday();
#endif
QWidget::showMaximized () ;
mClosed = false;
}
void MainWindow::closeEvent( QCloseEvent* ce )
{
if ( ! KOPrefs::instance()->mAskForQuit ) {
saveOnClose();
mClosed = true;
ce->accept();
return;
}
switch( QMessageBox::information( this, "KO/Pi",
i18n("Do you really want\nto close KO/Pi?"),
i18n("Close"), i18n("No"),
0, 0 ) ) {
case 0:
saveOnClose();
mClosed = true;
ce->accept();
break;
case 1:
ce->ignore();
@@ -461,192 +463,216 @@ void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
if ( msg == "-showList" ) {
mView->viewManager()->showListView();
}
else if ( msg == "-showDay" ) {
mView->viewManager()->showDayView();
}
else if ( msg == "-showWWeek" ) {
mView->viewManager()->showWorkWeekView();
}
else if ( msg == "-ringSync" ) {
mSyncManager->multiSync( false );
}
else if ( msg == "-showWeek" ) {
mView->viewManager()->showWeekView();
}
else if ( msg == "-showTodo" ) {
mView->viewManager()->showTodoView();
}
else if ( msg == "-showJournal" ) {
mView->dateNavigator()->selectDates( 1 );
mView->dateNavigator()->selectToday();
mView->viewManager()->showJournalView();
}
else if ( msg == "-showKO" ) {
mView->viewManager()->showNextXView();
}
else if ( msg == "-showWNext" || msg == "nextView()" ) {
mView->viewManager()->showWhatsNextView();
}
else if ( msg == "-showNextXView" ) {
mView->viewManager()->showNextXView();
}
}
showMaximized();
raise();
}
QPixmap MainWindow::loadPixmap( QString name )
{
return SmallIcon( name );
}
void MainWindow::initActions()
{
//KOPrefs::instance()->mShowFullMenu
iconToolBar->clear();
KOPrefs *p = KOPrefs::instance();
//QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
QPopupMenu *viewMenu = new QPopupMenu( this );
QPopupMenu *actionMenu = new QPopupMenu( this );
QPopupMenu *importMenu = new QPopupMenu( this );
selectFilterMenu = new QPopupMenu( this );
selectFilterMenu->setCheckable( true );
syncMenu = new QPopupMenu( this );
configureAgendaMenu = new QPopupMenu( this );
configureToolBarMenu = new QPopupMenu( this );
QPopupMenu *helpMenu = new QPopupMenu( this );
if ( KOPrefs::instance()->mShowFullMenu ) {
QMenuBar *menuBar1;
menuBar1 = menuBar();
menuBar1->insertItem( i18n("File"), importMenu );
menuBar1->insertItem( i18n("View"), viewMenu );
menuBar1->insertItem( i18n("Actions"), actionMenu );
#ifdef DESKTOP_VERSION
menuBar1->insertItem( i18n("Synchronize"), syncMenu );
menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
#else
menuBar1->insertItem( i18n("Sync"), syncMenu );
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 );
action->addTo( actionMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( edit_options() ) );
actionMenu->insertSeparator();
action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
action->addTo( actionMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( undo_delete() ) );
actionMenu->insertSeparator();
icon = loadPixmap( pathString + "newevent" );
configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
configureToolBarMenu->insertSeparator();
configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
ne_action->addTo( actionMenu );
connect( ne_action, SIGNAL( activated() ),
mView, SLOT( newEvent() ) );
icon = loadPixmap( pathString + "newtodo" );
configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
nt_action->addTo( actionMenu );
connect( nt_action, SIGNAL( activated() ),
mView, SLOT( newTodo() ) );
icon = loadPixmap( pathString + "today" );
QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
today_action->addTo( viewMenu );
connect( today_action, SIGNAL( activated() ),
mView, SLOT( goToday() ) );
viewMenu->insertSeparator();
icon = loadPixmap( pathString + "navi" );
action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
action->addTo( viewMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( toggleDateNavigatorWidget() ) );
mToggleNav = action ;
icon = loadPixmap( pathString + "filter" );
action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
action->addTo( viewMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( toggleFilter() ) );
mToggleFilter = action;
icon = loadPixmap( pathString + "allday" );
action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
action->addTo( viewMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( toggleAllDaySize() ) );
mToggleAllday = action;
connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
mToggleNav, SLOT( setEnabled ( bool ) ) );
connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
mToggleFilter, SLOT( setEnabled ( bool ) ) );
connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
mToggleAllday, SLOT( setEnabled ( bool ) ) );
viewMenu->insertSeparator();
icon = loadPixmap( pathString + "picker" );
action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
action->addTo( viewMenu );
connect( action, SIGNAL( activated() ),
mView, SLOT( showDatePicker() ) );
action->addTo( iconToolBar );
viewMenu->insertSeparator();
icon = loadPixmap( pathString + "list" );
configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
showlist_action->addTo( viewMenu );
@@ -1223,195 +1249,229 @@ void MainWindow::about()
#endif
i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
}
void MainWindow::keyBindings()
{
QString cap = i18n("KO/Pi Keys + Colors");
QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
i18n("<p><h3>In agenda view:</h3></p>\n") +
i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
i18n("<p><h3>In todo view:</h3></p>\n") +
i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
i18n("<p><h3>In list view:</h3></p>\n") +
i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
i18n("<p><b>return</b>: Select item+one step down</p>\n")+
i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
i18n("<p><b>A</b>: Show agenda view.</p>\n")+
i18n("<p><b>E</b>: Edit item</p>\n") +
i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
i18n("<p><b>White</b>: Item readonly</p>\n");
displayText( text, cap);
}
void MainWindow::aboutAutoSaving()
{
QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
}
void MainWindow::aboutKnownBugs()
{
QMessageBox* msg;
msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
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 {
if ( incidence->dtStart().time() != incidence->dtEnd().time() )
startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
"-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
bool ok;
QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
if ( ok ) {
int years = noc.date().year() - incidence->dtStart().date().year();
startString += i18n(" (%1 y.)"). arg( years );
}
}
else
startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
}
}
else
startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
if ( !incidence->location().isEmpty() )
startString += " (" +incidence->location()+")";
setCaption( incidence->summary()+startString);
enableIncidenceActions( true );
if ( incidence->type() == "Event" ) {
mShowAction->setText( i18n("Show Event...") );
mEditAction->setText( i18n("Edit Event...") );
mDeleteAction->setText( i18n("Delete Event...") );
mNewSubTodoAction->setEnabled( false );
} else if ( incidence->type() == "Todo" ) {
mShowAction->setText( i18n("Show Todo...") );
mEditAction->setText( i18n("Edit Todo...") );
mDeleteAction->setText( i18n("Delete Todo...") );
mNewSubTodoAction->setEnabled( true );
} else {
mShowAction->setText( i18n("Show...") );
mShowAction->setText( i18n("Edit...") );
mShowAction->setText( i18n("Delete...") );
mNewSubTodoAction->setEnabled( false );
}
}
void MainWindow::enableIncidenceActions( bool enabled )
{
mShowAction->setEnabled( enabled );
mEditAction->setEnabled( enabled );
mDeleteAction->setEnabled( enabled );
mCloneAction->setEnabled( enabled );
mMoveAction->setEnabled( enabled );
mBeamAction->setEnabled( enabled );
mCancelAction->setEnabled( enabled );
}
void MainWindow::importOL()
{
#ifdef _OL_IMPORT_
KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
id->exec();
delete id;
mView->updateView();
#endif
}
void MainWindow::importBday()
{
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
i18n("Import!"), i18n("Cancel"), 0,
0, 1 );