-rw-r--r-- | korganizer/koagendaview.cpp | 10 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 |
3 files changed, 18 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 0d36946..13d8398 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1440,140 +1440,150 @@ void KOAgendaView::setHolidayMasks() } #ifndef KORG_NOPLUGINS bool showHoliday = KOPrefs::instance()->mExcludeHolidays && !KOCore::self()->holiday(date).isEmpty(); #endif bool showDay = showSaturday || showSunday || showHoliday; if (showDay) { mHolidayMask.at(i) = true; } else { mHolidayMask.at(i) = false; } } mAgenda->setHolidayMask(&mHolidayMask); mAllDayAgenda->setHolidayMask(&mHolidayMask); } void KOAgendaView::setContentsPos(int y) { mAgenda->setContentsPos(0,y); } void KOAgendaView::setExpandedButton( bool expanded ) { if ( expanded ) { mExpandButton->setPixmap( mExpandedPixmap ); } else { mExpandButton->setPixmap( mNotExpandedPixmap ); } } void KOAgendaView::clearSelection() { mAgenda->deselectItem(); mAllDayAgenda->deselectItem(); } void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd) { mTimeSpanInAllDay = true; newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); } void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd) { if (!mSelectedDates.count()) return; QDate dayStart = mSelectedDates[gxStart]; QDate dayEnd = mSelectedDates[gxEnd]; QTime timeStart = mAgenda->gyToTime(gyStart); QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); QDateTime dtStart(dayStart,timeStart); QDateTime dtEnd(dayEnd,timeEnd); mTimeSpanBegin = dtStart; mTimeSpanEnd = dtEnd; } void KOAgendaView::deleteSelectedDateTime() { mTimeSpanBegin.setDate(QDate()); mTimeSpanEnd.setDate(QDate()); mTimeSpanInAllDay = false; } void KOAgendaView::keyPressEvent ( QKeyEvent * e ) { e->ignore(); } void KOAgendaView::scrollOneHourUp() { mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); } void KOAgendaView::scrollOneHourDown() { mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); } void KOAgendaView::setStartHour( int h ) { mAgenda->setStartHour( h ); } +void KOAgendaView::setInitStartHour() +{ + + if ( KOPrefs::instance()->mCenterOnCurrentTime ) + setStartHour( QTime::currentTime ().hour() ); + else + setStartHour( KOPrefs::instance()->mDayBegins ); + +} + void KOAgendaView::updateTodo( Todo * t, int ) { if ( !isVisible() ) return; bool remove = false; bool removeAD = false; QDate da; if ( t->hasCompletedDate() ) da = t->completed().date(); else da = t->dtDue().date(); if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { remove = true; removeAD = true; } else { bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; if ( overdue && QDate::currentDate() >= mSelectedDates.first() && QDate::currentDate() <= mSelectedDates.last()) { removeAD = false; remove = true; } else { if ( da < mSelectedDates.first() || da > mSelectedDates.last() ) { remove = true; removeAD = true; } else { remove = t->doesFloat() && !t->hasCompletedDate(); removeAD = !remove; } } } int days = mSelectedDates.first().daysTo( da ); //qDebug("daysto %d %d %d", days, remove,removeAD ); mAgenda->updateTodo( t , days, remove); if ( KOPrefs::instance()->mShowTodoInAgenda ) mAllDayAgenda->updateTodo( t , days, removeAD); //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); } diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 4a058ce..8b8bac0 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -84,192 +84,193 @@ class TimeLabels : public QScrollView { void updateConfig(); /** */ void setAgenda(KOAgenda* agenda); /** */ virtual void paintEvent(QPaintEvent* e); void contentsMousePressEvent ( QMouseEvent * ) ; void contentsMouseReleaseEvent ( QMouseEvent * ); void contentsMouseMoveEvent ( QMouseEvent * ); public slots: /** update time label positions */ void positionChanged(); signals: void scaleChanged(); protected: void drawContents(QPainter *p,int cx, int cy, int cw, int ch); private: int mMouseDownY; QString mOrgCap; int mRows; int mCellHeight; /** */ KOAgenda* mAgenda; }; class EventIndicator : public QFrame { Q_OBJECT public: enum Location { Top, Bottom }; EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); virtual ~EventIndicator(); void changeColumns(int columns); void setPaintWidget( KDGanttMinimizeSplitter* ); void setXOffset( int ); void enableColumn(int column, bool enable); protected: void drawContents(QPainter *); private: int mXOffset; KDGanttMinimizeSplitter* mPaintWidget; int mColumns; QHBox *mTopBox; QBoxLayout *mTopLayout; Location mLocation; QPixmap mPixmap; QMemArray<bool> mEnabled; }; /** KOAgendaView is the agenda-like view used to display events in an one or multi-day view. */ class KOAgendaView : public KOEventView { Q_OBJECT public: KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); virtual ~KOAgendaView(); void setStartHour( int ); void toggleAllDay(); /** Returns maximum number of days supported by the koagendaview */ virtual int maxDatesHint(); /** Returns number of currently shown dates. */ virtual int currentDateCount(); /** returns the currently selected events */ virtual QPtrList<Incidence> selectedIncidences(); /** returns the currently selected events */ virtual DateList selectedDates(); /** Remove all events from view */ void clearView(); KOAgenda *agenda() { return mAgenda;} virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); /** start-datetime of selection */ QDateTime selectionStart() {return mTimeSpanBegin;} /** end-datetime of selection */ QDateTime selectionEnd() {return mTimeSpanEnd;} /** returns true if selection is for whole day */ bool selectedIsAllDay() {return mTimeSpanInAllDay;} /** make selected start/end invalid */ void deleteSelectedDateTime(); void repaintAgenda(); public slots: + void setInitStartHour(); virtual void updateView(); virtual void updateConfig(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void updateTodo( Todo *, int ); void changeEventDisplay(Event *, int); void clearSelection(); void newTodo(int gx,int gy); void newEvent(int gx,int gy); void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); void newEventAllDay(int gx, int gy); void newTodoAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void setExpandedButton( bool expanded ); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void selectWeekNum( int ); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: KOAgendaButton* getNewDaylabel(); bool mBlockUpdating; int mUpcomingWidth; /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ void fillAgenda(); /** Create labels for the selected dates. */ void createDayLabels(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ void setHolidayMasks(); protected slots: void slotDaylabelClicked( int ); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); //void updateMovedTodo(); void updateEventIndicatorTop(int newY); void updateEventIndicatorBottom(int newY); /** Updates data for selected timespan */ void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); /** Updates data for selected timespan for all day event*/ void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); private: // view widgets QFrame *mDayLabels; QHBox *mDayLabelsFrame; QBoxLayout *mLayoutDayLabels; QFrame *mAllDayFrame; KOAgenda *mAllDayAgenda; KOAgenda *mAgenda; TimeLabels *mTimeLabels; QWidget *mDummyAllDayLeft; KDGanttMinimizeSplitter* mSplitterAgenda; QPushButton *mExpandButton; DateList mSelectedDates; // List of dates to be displayed int mViewType; bool mWeekStartsMonday; int mStartHour; KOEventPopupMenu *mAgendaPopup; KOEventPopupMenu *mAllDayAgendaPopup; EventIndicator *mEventIndicatorTop; EventIndicator *mEventIndicatorBottom; diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index b0f26d1..f8f6c1d 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -1,193 +1,200 @@ /* 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 { + config->setGroup( "Views" ); + int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); + mCurrentAgendaView = dateCount; showAgendaView(); + mCurrentAgendaView = dateCount; +#ifdef DESKTOP_VERSION + QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); +#endif } } void KOViewManager::showDateView( int view, QDate date) { static int lastMode = 0; static int lastCount = 0; static bool lastNDMode = false; static QDate lastDate; //qDebug("date %d %s", view, date.toString().latin1()); if (view != 9) lastMode = 0; //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); bool savemFlagShowNextxDays = mFlagShowNextxDays; mFlagShowNextxDays = false; if ( view == 3 ) { //mCurrentAgendaView = 1 ; lastDate = mMainView->dateNavigator()->selectedDates().first(); lastCount = mMainView->dateNavigator()->selectedDates().count(); lastNDMode = savemFlagShowNextxDays; mMainView->showDay( date ); lastMode = 1; } else if (view == 4 ) { mCurrentAgendaView = 7 ; mMainView->dateNavigator()->selectDates( date, 7 ); } else if (view == 5 ) { mCurrentAgendaView = 14 ; mMainView->dateNavigator()->selectDates( date, 14); } else if (view == 6 ) { //mMainView->dateNavigator()->selectDates( date, 7 ); showMonthView(); } 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 (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) if ( lastMode ) { mCurrentAgendaView = lastCount ; mMainView->dateNavigator()->selectDates( lastDate, lastCount); mFlagShowNextxDays = lastNDMode; if ( mFlagShowNextxDays ) { mCurrentAgendaView = 3 ; } } else showWeekView(); } else if (view == 10) { mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); } } 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; |