korganizer Library API Documentation

komonthview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #ifndef _KOMONTHVIEW_H
00026 #define _KOMONTHVIEW_H
00027 
00028 #include <qlistbox.h>
00029 #include <qptrvector.h>
00030 #include <qtooltip.h>
00031 #include "koeventview.h"
00032 
00033 class KNoScrollListBox;
00034 class QLabel;
00035 
00036 class KOMonthCellToolTip : public QToolTip
00037 {
00038   public:
00039     KOMonthCellToolTip (QWidget* parent, KNoScrollListBox* lv );
00040 
00041   protected:
00042     void maybeTip( const QPoint & pos);
00043 
00044   private:
00045     KNoScrollListBox* eventlist;
00046 };
00047 
00048 
00049 class KNoScrollListBox: public QListBox
00050 {
00051     Q_OBJECT
00052   public:
00053     KNoScrollListBox(QWidget *parent=0, const char *name=0);
00054     ~KNoScrollListBox() {}
00055 
00056     void setBackground( bool primary, bool workday );
00057 
00058   signals:
00059     void shiftDown();
00060     void shiftUp();
00061     void rightClick();
00062 
00063   protected slots:
00064     void keyPressEvent(QKeyEvent *);
00065     void keyReleaseEvent(QKeyEvent *);
00066     void mousePressEvent(QMouseEvent *);
00067     void resizeEvent(QResizeEvent *);
00068     void contentsMouseDoubleClickEvent( QMouseEvent * e );
00069 
00070   private:
00071     bool mSqueezing;
00072 };
00073 
00074 
00075 class MonthViewItem: public QListBoxItem
00076 {
00077   public:
00078     MonthViewItem( Incidence *, QDate qd, const QString & title );
00079 
00080     void setTodo(bool on)  { mTodo  = on; }
00081     void setTodoDone(bool on) { mTodoDone = on; }
00082     void setRecur(bool on) { mRecur = on; }
00083     void setAlarm(bool on) { mAlarm = on; }
00084     void setReply(bool on) { mReply = on; }
00085 
00086     void setPalette(const QPalette &p) { mPalette = p; }
00087     QPalette palette() const { return mPalette; }
00088 
00089     Incidence *incidence() const { return mIncidence; }
00090     QDate itemDate() { return mDate; }
00091 
00092     void setResourceColor( QColor& color ) { mResourceColor = color; }
00093     QColor &resourceColor() { return mResourceColor; }
00094     
00095   protected:
00096     virtual void paint(QPainter *);
00097     virtual int height(const QListBox *) const;
00098     virtual int width(const QListBox *) const;
00099     //Color of the resource
00100     QColor mResourceColor;
00101   private:
00102     bool mTodo;
00103     bool mTodoDone;
00104     bool mRecur;
00105     bool mAlarm;
00106     bool mReply;
00107 
00108     QPixmap mTodoPixmap;
00109     QPixmap mTodoDonePixmap;
00110     QPixmap mAlarmPixmap;
00111     QPixmap mRecurPixmap;
00112     QPixmap mReplyPixmap;
00113 
00114     QPalette mPalette;
00115     QDate mDate;
00116 
00117     Incidence *mIncidence;
00118 };
00119 
00120 
00121 class KOMonthView;
00122 
00127 class MonthViewCell : public QWidget
00128 {
00129     Q_OBJECT
00130   public:
00131     MonthViewCell( KOMonthView * );
00132 
00134     void setDate( const QDate & );
00136     QDate date() const;
00137 
00138     void setPrimary( bool );
00139     bool isPrimary() const;
00140 
00142     void setHoliday( bool );
00143     void setHoliday( const QString & );
00144 
00145     void updateCell();
00149     void addIncidence( Incidence * );
00154     bool removeIncidence( Incidence * );
00155 
00156     void updateConfig();
00157 
00158     void enableScrollBars( bool );
00159 
00160     Incidence *selectedIncidence();
00161     QDate selectedIncidenceDate();
00162 
00163     void deselect();
00164     void setCalendar( Calendar*cal ) { mCalendar = cal; }
00165 
00166   signals:
00167     void defaultAction( Incidence * );
00168     void newEventSignal( QDate );
00169 
00170   protected:
00171     void resizeEvent( QResizeEvent * );
00172 
00173   protected slots:
00174     void defaultAction( QListBoxItem * );
00175     void contextMenu( QListBoxItem * );
00176     void selection( QListBoxItem * );
00177     void cellClicked( QListBoxItem * );
00178 
00179   private:
00180     KOMonthView *mMonthView;
00181     Calendar *mCalendar;
00182 
00183     QDate mDate;
00184     bool mPrimary;
00185     bool mHoliday;
00186     QString mHolidayString;
00187 
00188     QLabel *mLabel;
00189     KNoScrollListBox *mItemList;
00190 
00191     QSize mLabelSize;
00192 //    QPalette mOriginalPalette;
00193     QPalette mHolidayPalette;
00194     QPalette mStandardPalette;
00195     QPalette mTodayPalette;
00196 };
00197 
00205 class KOMonthView: public KOEventView
00206 {
00207     Q_OBJECT
00208   public:
00209     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00210     ~KOMonthView();
00211 
00213     virtual int maxDatesHint();
00214 
00216     virtual int currentDateCount();
00217 
00219     virtual Incidence::List selectedIncidences();
00220 
00222     virtual DateList selectedDates();
00223 
00224     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00225 
00226     virtual void printPreview(CalPrinter *calPrinter,
00227                               const QDate &, const QDate &);
00228 
00229   public slots:
00230     virtual void updateView();
00231     virtual void updateConfig();
00232     virtual void showDates(const QDate &start, const QDate &end);
00233     virtual void showIncidences( const Incidence::List & );
00234 
00235     void changeIncidenceDisplay(Incidence *, int);
00236     void changeIncidenceDisplayAdded(Incidence *);
00237 
00238     void clearSelection();
00239 
00240     void showEventContextMenu( Incidence *, QDate );
00241     void showGeneralContextMenu();
00242 
00243     void setSelectedCell( MonthViewCell * );
00244 
00245   protected slots:
00246     void processSelectionChange();
00247 
00248   protected:
00249     void resizeEvent(QResizeEvent *);
00250 
00251     void viewChanged();
00252     void updateDayLabels();
00253 
00256     MonthViewCell *lookupCellByDate( const QDate &date );
00257 
00258   private:
00259     int mDaysPerWeek;
00260     int mNumWeeks;
00261     int mNumCells;
00262     int mWeekStartDay;
00263 
00264     QPtrVector<MonthViewCell> mCells;
00265     QPtrVector<QLabel> mDayLabels;
00266 
00267     bool mShortDayLabels;
00268     int mWidthLongDayLabel;
00269 
00270     QDate mStartDate;
00271     QDate mSelectedDate;
00272 
00273     MonthViewCell *mSelectedCell;
00274 
00275     KOEventPopupMenu *mEventContextMenu;
00276 };
00277 
00278 #endif
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:43:14 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003