MagicSmoke  $VERSION$
customerdlg.h
Go to the documentation of this file.
1 //
2 // C++ Interface: customer
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2011
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_CUSTOMERDLG_H
14 #define MAGICSMOKE_CUSTOMERDLG_H
15 
16 #include <QString>
17 #include <QDialog>
18 #include <QFrame>
19 #include <QItemDelegate>
20 #include <QList>
21 #include <QScrollArea>
22 
23 #include "MOCustomerInfo"
24 #include "MOCustomer"
25 
26 class QComboBox;
27 class QHBoxLayout;
28 class QLineEdit;
29 class QListView;
30 class QSortFilterProxyModel;
31 class QStandardItemModel;
32 class QTableView;
33 
35 class MCustomerListDialog:public QDialog
36 {
37  Q_OBJECT
38  public:
40  MCustomerListDialog(QWidget*,bool isselect=false,qint64 selected=-1);
41 
44 
45  private slots:
47  void newCustomer();
49  void editCustomer();
51  void deleteCustomer();
52 
53  private:
54  QList<MOCustomerInfo> m_list;
55  QListView*m_listview;
56  QStandardItemModel*m_listmodel;
57  QSortFilterProxyModel*m_proxymodel;
58  QLineEdit*m_filter;
59 
61  void updateList(int id=-1);
62 };
63 
64 class QLineEdit;
65 class QTextEdit;
66 class QLabel;
67 
69 class MAddressWidget:public QFrame
70 {
71  Q_OBJECT
72  public:
74  MAddressWidget(QWidget*parent=0,bool isselect=false);
75 
77  MOAddress address()const;
78 
79  public slots:
81  void setAddress(const MOAddress&);
82 
84  void setAddress(qint64);
85 
87  void clearAddress();
88 
89  signals:
92  void addressChanged(const MOAddress&);
93 
95  void addressEdited(const MOAddress&);
96 
98  void addressDeleted(const MOAddress&);
99 
101  void addressSelected(const MOAddress&);
102 
104  void addressSelected(qint64);
105 
107  void addrValid(bool);
108 
109  private slots:
111  void editClick();
113  void delClick();
115  void selectClick();
117  void redisplay();
118 
119  private:
120  MOAddress m_addr;
121  QLabel*m_lab;
122 };
123 
124 class QSignalMapper;
125 class QGridLayout;
126 
128 class MAddressListWidget:public QScrollArea
129 {
130  Q_OBJECT
131  public:
133  MAddressListWidget(QWidget*parent,const QList<MOAddress>&,bool isselect=false);
134 
136  QList<MOAddress> addressList()const{return m_addr;}
137 
139  MOAddress selection()const{return m_sel;}
140 
141  signals:
144  void addressChanged(const MOAddress&);
145 
147  void addressEdited(const MOAddress&);
148 
150  void addressDeleted(const MOAddress&);
151 
153  void addressSelected(const MOAddress&);
154 
156  void addressSelected(qint64);
157 
159  void addressCreated(const MOAddress&);
160 
161  public slots:
163  void createAddress();
164 
166  void preselect(int);
167 
169  void preselect(const MOAddress&);
170 
171  private slots:
173  void addrEdit(int);
174 
176  void addrSel(const MOAddress&);
177 
182  void addAddr(const MOAddress&,bool vis=false);
183 
184  private:
185  QList<MOAddress>m_addr;
186  MOAddress m_sel;
187  QSignalMapper *map;
188  bool m_select;
189  QGridLayout*m_layout;
190 };
191 
193 class MAddressChoiceDialog:public QDialog
194 {
195  Q_OBJECT
196  public:
198  MAddressChoiceDialog(QWidget*,const MOCustomer&);
199 
201  MOAddress address()const;
202 
204  qint64 addressId()const;
205 
207  MOCustomer customer()const{return m_cust;}
208  public slots:
210  void preselect(const MOAddress&);
212  void addUnselectButton(const QString&);
213  private slots:
215  void changed();
217  void updateCustomer();
219  void unselect();
220  private:
221  MOCustomer m_cust;
222  bool m_needupdate,m_unsel;
223  MAddressListWidget*m_lwidget;
224  QHBoxLayout*m_btnlayout;
225 };
226 
228 class MAddressDialog:public QDialog
229 {
230  Q_OBJECT
231  public:
233  MAddressDialog(QWidget*parent=0,MOAddress addr=MOAddress());
234 
236  MOAddress address();
237 
240  static MOCountry createNewCountry(QWidget*parent=0);
241  private slots:
242  void selectCountry();
243  private:
244  QLineEdit *m_name,*m_addr1,*m_addr2,*m_city,*m_state,*m_zip,*m_country;
245  MOAddress m_addr;
246 };
247 
249 class MCustomerDialog:public QDialog
250 {
251  Q_OBJECT
252  public:
254  MCustomerDialog(MOCustomer,QWidget*);
255 
258 
259  private slots:
261  void save();
263  void addContact();
265  void removeContact();
267  void changeMail();
269  void resetLogin();
270 
271  private:
272  MOCustomer m_cust;
273  QLineEdit*m_name,*m_fname,*m_title;
274  QTextEdit*m_comm;
275  MAddressListWidget*m_addr;
276  QLabel*m_mail;
277  QTableView*m_contact;
278  QStandardItemModel*m_contactmodel;
279 };
280 
282 class MContactTableDelegate:public QItemDelegate
283 {
284  Q_OBJECT
285  public:
286  MContactTableDelegate(QObject *parent = 0);
287 
288  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
289  const QModelIndex &index) const;
290 
291  void setEditorData(QWidget *editor, const QModelIndex &index) const;
292  void setModelData(QWidget *editor, QAbstractItemModel *model,
293  const QModelIndex &index) const;
294  private:
295  //cache of contact types
296  //why ever the interesting delegate methods are const, this has to be mutable then
297  mutable QList<MOContactType>m_typelist;
298 };
299 
300 
302 class MNewCustomerWizard:public QDialog
303 {
304  Q_OBJECT
305  public:
306  MNewCustomerWizard(QWidget* parent = 0, Qt::WindowFlags f = 0);
307 
308  MOCustomer customer()const{return m_cust;}
309 
310  static MOCustomer getNewCustomer(QWidget*parent=0);
311  private slots:
312  void save();
313  void newcountry();
314  void updateCountry(QString id=QString());
315  private:
316  MOCustomer m_cust;
317  QComboBox*m_title,*m_city,*m_state,*m_country;
318  QLineEdit*m_name,*m_fname,*m_addr1,*m_zipcode;
319  QList<MOContactType>m_typelist;
320  QList<MOCountry>m_countrylist;
321  QList<QLineEdit*>m_contact;
322 };
323 
324 #endif
void preselect(int)
pre-selects an address by its position in the current address list, this method should only be called...
Definition: customerdlg.cpp:654
void addressSelected(const MOAddress &)
emitted if the user presses the "select" button, contains the address
shows a list of customers, lets the user select and offers to alter/create customers ...
Definition: customerdlg.h:35
qint64 addressId() const
returns the ID of the chosen address or -1 if the unselect button was used
Definition: customerdlg.cpp:854
displays exactly one address; even though it offers to edit or delete addresses, it does not actually...
Definition: customerdlg.h:69
void addressEdited(const MOAddress &)
emitted if the address was changed by the user, contains the current address content ...
void createAddress()
asks the user for a new address
Definition: customerdlg.cpp:679
Definition: customer.h:24
MAddressListWidget(QWidget *parent, const QList< MOAddress > &, bool isselect=false)
creates the widget
Definition: customerdlg.cpp:596
Definition: customerinfo.h:22
MOAddress selection() const
returns the selected address
Definition: customerdlg.h:139
MCustomerListDialog(QWidget *, bool isselect=false, qint64 selected=-1)
creates a new customer list dialog; expects a usable webrequest object and a parent, if isselect is set to true it offers a select button, if selected is set to a matching customerID it will be pre-selected
Definition: customerdlg.cpp:53
void addressDeleted(const MOAddress &)
emitted if the address was deleted by the user, addressEdited is also emitted
void addrValid(bool)
internal: used to activate or de-activate buttons
dialog for editing exactly one address
Definition: customerdlg.h:228
void setAddress(const MOAddress &)
sets the address to be shown, enables the buttons if it is valid
Definition: customerdlg.cpp:530
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Definition: customerdlg.cpp:455
void addressChanged(const MOAddress &)
emitted if the address has changed, the parameter contains the current content; this also emits if th...
void addressDeleted(const MOAddress &)
emitted if the address was deleted by the user, addressEdited is also emitted
QList< MOAddress > addressList() const
returns the current list
Definition: customerdlg.h:136
void preselect(const MOAddress &)
pre-select an address
Definition: customerdlg.cpp:878
void clearAddress()
clears the display, disables the buttons
Definition: customerdlg.cpp:552
edit a specific customer
Definition: customerdlg.h:249
MCustomerDialog(MOCustomer, QWidget *)
creates a new customer dialog
Definition: customerdlg.cpp:231
MAddressWidget(QWidget *parent=0, bool isselect=false)
creates the widget, if isselect==true a "select" button is shown
Definition: customerdlg.cpp:506
MOCustomer getCustomer()
returns the customer as currently entered
Definition: customerdlg.cpp:343
static MOCountry createNewCountry(QWidget *parent=0)
helper function to create a new country, used by MAddressDialog and MNewCustomerWizard returns a vali...
Definition: customerdlg.cpp:743
void setEditorData(QWidget *editor, const QModelIndex &index) const
Definition: customerdlg.cpp:434
Definition: address.h:24
void addressSelected(const MOAddress &)
emitted if the user presses the "select" button, contains the address
MNewCustomerWizard(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: customerdlg.cpp:891
MAddressChoiceDialog(QWidget *, const MOCustomer &)
creates the dialog
Definition: customerdlg.cpp:814
Helper class for customer contact table.
Definition: customerdlg.h:282
widget that displays a list of addresses, it uses MAddressWidget to display every single address ...
Definition: customerdlg.h:128
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: customerdlg.cpp:416
MOAddress address() const
returns the chosen address or an invalid address if none was chosen
Definition: customerdlg.cpp:848
Wizard for creating a new customer.
Definition: customerdlg.h:302
void addressCreated(const MOAddress &)
emitted if the user creates a new address via createAddress()
void addressChanged(const MOAddress &)
emitted if the address has changed, the parameter contains the current content; this also emits if th...
wrapper dialog to chose an address; updates the customer is there is a change
Definition: customerdlg.h:193
MContactTableDelegate(QObject *parent=0)
Definition: customerdlg.cpp:411
MOCustomer customer() const
returns the (modified) customer object
Definition: customerdlg.h:207
static MOCustomer getNewCustomer(QWidget *parent=0)
Definition: customerdlg.cpp:1091
void addressEdited(const MOAddress &)
emitted if the address was changed by the user, contains the current address content ...
MOAddress address()
returns the address
Definition: customerdlg.cpp:726
MOCustomer customer() const
Definition: customerdlg.h:308
Definition: srcMOCountry.h:14
MAddressDialog(QWidget *parent=0, MOAddress addr=MOAddress())
creates the dialog, if no valid address is given it displays as "create address" otherwise as "edit a...
Definition: customerdlg.cpp:689
void addUnselectButton(const QString &)
add an unselect button
Definition: customerdlg.cpp:840
MOAddress address() const
returns the currently shown address
Definition: customerdlg.cpp:528
MOCustomerInfo getCustomer()
returns the selected customer
Definition: customerdlg.cpp:146