BPS C++ API  2.24.4
bpstableitem.h
Go to the documentation of this file.
1 
4 #ifndef BPSTABLEITEM_H
5 #define BPSTABLEITEM_H
6 
7 #include "bpsgui_global.h"
8 #include "bpstableoptions.h"
9 #include <QSqlRecord>
10 #include <QVariantMap>
11 
12 class BpsTableModel;
13 
18 {
20  friend class BpsTableModel;
21  friend class BpsTableModelPrivate;
22 
23 public:
27  enum Status {
28  StatusSaved = 0,
29  StatusEdited = 1,
30  StatusAdded = 2,
31  StatusDeleted = 3
32  };
33 
37  enum CacheIndex {
38  CacheDisplayColumnStart = 1000000
39  };
40 
44  QVariant key() const;
45 
49  Status status() const;
50 
54  bool isEditable() const;
55 
61  void setIsEditable(bool aIsEditable);
62 
66  QVariantMap values() const;
67 
71  QVariantMap changedValues() const;
72 
78  QVariant value(const QString& aField) const;
79 
86  bool setValue(const QString& aField, const QVariant& aValue);
87 
91  void setSaved();
92 
101  QVariant cache(const QString& aField) const;
102 
108  void setCache(const QString& aField, const QVariant& aValue);
109 
120  QVariant cache(int aIndex) const;
121 
132  void setCache(int aIndex, const QVariant& aValue);
133 
142  QVariant data(int aIndex = 0) const;
143 
149  void setData(const QVariant& aValue, int aIndex = 0);
150 
156  BpsTableOptions options(const QString& aMappingTable) const;
157 
164  bool setOptions(const QString& aMappingTable, const BpsTableOptions& aOptions);
165 
170  void addFields(const QSqlRecord& aRecord);
171 
177  bool hasField(const QString& aField);
178 
184  bool hasOptions(const QString& aTable);
185 
192 
194 private:
195  BpsTableItem(BpsTableModel* aModel, const QSqlRecord& aRecord);
196  BpsTableItem(BpsTableItem* aOther, bool aCopy);
197  BpsTableItem(BpsTableItem* aOther);
198  ~BpsTableItem();
199 
200  void checkStatus();
201  void setAdded();
202  void setDeleted();
203 
204  BpsTableItem* parent() const;
205  QVariant parentKey() const;
206  int index() const;
207 
208  QSqlRecord record() const;
209  int fieldCount() const;
210 
211  QVariant value(int aIndex) const;
212  bool setValue(int aIndex, const QVariant& aValue);
213 
214  void addOptions(const QString& aTable, const BpsTableOptions& aOptions);
215  QList<QString> optionTables() const;
216  BpsTableOptions oldOptions(const QString& aTable) const;
217 
218  int childCount() const;
219  BpsTableItem* childItem(int aIndex);
220  int childIndex(BpsTableItem* aChild) const;
221 
222  void insertChild(int aIndex, BpsTableItem* aChild);
223  void appendChild(BpsTableItem* aChild);
224  BpsTableItem* takeChild(int aIndex);
225 
226  bool childrenLoaded() const;
227  void setChildrenLoaded(bool aLoaded);
228 
229  void addSlaveModel(BpsTableModel* aModel);
230  QList<BpsTableModel*> slaveModels() const;
232 };
233 
234 #endif // BPSTABLEITEM_H
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
Public include file for BPS GUI library macros.
#define BPSGUI_EXPORT
Declare class an import from the shared library.
Definition: bpsgui_global.h:22
Public include file for BpsTableOptions type.
Items used by BpsTableModel.
Definition: bpstableitem.h:18
CacheIndex
Reserved cache indexes.
Definition: bpstableitem.h:37
bool hasField(const QString &aField)
Check if the field is present.
QVariantMap changedValues() const
BpsTableModel * slaveModel(const QString &aTable)
Get the named slave table model.
QVariant key() const
The record key (value of c_key field), only valid when status in not StatusAdded.
void addFields(const QSqlRecord &aRecord)
Add more fields to the record.
void setData(const QVariant &aValue, int aIndex=0)
Set application data.
BpsTableOptions options(const QString &aMappingTable) const
Get the named option key set.
void setSaved()
Set the item status to saved.
QVariantMap values() const
QVariant data(int aIndex=0) const
Get application data.
void setCache(const QString &aField, const QVariant &aValue)
Set the cache value of the named field.
bool isEditable() const
bool hasOptions(const QString &aTable)
Check if the options are present.
bool setValue(const QString &aField, const QVariant &aValue)
Set the value of the named field.
Status
Current status of the item.
Definition: bpstableitem.h:27
void setIsEditable(bool aIsEditable)
Enable / disable editing of a field.
void setCache(int aIndex, const QVariant &aValue)
Set the indexed cache value.
QVariant cache(const QString &aField) const
Get the named cache value.
bool setOptions(const QString &aMappingTable, const BpsTableOptions &aOptions)
Set the options of the named set.
QVariant value(const QString &aField) const
Get the named value.
Status status() const
QVariant cache(int aIndex) const
Get the indexed cache value.
A model for hierarchical or flat database tables.
Definition: bpstablemodel.h:21