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   public slots:
00086     void setText( const QString & );
00087     void useShortText();
00088     void useLongText();
00089     void useExtensiveText();
00090     void useDefaultText();
00091 
00092   protected:
00093     virtual void resizeEvent( QResizeEvent * );
00094     virtual void squeezeTextToLabel();
00095     bool mTextTypeFixed;
00096     QString mShortText, mLongText, mExtensiveText;
00097 };
00098 
00103 class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::Observer
00104 {
00105     Q_OBJECT
00106   public:
00107     KOAgendaView( Calendar *cal,
00108                   CalendarView *calendarView,
00109                   QWidget *parent = 0,
00110                   const char *name = 0,
00111                   bool isSideBySide = false );
00112     virtual ~KOAgendaView();
00113 
00115     virtual int maxDatesHint();
00116 
00118     virtual int currentDateCount();
00119 
00121     virtual Incidence::List selectedIncidences();
00122 
00124     virtual DateList selectedIncidenceDates();
00125 
00127     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00128 
00130     void clearView();
00131 
00132     KOrg::CalPrinterBase::PrintType printType();
00133 
00135     QDateTime selectionStart() { return mTimeSpanBegin; }
00137     QDateTime selectionEnd() { return mTimeSpanEnd; }
00139     bool selectedIsAllDay() { return mTimeSpanInAllDay; }
00141     void deleteSelectedDateTime();
00143     bool selectedIsSingleCell();
00144 
00145     void setTypeAheadReceiver( QObject * );
00146 
00147     KOAgenda* agenda() const { return mAgenda; }
00148     QSplitter* splitter() const { return mSplitterAgenda; }
00149     QFrame *dayLabels() const { return mDayLabels; }
00150 
00151     /* reimplmented from KCal::Calendar::Observer */
00152     void calendarIncidenceAdded( Incidence *incidence );
00153     void calendarIncidenceChanged( Incidence *incidence );
00154     void calendarIncidenceDeleted( Incidence *incidence );
00155 
00156   public slots:
00157     virtual void updateView();
00158     virtual void updateConfig();
00159     virtual void showDates( const QDate &start, const QDate &end );
00160     virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00161 
00162     void insertIncidence( Incidence *incidence, const QDate &curDate );
00163     void changeIncidenceDisplayAdded( Incidence *incidence );
00164     void changeIncidenceDisplay( Incidence *incidence, int mode );
00165 
00166     void clearSelection();
00167 
00168     void startDrag( Incidence * );
00169 
00170     void readSettings();
00171     void readSettings( KConfig * );
00172     void writeSettings( KConfig * );
00173 
00174     void setContentsPos( int y );
00175 
00176     void setExpandedButton( bool expanded );
00177 
00178     void finishTypeAhead();
00179 
00181     void slotTodoDropped( Todo *, const QPoint &, bool );
00182 
00183     void enableAgendaUpdate( bool enable );
00184     void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
00185 
00186     void zoomInHorizontally( const QDate& date=QDate() );
00187     void zoomOutHorizontally( const QDate& date=QDate() );
00188 
00189     void zoomInVertically( );
00190     void zoomOutVertically( );
00191 
00192     void zoomView( const int delta, const QPoint &pos,
00193       const Qt::Orientation orient=Qt::Horizontal );
00194 
00195     void clearTimeSpanSelection();
00196 
00197     void resourcesChanged();
00198 
00199   signals:
00200     void toggleExpand();
00201     void zoomViewHorizontally(const QDate &, int count );
00202 
00203     void timeSpanSelectionChanged();
00204 
00205   protected:
00207     void fillAgenda( const QDate &startDate );
00208 
00210     void fillAgenda();
00211 
00212     void connectAgenda( KOAgenda*agenda, QPopupMenu*popup, KOAgenda* otherAgenda );
00213 
00215     void createDayLabels();
00216 
00220     void setHolidayMasks();
00221 
00222     void removeIncidence( Incidence * );
00227     void updateEventIndicators();
00228 
00229     void updateTimeBarWidth();
00230 
00231   protected slots:
00233     void updateEventDates( KOAgendaItem *item );
00235     void doUpdateItem();
00236 
00237     void updateEventIndicatorTop( int newY );
00238     void updateEventIndicatorBottom( int newY );
00239 
00241     void newTimeSpanSelected( const QPoint &start, const QPoint &end );
00243     void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
00244 
00245   private:
00246     bool filterByResource( Incidence *incidence );
00247     void displayIncidence( Incidence *incidence );
00248 
00249   private:
00250     // view widgets
00251     QFrame *mDayLabels;
00252     QHBox *mDayLabelsFrame;
00253     QBoxLayout *mLayoutDayLabels;
00254     QFrame *mAllDayFrame;
00255     KOAgenda *mAllDayAgenda;
00256     KOAgenda *mAgenda;
00257     TimeLabels *mTimeLabels;
00258     QWidget *mDummyAllDayLeft;
00259     QSplitter *mSplitterAgenda;
00260     QPushButton *mExpandButton;
00261 
00262     DateList mSelectedDates;  // List of dates to be displayed
00263     int mViewType;
00264 
00265     KOEventPopupMenu *mAgendaPopup;
00266     KOEventPopupMenu *mAllDayAgendaPopup;
00267 
00268     EventIndicator *mEventIndicatorTop;
00269     EventIndicator *mEventIndicatorBottom;
00270 
00271     QMemArray<int> mMinY;
00272     QMemArray<int> mMaxY;
00273 
00274     QMemArray<bool> mHolidayMask;
00275 
00276     QPixmap mExpandedPixmap;
00277     QPixmap mNotExpandedPixmap;
00278 
00279     QDateTime mTimeSpanBegin;
00280     QDateTime mTimeSpanEnd;
00281     bool mTimeSpanInAllDay;
00282     bool mAllowAgendaUpdate;
00283 
00284     Incidence *mUpdateItem;
00285 
00286     bool mIsSideBySide;
00287     bool mPendingChanges;
00288 };
00289 
00290 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys