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