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