kpilot

todoWidget.h

Go to the documentation of this file.
00001 /* todoWidget.h         KPilot
00002 **
00003 ** Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00004 **
00005 
00006 ** This file defines the todo-viewing widget used in KPilot
00007 ** to display the Pilot's todo records.
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU General Public License as published by
00013 ** the Free Software Foundation; either version 2 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 #ifndef _KPILOT_TODOWIDGET_H
00031 #define _KPILOT_TODOWIDGET_H
00032 
00033 class QComboBox;
00034 class QPushButton;
00035 class QTextView;
00036 
00037 #include "pilotComponent.h"
00038 #include "pilotTodoEntry.h"
00039 #include "listItems.h"
00040 
00041 class TodoListView : public KListView
00042 {
00043 Q_OBJECT
00044 public:
00045     TodoListView(QWidget * parent = 0, const char * name = 0 ):KListView(parent, name){};
00046     ~TodoListView() {};
00047 signals:
00048     void itemChecked(QCheckListItem*item);
00049     void itemChecked(QCheckListItem*item, bool on);
00050 //protected:
00051 public:
00052     void itemWasChecked(QCheckListItem*item, bool on) {
00053         emit itemChecked(item);
00054         emit itemChecked(item, on);
00055     }
00056 };
00057 
00058 class TodoCheckListItem : public PilotCheckListItem
00059 {
00060 public:
00061     TodoCheckListItem(QListView*parent, const QString&text, recordid_t pilotid, void*r);
00062     ~TodoCheckListItem()  {};
00063     virtual void  stateChange(bool state);
00064 };
00065 
00066 class TodoWidget : public PilotComponent
00067 {
00068 Q_OBJECT
00069 
00070 public:
00071     TodoWidget(QWidget* parent,const QString& dbpath);
00072     ~TodoWidget();
00073 
00074     // Pilot Component Methods:
00075     virtual bool preHotSync(QString &);
00076     virtual void postHotSync();
00077     virtual void showComponent();
00078     virtual void hideComponent();
00079 
00080 public slots:
00085     void slotShowTodo(QListViewItem*);
00086     void slotEditRecord(QListViewItem*item);
00087     void slotEditRecord();
00088     void slotCreateNewRecord();
00089     void slotDeleteRecord();
00090     void slotEditCancelled();
00091 
00092     void slotUpdateButtons();   // Enable/disable buttons
00093 
00094 signals:
00095     void recordChanged(PilotTodoEntry *);
00096 
00097 protected slots:
00102     void slotUpdateRecord(PilotTodoEntry*);
00103 
00107     void slotAddRecord(PilotTodoEntry*);
00108 
00113     void slotSetCategory(int);
00114 
00115 
00116     void slotItemChecked(QCheckListItem*item, bool on);
00117     void slotItemRenamed(QListViewItem*item, const QString &txt, int nr);
00118 private:
00119     void setupWidget();
00120     void updateWidget(); // Called with the lists have changed..
00121     void writeTodo(PilotTodoEntry* which,PilotDatabase *db=0L);
00122 
00129     int getAllTodos(PilotDatabase *todoDB);
00130 
00135     QString createTitle(PilotTodoEntry *,int displayMode);
00136 
00151     QComboBox       *fCatList;
00152     QTextView       *fTodoInfo;
00153     PilotToDoInfo       *fTodoAppInfo;
00154     QPtrList<PilotTodoEntry>    fTodoList;
00155     TodoListView        *fListBox;
00156     QPushButton     *fEditButton,*fDeleteButton;
00157     PilotDatabase       *fTodoDB;
00158 protected:
00163     int fPendingTodos;
00164 
00165 };
00166 
00167 #endif