korganizer

kotodoview.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 TQt, and distribute the resulting executable,
00023     without including the source code for TQt in the source distribution.
00024 */
00025 #ifndef KOTODOVIEW_H
00026 #define KOTODOVIEW_H
00027 
00028 #include <tqmap.h>
00029 #include <tqtooltip.h>
00030 
00031 #include <klistview.h>
00032 
00033 #include <libkcal/todo.h>
00034 #include <korganizer/baseview.h>
00035 
00036 class TQDragEnterEvent;
00037 class TQDragMoveEvent;
00038 class TQDragLeaveEvent;
00039 class TQDropEvent;
00040 class TQPopupMenu;
00041 
00042 class KOTodoListView;
00043 class KOTodoViewItem;
00044 class KDatePickerPopup;
00045 
00046 class DocPrefs;
00047 
00048 namespace KPIM {
00049   class ClickLineEdit;
00050 }
00051 namespace KCal {
00052 class Incidence;
00053 class Calendar;
00054 }
00055 using namespace KCal;
00056 using namespace KOrg;
00057 
00058 class KOTodoListViewToolTip : public TQToolTip
00059 {
00060   public:
00061     KOTodoListViewToolTip( TQWidget *parent, Calendar *calendar, KOTodoListView *lv );
00062 
00063   protected:
00064     void maybeTip( const TQPoint &pos );
00065 
00066   private:
00067     Calendar *mCalendar;
00068     KOTodoListView *todolist;
00069 };
00070 
00071 
00072 class KOTodoListView : public KListView
00073 {
00074     Q_OBJECT
00075   TQ_OBJECT
00076   public:
00077     KOTodoListView( TQWidget *parent = 0, const char *name = 0 );
00078     ~KOTodoListView();
00079 
00080     void setCalendar( Calendar * );
00081 
00082     void setIncidenceChanger( IncidenceChangerBase *changer ) { mChanger = changer; }
00083 
00084   protected:
00085     virtual bool event( TQEvent * );
00086 
00087     void contentsDragEnterEvent( TQDragEnterEvent * );
00088     void contentsDragMoveEvent( TQDragMoveEvent * );
00089     void contentsDragLeaveEvent( TQDragLeaveEvent * );
00090     void contentsDropEvent( TQDropEvent * );
00091 
00092     void contentsMousePressEvent( TQMouseEvent * );
00093     void contentsMouseMoveEvent( TQMouseEvent * );
00094     void contentsMouseReleaseEvent( TQMouseEvent * );
00095     void contentsMouseDoubleClickEvent( TQMouseEvent * );
00096 
00097   private:
00098     Calendar *mCalendar;
00099     KOrg::IncidenceChangerBase *mChanger;
00100 
00101     TQPoint mPressPos;
00102     bool mMousePressed;
00103     TQListViewItem *mOldCurrent;
00104 };
00105 
00106 
00113 class KOTodoView : public KOrg::BaseView
00114 {
00115     Q_OBJECT
00116   TQ_OBJECT
00117   public:
00118     KOTodoView( Calendar *cal, TQWidget *parent = 0, const char *name = 0 );
00119     ~KOTodoView();
00120 
00121     void setCalendar( Calendar * );
00122 
00123     Incidence::List selectedIncidences();
00124     Todo::List selectedTodos();
00125 
00126     DateList selectedIncidenceDates() { return DateList(); }
00127 
00129     int currentDateCount() { return 0; }
00130 
00131     CalPrinterBase::PrintType printType();
00132 
00133     void setDocumentId( const TQString & );
00134 
00135     void saveLayout( KConfig *config, const TQString &group ) const;
00136     void restoreLayout( KConfig *config, const TQString &group );
00138     TQPopupMenu *getCategoryPopupMenu( KOTodoViewItem *todoItem );
00139     void setIncidenceChanger( IncidenceChangerBase *changer );
00140 
00141   public slots:
00142     void updateView();
00143     void updateConfig();
00144 
00145     void changeIncidenceDisplay( Incidence *, int );
00146 
00147     void showDates( const TQDate &start, const TQDate &end );
00148     void showIncidences( const Incidence::List &incidenceList, const TQDate &date );
00149 
00150     void clearSelection();
00151 
00152     void editItem( TQListViewItem *item, const TQPoint &, int );
00153     void editItem( TQListViewItem *item );
00154     void showItem( TQListViewItem *item, const TQPoint &, int );
00155     void showItem( TQListViewItem *item );
00156     void popupMenu( TQListViewItem *item, const TQPoint &, int );
00157     void newTodo();
00158     void newSubTodo();
00159     void showTodo();
00160     void editTodo();
00161     void printTodo();
00162     void deleteTodo();
00163 
00164     void setNewPercentage( KOTodoViewItem *item, int percentage );
00165 
00166     void setNewPriority( int );
00167     void setNewPercentage( int );
00168     void setNewDate( TQDate );
00169     void copyTodoToDate( TQDate );
00170     void changedCategories( int );
00171 
00172     void purgeCompleted();
00173 
00174     void itemStateChanged( TQListViewItem * );
00175 
00176     void setNewPercentageDelayed( KOTodoViewItem *item, int percentage );
00177     void processDelayedNewPercentage();
00178 
00179   signals:
00180     void unSubTodoSignal();
00181     void unAllSubTodoSignal();
00182     void purgeCompletedSignal();
00183     void configChanged();
00184 
00185   protected slots:
00186     void processSelectionChange();
00187     void addQuickTodo();
00188     void removeTodoItems();
00189 
00190   private:
00191     /*
00192      * the TodoEditor approach is rather unscaling in the long
00193      * run.
00194      * Korganizer keeps it in memory and we need to update
00195      * 1. make KOTodoViewItem a TQObject again?
00196      * 2. add a public method for setting one todo modified?
00197      * 3. add a private method for setting a todo modified + friend here?
00198      *  -- zecke 2002-07-08
00199      */
00200     friend class KOTodoViewItem;
00201 
00202     TQMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem( Todo *todo );
00203     bool scheduleRemoveTodoItem( KOTodoViewItem *todoItem );
00204     void restoreItemState( TQListViewItem * );
00205 
00206     KOTodoListView *mTodoListView;
00207     TQPopupMenu *mItemPopupMenu;
00208     TQPopupMenu *mPopupMenu;
00209     TQPopupMenu *mPriorityPopupMenu;
00210     TQPopupMenu *mPercentageCompletedPopupMenu;
00211     TQPopupMenu *mCategoryPopupMenu;
00212     KDatePickerPopup *mMovePopupMenu;
00213     KDatePickerPopup *mCopyPopupMenu;
00214 
00215     TQMap<int, int> mPercentage;
00216     TQMap<int, int> mPriority;
00217     TQMap<int, TQString> mCategory;
00218 
00219     KOTodoViewItem *mActiveItem;
00220 
00221     TQMap<Todo *,KOTodoViewItem *> mTodoMap;
00222     TQPtrList<KOTodoViewItem> mItemsToDelete;
00223     TQValueList< TQPair<KOTodoViewItem *, int> > mPercentChangedMap;
00224 
00225     DocPrefs *mDocPrefs;
00226     TQString mCurrentDoc;
00227     KPIM::ClickLineEdit *mQuickAdd;
00228 
00229   public:
00230     enum {
00231       eSummaryColumn = 0,
00232       eRecurColumn = 1,
00233       ePriorityColumn = 2,
00234       ePercentColumn = 3,
00235       eDueDateColumn = 4,
00236       eCategoriesColumn = 5,
00237       eFolderColumn = 6
00238     };
00239     enum {
00240       ePopupEdit = 1300,
00241       ePopupDelete = 1301,
00242       ePopupMoveTo = 1302,
00243       ePopupCopyTo = 1303,
00244       ePopupUnSubTodo = 1304,
00245       ePopupUnAllSubTodo = 1305
00246     };
00247 
00248 };
00249 
00250 #endif