korganizer

kolistview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00005     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00006     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00021 
00022     As a special exception, permission is given to link this program
00023     with any edition of Qt, and distribute the resulting executable,
00024     without including the source code for Qt in the source distribution.
00025 */
00026 #ifndef _KOLISTVIEW_H
00027 #define _KOLISTVIEW_H
00028 
00029 #include <tqdict.h>
00030 #include <tqmap.h>
00031 #include <tqtooltip.h>
00032 
00033 #include <libkcal/incidence.h>
00034 
00035 #include "koeventview.h"
00036 #include "customlistviewitem.h"
00037 
00038 using namespace KCal;
00039 
00040 typedef CustomListViewItem<Incidence *> KOListViewItem;
00041 
00042 class KOListView;
00043 
00044 class KOListViewToolTip : public QToolTip
00045 {
00046   public:
00047     KOListViewToolTip ( TQWidget* parent, Calendar *calendar, KListView* lv );
00048 
00049   protected:
00050     void maybeTip( const TQPoint &pos );
00051 
00052   private:
00053     Calendar *mCalendar;
00054     KListView* eventlist;
00055 };
00056 
00057 
00068 class KOListView : public KOEventView
00069 {
00070     Q_OBJECT
00071   public:
00072    explicit KOListView( Calendar *calendar,
00073                         TQWidget *parent = 0,
00074                         const char *name = 0,
00075                         bool nonInteractive = false );
00076     ~KOListView();
00077 
00078     virtual int maxDatesHint();
00079     virtual int currentDateCount();
00080     virtual Incidence::List selectedIncidences();
00081     virtual DateList selectedIncidenceDates();
00082 
00083     void showDates( bool show );
00084 
00085     // Shows all incidences of the calendar
00086     void showAll();
00087 
00088     void readSettings(KConfig *config);
00089     void writeSettings(KConfig *config);
00090 
00091     void clear();
00092     TQSize sizeHint() const;
00093 
00094   public slots:
00095     virtual void updateView();
00096     virtual void showDates( const TQDate &start, const TQDate &end );
00097     virtual void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
00098 
00099     void clearSelection();
00100 
00101     void showDates();
00102     void hideDates();
00103 
00104     void changeIncidenceDisplay(Incidence *, int);
00105 
00106     void defaultItemAction(TQListViewItem *item);
00107     void popupMenu(TQListViewItem *item,const TQPoint &,int);
00108 
00109   protected slots:
00110     void processSelectionChange();
00111 
00112   protected:
00113     void addIncidences(const Incidence::List &, const TQDate &date);
00114     void addIncidence(Incidence *,  const TQDate &date);
00115     KOListViewItem *getItemForIncidence(Incidence *incidence);
00116 
00117   private:
00118     class ListItemVisitor;
00119     KListView *mListView;
00120     KOEventPopupMenu *mPopupMenu;
00121     KOListViewItem *mActiveItem;
00122     TQDict<Incidence> mUidDict;
00123     TQMap<TQString, TQDate>mDateList;
00124     DateList mSelectedDates;
00125 
00126     // if it's non interactive we disable context menu, and incidence editing
00127     bool mIsNonInteractive;
00128 };
00129 
00130 #endif