aboutsummaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
Diffstat (limited to 'qt')
-rw-r--r--qt/README7
-rw-r--r--qt/driver.cxx1
-rw-r--r--qt/employee.hxx16
3 files changed, 18 insertions, 6 deletions
diff --git a/qt/README b/qt/README
index 077edba..2b30003 100644
--- a/qt/README
+++ b/qt/README
@@ -11,9 +11,10 @@ employee.hxx
establish a bidirectional employee-employer relationship. The QList
type is used to store the collection of employees employed by the
employer. We also use the QDateTime type to store the employee's date
- of birth and QString to store the employee's first and last name. A
- QSet instance keeps track of the employee's email addresses. Finally
- we use QByteArray to store the employee's public key.
+ of birth and QString to store the employee's first and last name. While
+ the employee's object id is QUuid and a QSet instance keeps track of
+ the employee's email addresses. Finally we use QByteArray to store the
+ employee's public key.
employee-odb.hxx
employee-odb.ixx
diff --git a/qt/driver.cxx b/qt/driver.cxx
index 3d05703..377594f 100644
--- a/qt/driver.cxx
+++ b/qt/driver.cxx
@@ -144,6 +144,7 @@ main (int argc, char* argv[])
cout << " public key length: " << p->publicKey ().size () << endl
<< " employer: " << pe->name () << endl
+ << " id: " << p->id ().toString () << endl
<< endl;
}
diff --git a/qt/employee.hxx b/qt/employee.hxx
index f2c34da..82bbcfb 100644
--- a/qt/employee.hxx
+++ b/qt/employee.hxx
@@ -6,6 +6,7 @@
#include <QtCore/QString>
#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
#include <QtCore/QDateTime>
#include <QtCore/QSharedPointer>
#include <QtCore/QList>
@@ -72,7 +73,8 @@ public:
const QDate& born,
const QByteArray& publicKey,
QSharedPointer<Employer> employer)
- : first_ (first),
+ : id_ (QUuid::createUuid ()),
+ first_ (first),
last_ (last),
born_ (born),
publicKey_ (publicKey),
@@ -80,6 +82,14 @@ public:
{
}
+ // Id.
+ //
+ const QUuid&
+ id () const
+ {
+ return id_;
+ }
+
// Name.
//
const QString&
@@ -141,8 +151,8 @@ private:
Employee () {}
- #pragma db id auto
- unsigned long id_;
+ #pragma db id
+ QUuid id_;
QString first_;
QString last_;