File: addresscluster.h

package info (click to toggle)
postbooks 4.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 112,660 kB
  • ctags: 22,890
  • sloc: cpp: 310,358; sh: 607; xml: 214; python: 140; awk: 104; makefile: 50
file content (245 lines) | stat: -rw-r--r-- 9,314 bytes parent folder | download
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
 * This file is part of the xTuple ERP: PostBooks Edition, a free and
 * open source Enterprise Resource Planning software suite,
 * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
 * It is licensed to you under the Common Public Attribution License
 * version 1.0, the full text of which (including xTuple-specific Exhibits)
 * is available at www.xtuple.com/CPAL.  By using this software, you agree
 * to be bound by its terms.
 */

#ifndef addressCluster_h
#define addressCluster_h

#include "widgets.h"
#include "virtualCluster.h"
#include "xcheckbox.h"
#include "xcombobox.h"

#include <QCheckBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QWidget>

class QGridLayout;
class AddressCluster;

class XTUPLEWIDGETS_EXPORT AddressList : public VirtualList
{
    Q_OBJECT

    friend class AddressCluster;
    friend class AddressInfo;
    friend class AddressSearch;

    public:
	AddressList(QWidget*, const char* = 0, bool = false, Qt::WindowFlags = 0);

    public slots:
	virtual void sFillList();
	virtual void sSearch(const QString& pTarget);

    protected:
	AddressCluster*	_parent;
	QLabel*		_searchLit;
	QLineEdit*	_search;
	QLabel*		_titleLit;
	QPushButton*	_close;
	QPushButton*	_select;
	XTreeWidget*	_list;
        QCheckBox*      _searchAcct;
};

class XTUPLEWIDGETS_EXPORT AddressSearch : public VirtualSearch
{
    Q_OBJECT

    friend class AddressCluster;

    public:
	AddressSearch(QWidget*, Qt::WindowFlags = 0);

    public slots:
	virtual void sFillList();

    protected:
	AddressCluster*	_parent;
	XCheckBox*	_searchStreet;
	XCheckBox*	_searchCity;
	XCheckBox*	_searchState;
	XCheckBox*	_searchCountry;
	XCheckBox*	_searchPostalCode;
	XCheckBox*	_searchInactive;
        QCheckBox*      _searchAcct;

};

class XTUPLEWIDGETS_EXPORT AddressCluster : public VirtualCluster
{
    Q_OBJECT
    Q_ENUMS   (Mode)
    Q_PROPERTY(bool     activeVisible 	      READ activeVisible            WRITE setActiveVisible)
    Q_PROPERTY(QString  fieldNameAddressChange READ fieldNameAddrChange     WRITE setFieldNameAddrChange)
    Q_PROPERTY(QString  fieldNameNumber        READ fieldNameNumber         WRITE setFieldNameNumber)
    Q_PROPERTY(QString  fieldNameActive        READ fieldNameActive         WRITE setFieldNameActive)
    Q_PROPERTY(QString  fieldNameLine1         READ fieldNameLine1          WRITE setFieldNameLine1)
    Q_PROPERTY(QString  fieldNameLine2         READ fieldNameLine2	    WRITE setFieldNameLine2)
    Q_PROPERTY(QString  fieldNameLine3         READ fieldNameLine3          WRITE setFieldNameLine3)
    Q_PROPERTY(QString  fieldNameCity          READ fieldNameCity           WRITE setFieldNameCity)
    Q_PROPERTY(QString  fieldNameState         READ fieldNameState          WRITE setFieldNameState)
    Q_PROPERTY(QString  fieldNamePostalCode    READ fieldNamePostalCode     WRITE setFieldNamePostalCode)
    Q_PROPERTY(QString  fieldNameCountry       READ fieldNameCountry        WRITE setFieldNameCountry)
    Q_PROPERTY(Mode     mode                   READ mode                    WRITE setMode)

    friend class AddressInfo;
    friend class AddressList;
    friend class AddressSearch;

    public:
	enum SaveFlags { CHECK = 0, CHANGEONE = 1, CHANGEALL = 2 }; 
        enum Mode      { Edit, View, Select };

	AddressCluster(QWidget*, const char* = 0);
	
	inline virtual bool    activeVisible() const { return _active->isVisible(); };
        inline virtual QString addrChange()   const { return _addrChange->text(); };
	Q_INVOKABLE virtual QString city()    const { return _city->text(); }
	Q_INVOKABLE virtual QString country() const { return _country->currentText(); }
	Q_INVOKABLE virtual QString description() const { return ""; }
	Q_INVOKABLE virtual bool    isValid() const { return _valid; }
	inline virtual QString label()	      const { return _label->text(); };
	Q_INVOKABLE virtual QString line1()   const { return _addr1->text(); }
	Q_INVOKABLE virtual QString line2()   const { return _addr2->text(); }
	Q_INVOKABLE virtual QString line3()   const { return _addr3->text(); }
	Q_INVOKABLE virtual int     id()      const { return _id; }
        Q_INVOKABLE virtual Mode    mode()    const { return _mode; };
	inline virtual QString notes()	      const { return _notes; };
        Q_INVOKABLE virtual QString number()       const { return _number->text(); };
	Q_INVOKABLE virtual QString postalCode()  const { return _postalcode->text(); }
	Q_INVOKABLE virtual QString state()   const { return _state->currentText(); }
        Q_INVOKABLE virtual int searchAcctId() { return _searchAcctId; }
	
	// Return data map values
	virtual QString  fieldNameAddrChange()  const { return _fieldNameAddrChange; };
	virtual QString  fieldNameNumber()	const { return _fieldNameNumber; };
	virtual QString  fieldNameActive()	const { return _fieldNameActive; };
	virtual QString  fieldNameLine1() 	const { return _fieldNameLine1; };
	virtual QString  fieldNameLine2()  	const { return _fieldNameLine2; };
	virtual QString  fieldNameLine3()   	const { return _fieldNameLine3; };
	virtual QString  fieldNameCity()   	const { return _fieldNameCity; };
	virtual QString  fieldNamePostalCode()  const { return _fieldNamePostalCode; };
	virtual QString  fieldNameState()  	const { return _fieldNameState; };
	virtual QString  fieldNameCountry() 	const { return _fieldNameCountry; };

    public slots:
	inline virtual void clearExtraClause()	{ };
	inline virtual void setExtraClause(const QString&, const QString&)  { };
	virtual void        setActiveVisible(const bool p);
        virtual void        setAddrChange(QString p);
	inline virtual void setCity(const QString& p)	{ _city->setText(p); };
	virtual void        setCountry(const QString& p);
	inline virtual void setDescription(const QString&) { };
	inline virtual void setLabel(const QString& p)  { _label->setText(p); _label->setHidden(_label->text().isEmpty()); };
	inline virtual void setLine1(const QString& p)	{ _addr1->setText(p); };
	inline virtual void setLine2(const QString& p)	{ _addr2->setText(p); };
	inline virtual void setLine3(const QString& p)	{ _addr3->setText(p); };
	       virtual void setMode(const Mode p);
	inline virtual void setNotes(const QString& p)  { _notes = p; };
	       virtual void setNumber(QString p);
               virtual void setNumber(const int)     {};
	inline virtual void setPostalCode(const QString& p) { _postalcode->setText(p); };
	       virtual void setState(const QString& p);
               virtual void setListVisible(bool p) { _list->setVisible(p); }
	virtual void	clear();
	virtual void	sEllipses();
	virtual void	sInfo();
	virtual void	sList();
	virtual void	sSearch();
	virtual void	setId(const int, const QString& = QString::null);
        virtual void	setSearchAcct(const int crmAcctId) { _searchAcctId = crmAcctId; }
        virtual int	save(enum SaveFlags);
        virtual void    check();
	virtual void    populateStateComboBox();

	// Set data map values      
        virtual void 	setDataWidgetMap(XDataWidgetMapper* m);
	virtual void  	setFieldNameAddrChange(QString p)   { _fieldNameAddrChange = p ; };
	virtual void  	setFieldNameNumber(QString p)       { _fieldNameNumber = p ; };
	virtual void  	setFieldNameActive(QString p)       { _fieldNameActive = p ; };
	virtual void  	setFieldNameLine1(QString p)        { _fieldNameLine1 = p ; };
	virtual void  	setFieldNameLine2(QString p)        { _fieldNameLine2 = p ; };
	virtual void  	setFieldNameLine3(QString p)        { _fieldNameLine3 = p ; };
	virtual void  	setFieldNameCity(QString p)         { _fieldNameCity = p ; };
	virtual void  	setFieldNamePostalCode(QString p)   { _fieldNamePostalCode = p ; };
	virtual void  	setFieldNameState(QString p)        { _fieldNameState = p ; };
	virtual void  	setFieldNameCountry(QString p)      { _fieldNameCountry = p ; };

    private slots:
        void emitAddressChanged();

    signals:
        void addressChanged(QString, QString, QString, QString, QString, QString, QString);
	void newId(int);
	void changed();

    protected:
	QString		_query;	
	QString		_extraClause;
        XLineEdit*      _addrChange;
	XLineEdit*      _number;
	QLabel*		_addrLit;
	XLineEdit*	_addr1;
	XLineEdit*	_addr2;
	XLineEdit*	_addr3;
	QLabel*		_cityLit;
	XLineEdit*	_city;
        Mode            _mode;
	QLabel*		_stateLit;
	XComboBox*	_state;
	QLabel*		_postalcodeLit;
	XLineEdit*	_postalcode;
	QLabel*		_countryLit;
	XComboBox*	_country;
	QCheckBox*	_active;

    private:
	virtual void	init();
	virtual void	populateCountryComboBox();
	virtual void	silentSetId(const int);
	int		_id;
	QString		_notes;
        int             _searchAcctId;
	bool		_selected;
	QString		_titlePlural;
	QString		_titleSingular;
	bool		_valid;
	XDataWidgetMapper* _mapper;
        QPushButton*    _list;

	// cached values
	QString         c_number;
	QString		c_addr1;
	QString		c_addr2;
	QString		c_addr3;
	QString		c_city;
	QString		c_state;
	QString		c_postalcode;
	QString		c_country;
	bool		c_active;
	QString		c_notes;

	// data map values
	QString  _fieldNameAddrChange;
	QString  _fieldNameNumber;
	QString  _fieldNameActive;
	QString  _fieldNameLine1;
	QString  _fieldNameLine2;
	QString  _fieldNameLine3;
	QString  _fieldNameCity;
	QString  _fieldNamePostalCode;
	QString  _fieldNameState;
	QString  _fieldNameCountry;
};

#endif