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 "calprinter.h"
00032 
00033 #include "agendaview.h"
00034 
00035 class QHBox;
00036 class QPushButton;
00037 class QBoxLayout;
00038 
00039 class KOAgenda;
00040 class KOAgendaItem;
00041 class KConfig;
00042 
00043 namespace KCal {
00044   class ResourceCalendar;
00045 }
00046 
00047 namespace KOrg {
00048   class IncidenceChangerBase;
00049 }
00050 
00051 class TimeLabels : public QScrollView
00052 {
00053     Q_OBJECT
00054   public:
00055     TimeLabels( int rows, QWidget *parent = 0, const char *name = 0,
00056                 WFlags f = 0 );
00057 
00059     virtual int minimumWidth() const;
00060 
00062     void updateConfig();
00063 
00065     void setAgenda( KOAgenda *agenda );
00066 
00068     virtual void paintEvent( QPaintEvent *e );
00069 
00070   public slots:
00072     void positionChanged();
00073 
00074   protected:
00075     void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
00076 
00077   private slots:
00079     void mousePosChanged(const QPoint &pos);
00080 
00081     void showMousePos();
00082     void hideMousePos();
00083 
00084     void setCellHeight( double height );
00085 
00086   private:
00087     int mRows;
00088     double mCellHeight;
00089     int mMiniWidth;
00090     KOAgenda* mAgenda;
00091 
00092     QFrame *mMousePos;  // shows a marker for the current mouse position in y direction
00093 };
00094 
00095 class EventIndicator : public QFrame
00096 {
00097     Q_OBJECT
00098   public:
00099     enum Location { Top, Bottom };
00100     EventIndicator( Location loc = Top, QWidget *parent = 0,
00101                     const char *name = 0 );
00102     virtual ~EventIndicator();
00103 
00104     void changeColumns( int columns );
00105 
00106     void enableColumn( int column, bool enable );
00107 
00108   protected:
00109     void drawContents( QPainter * );
00110 
00111   private:
00112     int mColumns;
00113     QHBox *mTopBox;
00114     QBoxLayout *mTopLayout;
00115     Location mLocation;
00116     QPixmap mPixmap;
00117     QMemArray<bool> mEnabled;
00118 };
00119 
00120 class KOAlternateLabel : public QLabel
00121 {
00122     Q_OBJECT
00123   public:
00124     KOAlternateLabel( const QString &shortlabel, const QString &longlabel,
00125                       const QString &extensivelabel = QString::null,
00126                       QWidget *parent = 0, const char *name = 0 );
00127     ~KOAlternateLabel();
00128 
00129     virtual QSize minimumSizeHint() const;
00130 
00131   public slots:
00132     void setText( const QString & );
00133     void useShortText();
00134     void useLongText();
00135     void useExtensiveText();
00136     void useDefaultText();
00137 
00138   protected:
00139     virtual void resizeEvent( QResizeEvent * );
00140     virtual void squeezeTextToLabel();
00141     bool mTextTypeFixed;
00142     QString mShortText, mLongText, mExtensiveText;
00143 };
00144 
00149 class KOAgendaView : public KOrg::AgendaView
00150 {
00151     Q_OBJECT
00152   public:
00153     KOAgendaView( Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00154     virtual ~KOAgendaView();
00155 
00156 
00157 
00159     virtual int maxDatesHint();
00160 
00162     virtual int currentDateCount();
00163 
00165     virtual Incidence::List selectedIncidences();
00166 
00168     virtual DateList selectedDates();
00169 
00171     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00172 
00174     void clearView();
00175 
00176     KOrg::CalPrinterBase::PrintType printType();
00177 
00179     QDateTime selectionStart() { return mTimeSpanBegin; }
00181     QDateTime selectionEnd() { return mTimeSpanEnd; }
00183     bool selectedIsAllDay() { return mTimeSpanInAllDay; }
00185     void deleteSelectedDateTime();
00187     bool selectedIsSingleCell();
00188 
00189     void setTypeAheadReceiver( QObject * );
00190 
00192     void setResource( KCal::ResourceCalendar *res, const QString &subResource = QString::null );
00193 
00194   public slots:
00195     virtual void updateView();
00196     virtual void updateConfig();
00197     virtual void showDates( const QDate &start, const QDate &end );
00198     virtual void showIncidences( const Incidence::List &incidenceList );
00199 
00200     void insertIncidence( Incidence *incidence, const QDate &curDate, int curCol = -1 );
00201     void changeIncidenceDisplayAdded( Incidence *incidence );
00202     void changeIncidenceDisplay( Incidence *incidence, int mode );
00203 
00204     void clearSelection();
00205 
00206     void startDrag( Incidence * );
00207 
00208     void readSettings();
00209     void readSettings( KConfig * );
00210     void writeSettings( KConfig * );
00211 
00212     void setContentsPos( int y );
00213 
00214     void setExpandedButton( bool expanded );
00215 
00216     void finishTypeAhead();
00217 
00219     void slotTodoDropped( Todo *, const QPoint &, bool );
00220 
00221     void enableAgendaUpdate( bool enable );
00222     void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
00223 
00224     void zoomInHorizontally( const QDate& date=QDate() );
00225     void zoomOutHorizontally( const QDate& date=QDate() );
00226 
00227     void zoomInVertically( );
00228     void zoomOutVertically( );
00229 
00230     void zoomView( const int delta, const QPoint &pos,
00231       const Qt::Orientation orient=Qt::Horizontal );
00232 
00233     void clearTimeSpanSelection();
00234   signals:
00235     void toggleExpand();
00236     void zoomViewHorizontally(const QDate &, int count );
00237 
00238     void timeSpanSelectionChanged();
00239 
00240   protected:
00242     void fillAgenda( const QDate &startDate );
00243 
00245     void fillAgenda();
00246 
00247     void connectAgenda( KOAgenda*agenda, QPopupMenu*popup, KOAgenda* otherAgenda );
00248 
00250     void createDayLabels();
00251 
00255     void setHolidayMasks();
00256 
00257     void removeIncidence( Incidence * );
00262     void updateEventIndicators();
00263 
00264     void updateTimeBarWidth();
00265 
00266   protected slots:
00268     void updateEventDates( KOAgendaItem *item );
00270     void doUpdateItem();
00271 
00272     void updateEventIndicatorTop( int newY );
00273     void updateEventIndicatorBottom( int newY );
00274 
00276     void newTimeSpanSelected( const QPoint &start, const QPoint &end );
00278     void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
00279 
00280   private:
00281     bool filterByResource( Incidence *incidence );
00282 
00283   private:
00284     // view widgets
00285     QFrame *mDayLabels;
00286     QHBox *mDayLabelsFrame;
00287     QBoxLayout *mLayoutDayLabels;
00288     QFrame *mAllDayFrame;
00289     KOAgenda *mAllDayAgenda;
00290     KOAgenda *mAgenda;
00291     TimeLabels *mTimeLabels;
00292     QWidget *mDummyAllDayLeft;
00293     QSplitter *mSplitterAgenda;
00294     QPushButton *mExpandButton;
00295 
00296     DateList mSelectedDates;  // List of dates to be displayed
00297     int mViewType;
00298 
00299     KOEventPopupMenu *mAgendaPopup;
00300     KOEventPopupMenu *mAllDayAgendaPopup;
00301 
00302     EventIndicator *mEventIndicatorTop;
00303     EventIndicator *mEventIndicatorBottom;
00304 
00305     QMemArray<int> mMinY;
00306     QMemArray<int> mMaxY;
00307 
00308     QMemArray<bool> mHolidayMask;
00309 
00310     QPixmap mExpandedPixmap;
00311     QPixmap mNotExpandedPixmap;
00312 
00313     QDateTime mTimeSpanBegin;
00314     QDateTime mTimeSpanEnd;
00315     bool mTimeSpanInAllDay;
00316     bool mAllowAgendaUpdate;
00317 
00318     Incidence *mUpdateItem;
00319 
00320     KCal::ResourceCalendar *mResource;
00321     QString mSubResource;
00322 };
00323 
00324 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys