summaryrefslogtreecommitdiffstats
path: root/kpilot/kpilot/addressWidget.h
blob: 9a7b2a8cb738ac0a377e210333a6615a9b1b3eb2 (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
/* addressWidget.h			KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
** Copyright (C) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
**
** This file defines the address-viewing widget used in KPilot
** to display the Pilot's address 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 kde-pim@kde.org
*/
#ifndef _KPILOT_ADDRESSWIDGET_H
#define _KPILOT_ADDRESSWIDGET_H

class TQMultiLineEdit;
class TQListBox;
class TQComboBox;
class TQTextView;

class PilotDatabase;


#include "pilotComponent.h"
#include "pilotAddress.h"

class AddressWidget : public PilotComponent
{
Q_OBJECT

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

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

public slots:
	/**
	* Called when a particular address is selected. This slot displays
	* it in the viewer widget.
	*/
	void slotShowAddress(int);
	void slotEditRecord();
	void slotCreateNewRecord();
	void slotDeleteRecord();
	void slotEditCancelled();
	void slotExport();

	void slotUpdateButtons();	// Enable/disable buttons

signals:
	void recordChanged(PilotAddress *);

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

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

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

private:
	void setupWidget();
	void updateWidget(); // Called with the lists have changed..
	void writeAddress(PilotAddress* which,PilotDatabase *db=0L);

	/**
	* getAllAddresses reads the database and places all
	* the addresses from the database in the list
	* in memory --- not the list on the screen.
	* @see fAddressList
	*/
	int getAllAddresses(PilotDatabase *addressDB);

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

	/**
	* We use a TQComboBox fCatList to hold the user-visible names
	* of all the categories. The TQTextView fAddrInfo is for
	* displaying the currently selected address, if any.
	* The TQListBox fListBox lists all the addresses in the
	* currently selected category.
	*
	* The entire address database is read into memory in the
	* QList fAddressList. We need the appinfo block from the
	* database to determine which categories there are; this
	* is held in fAddressAppInfo.
	*
	* The two buttons should speak for themselves.
	*/
	TQComboBox            *fCatList;
	TQTextView            *fAddrInfo;
	PilotAddressInfo     *fAddressAppInfo;
	TQPtrList<PilotAddress>   fAddressList;
	TQListBox             *fListBox;
	QPushButton	     *fEditButton,*fDeleteButton;

protected:
	/**
	* Keep track of how many open address editing windows there
	* are. You can't sync when there are open windows.
	*/
	int fPendingAddresses;

public:
	typedef enum { PhoneNumberLength=16 } Constants ;
};

#endif