-rw-r--r-- | korganizer/calendarview.cpp | 28 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 27 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 |
3 files changed, 43 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 73aa733..a330414 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3688,395 +3688,417 @@ void CalendarView::updateFilter() if (mFilterView->filtersEnabled()) { mess = i18n("Filter selected: ")+filter->name(); filter->setEnabled(true); } else filter->setEnabled(false); mCalendar->setFilter(filter); updateView(); if ( !mess.isEmpty() ) topLevelWidget()->setCaption( mess ); } } void CalendarView::filterEdited() { mFilterView->updateFilters(); updateFilter(); writeSettings(); } void CalendarView::takeOverEvent() { Incidence *incidence = currentSelection(); if (!incidence) return; incidence->setOrganizer(KOPrefs::instance()->email()); incidence->recreate(); incidence->setReadOnly(false); updateView(); } void CalendarView::takeOverCalendar() { // TODO: Create Calendar::allIncidences() function and use it here QPtrList<Event> events = mCalendar->events(); for(uint i=0; i<events.count(); ++i) { events.at(i)->setOrganizer(KOPrefs::instance()->email()); events.at(i)->recreate(); events.at(i)->setReadOnly(false); } QPtrList<Todo> todos = mCalendar->todos(); for(uint i=0; i<todos.count(); ++i) { todos.at(i)->setOrganizer(KOPrefs::instance()->email()); todos.at(i)->recreate(); todos.at(i)->setReadOnly(false); } QPtrList<Journal> journals = mCalendar->journals(); for(uint i=0; i<journals.count(); ++i) { journals.at(i)->setOrganizer(KOPrefs::instance()->email()); journals.at(i)->recreate(); journals.at(i)->setReadOnly(false); } updateView(); } void CalendarView::showIntro() { kdDebug() << "To be implemented." << endl; } QWidgetStack *CalendarView::viewStack() { return mRightFrame; } QWidget *CalendarView::leftFrame() { return ( QWidget *)mLeftFrame; } DateNavigator *CalendarView::dateNavigator() { return mNavigator; } KDateNavigator* CalendarView::dateNavigatorWidget() { return mDateNavigator->navigatorView(); } void CalendarView::toggleDateNavigatorWidget() { KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; if (!KOPrefs::instance()->mShowDateNavigator ) mDateNavigator->hide(); else mDateNavigator->show(); } void CalendarView::addView(KOrg::BaseView *view) { mViewManager->addView(view); } void CalendarView::showView(KOrg::BaseView *view) { mViewManager->showView(view, mLeftFrame->isVisible()); } Incidence *CalendarView::currentSelection() { return mViewManager->currentSelection(); } void CalendarView::toggleAllDaySize() { /* if ( KOPrefs::instance()->mAllDaySize > 47 ) KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; else KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; */ viewManager()->agendaView()->toggleAllDay(); } void CalendarView::toggleExpand() { // if ( mLeftFrame->isHidden() ) { // mLeftFrame->show(); // emit calendarViewExpanded( false ); // } else { // mLeftFrame->hide(); // emit calendarViewExpanded( true ); // } //qDebug(" CalendarView::toggleExpand()"); globalFlagBlockAgenda = 1; emit calendarViewExpanded( !mLeftFrame->isHidden() ); globalFlagBlockAgenda = 5; mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); //mViewManager->showView( 0, true ); } void CalendarView::calendarModified( bool modified, Calendar * ) { setModified( modified ); } Todo *CalendarView::selectedTodo() { Incidence *incidence = currentSelection(); if ( incidence && incidence->type() == "Todo" ) { return static_cast<Todo *>( incidence ); } incidence = mTodoList->selectedIncidences().first(); if ( incidence && incidence->type() == "Todo" ) { return static_cast<Todo *>( incidence ); } return 0; } void CalendarView::dialogClosing(Incidence *in) { // mDialogList.remove(in); } void CalendarView::showIncidence() { mViewerCallerIsSearchDialog = false; Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { ShowIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::editIncidenceDescription() { mFlagEditDescription = true; editIncidence(); mFlagEditDescription = false; } void CalendarView::editIncidence() { // qDebug("editIncidence() "); Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { EditIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::deleteIncidence() { Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { deleteIncidence(incidence); } } void CalendarView::showIncidence(Incidence *incidence) { mViewerCallerIsSearchDialog = false; //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); if ( sender() && mDialogManager->getSearchDialog() ) { if ( sender () == mDialogManager->getSearchDialog()->listview() ) { mViewerCallerIsSearchDialog = true; } } if ( incidence ) { ShowIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::editIncidence(Incidence *incidence) { if ( incidence ) { EditIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::deleteIncidence(Incidence *incidence) { //qDebug(" CalendarView::deleteIncidence "); if ( incidence ) { DeleteIncidenceVisitor v; v.act( incidence, this ); } } void CalendarView::lookForOutgoingMessages() { OutgoingDialog *ogd = mDialogManager->outgoingDialog(); ogd->loadMessages(); } void CalendarView::lookForIncomingMessages() { IncomingDialog *icd = mDialogManager->incomingDialog(); icd->retrieve(); } bool CalendarView::removeCompletedSubTodos( Todo* t ) { bool deleteTodo = true; QPtrList<Incidence> subTodos; Incidence *aTodo; subTodos = t->relations(); for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { if (! removeCompletedSubTodos( (Todo*) aTodo )) deleteTodo = false; } if ( deleteTodo ) { if ( t->isCompleted() && !t->doesRecur()) { checkExternalId( t ); mCalendar->deleteTodo( t ); changeTodoDisplay( t,KOGlobals::EVENTDELETED ); } else deleteTodo = false; } return deleteTodo; } void CalendarView::purgeCompleted() { int result = KMessageBox::warningContinueCancel(this, i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); if (result == KMessageBox::Continue) { QPtrList<Todo> todoCal; QPtrList<Todo> rootTodos; //QPtrList<Incidence> rel; Todo *aTodo;//, *rTodo; Incidence *rIncidence; bool childDelete = false; bool deletedOne = true; todoCal = calendar()->todos(); for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { if ( !aTodo->relatedTo() ) rootTodos.append( aTodo ); } for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { removeCompletedSubTodos( aTodo ); } updateView(); } } void CalendarView::slotCalendarChanged() { ; } void CalendarView::keyPressEvent ( QKeyEvent *e) { //qDebug(" alendarView::keyPressEvent "); e->ignore(); } bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) { // mSyncManager = manager; if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { qDebug("KO: SyncKDE request detected!"); } mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); return syncCalendar( filename, mode ); } bool CalendarView::syncExternal(KSyncManager* manager, QString resource) { //mSyncManager = manager; mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); if ( resource == "sharp" ) syncExternal( 0 ); if ( resource == "phone" ) syncExternal( 1 ); // pending setmodified return true; } void CalendarView::setSyncManager(KSyncManager* manager) { mSyncManager = manager; } void CalendarView::removeSyncInfo( QString syncProfile) { qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); mCalendar->removeSyncInfo( syncProfile ); } void CalendarView::undo_delete() { //qDebug("undo_delete() "); Incidence* undo = mCalendar->undoIncidence(); if ( !undo ) { KMessageBox::sorry(this,i18n("There is nothing to undo!"), i18n("KO/Pi")); return; } if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + i18n("\nAre you sure you want\nto restore this?"), i18n("KO/Pi Confirmation"),i18n("Restore"))) { mCalendar->undoDeleteIncidence(); updateView(); } } void CalendarView::slotViewerClosed() { QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); } void CalendarView::resetFocus() { if ( mViewerCallerIsSearchDialog ) { if ( mDialogManager->getSearchDialog()->isVisible() ){ mDialogManager->getSearchDialog()->raise(); mDialogManager->getSearchDialog()->setActiveWindow(); mDialogManager->getSearchDialog()->listview()->resetFocus(); } else mViewerCallerIsSearchDialog = false; } if ( !mViewerCallerIsSearchDialog ) { //mViewManager->currentView()->setFocus(); //qDebug("sssssssssssssssset focus "); topLevelWidget()->raise(); setActiveWindow(); //setFocus(); } mViewerCallerIsSearchDialog = false; } void CalendarView::showNextAlarms() { QString message; - if ( mNextAlarmDateTime > QDateTime::currentDateTime() ) { + QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); + if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { QString sum = mCalendar->nextSummary(); QDateTime nextA = mNextAlarmDateTime; - QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); - message = i18n("The next alarm is on:\n%1\nat: %2\n\n%3\n(%4)").arg( KGlobal::locale()->formatDate(nextA.date() , false)).arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; + QDateTime cur = QDateTime::currentDateTime(); + int secs = cur.secsTo( nextA ); + int min = secs /60; + int hours = min /60; + min = min % 60; + int days = hours /24; + hours = hours % 24; + + message = i18n("The next alarm is in:\n"); + if ( days > 1 ) + message += i18n("%1 days\n").arg( days ); + else if ( days == 1 ) + message += i18n("1 day\n"); + if ( hours > 1 ) + message += i18n("%1 hours\n").arg( hours ); + else if ( hours == 1 ) + message += i18n("1 hour\n"); + if ( min > 1 ) + message += i18n("%1 minutes\n").arg( min ); + else if ( min == 1 ) + message += i18n("1 minute\n"); + + message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; } else { message = i18n("There is no next alarm."); } KMessageBox::information( this, message); } diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 18f242c..f6f390b 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1,1227 +1,1224 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qhbox.h> #include <qvbox.h> #include <qlabel.h> #include <qframe.h> #include <qlayout.h> #ifndef KORG_NOSPLITTER #include <qsplitter.h> #endif #include <qfont.h> #include <qfontmetrics.h> #include <qpopupmenu.h> #include <qtooltip.h> #include <qpainter.h> #include <qpushbutton.h> #include <qapplication.h> #include <kapplication.h> #include <KDGanttMinimizeSplitter.h> #include <kdebug.h> #include <kstandarddirs.h> #include <kiconloader.h> #include <klocale.h> #include <kconfig.h> #include <kglobal.h> #include "calendarview.h" #include "koviewmanager.h" #include <libkcal/calendar.h> #include <libkcal/icaldrag.h> #include <libkcal/dndfactory.h> #include <kcalendarsystem.h> #include "koglobals.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koprefs.h" #include "koagenda.h" #include "koagendaitem.h" #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koagendaview.h" //#include "koagendaview.moc" //extern bool globalFlagBlockPainting; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockLabel; using namespace KOrg; TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { mRows = rows; setMinimumHeight( 20 ); mCellHeight = KOPrefs::instance()->mHourSize*4; enableClipper(true); setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); resizeContents(50,mRows * mCellHeight); viewport()->setBackgroundMode( PaletteBackground ); } void TimeLabels::setCellHeight(int height) { mCellHeight = height; } /* Optimization so that only the "dirty" portion of the scroll view is redrawn. Unfortunately, this is not called by default paintEvent() method. */ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) { // if ( globalFlagBlockAgenda ) // return; // bug: the parameters cx, cy, cw, ch are the areas that need to be // redrawn, not the area of the widget. unfortunately, this // code assumes the latter... // now, for a workaround... // these two assignments fix the weird redraw bug cx = contentsX() + 2; cw = contentsWidth() - 2; // end of workaround int cell = ((int)(cy/mCellHeight)); int y = cell * mCellHeight; QFontMetrics fm = fontMetrics(); QString hour; QString suffix; - QString fullTime; int tW = fm.width("24:00i"); int timeHeight = fm.height(); //timeHeight -= (timeHeight/4-2); int borderWidth = 0; QFont nFont = p->font(); if (!KGlobal::locale()->use12Clock()) suffix = "00"; else borderWidth = 0; if ( timeHeight > mCellHeight ) { timeHeight = mCellHeight-1; int pointS = nFont.pointSize(); while ( pointS > 4 ) { nFont.setPointSize( pointS ); fm = QFontMetrics( nFont ); if ( fm.height() < mCellHeight ) break; -- pointS; } fm = QFontMetrics( nFont ); borderWidth = 4; timeHeight = fm.height(); } timeHeight -= (timeHeight/4-2); QFont sFont = nFont; sFont.setPointSize( sFont.pointSize()/2+2 ); QFontMetrics fmS( sFont ); int sHei = fmS.height(); - + sHei -= (sHei/4-2); + int startW = this->width() - frameWidth(); while (y < cy + ch) { p->drawLine(cx,y,cx+tW,y); hour.setNum(cell); // handle 24h and am/pm time formats if (KGlobal::locale()->use12Clock()) { if (cell > 11) suffix = "pm"; else suffix = "am"; if (cell == 0) hour.setNum(12); if (cell > 12) hour.setNum(cell - 12); } - // create string in format of "XX:XX" or "XXpm/am" - fullTime = hour;// + suffix; - // center and draw the time label - int timeWidth = fm.width(fullTime+"i"); + int timeWidth = fm.width(hour+"i"); int tw2 = fm.width(suffix); - int offset = this->width() - timeWidth - tw2; + int offset = startW - timeWidth - tw2 ; p->setFont( nFont ); - p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); + p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); p->setFont( sFont ); - offset += timeWidth; + offset = startW - tw2-1; p->drawText(cx - borderWidth + offset, y+ sHei, suffix); // increment indices y += mCellHeight; cell++; } } /** Calculates the minimum width. */ int TimeLabels::minimumWidth() const { return mMiniWidth; } /** updates widget's internal state */ void TimeLabels::updateConfig() { // set the font // config->setGroup("Fonts"); // QFont font = config->readFontEntry("TimeBar Font"); setFont(KOPrefs::instance()->mTimeBarFont); - mMiniWidth = fontMetrics().width("88:88") + 2 ; + QString test = "88:88"; + if (KGlobal::locale()->use12Clock()) + test += "i"; + mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; // update geometry restrictions based on new settings setFixedWidth(minimumWidth()); // update HourSize mCellHeight = KOPrefs::instance()->mHourSize*4; resizeContents(50,mRows * mCellHeight); } /** update time label positions */ void TimeLabels::positionChanged() { int adjustment = mAgenda->contentsY(); setContentsPos(0, adjustment); } /** */ void TimeLabels::setAgenda(KOAgenda* agenda) { mAgenda = agenda; } void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) { mMouseDownY = e->pos().y(); mOrgCap = topLevelWidget()->caption(); } void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) { int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize-2)/2; topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); } void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) { topLevelWidget()->setCaption( mOrgCap ); int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10); if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize/2)*2; if ( tSize == KOPrefs::instance()->mHourSize ) return; KOPrefs::instance()->mHourSize = tSize; emit scaleChanged(); } /** This is called in response to repaint() */ void TimeLabels::paintEvent(QPaintEvent*) { // kdDebug() << "paintevent..." << endl; // this is another hack! // QPainter painter(this); //QString c repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); } //////////////////////////////////////////////////////////////////////////// EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) : QFrame(parent,name) { mColumns = 1; mTopBox = 0; mLocation = loc; mTopLayout = 0; mPaintWidget = 0; mXOffset = 0; if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); else mPixmap = SmallIcon("1downarrow"); mEnabled.resize(mColumns); mEnabled.fill( false ); setMinimumHeight(mPixmap.height()); } EventIndicator::~EventIndicator() { } void EventIndicator::drawContents(QPainter *p) { // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; KDGanttSplitterHandle* han = 0; if ( mPaintWidget ) han = mPaintWidget->firstHandle(); if ( ! han ) { int i; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : i*cellWidth + (cellWidth -mPixmap.width()) /2; p->drawPixmap(QPoint(1+xOffset,0),mPixmap); } } } else { han->repaint(); //mPaintWidget->setBackgroundColor( red ); QPainter pa( han ); int i; bool setColor = false; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { setColor = true; int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : i*cellWidth + cellWidth/2 -mPixmap.width()/2; pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); //qDebug("222draw pix %d ",xOffset ); } } pa.end(); } } void EventIndicator::setXOffset( int x ) { mXOffset = x; } void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) { mPaintWidget = w; setMaximumHeight(0); setMinimumHeight(0); } void EventIndicator::changeColumns(int columns) { mColumns = columns; mEnabled.resize(mColumns); update(); } void EventIndicator::enableColumn(int column, bool enable) { mEnabled[column] = enable; } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : KOEventView (cal,parent,name) { mBlockUpdating = true; mStartHour = 8; mSelectedDates.append(QDate::currentDate()); mLayoutDayLabels = 0; mDayLabelsFrame = 0; mDayLabels = 0; bool isRTL = KOGlobals::self()->reverseLayout(); QPixmap expandPix; if ( KOPrefs::instance()->mVerticalScreen ) { expandPix = SmallIcon( "1updownarrow" ); } else { expandPix = SmallIcon("1leftrightarrow" ); } QBoxLayout *topLayout = new QVBoxLayout(this); // Create day name labels for agenda columns // Create agenda splitter mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); topLayout->addWidget( mSplitterAgenda ); mAllDayFrame = new QHBox(mSplitterAgenda); mAllDayFrame->setFocusPolicy(NoFocus); QWidget *agendaFrame = new QWidget(mSplitterAgenda); agendaFrame->setFocusPolicy(NoFocus); // Create all-day agenda widget mDummyAllDayLeft = new QVBox( mAllDayFrame ); mExpandButton = new QPushButton(mDummyAllDayLeft); mExpandButton->setPixmap( expandPix ); int widebut = mExpandButton->sizeHint().width()+4; int heibut = mExpandButton->sizeHint().height()+4; if ( heibut > widebut ) widebut = heibut ; if ( QApplication::desktop()->width() < 480 ) widebut = widebut*3/2; //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, // QSizePolicy::Fixed ) ); mExpandButton->setFixedSize( widebut, widebut); connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); mExpandButton->setFocusPolicy(NoFocus); mAllDayAgenda = new KOAgenda(1,mAllDayFrame); mAllDayAgenda->setFocusPolicy(NoFocus); QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); // Create event context menu for all day agenda mAllDayAgendaPopup = eventPopup(); connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); // Create agenda frame QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); // QHBox *agendaFrame = new QHBox(splitterAgenda); // create event indicator bars mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); #ifndef DESKTOP_VERSION // FIX mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); #endif mDayLabelsFrame = new QHBox(agendaFrame); //topLayout->addWidget(mDayLabelsFrame); mDayLabels = new QFrame (mDayLabelsFrame); mLayoutDayLabels = new QHBoxLayout(mDayLabels); agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); agendaLayout->addWidget(mEventIndicatorTop,1,1); mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, agendaFrame); agendaLayout->addWidget(mEventIndicatorBottom,3,1); QWidget *dummyAgendaRight = new QWidget(agendaFrame); agendaLayout->addWidget(dummyAgendaRight,1,2); // Create time labels mTimeLabels = new TimeLabels(24,agendaFrame); agendaLayout->addWidget(mTimeLabels,2,0); connect(mTimeLabels,SIGNAL( scaleChanged()), this,SLOT(updateConfig())); // Create agenda mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); agendaLayout->setColStretch(1,1); mAgenda->setFocusPolicy(NoFocus); // Create event context menu for agenda mAgendaPopup = eventPopup(); mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), i18n("Toggle Alarm"),mAgenda, SLOT(popupAlarm()),true); connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); // make connections between dependent widgets mTimeLabels->setAgenda(mAgenda); // Update widgets to reflect user preferences // updateConfig(); // createDayLabels(); // these blank widgets make the All Day Event box line up with the agenda dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); // Scrolling connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), mTimeLabels, SLOT(positionChanged())); connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(setContentsPos(int))); connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); // Create/Show/Edit/Delete Event connect(mAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEvent(int,int))); connect(mAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodo(int,int))); connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEvent(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEventAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodoAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEventAllDay(int,int))); connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelected(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int ))); connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int))); // event indicator update connect(mAgenda,SIGNAL(lowerYChanged(int)), SLOT(updateEventIndicatorTop(int))); connect(mAgenda,SIGNAL(upperYChanged(int)), SLOT(updateEventIndicatorBottom(int))); // drag signals /* connect(mAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); */ // synchronize selections connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAllDayAgenda, SLOT( deselectItem() ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAgenda, SLOT( deselectItem() ) ); connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAgenda, SIGNAL( resizedSignal() ), SLOT( updateConfig( ) ) ); connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), SLOT( addToCalSlot(Incidence * , Incidence *) ) ); // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); } void KOAgendaView::toggleAllDay() { if ( mSplitterAgenda->firstHandle() ) mSplitterAgenda->firstHandle()->toggle(); } void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) { calendar()->addIncidence( inc ); if ( incOld ) { if ( incOld->type() == "Todo" ) emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); else emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); } } KOAgendaView::~KOAgendaView() { delete mAgendaPopup; delete mAllDayAgendaPopup; delete KOAgendaItem::paintPix(); delete KOAgendaItem::paintPixSel(); } void KOAgendaView::resizeEvent( QResizeEvent* e ) { //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); bool uc = false; int ow = e->oldSize().width(); int oh = e->oldSize().height(); int w = e->size().width(); int h = e->size().height(); if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) uc = true; //qDebug("view changed %d %d %d %d ", ow, oh , w , h); } mUpcomingWidth = e->size().width() ; if ( mBlockUpdating || uc ) { mBlockUpdating = false; //mAgenda->setMinimumSize(800 , 600 ); //qDebug("mAgenda->resize+++++++++++++++ "); updateConfig(); //qDebug("KOAgendaView::Updating now possible "); } else createDayLabels(); //qDebug("resizeEvent end "); } void KOAgendaView::slotDaylabelClicked( int num ) { QDate firstDate = mSelectedDates.first(); if ( num == -1 ) emit showDateView( 6, firstDate ); else if (num >= 0 ) { if ( mSelectedDates.count() == 1) emit showDateView( 9, firstDate.addDays( num ) ); else emit showDateView( 3, firstDate.addDays( num ) ); } else showDateView( 10, firstDate.addDays(1) ); } KOAgendaButton* KOAgendaView::getNewDaylabel() { KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); return dayLabel ; } void KOAgendaView::createDayLabels() { if ( mBlockUpdating || globalFlagBlockLabel == 1) { // qDebug(" KOAgendaView::createDayLabels() blocked "); return; } int newHight; // ### Before deleting and recreating we could check if mSelectedDates changed... // It would remove some flickering and gain speed (since this is called by // each updateView() call) int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); if ( maxWid < 0 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); int selCount = mSelectedDates.count(); QString dayTest = "Mon 20"; //QString dayTest = "Mon 20"; int wid = fm.width( dayTest ); //maxWid -= ( selCount * 3 ); //working for QLabels maxWid -= ( selCount * 3 ); //working for QPushButton if ( maxWid < 0 ) maxWid = 20; int needWid = wid * selCount; //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); //if ( needWid > maxWid ) // qDebug("DAYLABELS TOOOOOOO BIG "); while ( needWid > maxWid ) { dayTest = dayTest.left( dayTest.length() - 1 ); wid = fm.width( dayTest ); needWid = wid * selCount; } int maxLen = dayTest.length(); int fontPoint = dlf.pointSize(); if ( maxLen < 2 ) { int fontPoint = dlf.pointSize(); while ( fontPoint > 4 ) { --fontPoint; dlf.setPointSize( fontPoint ); QFontMetrics f( dlf ); wid = f.width( "30" ); needWid = wid * selCount; if ( needWid < maxWid ) break; } maxLen = 2; } //qDebug("Max len %d ", dayTest.length() ); QFontMetrics tempF( dlf ); newHight = tempF.height(); mDayLabels->setFont( dlf ); // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; // mLayoutDayLabels->addSpacing(mTimeLabels->width()); //mLayoutDayLabels->addSpacing( 2 ); // QFont lFont = dlf; bool appendLabels = false; KOAgendaButton *dayLabel; dayLabel = mDayLabelsList.first(); if ( !dayLabel ) { appendLabels = true; dayLabel = getNewDaylabel(); } dayLabel->setFixedWidth( mTimeLabels->width()+2 ); dayLabel->setFont( dlf ); dayLabel->setNum( -1 ); //dayLabel->setAlignment(QLabel::AlignHCenter); dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); dayLabel->show(); DateList::ConstIterator dit; bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); int counter = -1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { ++counter; QDate date = *dit; // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { dayLabel = getNewDaylabel(); } dayLabel->setMinimumWidth( 1 ); dayLabel->setMaximumWidth( 10240 ); dayLabel->setFont( dlf ); dayLabel->show(); dayLabel->setNum( counter ); QString str; int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); switch ( maxLen ) { case 2: str = QString::number( date.day() ); break; case 3: str = dayName.left( 1 ) +QString::number( date.day()); break; case 4: str = dayName.left( 1 ) + " " +QString::number( date.day()); break; case 5: str = dayName.left( 2 ) + " " +QString::number( date.day()); break; case 6: str = dayName.left( 3 ) + " " +QString::number( date.day()); break; default: break; } if ( oneday ) { QString addString; if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) addString = i18n("Yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) addString = i18n("Day before yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) addString = i18n("Day after tomorrow"); if ( !addString.isEmpty() ) { str = addString+", " + str; } else { str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); } } dayLabel->setText(str); //dayLabel->setAlignment(QLabel::AlignHCenter); if (date == QDate::currentDate()) { QFont bFont = dlf; bFont.setBold( true ); dayLabel->setFont(bFont); } //dayLayout->addWidget(dayLabel); #ifndef KORG_NOPLUGINS CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); CalendarDecoration *it; for(it = cds.first(); it; it = cds.next()) { QString text = it->shortText( date ); if ( !text.isEmpty() ) { QLabel *label = new QLabel(text,mDayLabels); label->setAlignment(AlignCenter); dayLayout->addWidget(label); } } for(it = cds.first(); it; it = cds.next()) { QWidget *wid = it->smallWidget(mDayLabels,date); if ( wid ) { // wid->setHeight(20); dayLayout->addWidget(wid); } } #endif } if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { dayLabel = getNewDaylabel(); } //dayLabel->hide();//test only int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; if ( offset < 0 ) offset = 0; //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); dayLabel->setFont( dlf ); dayLabel->show(); dayLabel->setNum( -2 ); dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); if ( !appendLabels ) { dayLabel = mDayLabelsList.next(); while ( dayLabel ) { //qDebug("!dayLabel %d",dayLabel ); dayLabel->hide(); dayLabel = mDayLabelsList.next(); } } - //mDayLabelsFrame->show(); - //mDayLabels->show(); - //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); - //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); - mDayLabelsFrame->setFixedHeight( newHight ); + + mDayLabelsFrame->setFixedHeight( newHight + 4 ); } int KOAgendaView::maxDatesHint() { // Not sure about the max number of events, so return 0 for now. return 0; } int KOAgendaView::currentDateCount() { return mSelectedDates.count(); } QPtrList<Incidence> KOAgendaView::selectedIncidences() { QPtrList<Incidence> selected; Incidence *incidence; incidence = mAgenda->selectedIncidence(); if (incidence) selected.append(incidence); incidence = mAllDayAgenda->selectedIncidence(); if (incidence) selected.append(incidence); return selected; } DateList KOAgendaView::selectedDates() { DateList selected; QDate qd; qd = mAgenda->selectedIncidenceDate(); if (qd.isValid()) selected.append(qd); qd = mAllDayAgenda->selectedIncidenceDate(); if (qd.isValid()) selected.append(qd); return selected; } void KOAgendaView::updateView() { if ( mBlockUpdating ) return; // kdDebug() << "KOAgendaView::updateView()" << endl; fillAgenda(); } /* Update configuration settings for the agenda view. This method is not complete. */ void KOAgendaView::updateConfig() { if ( mBlockUpdating ) return; if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { int old = KOPrefs::instance()->mHourSize; KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); } // update config for children mTimeLabels->updateConfig(); mAgenda->storePosition(); mAgenda->updateConfig(); mAllDayAgenda->updateConfig(); // widget synchronization //TODO: find a better way, maybe signal/slot mTimeLabels->positionChanged(); // for some reason, this needs to be called explicitly mTimeLabels->repaint(); mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); // ToolTips displaying summary of events KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() ->mEnableToolTips); //setHolidayMasks(); //createDayLabels(); called by via updateView(); mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); updateView(); mAgenda->restorePosition(); } void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) { // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; //qDebug("KOAgendaView::updateEventDates "); QDateTime startDt,endDt; QDate startDate; int lenInSecs; // if ( type == KOAgenda::RESIZETOP ) // qDebug("RESIZETOP "); // if ( type == KOAgenda::RESIZEBOTTOM ) // qDebug("RESIZEBOTTOM "); // if ( type == KOAgenda::MOVE ) // qDebug("MOVE "); if ( item->incidence()->type() == "Event" ) { startDt =item->incidence()->dtStart(); endDt = item->incidence()->dtEnd(); lenInSecs = startDt.secsTo( endDt ); } // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { startDate = mSelectedDates[item->mLastMoveXPos]; } else { if (item->cellX() < 0) { startDate = (mSelectedDates.first()).addDays(item->cellX()); } else { startDate = mSelectedDates[item->cellX()]; } } startDt.setDate(startDate); if (item->incidence()->doesFloat()) { endDt.setDate(startDate.addDays(item->cellWidth() - 1)); } else { if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) startDt.setTime(mAgenda->gyToTime(item->cellYTop())); if ( item->incidence()->type() == "Event" ) { if ( type == KOAgenda::MOVE ) { endDt = startDt.addSecs(lenInSecs); } else if ( type == KOAgenda::RESIZEBOTTOM ) { if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); endDt.setDate(startDate); } } } else { // todo if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); if ( item->cellYBottom() > 0 ) endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); else endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); endDt.setDate(startDate); } } } if ( item->incidence()->type() == "Event" ) { item->incidence()->setDtStart(startDt); (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); } else if ( item->incidence()->type() == "Todo" ) { Todo* to = static_cast<Todo*>(item->incidence()); to->setDtDue(endDt); if ( to->hasStartDate() ) { if (to->dtStart() >= to->dtDue() ) to->setDtStart(to->dtDue().addDays( -2 )); } } //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); item->incidence()->setRevision(item->incidence()->revision()+1); item->setItemDate(startDt.date()); //item->updateItem(); if ( item->incidence()->type() == "Todo" ) { emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); } else emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); item->updateItem(); } void KOAgendaView::showDates( const QDate &start, const QDate &end ) { // kdDebug() << "KOAgendaView::selectDates" << endl; mSelectedDates.clear(); // qDebug("KOAgendaView::showDates "); QDate d = start; while (d <= end) { mSelectedDates.append(d); d = d.addDays( 1 ); } // and update the view fillAgenda(); } void KOAgendaView::showEvents(QPtrList<Event>) { kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; } void KOAgendaView::changeEventDisplay(Event *, int) { // qDebug("KOAgendaView::changeEventDisplay "); // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; // this should be re-written to be MUCH smarter. Right now we // are just playing dumb. fillAgenda(); } void KOAgendaView::fillAgenda(const QDate &) { // qDebug("KOAgendaView::fillAgenda "); fillAgenda(); } void KOAgendaView::fillAgenda() { if ( globalFlagBlockStartup ) return; if ( globalFlagBlockAgenda == 1 ) return; //if ( globalFlagBlockAgenda == 2 ) //globalFlagBlockAgenda = 0; // globalFlagBlockPainting = false; if ( globalFlagBlockAgenda == 0 ) globalFlagBlockAgenda = 1; // clearView(); //qDebug("fillAgenda()++++ "); globalFlagBlockAgendaItemPaint = 1; mAllDayAgenda->changeColumns(mSelectedDates.count()); mAgenda->changeColumns(mSelectedDates.count()); qApp->processEvents(); mEventIndicatorTop->changeColumns(mSelectedDates.count()); mEventIndicatorBottom->changeColumns(mSelectedDates.count()); setHolidayMasks(); //mAgenda->hideUnused(); //mAllDayAgenda->hideUnused(); // mAgenda->blockNextRepaint( false ); // mAgenda->viewport()->repaint(); // mAgenda->blockNextRepaint( true ); mMinY.resize(mSelectedDates.count()); mMaxY.resize(mSelectedDates.count()); QPtrList<Event> dayEvents; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Therefore, gtodoset all of them. QPtrList<Todo> todos = calendar()->todos(); mAgenda->setDateList(mSelectedDates); QDate today = QDate::currentDate(); DateList::ConstIterator dit; int curCol = 0; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { QDate currentDate = *dit; // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() // << endl; dayEvents = calendar()->events(currentDate,true); // Default values, which can never be reached mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; unsigned int numEvent; for(numEvent=0;numEvent<dayEvents.count();++numEvent) { Event *event = dayEvents.at(numEvent); if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) if ( event->uid().left(15) == QString("last-syncEvent-") ) continue; // kdDebug() << " Event: " << event->summary() << endl; int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; if (event->doesFloat()) { if (event->recurrence()->doesRecur()) { mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); } else { if (beginX <= 0 && curCol == 0) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } else if (beginX == curCol) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } } } else if (event->isMultiDay()) { if ( event->doesRecur () ) { QDate dateit = currentDate; int count = 0; int max = event->dtStart().daysTo( event->dtEnd() ) +2; while (! event->recursOn( dateit ) && count <= max ) { ++count; dateit = dateit.addDays( -1 ); } bool ok; QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); if ( ok ) { int secs = event->dtStart().secsTo( event->dtEnd() ); QDateTime nextOcend =nextOcstart.addSecs( secs ); ; beginX = currentDate.daysTo(nextOcstart.date()) + curCol; endX = currentDate.daysTo(nextOcend.date()) + curCol; } } int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); if ((beginX <= 0 && curCol == 0) || beginX == curCol) { //qDebug("insert!!! "); mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); } if (beginX == curCol) { mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); if (startY < mMinY[curCol]) mMinY[curCol] = startY; } else if (endX == curCol) { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } else { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); } } else { int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; if (endY < startY) endY = startY; mAgenda->insertItem(event,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } // ---------- [display Todos -------------- unsigned int numTodo; for (numTodo = 0; numTodo < todos.count(); ++numTodo) { Todo *todo = todos.at(numTodo); if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Already completed items can be displayed on their original due date //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; bool fillIn = false; if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) fillIn = true; if ( ! fillIn && !todo->hasCompletedDate() ) fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); if ( fillIn ) { if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue if ( KOPrefs::instance()->mShowTodoInAgenda ) mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); } else { QDateTime dt; if ( todo->hasCompletedDate() ) dt = todo->completed(); else dt = todo->dtDue();; int endY = mAgenda->timeToY(dt.time()) - 1; int hi = (18/KOPrefs::instance()->mHourSize); //qDebug("hei %d ",KOPrefs::instance()->mHourSize); int startY = endY -hi; mAgenda->insertItem(todo,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 7a4275b..ca0d542 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1342,770 +1342,774 @@ void MainWindow::keyBindings() 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.info\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; } mWeekPixmap.fill( mWeekBgColor ); QPainter p ( &mWeekPixmap ); p.setFont( mWeekFont ); p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); p.end(); QIconSet icon3 ( mWeekPixmap ); mWeekAction->setIconSet ( icon3 ); } 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 ); if ( result == 0 ) { mView->importBday(); } } void MainWindow::importQtopia() { //#ifndef DESKTOP_VERSION QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); #ifdef DESKTOP_VERSION mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); #endif int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { #ifndef DESKTOP_VERSION QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; #else QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; #endif mView->importQtopia( categories, datebook, todolist ); } #if 0 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Not supported \non desktop!\n"), i18n("Ok"), i18n("Cancel"), 0, 0, 1 ); #endif } void MainWindow::saveOnClose() { KOPrefs *p = KOPrefs::instance(); p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); p->mToolBarUp = iconToolBar->x() > width()/2 || iconToolBar->y() > height()/2; mView->writeSettings(); if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) save(); } void MainWindow::slotModifiedChanged( bool changed ) { if ( mBlockAtStartup ) return; int msec; // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } void MainWindow::saveStopTimer() { mSaveTimer.stop(); if (mSaveTimer.isActive() ) qDebug("ti active "); else qDebug("KO: Save timer stopped"); } void MainWindow::save() { if ( !mCalendarModifiedFlag ) { qDebug("KO: Calendar not modified. Nothing saved."); return; } if ( mSyncManager->blockSave() ) return; mSyncManager->setBlockSave(true); if ( mView->checkFileVersion( defaultFileName()) ) { QTime neededSaveTime = QDateTime::currentDateTime().time(); setCaption(i18n("KO/Pi:Saving Data to File ..." )); qDebug("KO: Start saving data to file!"); mView->saveCalendar( defaultFileName() ); mCalendarModifiedFlag = false; int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Needed %d ms for saving.",msNeeded ); QString savemes; savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); setCaption(savemes); } else setCaption(i18n("Saving cancelled!")); mSyncManager->setBlockSave( false ); } void MainWindow::keyReleaseEvent ( QKeyEvent * e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void MainWindow::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; KOPrefs *p = KOPrefs::instance(); bool showSelectedDates = false; int size; int pro = 0; //qDebug("MainWindow::keyPressEvent "); switch ( e->key() ) { case Qt::Key_Right: if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->goNextMonth(); else mView->goNext(); showSelectedDates = true; break; case Qt::Key_Left: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->goPreviousMonth(); else mView->goPrevious(); showSelectedDates = true; break; case Qt::Key_Down: mView->viewManager()->agendaView()->scrollOneHourDown(); break; case Qt::Key_Up: mView->viewManager()->agendaView()->scrollOneHourUp(); break; case Qt::Key_K: mView->viewManager()->showMonthViewWeek(); break; case Qt::Key_I: mView->showIncidence(); break; case Qt::Key_Delete: case Qt::Key_Backspace: mView->deleteIncidence(); break; case Qt::Key_D: mView->viewManager()->showDayView(); showSelectedDates = true; break; case Qt::Key_O: mView->toggleFilerEnabled( ); break; case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: pro = e->key()-48; if ( pro == 0 ) pro = 10; if ( e->state() == Qt::ControlButton) pro += 10; break; case Qt::Key_M: mView->viewManager()->showMonthView(); showSelectedDates = true; break; case Qt::Key_Insert: mView->newEvent(); break; case Qt::Key_S : if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->newSubTodo(); else mView->dialogManager()->showSearchDialog(); break; case Qt::Key_Y : case Qt::Key_Z : mView->viewManager()->showWorkWeekView(); showSelectedDates = true; break; case Qt::Key_U : mView->viewManager()->showWeekView(); showSelectedDates = true; break; case Qt::Key_H : keyBindings(); break; case Qt::Key_W: mView->viewManager()->showWhatsNextView(); break; case Qt::Key_L: mView->viewManager()->showListView(); break; case Qt::Key_N: - mView->viewManager()->showNextXView(); - showSelectedDates = true; + if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) + mView->viewManager()->showNextView(); + else { + mView->viewManager()->showNextXView(); + showSelectedDates = true; + } break; case Qt::Key_V: mView->viewManager()->showTodoView(); break; case Qt::Key_C: mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); break; case Qt::Key_P: mView->showDatePicker( ); break; case Qt::Key_F: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->editFilters(); else mView->toggleFilter(); break; case Qt::Key_X: mView->toggleDateNavigatorWidget(); break; case Qt::Key_Space: mView->toggleExpand(); break; case Qt::Key_A: if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) mView->showNextAlarms(); else mView->toggleAllDaySize(); break; case Qt::Key_T: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newTodo(); else { mView->goToday(); showSelectedDates = true; } break; case Qt::Key_J: mView->viewManager()->showJournalView(); break; case Qt::Key_B: mView->editIncidenceDescription();; break; // case Qt::Key_Return: case Qt::Key_E: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newEvent(); else mView->editIncidence(); break; case Qt::Key_Plus: size = p->mHourSize +2; if ( size <= 22 ) configureAgenda( size ); break; case Qt::Key_Minus: size = p->mHourSize - 2; if ( size >= 4 ) configureAgenda( size ); break; default: e->ignore(); } if ( pro > 0 ) { mView->selectFilter( pro-1 ); } if ( showSelectedDates ) { ;// setCaptionToDates(); } } void MainWindow::fillFilterMenu() { selectFilterMenu->clear(); bool disable = false; selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); selectFilterMenu->insertSeparator(); if ( mView->filterView()->filtersEnabled() ) { selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); } else { selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); disable = true; } selectFilterMenu->insertSeparator(); QPtrList<CalFilter> fili = mView->filters(); CalFilter *curfilter = mView->filterView()->selectedFilter(); CalFilter *filter = fili.first(); int iii = 2; while(filter) { selectFilterMenu->insertItem( filter->name(), iii ); if ( filter == curfilter) selectFilterMenu->setItemChecked( iii, true ); if ( disable ) selectFilterMenu->setItemEnabled( iii, false ); filter = fili.next(); ++iii; } } void MainWindow::selectFilter( int fil ) { if ( fil == 0 ) { mView->editFilters( ); } else if ( fil == 1 ){ mView->toggleFilerEnabled( ); } else { mView->selectFilter( fil-2 ); } } void MainWindow::configureToolBar( int item ) { configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); KOPrefs *p = KOPrefs::instance(); p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); // initActions(); } void MainWindow::setCaption ( const QString & c ) { QString cap = c; cap.replace( QRegExp("\n"), " " ); cap = cap.stripWhiteSpace(); if ( cap.isEmpty() ) cap = "KO/Pi"; QWidget::setCaption( cap ); } void MainWindow::setCaptionToDates() { QString selDates; QDate date = mView->startDate(); if ( ! date.isValid() ) { setCaption(""); return; } selDates = KGlobal::locale()->formatDate( date, true); if (mView->startDate() < mView->endDate() ) selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); else { QString addString; if ( date == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( date == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); if ( !addString.isEmpty() ) selDates = addString+", "+selDates ; } setCaption( i18n("Dates: ") + selDates ); } void MainWindow::showConfigureAgenda( ) { int iii; for ( iii = 1;iii<= 10 ;++iii ){ configureAgendaMenu->setItemChecked( (iii+1)*2, false ); } configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); } void MainWindow::configureAgenda( int item ) { if ( KOPrefs::instance()->mHourSize == item ) return; KOPrefs::instance()->mHourSize=item; mView->viewManager()->agendaView()->updateConfig(); } void MainWindow::saveCalendar() { QString fn = KOPrefs::instance()->mLastSaveFile; fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { mView->saveCalendar( fn ); mes = i18n("KO/Pi:Saved %1").arg(fn); KOPrefs::instance()->mLastSaveFile = fn; setCaption(mes); } } void MainWindow::loadCalendar() { QString fn = KOPrefs::instance()->mLastLoadFile; fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( info. exists() ) { mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); int result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, i18n("Load!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { loadbup = false; } } else { QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 0, 1 ); return; } if ( loadbup ) { mView->openCalendar( fn ); KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } } void MainWindow::quickImportIcal() { importFile( KOPrefs::instance()->mLastImportFile, false ); } void MainWindow::importFile( QString fn, bool quick ) { QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return; } int result = 0; if ( !quick ) { mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, "Import", "Cancel", 0, 0, 1 ); } if ( result == 0 ) { if ( mView->openCalendar( fn, true )) { KOPrefs::instance()->mLastImportFile = fn; setCaption(i18n("Imported file successfully")); } else { setCaption(i18n("Error importing file")); } } } void MainWindow::importIcal() { QString fn =KOPrefs::instance()->mLastImportFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; importFile( fn, true ); } void MainWindow::exportVCalendar() { QString fn = KOPrefs::instance()->mLastVcalFile; fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { if ( mView->exportVCalendar( fn ) ) { KOPrefs::instance()->mLastVcalFile = fn; if ( fn.length() > 20 ) mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; else mes = i18n("KO/Pi:Exported to %1").arg(fn ); setCaption(mes); } } } QString MainWindow::sentSyncFile() { #ifdef DESKTOP_VERSION return locateLocal( "tmp", "copysynccal.ics" ); #else return QString( "/tmp/copysynccal.ics" ); #endif } void MainWindow::syncFileRequest() { if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); } setCaption(i18n("Saving Data to temp file ..." )); mView->saveCalendar( sentSyncFile() ); setCaption(i18n("Data saved to temp file!" )); } void MainWindow::getFile( bool success ) { if ( ! success ) { setCaption( i18n("Error receiving file. Nothing changed!") ); return; } mView->openCalendar( sentSyncFile() ); if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); } setCaption( i18n("Pi-Sync successful!") ); } void MainWindow::printSel( ) { mView->viewManager()->agendaView()->agenda()->printSelection(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } #include "libkdepim/kdatepicker.h" #include <kdatetbl.h> void MainWindow::weekAction() { int month; KPopupFrame* popup = new KPopupFrame(this); KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); // ----- picker->resize(picker->sizeHint()); popup->setMainWidget(picker); picker->setFocus(); connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); int x = 0; |