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 
00035 #include "agendaview.h"
00036 
00037 class QHBox;
00038 class QPushButton;
00039 class QBoxLayout;
00040 
00041 class KOAgenda;
00042 class KOAgendaItem;
00043 class TimeLabels;
00044 class KConfig;
00045 
00046 namespace KOrg {
00047   class IncidenceChangerBase;
00048 }
00049 
00050 class EventIndicator : public QFrame
00051 {
00052     Q_OBJECT
00053   public:
00054     enum Location { Top, Bottom };
00055     EventIndicator( Location loc = Top, QWidget *parent = 0,
00056                     const char *name = 0 );
00057     virtual ~EventIndicator();
00058 
00059     void changeColumns( int columns );
00060 
00061     void enableColumn( int column, bool enable );
00062 
00063   protected:
00064     void drawContents( QPainter * );
00065 
00066   private:
00067     int mColumns;
00068     Location mLocation;
00069     QPixmap mPixmap;
00070     QMemArray<bool> mEnabled;
00071 };
00072 
00073 class KOAlternateLabel : public QLabel
00074 {
00075     Q_OBJECT
00076   public:
00077     KOAlternateLabel( const QString &shortlabel, const QString &longlabel,
00078                       const QString &extensivelabel = QString::null,
00079                       QWidget *parent = 0, const char *name = 0 );
00080     ~KOAlternateLabel();
00081 
00082     virtual QSize minimumSizeHint() const;
00083 
00084   public slots:
00085     void setText( const QString & );
00086     void useShortText();
00087     void useLongText();
00088     void useExtensiveText();
00089     void useDefaultText();
00090 
00091   protected:
00092     virtual void resizeEvent( QResizeEvent * );
00093     virtual void squeezeTextToLabel();
00094     bool mTextTypeFixed;
00095     QString mShortText, mLongText, mExtensiveText;
00096 };
00097 
00102 class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::Observer
00103 {
00104     Q_OBJECT
00105   public:
00106     KOAgendaView( Calendar *cal, QWidget *parent = 0, const char *name = 0, bool isSideBySide = false );
00107     virtual ~KOAgendaView();
00108 
00110     virtual int maxDatesHint();
00111 
00113     virtual int currentDateCount();
00114 
00116     virtual Incidence::List selectedIncidences();
00117 
00119     virtual DateList selectedDates();
00120 
00122     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00123 
00125     void clearView();
00126 
00127     KOrg::CalPrinterBase::PrintType printType();
00128 
00130     QDateTime selectionStart() { return mTimeSpanBegin; }
00132     QDateTime selectionEnd() { return mTimeSpanEnd; }
00134     bool selectedIsAllDay() { return mTimeSpanInAllDay; }
00136     void deleteSelectedDateTime();
00138     bool selectedIsSingleCell();
00139 
00140     void setTypeAheadReceiver( QObject * );
00141 
00142     KOAgenda* agenda() const { return mAgenda; }
00143     QSplitter* splitter() const { return mSplitterAgenda; }
00144     QFrame *dayLabels() const { return mDayLabels; }
00145 
00146     /* reimplmented from KCal::Calendar::Observer */
00147     void calendarIncidenceAdded( Incidence *incidence );
00148     void calendarIncidenceChanged( Incidence *incidence );
00149     void calendarIncidenceDeleted( Incidence *incidence );
00150 
00151   public slots:
00152     virtual void updateView();
00153     virtual void updateConfig();
00154     virtual void showDates( const QDate &start, const QDate &end );
00155     virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00156 
00157     void insertIncidence( Incidence *incidence, const QDate &curDate );
00158     void changeIncidenceDisplayAdded( Incidence *incidence );
00159     void changeIncidenceDisplay( Incidence *incidence, int mode );
00160 
00161     void clearSelection();
00162 
00163     void startDrag( Incidence * );
00164 
00165     void readSettings();
00166     void readSettings( KConfig * );
00167     void writeSettings( KConfig * );
00168 
00169     void setContentsPos( int y );
00170 
00171     void setExpandedButton( bool expanded );
00172 
00173     void finishTypeAhead();
00174 
00176     void slotTodoDropped( Todo *, const QPoint &, bool );
00177 
00178     void enableAgendaUpdate( bool enable );
00179     void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
00180 
00181     void zoomInHorizontally( const QDate& date=QDate() );
00182     void zoomOutHorizontally( const QDate& date=QDate() );
00183 
00184     void zoomInVertically( );
00185     void zoomOutVertically( );
00186 
00187     void zoomView( const int delta, const QPoint &pos,
00188       const Qt::Orientation orient=Qt::Horizontal );
00189 
00190     void clearTimeSpanSelection();
00191 
00192     void resourcesChanged();
00193 
00194   signals:
00195     void toggleExpand();
00196     void zoomViewHorizontally(const QDate &, int count );
00197 
00198     void timeSpanSelectionChanged();
00199 
00200   protected:
00202     void fillAgenda( const QDate &startDate );
00203 
00205     void fillAgenda();
00206 
00207     void connectAgenda( KOAgenda*agenda, QPopupMenu*popup, KOAgenda* otherAgenda );
00208 
00210     void createDayLabels();
00211 
00215     void setHolidayMasks();
00216 
00217     void removeIncidence( Incidence * );
00222     void updateEventIndicators();
00223 
00224     void updateTimeBarWidth();
00225 
00226   protected slots:
00228     void updateEventDates( KOAgendaItem *item );
00230     void doUpdateItem();
00231 
00232     void updateEventIndicatorTop( int newY );
00233     void updateEventIndicatorBottom( int newY );
00234 
00236     void newTimeSpanSelected( const QPoint &start, const QPoint &end );
00238     void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
00239 
00240   private:
00241     bool filterByResource( Incidence *incidence );
00242     void displayIncidence( Incidence *incidence );
00243 
00244   private:
00245     // view widgets
00246     QFrame *mDayLabels;
00247     QHBox *mDayLabelsFrame;
00248     QBoxLayout *mLayoutDayLabels;
00249     QFrame *mAllDayFrame;
00250     KOAgenda *mAllDayAgenda;
00251     KOAgenda *mAgenda;
00252     TimeLabels *mTimeLabels;
00253     QWidget *mDummyAllDayLeft;
00254     QSplitter *mSplitterAgenda;
00255     QPushButton *mExpandButton;
00256 
00257     DateList mSelectedDates;  // List of dates to be displayed
00258     int mViewType;
00259 
00260     KOEventPopupMenu *mAgendaPopup;
00261     KOEventPopupMenu *mAllDayAgendaPopup;
00262 
00263     EventIndicator *mEventIndicatorTop;
00264     EventIndicator *mEventIndicatorBottom;
00265 
00266     QMemArray<int> mMinY;
00267     QMemArray<int> mMaxY;
00268 
00269     QMemArray<bool> mHolidayMask;
00270 
00271     QPixmap mExpandedPixmap;
00272     QPixmap mNotExpandedPixmap;
00273 
00274     QDateTime mTimeSpanBegin;
00275     QDateTime mTimeSpanEnd;
00276     bool mTimeSpanInAllDay;
00277     bool mAllowAgendaUpdate;
00278 
00279     Incidence *mUpdateItem;
00280 
00281     bool mIsSideBySide;
00282     bool mPendingChanges;
00283 };
00284 
00285 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys