summaryrefslogtreecommitdiffstats
path: root/kpilot/todoWidget.h
blob: 238d818ac897c0b4d6266fce9110f1e26e505022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* todoWidget.h			KPilot
**
** Copyright (C) 2004 Reinhold Kainhofer <[email protected]>
**

** This file defines the todo-viewing widget used in KPilot
** to display the Pilot's todo records.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to [email protected]
*/
#ifndef _KPILOT_TODOWIDGET_H
#define _KPILOT_TODOWIDGET_H

class TQComboBox;
class TQPushButton;
class TQTextView;

#include "pilotComponent.h"
#include "pilotTodoEntry.h"
#include "listItems.h"

class TodoListView : public TDEListView
{
Q_OBJECT
  
public:
	TodoListView(TQWidget * parent = 0, const char * name = 0 ):TDEListView(parent, name){};
	~TodoListView() {};
signals:
	void itemChecked(TQCheckListItem*item);
	void itemChecked(TQCheckListItem*item, bool on);
//protected:
public:
	void itemWasChecked(TQCheckListItem*item, bool on) {
		emit itemChecked(item);
		emit itemChecked(item, on);
	}
};

class TodoCheckListItem : public PilotCheckListItem
{
public:
	TodoCheckListItem(TQListView*parent, const TQString&text, recordid_t pilotid, void*r);
	~TodoCheckListItem()  {};
	virtual void  stateChange(bool state);
};

class TodoWidget : public PilotComponent
{
Q_OBJECT
  

public:
	TodoWidget(TQWidget* parent,const TQString& dbpath);
	~TodoWidget();

	// Pilot Component Methods:
	virtual bool preHotSync(TQString &);
	virtual void postHotSync();
	virtual void showComponent();
	virtual void hideComponent();

public slots:
	/**
	* Called when a particular todo is selected. This slot displays
	* it in the viewer widget.
	*/
	void slotShowTodo(TQListViewItem*);
	void slotEditRecord(TQListViewItem*item);
	void slotEditRecord();
	void slotCreateNewRecord();
	void slotDeleteRecord();
	void slotEditCancelled();

	void slotUpdateButtons();	// Enable/disable buttons

signals:
	void recordChanged(PilotTodoEntry *);

protected slots:
	/**
	* When an edit window is closed, the corresponding record
	* is updated and possibly re-displayed.
	*/
	void slotUpdateRecord(PilotTodoEntry*);

	/**
	* Pop up an edit window for a new record.
	*/
	void slotAddRecord(PilotTodoEntry*);

	/**
	* Change category. This means that the display should be
	* cleared and that the list should be repopulated.
	*/
	void slotSetCategory(int);


	void slotItemChecked(TQCheckListItem*item, bool on);
	void slotItemRenamed(TQListViewItem*item, const TQString &txt, int nr);
private:
	void setupWidget();
	void updateWidget(); // Called with the lists have changed..
	void writeTodo(PilotTodoEntry* which,PilotDatabase *db=0L);

	/**
	* getAllTodos reads the database and places all
	* the todos from the database in the list
	* in memory --- not the list on the screen.
	* @see fTodoList
	*/
	int getAllTodos(PilotDatabase *todoDB);

	/**
	* Create a sensible "title" for an todo, composed
	* of first + last name if possible.
	*/
	TQString createTitle(PilotTodoEntry *,int displayMode);

	/**
	* We use a TQComboBox fCatList to hold the user-visible names
	* of all the categories. The TQTextView fTodoInfo is for
	* displaying the currently selected todo, if any.
	* The TQListView fListBox lists all the todoes in the
	* currently selected category.
	*
	* The entire todo database is read into memory in the
	* TQPtrList fTodoList. We need the appinfo block from the
	* database to determine which categories there are; this
	* is held in fTodoAppInfo.
	*
	* The two buttons should speak for themselves.
	*/
	TQComboBox		*fCatList;
	TQTextView		*fTodoInfo;
	PilotToDoInfo 		*fTodoAppInfo;
	TQPtrList<PilotTodoEntry>	fTodoList;
	TodoListView		*fListBox;
	TQPushButton		*fEditButton,*fDeleteButton;
	PilotDatabase		*fTodoDB;
protected:
	/**
	* Keep track of how many open todo editing windows there
	* are. You can't sync when there are open windows.
	*/
	int fPendingTodos;

};

#endif