FactDev  0.1
projectdatabase.h
1 #ifndef PROJECTDATABASE_H
2 #define PROJECTDATABASE_H
3 #include "database/database.h"
4 
5 #include "exceptions/dbexception.h"
6 
7 #include "models/project.h"
8 
9 #include "utils/string.h"
10 #include "utils/log.h"
11 #include "gui/widgets/widgetsmodels/projectstablemodel.h"
12 
13 using namespace Utils;
14 using namespace Exceptions;
15 using namespace Gui::Widgets;
16 
17 namespace Databases {
18 
25 class ProjectDatabase : public Database
26 {
27 
28 public:
33  static ProjectDatabase* instance() throw (DbException*);
34 
41  Models::Project* getProject(const int pId);
42 
48  Models::Project* getProject(QSqlQuery& q);
49 
55  int addProject(const Models::Project&);
56 
61  void updateProject(const Models::Project&);
62 
67  void removeProject(const int pId);
68 
74  int getNbProjects();
75 
82  int getNbProjects(const int customerId);
83 
89  QMap<int, Models::Project> getProjectsOfCustomer(
90  QSharedPointer<Models::Customer> c, const bool projectLocked=true);
91 
97  QList<Models::Project> getProjects(const int customerId);
98 
104  WdgModels::ProjectsTableModel* getProjectsTable(const int pId)
105  throw(DbException*);
106 
112  QSharedPointer<Project> updateProject(QSqlQuery &q);
113 
118  QList<Project*> getAllProjects();
119 
126  double getCostProjects(QList<Project*> projects);
127 
128 private:
129  static ProjectDatabase* _instance;
130 
134  ProjectDatabase() throw (DbException*);
135 
136 };
137 }
138 #endif // PROJECTDATABASE_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 Project class : Project linked to a Customer.
Definition: project.h:17
The ProjectsTableModel class for a Project table.
Definition: projectstablemodel.h:22
The ProjectDatabase class Project table database.
Definition: projectdatabase.h:25