summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/contacteditor.h
blob: e7432eeb78caf7d0e7c8e94fc11e35e210affd17 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
 *
 * This file is an add-on for the OPIE Palmtop Environment
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
 * of this file.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This is a rewrite of the abeditor.h file, modified to provide a more
 * intuitive interface to TrollTech's original Address Book editor.  This
 * is made to operate exactly in interface with the exception of name.
 *
 */

#ifndef CONTACTEDITOR_H
#define CONTACTEDITOR_H

#include <opie/ocontact.h>

#include <qpe/datebookmonth.h>

#include <qdialog.h>
#include <qlist.h>
#include <qmap.h>
#include <qstringlist.h>
#include <qwidgetstack.h> 

#include "ocontactfields.h"

const int NAME_LF  = 0;
const int NAME_LFM = 1;
const int NAME_FL  = 2;
const int NAME_FML = 3;

const int NAME_F = 4;
const int NAME_M = 5;
const int NAME_L = 6;
const int NAME_S = 7;


class QScrollView;
class QTabWidget;
class QMultiLineEdit;
class QLineEdit;
class QComboBox;
class QPushButton;
class CategorySelect;
class QLabel;

class ContactEditor : public QDialog {
	Q_OBJECT

	public:
		ContactEditor(	const OContact &entry,
				QWidget *parent = 0,
				const char *name = 0,
				WFlags fl = 0 );
		~ContactEditor();
		void setNameFocus();
		void setPersonalView( bool personal = true );
		OContact entry() const { return ent; }

	public slots:
		void slotNote();
		void slotName();
		void setEntry(const OContact &entry);

	protected slots:
		void accept();

	private:
		void init();
		void saveEntry();
		bool isEmpty();
		void cleanupFields();
		void updateDatePicker();
		QString parseName( QString fullName, int type );
		void chooserError( int index );
	private slots:
		void slotChooser1Change( const QString &textChanged );
		void slotChooser2Change( const QString &textChanged );
		void slotChooser3Change( const QString &textChanged );
		void slotChooser4Change( const QString &textChanged );
		void slotCmbChooser1Change( int index );
		void slotCmbChooser2Change( int index );
		void slotCmbChooser3Change( int index );
		void slotCmbChooser4Change( int index );
		void slotAddressTypeChange( int index );
		void slotAddressChange( const QString &textChanged );
		void slotAddress2Change( const QString &textChanged );
		void slotPOBoxChange( const QString &textChanged );
		void slotCityChange( const QString &textChanged );
		void slotStateChange( const QString &textChanged );
		void slotZipChange( const QString &textChanged );
		void slotCountryChange( const QString &textChanged );
		void slotFullNameChange( const QString &textChanged );
		void slotSuffixChange( const QString &textChanged );
		void slotOrganizationChange( const QString &textChanged );
		void slotAnniversaryDateChanged( int year, int month, int day);
		void slotBirthdayDateChanged( int year, int month, int day);
		void slotRemoveBirthday();
		void slotRemoveAnniversary();
		void defaultEmailChanged(int);

	private:
		enum StackWidgets { TextField = 1, Combo };
		int defaultEmailChooserPosition;
		void populateDefaultEmailCmb();
		void chooserChange( const QString&, int , QLineEdit*, int );
		bool cmbChooserChange( int , QWidgetStack*, int );
		OContactFields contactfields;

		OContact ent;

		QDialog *dlgNote;
		QDialog *dlgName;

		QList<QLineEdit> listValue;
		QList<QLabel> listName;

		QStringList slDynamicEntries;
		QStringList trlDynamicEntries;

		bool m_personalView;

		QStringList slHomeAddress;
		QStringList slBusinessAddress;
		QStringList slChooserNames;
		QStringList slChooserValues;
		QStringList emails;
		QString defaultEmail;

		QMultiLineEdit *txtNote;
		QLabel *lblNote;

		//QLineEdit *txtTitle;
		QLineEdit *txtFirstName;
		QLineEdit *txtMiddleName;
		QLineEdit *txtLastName;
		QLineEdit *txtSuffix;

		QTabWidget *tabMain;
		QScrollView *svGeneral;
		QPushButton *btnFullName;
		QPushButton *btnNote;
		QLineEdit *txtFullName;
		QLineEdit *txtJobTitle;
		QLineEdit *txtOrganization;
		QLineEdit *txtChooserField1;
		QLineEdit *txtChooserField2;
		QLineEdit *txtChooserField3;
		QLineEdit *txtChooserField4;
		QWidgetStack* m_widgetStack1;
		QWidgetStack* m_widgetStack2;
		QWidgetStack* m_widgetStack3;
		QWidgetStack* m_widgetStack4;
		QComboBox *cmbChooserField1;
		QComboBox *cmbChooserField2;
		QComboBox *cmbChooserField3;
		QComboBox *cmbChooserField4;
		QComboBox *cmbDefaultEmail;
		QComboBox *cmbFileAs;
		CategorySelect *cmbCat;
		QLabel *labCat;

		QScrollView *svAddress;
		QLineEdit *txtAddress;
		//QLineEdit *txtAddress2;
		//QLineEdit *txtPOBox;
		QLineEdit *txtCity;
		QLineEdit *txtState;
		QLineEdit *txtZip;
		QComboBox *cmbAddress;
		QComboBox *cmbCountry;

		QScrollView *svDetails;
		QComboBox *cmbGender;
		DateBookMonth* birthdayPicker;
		QToolButton* birthdayButton;
		DateBookMonth* anniversaryPicker;
		QToolButton* anniversaryButton;

		bool initializing;
	};

#endif