korganizer

koagendaview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001,2003 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 #ifndef KOAGENDAVIEW_H
00026 #define KOAGENDAVIEW_H
00027 
00028 #include <qscrollview.h>
00029 #include <qlabel.h>
00030 
00031 #include <libkcal/calendar.h>
00032 
00033 #include "calprinter.h"
00034 #include "calendarview.h"
00035 
00036 #include "agendaview.h"
00037 
00038 class QHBox;
00039 class QPushButton;
00040 class QBoxLayout;
00041 
00042 class KOAgenda;
00043 class KOAgendaItem;
00044 class TimeLabels;
00045 class KConfig;
00046 
00047 namespace KOrg {
00048   class IncidenceChangerBase;
00049 }
00050 
00051 class EventIndicator : public QFrame
00052 {
00053     Q_OBJECT
00054   public:
00055     enum Location { Top, Bottom };
00056     EventIndicator( Location loc = Top, QWidget *parent = 0,
00057                     const char *name = 0 );
00058     virtual ~EventIndicator();
00059 
00060     void changeColumns( int columns );
00061 
00062     void enableColumn( int column, bool enable );
00063 
00064   protected:
00065     void drawContents( QPainter * );
00066 
00067   private:
00068     int mColumns;
00069     Location mLocation;
00070     QPixmap mPixmap;
00071     QMemArray<bool> mEnabled;
00072 };
00073 
00074 class KOAlternateLabel : public QLabel
00075 {
00076     Q_OBJECT
00077   public:
00078     KOAlternateLabel( const QString &shortlabel, const QString &longlabel,
00079                       const QString &extensivelabel = QString::null,
00080                       QWidget *parent = 0, const char *name = 0 );
00081     ~KOAlternateLabel();
00082 
00083     virtual QSize minimumSizeHint() const;
00084 
00085     enum TextType { Short = 0, Long = 1, Extensive = 2 };
00086     TextType largestFittingTextType() const;
00087     void setFixedType( TextType type );
00088 
00089   public slots:
00090     void useShortText();
00091     void useLongText();
00092     void useExtensiveText();
00093     void useDefaultText();
00094 
00095   protected:
00096     virtual void resizeEvent( QResizeEvent * );
00097     virtual void squeezeTextToLabel();
00098     bool mTextTypeFixed;
00099     QString mShortText, mLongText, mExtensiveText;
00100 };
00101 
00106 class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::Observer
00107 {
00108     Q_OBJECT
00109   public:
00110     KOAgendaView( Calendar *cal,
00111                   CalendarView *calendarView,
00112                   QWidget *parent = 0,
00113                   const char *name = 0,
00114                   bool isSideBySide = false );
00115     virtual ~KOAgendaView();
00116 
00118     virtual int maxDatesHint();
00119 
00121     virtual int currentDateCount();
00122 
00124     virtual Incidence::List selectedIncidences();
00125 
00127     virtual DateList selectedIncidenceDates();
00128 
00130     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00131 
00133     void clearView();
00134 
00135     KOrg::CalPrinterBase::PrintType printType();
00136 
00138     QDateTime selectionStart() { return mTimeSpanBegin; }
00140     QDateTime selectionEnd() { return mTimeSpanEnd; }
00142     bool selectedIsAllDay() { return mTimeSpanInAllDay; }
00144     void deleteSelectedDateTime();
00146     bool selectedIsSingleCell();
00147 
00148     void setTypeAheadReceiver( QObject * );
00149 
00150     KOAgenda* agenda() const { return mAgenda; }
00151     QSplitter* splitter() const { return mSplitterAgenda; }
00152     QFrame *dayLabels() const { return mDayLabels; }
00153 
00154     /* reimplmented from KCal::Calendar::Observer */
00155     void calendarIncidenceAdded( Incidence *incidence );
00156     void calendarIncidenceChanged( Incidence *incidence );
00157     void calendarIncidenceDeleted( Incidence *incidence );
00158 
00160     void updateEventDates( KOAgendaItem *item,
00161                            bool useLastGroupwareDialogAnswer,
00162                            ResourceCalendar *res,
00163                            const QString &subRes,
00164                            bool addIncidence );
00165     QMemArray<bool> busyDayMask();
00166   public slots:
00167     virtual void updateView();
00168     virtual void updateConfig();
00169     virtual void showDates( const QDate &start, const QDate &end );
00170     virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00171 
00172     void insertIncidence( Incidence *incidence, const QDate &curDate );
00173     void changeIncidenceDisplayAdded( Incidence *incidence );
00174     void changeIncidenceDisplay( Incidence *incidence, int mode );
00175 
00176     void clearSelection();
00177 
00178     void startDrag( Incidence * );
00179 
00180     void readSettings();
00181     void readSettings( KConfig * );
00182     void writeSettings( KConfig * );
00183 
00184     void setContentsPos( int y );
00185 
00186     void setExpandedButton( bool expanded );
00187 
00188     void finishTypeAhead();
00189 
00191     void slotTodoDropped( Todo *, const QPoint &, bool );
00192 
00193     void enableAgendaUpdate( bool enable );
00194     void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
00195 
00196     void zoomInHorizontally( const QDate& date=QDate() );
00197     void zoomOutHorizontally( const QDate& date=QDate() );
00198 
00199     void zoomInVertically( );
00200     void zoomOutVertically( );
00201 
00202     void zoomView( const int delta, const QPoint &pos,
00203       const Qt::Orientation orient=Qt::Horizontal );
00204 
00205     void clearTimeSpanSelection();
00206 
00207     void resourcesChanged();
00208 
00209   signals:
00210     void toggleExpand();
00211     void zoomViewHorizontally(const QDate &, int count );
00212 
00213     void timeSpanSelectionChanged();
00214 
00215   protected:
00217     void fillAgenda( const QDate &startDate );
00218 
00220     void fillAgenda();
00221 
00222     void connectAgenda( KOAgenda*agenda, QPopupMenu*popup, KOAgenda* otherAgenda );
00223 
00225     void createDayLabels( bool force );
00226 
00230     void setHolidayMasks();
00231 
00232     void removeIncidence( Incidence *, bool relayoutIncidence = true );
00237     void updateEventIndicators();
00238 
00239     void updateTimeBarWidth();
00240 
00241     virtual void resizeEvent( QResizeEvent *resizeEvent );
00242 
00243   protected slots:
00245     void doUpdateItem();
00246 
00247     void updateEventIndicatorTop( int newY );
00248     void updateEventIndicatorBottom( int newY );
00249 
00251     void newTimeSpanSelected( const QPoint &start, const QPoint &end );
00253     void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
00254 
00255     void updateDayLabelSizes();
00256 
00257   private:
00258     bool filterByResource( Incidence *incidence );
00259     void displayIncidence( Incidence *incidence );
00260 
00261   private:
00262     // view widgets
00263     QFrame *mDayLabels;
00264     QHBox *mDayLabelsFrame;
00265     QBoxLayout *mLayoutDayLabels;
00266     QPtrList<KOAlternateLabel> mDateDayLabels;
00267     QFrame *mAllDayFrame;
00268     KOAgenda *mAllDayAgenda;
00269     KOAgenda *mAgenda;
00270     TimeLabels *mTimeLabels;
00271     QWidget *mDummyAllDayLeft;
00272     QSplitter *mSplitterAgenda;
00273     QPushButton *mExpandButton;
00274 
00275     DateList mSelectedDates;  // List of dates to be displayed
00276     DateList mSaveSelectedDates; // Save the list of dates between updateViews
00277     int mViewType;
00278 
00279     KOEventPopupMenu *mAgendaPopup;
00280     KOEventPopupMenu *mAllDayAgendaPopup;
00281 
00282     EventIndicator *mEventIndicatorTop;
00283     EventIndicator *mEventIndicatorBottom;
00284 
00285     QMemArray<int> mMinY;
00286     QMemArray<int> mMaxY;
00287 
00288     QMemArray<bool> mHolidayMask;
00289 
00290     QPixmap mExpandedPixmap;
00291     QPixmap mNotExpandedPixmap;
00292 
00293     QDateTime mTimeSpanBegin;
00294     QDateTime mTimeSpanEnd;
00295     bool mTimeSpanInAllDay;
00296     bool mAllowAgendaUpdate;
00297 
00298     Incidence *mUpdateItem;
00299 
00300     bool mIsSideBySide;
00301     bool mPendingChanges;
00302 
00303     // the current date is inserted into mSelectedDates in the constructor
00304     // however whe should only show events when setDates is called, otherwise
00305     // we see day view with current date for a few milisecs, then we see something else
00306     // because someone called setDates with the real dates that should be displayed.
00307     // Other solution would be not initializing mSelectedDates in the ctor, but that requires
00308     // lots of changes in koagenda.cpp and koagendaview.cpp
00309     bool mAreDatesInitialized;
00310 };
00311 
00312 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys