DbModel Pile   version 0.0.1
DbModel pile.
dbmodel.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_DBMODEL_H_INCLUDE
11 #define GUARD_DBMODEL_H_INCLUDE
12 
13 #include <dbmodel/dbmodel-config.h>
14 #include <dbmodel/dbmodelcol.h>
15 #include <dbmodel/dbmodeltbl.h>
16 
17 #include <QSql>
18 #include <QSqlRecord>
19 #include <QSortFilterProxyModel>
20 #include <QSqlDatabase>
21 #include <QVector>
22 
23 class DbModelPrivate;
24 
26 class DBMODEL_EXPORT DbModel : public QSortFilterProxyModel {
27  Q_OBJECT
28 
29  DbModelPrivate * impl;
30  QString filter_;
32 public:
33 
35  DbModel (
36  DbStruct * db,
37  DbTaew * meta,
38  QObject * parent = NULL);
39 
41  DbModel (
42  DbStruct * db,
43  int component,
44  QObject * parent = NULL);
45 
46  Q_DISABLE_COPY(DbModel)
47 
48 
49  virtual ~DbModel();
50 
52  bool
53  isValid() const;
54 
57  void
58  setMeta (
59  DbTaew * meta);
60 
63  void
64  setMeta (
65  DbStruct * database,
66  DbTaew * meta);
67 
69  DbTaew *
70  takeMeta ();
71 
73  DbTaew *
74  metaTaew () const;
75 
77  QSqlTableModel *
78  mainModel () const;
79 
81  bool
82  selectMe ();
83 
85  int
86  rowCount () const;
87 
89  int
90  columnCount () const;
91 
93  bool
94  lessThan (
95  const QModelIndex &left,
96  const QModelIndex &right) const;
97 
98 
101  DbStruct *
102  database () const;
103 
105  void
106  setDatabase (
107  DbStruct * value);
108 
110  DbStruct *
111  takeDatabase ();
112 
114  const DbModelCol &
115  columnData (
116  int index) const;
117 
119  const DbModelTbl &
120  tableData (
121  int table_index) const;
122 
124  bool
125  setFilter (
126  const QString & filter,
127  int table_index = 0);
128 
130  bool
131  setFilter (
132  const QString & filter,
133  const QString & table);
134 
136  const QString &
137  filter () const {
138  return filter_;
139  }
140 
142  bool
143  setOrder (
144  int column,
145  Qt::SortOrder order,
146  int table_index = 0);
147 
149  bool
150  setOrder (
151  int column,
152  Qt::SortOrder order,
153  const QString & table);
154 
155 
157  int
158  findTable (
159  const QString & table) const;
160 
162  QSqlRecord
163  record (
164  int row) const;
165 
167  void
168  reloadHeaders ();
169 
170 
172  bool
173  setColumnCallback (
174  int table_index,
175  int column_index,
176  DbColumn::Callback value,
177  void * user_data = NULL);
178 
180  bool
182  int column_index,
183  DbColumn::Callback value,
184  void * user_data = NULL) {
185  return setColumnCallback (0, column_index, value, user_data);
186  }
187 
189  DbColumn::Callback
190  columnCallback (
191  int table_index,
192  int column_index);
193 
195  void *
196  columnCallbackData ();
197 
198  /* - - - - - - - - - - - - - - - - */
204 
207  bool
208  setCurrentMarker (
209  int row,
210  int column);
211 
213  int
214  getMarkerRow () const;
215 
217  int
218  getMarkerCol () const;
219 
221  bool
222  hasMarkerCell () const;
223 
225  /* - - - - - - - - - - - - - - - - */
226 
227 };
228 
229 #endif // GUARD_DBMODEL_H_INCLUDE
Internal model.
Definition: dbmodelprivate.h:75
A Qt model capable of representing sql tables.
Definition: dbmodel.h:26
Model representation of a column.
Definition: dbmodelcol.h:56
const QString & filter() const
Get the filter installed on main model.
Definition: dbmodel.h:137
file dbmodeltbl.h date November 2015 author Nicu Tofan
Definition: dbmodeltbl.h:46
bool setColumnCallback(int column_index, DbColumn::Callback value, void *user_data=NULL)
Set the callback for a column in main table.
Definition: dbmodel.h:181