korganizer Library API Documentation

komonthview.h

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef _KOMONTHVIEW_H
00021 #define _KOMONTHVIEW_H
00022 
00023 #include <qlabel.h>
00024 #include <qframe.h>
00025 #include <qdatetime.h>
00026 #include <qlistbox.h>
00027 #include <qlayout.h>
00028 #include <qintdict.h>
00029 #include <qpushbutton.h>
00030 #include <qvaluelist.h>
00031 #include <qptrvector.h>
00032 
00033 #include <libkcal/calendar.h>
00034 #include <libkcal/event.h>
00035 
00036 #include "koeventview.h"
00037 
00038 
00039 class KNoScrollListBox: public QListBox
00040 {
00041     Q_OBJECT
00042   public:
00043     KNoScrollListBox(QWidget *parent=0, const char *name=0);
00044     ~KNoScrollListBox() {}
00045 
00046   signals:
00047     void shiftDown();
00048     void shiftUp();
00049     void rightClick();
00050 
00051    protected slots:
00052     void keyPressEvent(QKeyEvent *);
00053     void keyReleaseEvent(QKeyEvent *);
00054     void mousePressEvent(QMouseEvent *);
00055 };
00056 
00057 
00058 class MonthViewItem: public QListBoxItem
00059 {
00060   public:
00061     MonthViewItem( Incidence *, QDate qd, const QString & title );
00062 
00063     void setRecur(bool on) { mRecur = on; }
00064     void setAlarm(bool on) { mAlarm = on; }
00065     void setReply(bool on) { mReply = on; }
00066 
00067     void setPalette(const QPalette &p) { mPalette = p; }
00068     QPalette palette() const { return mPalette; }
00069 
00070     Incidence *incidence() const { return mIncidence; }
00071     QDate incidenceDate() { return mDate; }
00072 
00073   protected:
00074     virtual void paint(QPainter *);
00075     virtual int height(const QListBox *) const;
00076     virtual int width(const QListBox *) const;
00077 
00078   private:
00079     bool mRecur;
00080     bool mAlarm;
00081     bool mReply;
00082 
00083     QPixmap mAlarmPixmap;
00084     QPixmap mRecurPixmap;
00085     QPixmap mReplyPixmap;
00086 
00087     QPalette mPalette;
00088     QDate mDate;
00089 
00090     Incidence *mIncidence;
00091 };
00092 
00093 
00094 class KOMonthView;
00095 
00096 class MonthViewCell : public QWidget
00097 {
00098     Q_OBJECT
00099   public:
00100     MonthViewCell( KOMonthView * );
00101 
00102     void setDate( const QDate & );
00103     QDate date() const;
00104 
00105     void setPrimary( bool );
00106     bool isPrimary() const;
00107 
00108     void setHoliday( bool );
00109     void setHoliday( const QString & );
00110 
00111     void updateCell();
00112 
00113     void updateConfig();
00114 
00115     void enableScrollBars( bool );
00116 
00117     Incidence *selectedIncidence();
00118     QDate selectedIncidenceDate();
00119 
00120     void deselect();
00121 
00122   signals:
00123     void defaultAction( Incidence * );
00124     void newEventSignal( QDateTime );
00125     
00126   protected:
00127     void resizeEvent( QResizeEvent * );
00128 
00129   protected slots:
00130     void defaultAction( QListBoxItem * );
00131     void contextMenu( QListBoxItem * );
00132     void selection( QListBoxItem * );
00133     void cellClicked( QListBoxItem * );
00134     
00135   private:
00136     KOMonthView *mMonthView;
00137   
00138     QDate mDate;
00139     bool mPrimary;
00140     bool mHoliday;
00141     QString mHolidayString;
00142     
00143     QLabel *mLabel;
00144     QListBox *mItemList;
00145     
00146     QSize mLabelSize;
00147     QPalette mHolidayPalette;
00148     QPalette mStandardPalette;
00149     
00150 };
00151 
00152 
00153 class KOMonthView: public KOEventView
00154 {
00155     Q_OBJECT
00156   public:
00157     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00158     ~KOMonthView();
00159 
00161     virtual int maxDatesHint();
00162 
00164     virtual int currentDateCount();
00165 
00167     virtual QPtrList<Incidence> selectedIncidences();
00168 
00170     virtual DateList selectedDates();
00171 
00172     virtual void printPreview(CalPrinter *calPrinter,
00173                               const QDate &, const QDate &);
00174 
00175   public slots:
00176     virtual void updateView();
00177     virtual void updateConfig();
00178     virtual void showDates(const QDate &start, const QDate &end);
00179     virtual void showEvents(QPtrList<Event> eventList);
00180 
00181     void changeEventDisplay(Event *, int);
00182 
00183     void clearSelection();
00184 
00185     void showContextMenu( Incidence * );
00186 
00187     void setSelectedCell( MonthViewCell * );
00188 
00189   protected slots:
00190     void processSelectionChange();
00191 
00192   protected:
00193     void resizeEvent(QResizeEvent *);
00194 
00195     void viewChanged();
00196     void updateDayLabels();
00197 
00198   private:
00199     int mDaysPerWeek;
00200     int mNumWeeks;
00201     int mNumCells;
00202     bool mWeekStartsMonday;
00203 
00204     QPtrVector<MonthViewCell> mCells;
00205     QPtrVector<QLabel> mDayLabels;
00206 
00207     bool mShortDayLabels;
00208     int mWidthLongDayLabel;
00209 
00210     QDate mStartDate;
00211 
00212     MonthViewCell *mSelectedCell;
00213 
00214     KOEventPopupMenu *mContextMenu;
00215 
00216 };
00217 
00218 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:41:09 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001