author | zautrix <zautrix> | 2005-01-31 17:16:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 17:16:55 (UTC) |
commit | 8e627854bec00289be27915b81458cf22bbb000f (patch) (side-by-side diff) | |
tree | 18db63d50f031122b5069927c2491ac8cf5c6295 | |
parent | ec037c4616342c1b3976c55db98b775f48e0d455 (diff) | |
download | kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.zip kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.tar.gz kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.tar.bz2 |
sss
-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 |
3 files changed, 2 insertions, 4 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6646b98..4cff23a 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -419,673 +419,673 @@ void MonthViewCell::startUpdateCell() #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif mToolTip = ""; //qApp->processEvents(); if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); mItemList->insertItem( item ); mToolTip += mHolidayString+"\n"; } } void MonthViewCell::insertEvent(Event *event) { if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } if ( event->categories().contains("Holiday") || event->categories().contains(i18n("Holiday"))) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) mItemList->setLineWidth( 3 ); } QString text; if (event->isMultiDay()) { QString prefix = "<->"; if ( event->doesRecur() ) { if ( event->recursOn( mDate) ) prefix ="->" ; else { int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); if ( event->recursOn( mDate.addDays( -days)) ) prefix ="<-" ; } } else { if (mDate == event->dtStart().date()) { prefix ="->" ; } else if (mDate == event->dtEnd().date()) { prefix ="<-" ; } } text = prefix + event->summary(); mToolTip += text; } else { if (event->doesFloat()) { text = event->summary(); mToolTip += text; } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } MonthViewItem *item = new MonthViewItem( event, mDate, text ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } } else { if (cat.isEmpty()) { pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } item->setPalette( pal ); item->setRecur( event->recurrence()->doesRecur() ); item->setAlarm( event->isAlarmEnabled() ); item->setMoreInfo( event->description().length() > 0 ); #ifdef DESKTOP_VERSION Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email()); if ( me != 0 ) { if ( me->status() == Attendee::NeedsAction && me->RSVP()) item->setReply(true); else item->setReply(false); } else item->setReply(false); #endif mItemList->insertItem( item ); mToolTip += "\n"; } void MonthViewCell::insertTodo(Todo *todo) { QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { text += KGlobal::locale()->formatTime(todo->dtDue().time()); text += " "; } } text += i18n("To-Do: %1").arg(todo->summary()); MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = todo->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } } else { if (cat.isEmpty()) { pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } item->setPalette( pal ); mItemList->insertItem( item ); mToolTip += text+"\n"; } void MonthViewCell::finishUpdateCell() { #ifdef DESKTOP_VERSION if (mToolTip != "") QToolTip::add(this,mToolTip,toolTipGroup(),""); #endif //setMyPalette(); setMyPalette(); QString text; bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; mLabel->resize( mLabelBigSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } else { mLabel->resize( mLabelSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } mLabel->setText( text ); resizeEvent( 0 ); } void MonthViewCell::updateCell() { if ( !mMonthView->isUpdatePossible() ) return; startUpdateCell(); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); Event *event; for( event = events.first(); event; event = events.next() ) { // for event insertEvent(event); } // insert due todos QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { insertTodo( todo ); } finishUpdateCell(); // if ( isVisible()) //qApp->processEvents(); } void MonthViewCell::updateConfig() { - qDebug("MonthViewCell::updateConfig() "); setFont( KOPrefs::instance()->mMonthViewFont ); QFontMetrics fm( font() ); mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); mHolidayPalette = mStandardPalette; mPrimaryPalette = mStandardPalette; mNonPrimaryPalette = mStandardPalette; if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); } - updateCell(); + //updateCell(); } void MonthViewCell::enableScrollBars( bool enabled ) { if ( enabled ) { mItemList->setVScrollBarMode(QScrollView::Auto); mItemList->setHScrollBarMode(QScrollView::Auto); } else { mItemList->setVScrollBarMode(QScrollView::AlwaysOff); mItemList->setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { int index = mItemList->currentItem(); if ( index < 0 ) return 0; MonthViewItem *item = static_cast<MonthViewItem *>( mItemList->item( index ) ); if ( !item ) return 0; return item->incidence(); } QDate MonthViewCell::selectedIncidenceDate() { QDate qd; int index = mItemList->currentItem(); if ( index < 0 ) return qd; MonthViewItem *item = static_cast<MonthViewItem *>( mItemList->item( index ) ); if ( !item ) return qd; return item->incidenceDate(); } void MonthViewCell::deselect() { mItemList->clearSelection(); enableScrollBars( false ); // updateCell(); } void MonthViewCell::select() { ;// updateCell(); } void MonthViewCell::resizeEvent ( QResizeEvent * ) { if ( !mMonthView->isUpdatePossible() ) return; #ifndef DESKTOP_VERSION if ( !isVisible() ){ return; } #endif int size = height() - mLabel->height(); if ( size > 0 ) mItemList->verticalScrollBar()->setMaximumHeight( size ); size = width() - mLabel->width(); if ( size > 0 ) mItemList->horizontalScrollBar()->setMaximumWidth( size ); mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); } void MonthViewCell::defaultAction( QListBoxItem *item ) { if ( !item ) return; MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->defaultAction( incidence ); } void MonthViewCell::showDay() { emit showDaySignal( date() ); } void MonthViewCell::newEvent() { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { static QListBoxItem * lastClicked = 0; if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } /* if ( lastClicked ) if ( ! item ) { if ( lastClicked->listBox() != item->listBox() ) lastClicked->listBox()->clearSelection(); } */ mMonthView->setSelectedCell( this ); if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); select(); } void MonthViewCell::contextMenu( QListBoxItem *item ) { if ( !item ) return; MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) return; mMonthView->setSelectedCell( this ); } // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView( calendar, parent, name ), mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { updatePossible = false; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; // mDayLayout = new QGridLayout( this ); // create the day of the week labels (Sun, Mon, etc) and add them to // the layout. mDayLabels.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; for( i = 0; i < mDaysPerWeek; i++ ) { QLabel *label = new QLabel( this ); label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabels.insert( i, label ); } bfont.setBold( false ); mWeekLabels.resize( mNumWeeks+1 ); for( i = 0; i < mNumWeeks+1; i++ ) { KOWeekButton *label = new KOWeekButton( this ); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabels.insert( i, label ); } mWeekLabels[mNumWeeks]->setText( i18n("W")); int row, col; mCells.resize( mNumCells ); for( row = 0; row < mNumWeeks; ++row ) { for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this ); mCells.insert( row * mDaysPerWeek + col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); } } mContextMenu = eventPopup(); // updateConfig(); //useless here emit incidenceSelected( 0 ); } KOMonthView::~KOMonthView() { delete mContextMenu; } int KOMonthView::maxDatesHint() { return mNumCells; } int KOMonthView::currentDateCount() { return mNumCells; } QPtrList<Incidence> KOMonthView::selectedIncidences() { QPtrList<Incidence> selected; if ( mSelectedCell ) { Incidence *incidence = mSelectedCell->selectedIncidence(); if ( incidence ) selected.append( incidence ); } return selected; } DateList KOMonthView::selectedDates() { DateList selected; if ( mSelectedCell ) { QDate qd = mSelectedCell->selectedIncidenceDate(); if ( qd.isValid() ) selected.append( qd ); } return selected; } void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Month, fd, td); #endif } void KOMonthView::updateConfig() { mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; for (int i = 0; i < 7; i++) { int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; } bool temp = mShowSatSunComp ; mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) computeLayout(); updateDayLabels(); //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; //resizeEvent( 0 ); for (uint i = 0; i < mCells.count(); ++i) { mCells[i]->updateConfig(); } #ifdef DESKTOP_VERSION MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); #endif + updateView(); } void KOMonthView::updateDayLabels() { for (int i = 0; i < 7; i++) { if (mWeekStartsMonday) { bool show = mShortDayLabels; if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) show = true; mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); } else { if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); } } } void KOMonthView::showDates(const QDate &start, const QDate &) { // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; mStartDate = start; int startWeekDay = mWeekStartsMonday ? 1 : 7; while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { mStartDate = mStartDate.addDays( -1 ); } bool primary = false; uint i; for( i = 0; i < mCells.size(); ++i ) { QDate date = mStartDate.addDays( i ); mCells[i]->setDate( date ); #ifndef KORG_NOPLUGINS // add holiday, if present QString hstring(KOCore::self()->holiday(date)); mCells[i]->setHoliday( hstring ); #endif } QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); for( i = 0; i < 6; ++i ) { int wno; // remember, according to ISO 8601, the first week of the year is the // first week that contains a thursday. Thus we must subtract off 4, // not just 1. int dayOfYear = date.dayOfYear(); if (dayOfYear % 7 != 0) wno = dayOfYear / 7 + 1; else wno =dayOfYear / 7; mWeekLabels[i]->setWeekNum( wno ); date = date.addDays( 7 ); } updateView(); } void KOMonthView::showEvents(QPtrList<Event>) { qDebug("KOMonthView::selectEvents is not implemented yet. "); } void KOMonthView::changeEventDisplay(Event *, int) { // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. updateView(); } void KOMonthView::updateView() { if ( !updatePossible ) return; QTime ti; ti.start(); #if 1 int i; for( i = 0; i < mCells.count(); ++i ) { mCells[i]->startUpdateCell(); } QPtrList<Event> events = calendar()->events(); Event *event; QDateTime dt; bool ok; int timeSpan = mCells.size()-1; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event if ( event->doesRecur() ) { bool last; QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( incidenceEnd.date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); for ( iii = st;iii<= end;++iii) mCells[iii]->insertEvent( event ); } } } else { if ( invalid ) break; invalid = true; //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ); } if ( last ) break; bool ok; incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); if ( ! ok ) break; if ( incidenceStart.date() > endDate ) break; } } else { // no recur int st = event->dtStart().date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( event->dtEnd().date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; for ( iii = st;iii<= end;++iii) mCells[iii]->insertEvent( event ); } } } } // insert due todos QPtrList<Todo> todos = calendar()->todos( ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { //insertTodo( todo ); if ( todo->hasDueDate() ) { int day = mStartDate.daysTo( todo->dtDue().date() ); if ( day >= 0 && day < mCells.size() ) { mCells[day]->insertTodo( todo ); } } } for( i = 0; i < mCells.count(); ++i ) { mCells[i]->finishUpdateCell(); } processSelectionChange(); mCells[0]->setFocus(); #else // old code //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); int i; for( i = 0; i < mCells.count(); ++i ) { mCells[i]->updateCell(); } //qDebug("KOMonthView::updateView() "); processSelectionChange(); // qDebug("---------------------------------------------------------------------+ "); mCells[0]->setFocus(); #endif qDebug("update time %d ", ti.elapsed()); } void KOMonthView::resizeEvent(QResizeEvent * e) { computeLayout(); mCells[0]->setFocus(); } void KOMonthView::computeLayout() diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index c95917f..db23882 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -1,314 +1,313 @@ /* 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 <qwidgetstack.h> #include <kconfig.h> #include <kglobal.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <qdatetime.h> #include "calendarview.h" #include "datenavigator.h" #include "kotodoview.h" #include "koagendaview.h" #include "kodialogmanager.h" #include "komonthview.h" #include "kolistview.h" #include "kowhatsnextview.h" #include "kojournalview.h" #include "kotimespanview.h" #include "koprefs.h" #include "navigatorbar.h" #include "kdatenavigator.h" #include "koviewmanager.h" //extern bool externFlagMonthviewBlockPainting; //bool globalFlagBlockPainting = false; int globalFlagBlockAgenda = 0; int globalFlagBlockLabel = 0; int globalFlagBlockAgendaItemPaint = 1; int globalFlagBlockAgendaItemUpdate = 1; KOViewManager::KOViewManager( CalendarView *mainView ) : QObject(), mMainView( mainView ) { mCurrentView = 0; mWhatsNextView = 0; mTodoView = 0; mAgendaView = 0; mMonthView = 0; mListView = 0; mJournalView = 0; mTimeSpanView = 0; mCurrentAgendaView = 0 ; mFlagShowNextxDays = false; } KOViewManager::~KOViewManager() { } KOrg::BaseView *KOViewManager::currentView() { return mCurrentView; } void KOViewManager::readSettings(KConfig *config) { config->setGroup("General"); QString view = config->readEntry("Current View"); if (view == "WhatsNext") showWhatsNextView(); else if (view == "Month") showMonthView(); else if (view == "List") showListView(); else if (view == "Journal") showJournalView(); else if (view == "TimeSpan") showTimeSpanView(); else if (view == "Todo") showTodoView(); else { showAgendaView(); } } void KOViewManager::showDateView( int view, QDate date) { //qDebug("date %d %s", view, date.toString().latin1()); #if 0 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); #endif if ( view == 3 ) { mMainView->showDay( date ); } else if (view == 4 ) { mMainView->dateNavigator()->selectDates( date, 7 ); } else if (view == 5 ) { mMainView->dateNavigator()->selectDates( date, 14); } else if (view == 6 ) { mMainView->dateNavigator()->blockSignals( true ); showMonthView(); - qApp->processEvents(); mMainView->dateNavigator()->selectMonthByDate( date ); mMainView->dateNavigator()->blockSignals( false ); mMainView->dateNavigator()->selectDate( date ); } else if (view == 7 ) { mMainView->dateNavigator()->selectDate( date ); showJournalView(); } else if (view == 8 ) { globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( date , KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; } #if 0 dateNavigator()->blockSignals( true ); dateNavigator()->selectDate( d ); dateNavigator()->blockSignals( false ); mViewManager->showDayView(); #endif } void KOViewManager::writeSettings(KConfig *config) { config->setGroup("General"); QString view; if (mCurrentView == mWhatsNextView) view = "WhatsNext"; else if (mCurrentView == mMonthView) view = "Month"; else if (mCurrentView == mListView) view = "List"; else if (mCurrentView == mJournalView) view = "Journal"; else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; else if (mCurrentView == mTodoView) view = "Todo"; else view = "Agenda"; config->writeEntry("Current View",view); if (mAgendaView) { mAgendaView->writeSettings(config); } if (mTimeSpanView) { mTimeSpanView->writeSettings(config); } if (mListView) { mListView->writeSettings(config); } if (mTodoView) { mTodoView->saveLayout(config,"Todo View"); } } void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) { //mFlagShowNextxDays = false; //if(view == mCurrentView) return; if ( view == 0 ) { view = mCurrentView; if ( view == 0 ) return; } bool full = fullScreen; if(view == mCurrentView && view != mWhatsNextView ) { if ( mCurrentAgendaView < 0 ) return; full = mMainView->leftFrame()->isVisible(); } else { mCurrentView = view; // bool full = fullScreen; bool isFull = !mMainView->leftFrame()->isVisible(); if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) full = true; if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) full = false; } if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); //raiseCurrentView( full ); mMainView->processIncidenceSelection( 0 ); //mMainView->updateView(); raiseCurrentView( full, true ); mMainView->adaptNavigationUnits(); } void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) { mCurrentAgendaView = 0; int wid = mMainView->width() ; int hei = mMainView->height(); if ( mCurrentView == mMonthView ) { mMainView->navigatorBar()->show(); hei -= mMainView->navigatorBar()->sizeHint().height(); //mMainView->navigatorBar()->hide(); } else { mMainView->navigatorBar()->hide(); } if ( fullScreen ) { mMainView->leftFrame()->hide(); } else { mMainView->leftFrame()->show(); if ( KOPrefs::instance()->mVerticalScreen ) hei -= mMainView->leftFrame()->height(); else wid -= mMainView->leftFrame()->width(); } emit signalFullScreen( !fullScreen ); if ( callUpdateView ) mMainView->updateView(); if ( globalFlagBlockAgenda == 5 ) { globalFlagBlockAgenda = 4; globalFlagBlockAgendaItemPaint = 1; } mMainView->viewStack()->raiseWidget(mCurrentView); if ( globalFlagBlockAgenda == 4 ) { if ( mCurrentView == mAgendaView ) { //globalFlagBlockAgenda =1 ; if ( KOPrefs::instance()->mSetTimeToDayStartAt ) mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) mAgendaView->setStartHour( QTime::currentTime ().hour() ); qApp->processEvents(); //qDebug("qApp->processEvents() "); globalFlagBlockAgenda = 0; mAgendaView->repaintAgenda(); } globalFlagBlockAgenda = 0; } emit signalAgendaView( mCurrentView == mAgendaView ); //qDebug("raiseCurrentView ende "); } void KOViewManager::updateView() { // qDebug("KOViewManager::updateView() "); // if we are updating mTodoView, we get endless recursion if ( mTodoView == mCurrentView ) return; if ( mCurrentView ) mCurrentView->updateView(); } void KOViewManager::updateView(const QDate &start, const QDate &end) { // kdDebug() << "KOViewManager::updateView()" << endl; if (mCurrentView) mCurrentView->showDates(start, end); if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); } void KOViewManager::updateWNview() { if ( mCurrentView == mWhatsNextView && mWhatsNextView ) mWhatsNextView->updateView(); } void KOViewManager::showWhatsNextView() { if (!mWhatsNextView) { mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::WhatsNextView"); mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); addView(mWhatsNextView); connect(this, SIGNAL( printWNV() ), mWhatsNextView, SLOT( printMe() ) ); } globalFlagBlockAgenda = 1; showView(mWhatsNextView, true ); //mWhatsNextView->updateView(); } void KOViewManager::showListView() { if (!mListView) { mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); addView(mListView); connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e75154b..0eba6a9 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -398,328 +398,327 @@ void CalendarLocal::reInitAlarmSettings() } deRegisterAlarm(); mNextAlarmIncidence = 0; checkAlarmForIncidence( 0, false ); } QDateTime CalendarLocal::nextAlarm( int daysTo ) { QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); QDateTime next; Event *e; bool ok; bool found = false; int offset; mNextAlarmIncidence = 0; for( e = mEventList.first(); e; e = mEventList.next() ) { next = e->getNextAlarmDateTime(& ok, &offset ) ; if ( ok ) { if ( next < nextA ) { nextA = next; found = true; mNextSummary = e->summary(); mNextAlarmEventDateTime = next.addSecs(offset ) ; mNextAlarmIncidence = (Incidence *) e; } } } Todo *t; for( t = mTodoList.first(); t; t = mTodoList.next() ) { next = t->getNextAlarmDateTime(& ok, &offset ) ; if ( ok ) { if ( next < nextA ) { nextA = next; found = true; mNextSummary = t->summary(); mNextAlarmEventDateTime = next.addSecs(offset ); mNextAlarmIncidence = (Incidence *) t; } } } if ( mNextAlarmIncidence ) { mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); mNextAlarmDateTime = nextA; } return nextA; } Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) { return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); } Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) { kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " << to.toString() << ")\n"; Alarm::List alarms; Event *e; for( e = mEventList.first(); e; e = mEventList.next() ) { if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); else appendAlarms( alarms, e, from, to ); } Todo *t; for( t = mTodoList.first(); t; t = mTodoList.next() ) { appendAlarms( alarms, t, from, to ); } return alarms; } void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ) { QPtrList<Alarm> alarmList = incidence->alarms(); Alarm *alarm; for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; if ( alarm->enabled() ) { if ( alarm->time() >= from && alarm->time() <= to ) { kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() << "': " << alarm->time().toString() << endl; alarms.append( alarm ); } } } } void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ) { QPtrList<Alarm> alarmList = incidence->alarms(); Alarm *alarm; QDateTime qdt; for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { if (incidence->recursOn(from.date())) { qdt.setTime(alarm->time().time()); qdt.setDate(from.date()); } else qdt = alarm->time(); // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); if ( alarm->enabled() ) { if ( qdt >= from && qdt <= to ) { alarms.append( alarm ); } } } } /****************************** PROTECTED METHODS ****************************/ // after changes are made to an event, this should be called. void CalendarLocal::update( IncidenceBase *incidence ) { incidence->setSyncStatus( Event::SYNCMOD ); incidence->setLastModified( QDateTime::currentDateTime() ); // we should probably update the revision number here, // or internally in the Event itself when certain things change. // need to verify with ical documentation. setModified( true ); } void CalendarLocal::insertEvent( Event *event ) { if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); } QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) { QPtrList<Event> eventList; Event *event; for( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->doesRecur() ) { if ( event->isMultiDay() ) { int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); int i; for ( i = 0; i <= extraDays; i++ ) { if ( event->recursOn( qd.addDays( -i ) ) ) { eventList.append( event ); break; } } } else { if ( event->recursOn( qd ) ) eventList.append( event ); } } else { if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { eventList.append( event ); } } } if ( !sorted ) { return eventList; } // kdDebug(5800) << "Sorting events for date\n" << endl; // now, we have to sort it based on dtStart.time() QPtrList<Event> eventListSorted; Event *sortEvent; for ( event = eventList.first(); event; event = eventList.next() ) { sortEvent = eventListSorted.first(); int i = 0; while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) { i++; sortEvent = eventListSorted.next(); } eventListSorted.insert( i, event ); } return eventListSorted; } QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, bool inclusive ) { - qDebug("CalendarLocal::rawEvents called "); Event *event = 0; QPtrList<Event> eventList; // Get non-recurring events for( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->doesRecur() ) { QDate rStart = event->dtStart().date(); bool found = false; if ( inclusive ) { if ( rStart >= start && rStart <= end ) { // Start date of event is in range. Now check for end date. // if duration is negative, event recurs forever, so do not include it. if ( event->recurrence()->duration() == 0 ) { // End date set QDate rEnd = event->recurrence()->endDate(); if ( rEnd >= start && rEnd <= end ) { // End date within range found = true; } } else if ( event->recurrence()->duration() > 0 ) { // Duration set // TODO: Calculate end date from duration. Should be done in Event // For now exclude all events with a duration. } } } else { bool founOne; QDate next = event->getNextOccurence( start, &founOne ).date(); if ( founOne ) { if ( next <= end ) { found = true; } } /* // crap !!! if ( rStart <= end ) { // Start date not after range if ( rStart >= start ) { // Start date within range found = true; } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever found = true; } else if ( event->recurrence()->duration() == 0 ) { // End date set QDate rEnd = event->recurrence()->endDate(); if ( rEnd >= start && rEnd <= end ) { // End date within range found = true; } } else { // Duration set // TODO: Calculate end date from duration. Should be done in Event // For now include all events with a duration. found = true; } } */ } if ( found ) eventList.append( event ); } else { QDate s = event->dtStart().date(); QDate e = event->dtEnd().date(); if ( inclusive ) { if ( s >= start && e <= end ) { eventList.append( event ); } } else { if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { eventList.append( event ); } } } } return eventList; } QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) { return rawEventsForDate( qdt.date() ); } QPtrList<Event> CalendarLocal::rawEvents() { return mEventList; } bool CalendarLocal::addJournal(Journal *journal) { if ( journal->dtStart().isValid()) kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; else kdDebug(5800) << "Adding Journal without a DTSTART" << endl; mJournalList.append(journal); journal->registerObserver( this ); setModified( true ); return true; } void CalendarLocal::deleteJournal( Journal *journal ) { if ( mUndoIncidence ) delete mUndoIncidence; mUndoIncidence = journal->clone(); mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); if ( mJournalList.removeRef(journal) ) { setModified( true ); } } Journal *CalendarLocal::journal( const QDate &date ) { // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->dtStart().date() == date ) return it; return 0; } Journal *CalendarLocal::journal( const QString &uid ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->uid() == uid ) return it; return 0; } QPtrList<Journal> CalendarLocal::journals() { return mJournalList; } |