AutoTableModel now can display data from related table.
Usage example of ComboBox binding in Accommodation plugin.print
parent
1b6141923f
commit
7ea06881ef
@ -0,0 +1,8 @@
|
||||
#ifndef ACCOMMODATIONDATA_H
|
||||
#define ACCOMMODATIONDATA_H
|
||||
|
||||
#include "address.h"
|
||||
#include "person.h"
|
||||
|
||||
#endif // ACCOMMODATIONDATA_H
|
||||
|
@ -0,0 +1,58 @@
|
||||
#include "address.h"
|
||||
|
||||
Address::Address(QObject *parent) : ComboItem(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Address::~Address()
|
||||
{
|
||||
|
||||
}
|
||||
QString Address::city() const
|
||||
{
|
||||
return m_city;
|
||||
}
|
||||
|
||||
void Address::setCity(const QString &city)
|
||||
{
|
||||
m_city = city;
|
||||
}
|
||||
QString Address::street() const
|
||||
{
|
||||
return m_street;
|
||||
}
|
||||
|
||||
void Address::setStreet(const QString &street)
|
||||
{
|
||||
m_street = street;
|
||||
}
|
||||
QString Address::houseNumber() const
|
||||
{
|
||||
return m_houseNumber;
|
||||
}
|
||||
|
||||
void Address::setHouseNumber(const QString &houseNumber)
|
||||
{
|
||||
m_houseNumber = houseNumber;
|
||||
}
|
||||
int Address::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Address::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
bool Address::eq(ComboItem *other)
|
||||
{
|
||||
Address *addr = qobject_cast<Address*>(other);
|
||||
return addr != NULL && m_id == addr->id();
|
||||
}
|
||||
|
||||
QString Address::toString()
|
||||
{
|
||||
return m_street + ", " + m_houseNumber + ", " + m_city;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
#ifndef ADDRESS_H
|
||||
#define ADDRESS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <data/comboitem.h>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class Address : public ComboItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString city READ city WRITE setCity)
|
||||
Q_PROPERTY(QString street READ street WRITE setStreet)
|
||||
Q_PROPERTY(QString houseNumber READ houseNumber WRITE setHouseNumber)
|
||||
|
||||
public:
|
||||
explicit Address(QObject *parent = 0);
|
||||
~Address();
|
||||
|
||||
QString city() const;
|
||||
void setCity(const QString &city);
|
||||
|
||||
QString street() const;
|
||||
void setStreet(const QString &street);
|
||||
|
||||
QString houseNumber() const;
|
||||
void setHouseNumber(const QString &houseNumber);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_city;
|
||||
QString m_street;
|
||||
QString m_houseNumber;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
// ComboItem interface
|
||||
public:
|
||||
virtual bool eq(ComboItem *other);
|
||||
virtual QString toString();
|
||||
};
|
||||
|
||||
#endif // ADDRESS_H
|
Loading…
Reference in New Issue