author | zautrix <zautrix> | 2005-03-25 21:08:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 21:08:48 (UTC) |
commit | 6427570041c902840fe0f557415a07bb7aa8c031 (patch) (side-by-side diff) | |
tree | e397342aca97119927ec6c312be5ac5f953d5eec /korganizer | |
parent | 4d93404e3453229e58c2ff9305beae131c9f1af9 (diff) | |
download | kdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.zip kdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.tar.gz kdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.tar.bz2 |
fix
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 2 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.h | 1 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 3 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 10 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 3 |
7 files changed, 22 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6ed6a1c..92fd59c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -277,192 +277,196 @@ void CalendarView::init() mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); #ifdef KORG_NORESOURCEVIEW mResourceView = 0; #else if ( mResourceManager ) { mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); mResourceView->updateView(); connect( mResourceView, SIGNAL( resourcesChanged() ), SLOT( updateView() ) ); } else { mResourceView = 0; } #endif QWidget *rightBox = new QWidget( mPanner ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 1 ); mLeftFrame = mLeftSplitter; #else //QWidget *mainBox = new QWidget( this ); //QWidget *leftFrame = new QWidget( mainBox ); //QBoxLayout * mainBoxLayout; if ( KOPrefs::instance()->mVerticalScreen ) { //mainBoxLayout = new QVBoxLayout(mainBox); //leftFrameLayout = new QHBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); } else { //mainBoxLayout = new QHBoxLayout(mainBox); //leftFrameLayout = new QVBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); } mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); //QBoxLayout * leftFrameLayout; topLayout->addWidget( mMainFrame ); //mainBoxLayout->addWidget (mLeftFrame); mDateNavigator = new DateNavigatorContainer( mLeftFrame, "CalendarView::DateNavigator" ); #if 0 // FIXME mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate()); #endif // mDateNavigator->blockSignals( true ); //leftFrameLayout->addWidget( mDateNavigator ); mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); mTodoList->setNavigator( mNavigator ); #if 0 if ( QApplication::desktop()->width() < 480 ) { leftFrameLayout->addWidget(mFilterView); leftFrameLayout->addWidget(mTodoList, 2 ); } else { leftFrameLayout->addWidget(mTodoList,2 ); leftFrameLayout->addWidget(mFilterView ); } #endif mFilterView->hide(); QWidget *rightBox = new QWidget( mMainFrame ); //mainBoxLayout->addWidget ( rightBox, 10 ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 10 ); //mLeftFrame = (QWidget *)leftFrame; if ( KOPrefs::instance()->mVerticalScreen ) { //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); } if ( !KOPrefs::instance()->mShowDateNavigator) mDateNavigator->hide(); //qDebug("Calendarview Size %d %d ", width(), height()); #endif connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( showDates( const KCal::DateList & ) ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); + + connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), + mViewManager, SLOT( showMonth( const QDate & ) ) ); + connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), mNavigator, SLOT( selectWeek( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mDateNavigator, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mDateNavigator, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mDateNavigator, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mDateNavigator, SIGNAL( goPrevious() ), mNavigator, SLOT( selectPrevious() ) ); connect( mDateNavigator, SIGNAL( goNext() ), mNavigator, SLOT( selectNext() ) ); connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); #if 0 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), SLOT( incidenceAdded( Incidence *) ) ); #endif // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); connect( this, SIGNAL( configChanged() ), mDateNavigator, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( newTodoSignal() ), SLOT( newTodo() ) ); connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), SLOT( newSubTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), SLOT( editTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), SLOT( showTodo( Todo *) ) ); connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), SLOT( deleteTodo( Todo *) ) ); connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( purgeCompletedSignal() ), SLOT( purgeCompleted() ) ); connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), SIGNAL( todoModified( Todo *, int ) ) ); connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), this, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), this, SLOT (cancelIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), this, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), this, SLOT ( beamIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), this, SLOT ( todo_unsub( Todo * ) ) ); connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), this, SLOT ( todo_resub( Todo *,Todo * ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, SLOT( updateTodo( Todo *, int ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), this, SLOT( changeTodoDisplay( Todo *, int ) ) ); connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDateFrame->setCaption( i18n( "Pick a date to display")); mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 11dc592..edeebdf 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -1,169 +1,171 @@ /* This file is part of KOrganizer. Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 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 <kdebug.h> #include <klocale.h> //#include "koglobals.h" #include "navigatorbar.h" #include "kdatenavigator.h" #include <kcalendarsystem.h> #include "datenavigatorcontainer.h" #include "koprefs.h" DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, const char *name ) : QWidget( parent, name ), mCalendar( 0 ), mHorizontalCount( 1 ), mVerticalCount( 1 ) { mResizeEnabled = false; mExtraViews.setAutoDelete( true ); mNavigatorView = new KDateNavigator( this, name ); mNavigatorView->hide(); connectNavigatorView( mNavigatorView ); //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); mLastDisplayedDN = 0; mUpdateTimer; mUpdateTimer = new QTimer( this ); connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); mFirstSelectedDate = QDate::currentDate(); mSelectedDateCount = 1; } DateNavigatorContainer::~DateNavigatorContainer() { } void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) { connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), SIGNAL( datesSelected( const KCal::DateList & ) ) ); #if 0 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); #endif connect( v, SIGNAL( weekClicked( const QDate & ) ), SIGNAL( weekClicked( const QDate & ) ) ); + connect( v, SIGNAL( showMonth( const QDate & ) ), + SIGNAL( showMonth( const QDate & ) ) ); connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); } void DateNavigatorContainer::slotgoNextYear() { jumpMonth( 12 ); emit goNextYear(); } void DateNavigatorContainer::slotgoPrevYear() { jumpMonth( -12 ); emit goPrevYear(); } void DateNavigatorContainer::slotgoPrevMonth() { jumpMonth( -1 ); emit goPrevMonth(); } void DateNavigatorContainer::slotgoNextMonth() { jumpMonth( 1 ); emit goNextMonth(); } void DateNavigatorContainer::jumpMonth( int month ) { QDate baseDate = mNavigatorView->baseDate(); computeMonthSelected( baseDate.month() + month, false ); } void DateNavigatorContainer::slotMonthSelected( int month ) { computeMonthSelected( month, true ); } void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) { //qDebug("slotMonthSelected %d ", month); QDate baseDate = mNavigatorView->baseDate(); if ( baseDate.month() == month ) return; //qDebug("month %d %d ",baseDate.month(),month); QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); date = date.addDays( -(baseDate.month()-month ) *30 ); QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); //qDebug("NEW BASE %s", newBase.toString().latin1()); mNavigatorView->setBaseDate( newBase ); QDate last = lastAvailableDate(); QDate first = firstAvailableDate(); QDate selFirst = mFirstSelectedDate; QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); if ( selFirst >= first && selLast <= last ) { setBaseDates(); if ( forceEmit ) updateDayMatrixDates(); } else { setBaseDates(); if ( forceEmit ) updateDayMatrixDates(); if ( forceEmit ) emit monthSelected( month ); } } void DateNavigatorContainer::setCalendar( Calendar *cal ) { mCalendar = cal; mNavigatorView->setCalendar( cal ); for( uint i = 0; i < mLastDisplayedDN; ++i ) { KDateNavigator *n = mExtraViews.at( i ); n->setCalendar( cal ); } } void DateNavigatorContainer::checkUpdateDayMatrixDates() { //qDebug("KODNC: wid %d hei %d ", width(), height()); mUpdateTimer->stop(); //return; if ( width() < 3 || height() < 3 ) return; static int lastWid = 0; static int lastHei = 0; if ( lastWid == width() && height() == lastHei ) { qDebug("KODNC: No layout computing needed. "); } else { diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h index ac9745d..87cc59f 100644 --- a/korganizer/datenavigatorcontainer.h +++ b/korganizer/datenavigatorcontainer.h @@ -1,108 +1,109 @@ /* This file is part of KOrganizer. Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 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. */ #ifndef DATENAVIGATORCONTAINER_H #define DATENAVIGATORCONTAINER_H class KDateNavigator; #include <qwidget.h> #include <qtimer.h> #include <libkcal/calendar.h> using namespace KCal; class DateNavigatorContainer: public QWidget { Q_OBJECT public: DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); ~DateNavigatorContainer(); /** Associate date navigator with a calendar. It is used by KODayMatrix. */ void setCalendar( Calendar * ); QSize minimumSizeHint() const; QSize sizeHint() const; KDateNavigator * navigatorView() { return mNavigatorView;} QDate lastAvailableDate() const ; QDate firstAvailableDate() const ; public slots: void selectDates( const KCal::DateList & ); void updateView(); void updateConfig(); void updateDayMatrix(); void updateDayMatrixDates(); void checkUpdateDayMatrixDates(); void updateToday(); void slotMonthSelected( int month ); void slotgoNextMonth(); void slotgoPrevMonth(); void slotgoNextYear(); void slotgoPrevYear(); void setResizeEnabled(); signals: void datesSelected( const KCal::DateList & ); void incidenceDropped( Incidence *, const QDate & ); void incidenceDroppedMove( Incidence *, const QDate & ); void weekClicked( const QDate &); void goPrevious(); void goNext(); void goNextMonth(); void goPrevMonth(); void goNextYear(); void goPrevYear(); + void showMonth( const QDate & ); void monthSelected( int month ); protected: void computeMonthSelected( int month , bool forceEmit ); void jumpMonth( int month ); void resizeEvent( QResizeEvent * ); void setBaseDates(); void connectNavigatorView( KDateNavigator *v ); private: bool mResizeEnabled; QTimer* mUpdateTimer; int mLastDisplayedDN; QDate mFirstSelectedDate; int mSelectedDateCount; KDateNavigator *mNavigatorView; KCal::Calendar *mCalendar; QPtrList<KDateNavigator> mExtraViews; int mHorizontalCount; int mVerticalCount; }; #endif diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 5eccfd6..38bddc2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -354,114 +354,117 @@ void KDateNavigator::updateConfig() int day; for(int i=0; i<7; i++) { // take the first letter of the day name to be the abbreviation if (KGlobal::locale()->weekStartsMonday()) { day = i+1; } else { if (i==0) day = 7; else day = i; } QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, true ); if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); headings[i]->setText( dayName ); } updateDates(); updateView(); } void KDateNavigator::setShowWeekNums(bool enabled) { qDebug("KDateNavigator::setShowWeekNums***************************** "); m_bShowWeekNums = enabled; for(int i=0; i<6; i++) { if(enabled) weeknos[i]->show(); else weeknos[i]->hide(); } resize(size()); } void KDateNavigator::selectDates(const DateList& dateList) { if (dateList.count() > 0) { mNavigatorBar->selectDates( dateList ); mSelectedDates = dateList; // set our record of the month and year that this datetbl is // displaying. m_MthYr = mSelectedDates.first(); // set our record of the first day of the week of the current // month. This needs to be done before calling dayToIndex, since it // relies on this information being up to date. QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); m_fstDayOfWk = dayone.dayOfWeek(); updateDates(); daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); updateView(); } } int KDateNavigator::dayNum(int row, int col) { return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; } int KDateNavigator::dayToIndex(int dayNum) { int row, col; row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) row++; col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; return row * 7 + col; } void KDateNavigator::wheelEvent (QWheelEvent *e) { if(e->delta()>0) emit goPrevious(); else emit goNext(); e->accept(); } bool KDateNavigator::eventFilter (QObject *o,QEvent *e) { if (e->type() == QEvent::MouseButtonPress) { int i; for(i=0;i<6;++i) { if (o == weeknos[i]) { QDate weekstart = daymatrix->getDate(i*7); emit weekClicked(weekstart); break; } } for(i=0;i<7;++i) { if (o == headings[i]) { KCal::DateList selDays; QDate date = daymatrix->getDate(14); + emit showMonth(date ); +#if 0 int dio = date.daysInMonth(); int j; int ye = date.year(); int mo = date.month(); for ( j = 1; j <= dio; ++j ) { selDays.append( QDate( ye, mo, j ) ); } emit datesSelected( selDays ); +#endif break; } } return true; } else { return false; } } //#include "kdatenavigator.moc" diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 93bbceb..780ebb8 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h @@ -1,166 +1,167 @@ /* 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. */ #ifndef KDATENAVIGATOR_H #define KDATENAVIGATOR_H #include <qframe.h> #include <qdatetime.h> #include <qlabel.h> #include <libkcal/calendar.h> #include "kodaymatrix.h" class QPushButton; class QTimer; class KCalendarSystem; class NavigatorBar; class KDateNavigator: public QFrame { Q_OBJECT public: KDateNavigator( QWidget *parent = 0,const char *name = 0 ); ~KDateNavigator(); /** The DateNavigator automatically checks for * the passage of midnight. If rollover type is * set to None, no signals are emitted and no * processing is done. With rollover set to * FollowDay, the day highlighter changes at * midnight and dayPassed() is emitted. * With FollowMonth, it has the same effect * as FollowDay but also adjusts the month that is * visible and emits monthPassed() when the month changes. */ enum RolloverType { None, FollowDay, FollowMonth } ; void enableRollover( RolloverType ); void setShowWeekNums( bool enabled ); void setCalendar( Calendar * ); void setBaseDate( const QDate & , bool doRepaint = true ); QDate baseDate() const { return m_MthYr;} KCal::DateList selectedDates() const { return mSelectedDates; } NavigatorBar *navigatorBar() const { return mNavigatorBar; } void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} QSize yourSizeHint()const { return mySizeHint; }; QSize yourFullSizeHint() const { return myFullSizeHint;}; QFont yourFontHint( QSize , bool * b); bool fontChanged() {return mFontChanged; } void unsetFontChanged() { mFontChanged = false; } KODayMatrix *dayMatrix() { return daymatrix ;} QSize sizeHint() const; QSize sizeHintTwoButtons( int butnum = 2 ) const; void changeFont ( QFont fo ); public slots: void selectDates( const KCal::DateList & ); void updateView(); void updateConfig(); void updateDayMatrix(); signals: void datesSelected( const KCal::DateList & ); void eventDropped( Event * ); void weekClicked( const QDate &); + void showMonth( const QDate & ); void goPrevious(); void goNext(); void goNextMonth(); void goPrevMonth(); void goNextYear(); void goPrevYear(); void monthSelected( int ); // Signals emitted at midnight carrying the new date. void dayPassed( QDate ); void monthPassed( QDate ); protected slots: /** * Called regularly to see if we need to update the view * wrt. the today box and the month box. Only important * if you leave KOrganizer idle for long periods of time. * * Until we have a reliable way of setting QTimers to go * off at a particular wall-clock time, we need this, * which calls passedMidnight() at the right moments. */ void possiblyPastMidnight(); /** handles updating the view when midnight has come by due to idle time. * */ void passedMidnight(); void slotMonthSelected( int m ); protected: void updateDates(); void wheelEvent (QWheelEvent *); bool eventFilter (QObject *,QEvent *); private: QSize mySizeHint; QSize myFullSizeHint; bool mFontChanged; int mMonthSignalOffset; NavigatorBar *mNavigatorBar; QFrame *headingSep; QFrame *weeknumSep; QLabel *headings[7]; QLabel *weeknos[7]; KODayMatrix *daymatrix; KCal::DateList mSelectedDates; QDate m_MthYr; int m_fstDayOfWk; bool m_bShowWeekNums; int dayNum(int row, int col); int dayToIndex(int dayNum); Calendar *mCalendar; KCalendarSystem *mCalendarSystem; const QString *curHeaders; /** used to update the day view periodically, in particular every * midnight to move the "today" rectangle. */ QTimer *updateTimer; QDate lastDayChecked; RolloverType updateRollover; // Disabling copy constructor and assignment operator KDateNavigator(const KDateNavigator & ); KDateNavigator &operator=(const KDateNavigator &); }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index c6e76c4..5a2dce3 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -35,194 +35,195 @@ #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") { if ( !KOPrefs::instance()->mMonthViewWeek ) showMonthView(); else showMonthViewWeek(); } 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 ); + mMainView->dateNavigator()->selectDate( date ); lastMode = 1; + mCurrentAgendaView = 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; if ( view == 0 ) { view = mCurrentView; if ( view == 0 ) return; } bool callupdate = !(view == mCurrentView); bool full = fullScreen; if(view == mCurrentView && view != mWhatsNextView ) { if ( mCurrentAgendaView < 0 ) return; if ( view != mMonthView ) full = mMainView->leftFrame()->isVisible(); } else { if ( view == mMonthView && mMonthView) ;//mMonthView->skipResize = true ; mCurrentView = view; // bool full = fullScreen; bool isFull = !mMainView->leftFrame()->isVisible(); if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) full = true; if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) full = false; } @@ -484,192 +485,199 @@ void KOViewManager::showNextXView() { globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( QDate::currentDate(), KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; } bool KOViewManager::showsNextDays() { return mFlagShowNextxDays; } void KOViewManager::createMonthView() { if (!mMonthView) { mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); addView(mMonthView); // mMonthView->show(); // SIGNALS/SLOTS FOR MONTH VIEW connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( selectWeekNum( int ) ), mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); connect( mMonthView, SIGNAL( selectMonth() ), mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), mMainView, SLOT ( showDay( QDate ) ) ); connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); connect( mMonthView, SIGNAL(nextMonth() ), mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); connect( mMonthView, SIGNAL(prevMonth() ), mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), mMainView->dateNavigator(), SLOT( selectNextYear() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); } } void KOViewManager::showMonthViewWeek() { createMonthView(); globalFlagBlockAgenda = 1; bool full = true; if ( mCurrentView == mMonthView) full = mMainView->leftFrame()->isVisible(); if ( !KOPrefs::instance()->mMonthViewWeek ) { mMonthView->switchView(); if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) full = false; else full = true; } mMainView->dateNavigator()->selectWeek(); showView(mMonthView, full ); } +void KOViewManager::showMonth( const QDate & date ) +{ + mMainView->dateNavigator()->blockSignals( true ); + mMainView->dateNavigator()->selectDate( date ); + mMainView->dateNavigator()->blockSignals( false ); + showMonthView(); +} void KOViewManager::showMonthView() { createMonthView(); globalFlagBlockAgenda = 1; //mFlagShowNextxDays = false; bool full = true; if ( mCurrentView == mMonthView) full = mMainView->leftFrame()->isVisible(); // if(mMonthView == mCurrentView) return; if ( KOPrefs::instance()->mMonthViewWeek ) { mMonthView->switchView(); if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) full = false; else full = true; } mMainView->dateNavigator()->selectMonth(); showView(mMonthView, full ); } void KOViewManager::showTodoView() { //mFlagShowNextxDays = false; if ( !mTodoView ) { mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), "KOViewManager::TodoView" ); addView( mTodoView ); // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); // SIGNALS/SLOTS FOR TODO VIEW connect( mTodoView, SIGNAL( newTodoSignal() ), mMainView, SLOT( newTodo() ) ); connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), mMainView, SLOT( newSubTodo( Todo *) ) ); connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), mMainView, SLOT( showTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), mMainView, SLOT( editTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), mMainView, SLOT( deleteTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( purgeCompletedSignal() ), mMainView, SLOT( purgeCompleted() ) ); connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMainView, SIGNAL( configChanged() ), mTodoView, SLOT( updateConfig() ) ); connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, SLOT( updateTodo( Todo *, int ) ) ); connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), mMainView, SLOT ( todo_unsub( Todo * ) ) ); connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); KConfig *config = KOGlobals::config(); mTodoView->restoreLayout(config,"Todo View"); mTodoView->setNavigator( mMainView->dateNavigator() ); } globalFlagBlockAgenda = 1; showView( mTodoView, true ); } void KOViewManager::showJournalView() { //mFlagShowNextxDays = false; if (!mJournalView) { mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::JournalView"); connect( mMainView, SIGNAL( configChanged() ), mJournalView, SLOT( updateConfig() ) ); connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); addView(mJournalView); } showView(mJournalView); mMainView->dateNavigator()->selectDates( 1 ); } void KOViewManager::showTimeSpanView() { diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 8f0bf82..6290227 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -1,120 +1,121 @@ /* 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. */ #ifndef KOVIEWMANAGER_H #define KOVIEWMANAGER_H #include <qobject.h> #include <korganizer/baseview.h> class CalendarView; class KOListView; class KOAgendaView; class KOMonthView; class KOTimeSpanView; class KOTodoView; class KOWhatsNextView; class KOJournalView; using namespace KCal; /** This class manages the views of the calendar. It owns the objects and handles creation and selection. */ class KOViewManager : public QObject { Q_OBJECT public: KOViewManager( CalendarView * ); virtual ~KOViewManager(); /** changes the view to be the currently selected view */ void showView(KOrg::BaseView *, bool fullScreen = false ); void updateWNview(); void readSettings(KConfig *config); void writeSettings(KConfig *config); bool showsNextDays(); /** Read which view was shown last from config file */ void readCurrentView(KConfig *); /** Write which view is currently shown to config file */ void writeCurrentView(KConfig *); KOrg::BaseView *currentView(); void setDocumentId( const QString & ); void updateView( const QDate &start, const QDate &end ); void raiseCurrentView( bool fullScreen = false , bool updateView = false); void addView(KOrg::BaseView *); Incidence *currentSelection(); QDate currentSelectionDate(); KOAgendaView *agendaView() const { return mAgendaView; } signals: void printWNV(); void signalFullScreen( bool ); void signalAgendaView( bool ); - public slots: + public slots: + void showMonth( const QDate & ); void showDateView( int, QDate ); void updateView(); void showWhatsNextView(); void showListView(); void showAgendaView( bool fullScreen = false ); void showDayView(); void showWorkWeekView(); void showWeekView(); void showNextXView(); void showMonthView(); void showMonthViewWeek(); void showTodoView(); void showJournalView(); void showTimeSpanView(); private: void createMonthView(); CalendarView *mMainView; int mCurrentAgendaView; KOAgendaView *mAgendaView; KOListView *mListView; KOMonthView *mMonthView; KOTodoView *mTodoView; KOWhatsNextView *mWhatsNextView; KOJournalView *mJournalView; KOTimeSpanView *mTimeSpanView; KOrg::BaseView *mCurrentView; // currently active event view int mAgendaViewMode; bool mFlagShowNextxDays; }; #endif |