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 TQt, and distribute the resulting executable,
00024     without including the source code for TQt 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 TQToolTip
00045 {
00046   public:
00047     KOListViewToolTip ( TQWidget* parent, Calendar *calendar, TDEListView* lv );
00048 
00049   protected:
00050     void maybeTip( const TQPoint &pos );
00051 
00052   private:
00053     Calendar *mCalendar;
00054     TDEListView* eventlist;
00055 };
00056 
00057 
00068 class KOListView : public KOEventView
00069 {
00070     Q_OBJECT
00071   
00072   public:
00073    explicit KOListView( Calendar *calendar,
00074                         TQWidget *parent = 0,
00075                         const char *name = 0,
00076                         bool nonInteractive = false );
00077     ~KOListView();
00078 
00079     virtual int maxDatesHint();
00080     virtual int currentDateCount();
00081     virtual Incidence::List selectedIncidences();
00082     virtual DateList selectedIncidenceDates();
00083 
00084     void showDates( bool show );
00085 
00086     // Shows all incidences of the calendar
00087     void showAll();
00088 
00089     void readSettings(TDEConfig *config);
00090     void writeSettings(TDEConfig *config);
00091 
00092     void clear();
00093     TQSize sizeHint() const;
00094 
00095   public slots:
00096     virtual void updateView();
00097     virtual void showDates( const TQDate &start, const TQDate &end );
00098     virtual void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
00099 
00100     void clearSelection();
00101 
00102     void showDates();
00103     void hideDates();
00104 
00105     void changeIncidenceDisplay(Incidence *, int);
00106 
00107     void defaultItemAction(TQListViewItem *item);
00108     void popupMenu(TQListViewItem *item,const TQPoint &,int);
00109 
00110   protected slots:
00111     void processSelectionChange();
00112 
00113   protected:
00114     void addIncidences(const Incidence::List &, const TQDate &date);
00115     void addIncidence(Incidence *,  const TQDate &date);
00116     KOListViewItem *getItemForIncidence(Incidence *incidence);
00117 
00118   private:
00119     class ListItemVisitor;
00120     TDEListView *mListView;
00121     KOEventPopupMenu *mPopupMenu;
00122     KOListViewItem *mActiveItem;
00123     TQDict<Incidence> mUidDict;
00124     TQMap<TQString, TQDate>mDateList;
00125     DateList mSelectedDates;
00126 
00127     // if it's non interactive we disable context menu, and incidence editing
00128     bool mIsNonInteractive;
00129 };
00130 
00131 #endif