FactDev  0.1
customerdatabase.h
1 #ifndef BDDCUSTOMER_H
2 #define BDDCUSTOMER_H
3 
4 #include <QPixmap>
5 #include <QBuffer>
6 #include "database/database.h"
7 #include "database/billingdatabase.h"
8 #include "exceptions/dbexception.h"
9 #include "models/customer.h"
10 #include "models/billing.h"
11 #include "utils/log.h"
12 #include "utils/string.h"
13 #include "gui/utils/image.h"
14 #include "gui/widgets/widgetsmodels/customerstablemodel.h"
15 
16 using namespace Exceptions;
17 using namespace Utils;
18 using namespace Gui::Widgets;
19 
20 namespace Databases {
30 class CustomerDatabase : public Database
31 {
32 
33 public:
40  static CustomerDatabase* instance()throw(DbException*);
41 
49  WdgModels::CustomersTableModel* getCustomersTable(QString filter="")
50  throw(DbException*);
51 
52 
60  QStandardItemModel *getTree(QString filter="") throw(DbException*);
61 
68  QSharedPointer<Models::Customer> getCustomer(const int pId);
69 
75  int addCustomer(const Models::Customer &);
76 
81  void updateCustomer(Customer &);
82 
88  void removeCustomer(const int pId);
89 
95  int getNbCustomers();
96 
102  QStandardItem *getItemRoot();
103 
110  QStandardItem *getItemCustomer(QSqlQuery q1);
117  QStandardItem *getItemProject(QSqlQuery q2);
118 
125  QSharedPointer<Models::Customer> getCustomer(QSqlQuery &q);
126 
132  void updateCustomer(QSqlQuery &q, Customer &pCustomer);
133 
139  QPixmap getCustomerImage(const int pId);
140 
146  void setCustomerImage(Customer &pCustomer);
147 
152  QList<Customer> getCustomers();
153 
154 private:
156  static CustomerDatabase* _instance;
157 
161  CustomerDatabase() throw(DbException*) ;
162 };
163 }
164 #endif // BDDCUSTOMER_H
The DbException class for database exception : queries, db file, …
Definition: dbexception.h:18
The Database class Master class for all database access.
Definition: database.h:34
The CustomersTableModel class for a customer table.
Definition: customerstablemodel.h:21
The CustomerDatabase class Customer table database.
Definition: customerdatabase.h:30
The Customer class Customer.
Definition: customer.h:15