Merge branch 'master' of https://git.bukova.info/repos/git/prodejna
						commit
						580b623aca
					
				@ -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
 | 
			
		||||
@ -0,0 +1,42 @@
 | 
			
		||||
#include "combodata.h"
 | 
			
		||||
 | 
			
		||||
ComboData::ComboData(const QVariant &index, const QString &label)
 | 
			
		||||
{
 | 
			
		||||
    m_index = index;
 | 
			
		||||
    m_label = label;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ComboData::ComboData(const QSharedPointer<QObject> &index)
 | 
			
		||||
{
 | 
			
		||||
    m_index = QVariant::fromValue(index);
 | 
			
		||||
    ComboItem *ci = qobject_cast<ComboItem*>(index.data());
 | 
			
		||||
 | 
			
		||||
    if (ci != NULL)
 | 
			
		||||
    {
 | 
			
		||||
        m_label = ci->toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ComboData::~ComboData()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QVariant ComboData::index() const
 | 
			
		||||
{
 | 
			
		||||
    return m_index;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ComboData::setIndex(const QVariant &index)
 | 
			
		||||
{
 | 
			
		||||
    m_index = index;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString ComboData::label() const
 | 
			
		||||
{
 | 
			
		||||
    return m_label;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ComboData::setLabel(const QString &label)
 | 
			
		||||
{
 | 
			
		||||
    m_label = label;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,28 @@
 | 
			
		||||
#ifndef COMBODATA_H
 | 
			
		||||
#define COMBODATA_H
 | 
			
		||||
 | 
			
		||||
#include <QVariant>
 | 
			
		||||
#include <QSharedDataPointer>
 | 
			
		||||
 | 
			
		||||
#include "core_global.h"
 | 
			
		||||
#include "data/comboitem.h"
 | 
			
		||||
 | 
			
		||||
class CORESHARED_EXPORT ComboData
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    ComboData(const QVariant &index, const QString &label);
 | 
			
		||||
    ComboData(const QSharedPointer<QObject> &index);
 | 
			
		||||
    ~ComboData();
 | 
			
		||||
 | 
			
		||||
    QVariant index() const;
 | 
			
		||||
    void setIndex(const QVariant &index);
 | 
			
		||||
 | 
			
		||||
    QString label() const;
 | 
			
		||||
    void setLabel(const QString &label);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QVariant m_index;
 | 
			
		||||
    QString m_label;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // COMBODATA_H
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
#include "comboitem.h"
 | 
			
		||||
 | 
			
		||||
ComboItem::ComboItem(QObject *parent)
 | 
			
		||||
    :QObject(parent)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ComboItem::~ComboItem()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,21 @@
 | 
			
		||||
#ifndef COMBOITEM_H
 | 
			
		||||
#define COMBOITEM_H
 | 
			
		||||
 | 
			
		||||
#include "core_global.h"
 | 
			
		||||
#include <QSharedPointer>
 | 
			
		||||
#include <QVariant>
 | 
			
		||||
#include <QObject>
 | 
			
		||||
 | 
			
		||||
class CORESHARED_EXPORT ComboItem : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ComboItem(QObject *parent = NULL);
 | 
			
		||||
    ~ComboItem();
 | 
			
		||||
 | 
			
		||||
    virtual bool eq(ComboItem *other) = 0;
 | 
			
		||||
    virtual QString toString() = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // COMBOITEM_H
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue