summaryrefslogtreecommitdiffstats
path: root/kpilot/kpilot/pilotComponent.h
blob: 4517acc7e48a2be68be16d890437bfefcb2e48ad (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
#ifndef _KPILOT_PILOTCOMPONENT_H
#define _KPILOT_PILOTCOMPONENT_H
/* pilotComponent.h			KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
**
** See the .cc file for an explanation of what this file is for.
*/

/*
** 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 kde-pim@kde.org
*/

/**
  * Base class for any module to KPilot
  */
#include <tqwidget.h>

struct CategoryAppInfo;
class TQComboBox;
class TQString;

class PilotComponent : public QWidget
{
Q_OBJECT
friend class KPilotInstaller;

public:
	PilotComponent(TQWidget* parent,
		const char *id,
		const TQString& dbPath);

	/**
	* Called when the component is shown in kpilot. It should
	* load the database and populate the widgets.
	*/
	virtual void showComponent() {}
	/**
	* Called when the component is hidden in kpilot. It should
	* unload the databases and clean up to save memory. This method
	* can be called even if the component is not visible.
	* If there are some editing dlgs open, this needs to be deferred
	* until they are all closed. Then, one can explicitly call hideComponent().
	*/
	virtual void hideComponent() {}

	/**
	* Set the shown variable to true or false, then call showComponent
	* or hideComponent.
	*/
	void showKPilotComponent( bool toShow );


	/**
	* Get ready for a hotsync -- write any unflushed records
	* to disk, close windows, whatever. Returns false if it
	* is impossible to go into a sync now (due to open windows
	* or strange state.).
	*
	* The default implementation returns true.
	*
	* If the function returns false, it can also put a string
	* stating the reason why into @p s. This string will be
	* displayed to the user:
	*     "Can't start HotSync. %1"
	* where %1 is replaced by s.
	*/
	virtual bool preHotSync(TQString &s) ;

	/**
	* Reload data (possibly changed by the hotsync) etc. etc.
	*/
	virtual void postHotSync() { } ;


protected:
	/**
	* Look up the selected category from the combo box in the
	* Pilot's register of categories. We need this functon because
	* the combo box doesn't contain any reference to the category
	* ID, and we need that ID to do anything with the Pilot.
	*
	* If AllIsUnfiled is true, then when the user selects the
	* category "All" in the combo box (always the first category),
	* Unfiled (0) is returned. Otherwise if the category "All"
	* is selected -1 is returned. For all other categories
	* selected, their ID is returned. If nothing is selected,
	* behave as if "All" is selected.
	*/
	int findSelectedCategory(TQComboBox *,
		CategoryAppInfo *,
		bool AllIsUnfiled=false);

	/**
	* Populate the combo box with the categories found in
	* the Pilot's application categories block. Erases
	* combo box's contents first.
	*
	* Always includes the category "All" as the first
	* entry in the combo box.
	*
	* If info is a NULL pointer, just put "All" in the combo box.
	*/
	void populateCategories(TQComboBox *,
		CategoryAppInfo *info=0);

	void setDBPath(const TQString &path) { fDBPath = path; } ;
	const TQString& dbPath() const { return fDBPath; } ;
	void markDBDirty(const TQString db);

public slots:
	void slotShowComponent();

signals:
	void showComponent(PilotComponent *);

private:
	TQString fDBPath;
protected:
	bool shown;
} ;

#endif