UI functions on Save receipt form.
This commit is contained in:
@@ -17,14 +17,16 @@ SOURCES += addressbook.cpp \
|
|||||||
data/addressbookdata.cpp \
|
data/addressbookdata.cpp \
|
||||||
addressbookform.cpp \
|
addressbookform.cpp \
|
||||||
addressbookgrid.cpp \
|
addressbookgrid.cpp \
|
||||||
addressbooktablemodel.cpp
|
addressbooktablemodel.cpp \
|
||||||
|
addressbookservice.cpp
|
||||||
|
|
||||||
HEADERS += addressbook.h\
|
HEADERS += addressbook.h\
|
||||||
addressbook_global.h \
|
addressbook_global.h \
|
||||||
data/addressbookdata.h \
|
data/addressbookdata.h \
|
||||||
addressbookform.h \
|
addressbookform.h \
|
||||||
addressbookgrid.h \
|
addressbookgrid.h \
|
||||||
addressbooktablemodel.h
|
addressbooktablemodel.h \
|
||||||
|
addressbookservice.h
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#include <service.h>
|
||||||
|
#include "addressbookservice.h"
|
||||||
|
#include "addressbook-odb.hxx"
|
||||||
|
|
||||||
|
AddressBookService::AddressBookService()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AddressBookService::~AddressBookService()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QSharedPointer<AddressbookData> > AddressBookService::all(const QString &where)
|
||||||
|
{
|
||||||
|
Service<AddressbookData> srv;
|
||||||
|
return srv.all(where);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef ADDRESSBOOKSERVICE_H
|
||||||
|
#define ADDRESSBOOKSERVICE_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "data/addressbookdata.h"
|
||||||
|
#include "addressbook_global.h"
|
||||||
|
|
||||||
|
class ADDRESSBOOKSHARED_EXPORT AddressBookService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AddressBookService();
|
||||||
|
~AddressBookService();
|
||||||
|
|
||||||
|
QList<QSharedPointer<AddressbookData> > all(const QString &where = "");
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDRESSBOOKSERVICE_H
|
||||||
@@ -1,108 +1,119 @@
|
|||||||
#include "addressbookdata.h"
|
#include "addressbookdata.h"
|
||||||
|
|
||||||
AddressbookData::AddressbookData(QObject * parent)
|
AddressbookData::AddressbookData(QObject * parent)
|
||||||
:QObject(parent)
|
:ComboItem(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AddressbookData::title() const
|
QString AddressbookData::title() const
|
||||||
{
|
{
|
||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setTitle(const QString &title)
|
void AddressbookData::setTitle(const QString &title)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
}
|
}
|
||||||
QString AddressbookData::firstName() const
|
QString AddressbookData::firstName() const
|
||||||
{
|
{
|
||||||
return m_firstName;
|
return m_firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setFirstName(const QString &firstName)
|
void AddressbookData::setFirstName(const QString &firstName)
|
||||||
{
|
{
|
||||||
m_firstName = firstName;
|
m_firstName = firstName;
|
||||||
}
|
}
|
||||||
QString AddressbookData::lastName() const
|
QString AddressbookData::lastName() const
|
||||||
{
|
{
|
||||||
return m_lastName;
|
return m_lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setLastName(const QString &lastName)
|
void AddressbookData::setLastName(const QString &lastName)
|
||||||
{
|
{
|
||||||
m_lastName = lastName;
|
m_lastName = lastName;
|
||||||
}
|
}
|
||||||
QDate AddressbookData::birthDate() const
|
QDate AddressbookData::birthDate() const
|
||||||
{
|
{
|
||||||
return m_birthDate;
|
return m_birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setBirthDate(const QDate &birthDate)
|
void AddressbookData::setBirthDate(const QDate &birthDate)
|
||||||
{
|
{
|
||||||
m_birthDate = birthDate;
|
m_birthDate = birthDate;
|
||||||
}
|
}
|
||||||
QString AddressbookData::idCardNumber() const
|
QString AddressbookData::idCardNumber() const
|
||||||
{
|
{
|
||||||
return m_idCardNumber;
|
return m_idCardNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setIdCardNumber(const QString &idCardNumber)
|
void AddressbookData::setIdCardNumber(const QString &idCardNumber)
|
||||||
{
|
{
|
||||||
m_idCardNumber = idCardNumber;
|
m_idCardNumber = idCardNumber;
|
||||||
}
|
}
|
||||||
bool AddressbookData::ztp() const
|
bool AddressbookData::ztp() const
|
||||||
{
|
{
|
||||||
return m_ztp;
|
return m_ztp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setZtp(bool ztp)
|
void AddressbookData::setZtp(bool ztp)
|
||||||
{
|
{
|
||||||
m_ztp = ztp;
|
m_ztp = ztp;
|
||||||
}
|
}
|
||||||
QString AddressbookData::addressCity() const
|
QString AddressbookData::addressCity() const
|
||||||
{
|
{
|
||||||
return m_addressCity;
|
return m_addressCity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setAddressCity(const QString &addressCity)
|
void AddressbookData::setAddressCity(const QString &addressCity)
|
||||||
{
|
{
|
||||||
m_addressCity = addressCity;
|
m_addressCity = addressCity;
|
||||||
}
|
}
|
||||||
QString AddressbookData::addressStreet() const
|
QString AddressbookData::addressStreet() const
|
||||||
{
|
{
|
||||||
return m_addressStreet;
|
return m_addressStreet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setAddressStreet(const QString &addressStreet)
|
void AddressbookData::setAddressStreet(const QString &addressStreet)
|
||||||
{
|
{
|
||||||
m_addressStreet = addressStreet;
|
m_addressStreet = addressStreet;
|
||||||
}
|
}
|
||||||
QString AddressbookData::addressHouseNumber() const
|
QString AddressbookData::addressHouseNumber() const
|
||||||
{
|
{
|
||||||
return m_addressHouseNumber;
|
return m_addressHouseNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setAddressHouseNumber(const QString &addressHouseNumber)
|
void AddressbookData::setAddressHouseNumber(const QString &addressHouseNumber)
|
||||||
{
|
{
|
||||||
m_addressHouseNumber = addressHouseNumber;
|
m_addressHouseNumber = addressHouseNumber;
|
||||||
}
|
}
|
||||||
QString AddressbookData::addressZipCode() const
|
QString AddressbookData::addressZipCode() const
|
||||||
{
|
{
|
||||||
return m_addressZipCode;
|
return m_addressZipCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setAddressZipCode(const QString &addressZipCode)
|
void AddressbookData::setAddressZipCode(const QString &addressZipCode)
|
||||||
{
|
{
|
||||||
m_addressZipCode = addressZipCode;
|
m_addressZipCode = addressZipCode;
|
||||||
}
|
}
|
||||||
int AddressbookData::id() const
|
int AddressbookData::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressbookData::setId(int id)
|
void AddressbookData::setId(int id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AddressbookData::eq(ComboItem *other)
|
||||||
|
{
|
||||||
|
AddressbookData *adb = qobject_cast<AddressbookData*>(other);
|
||||||
|
return adb != NULL && adb->id() == this->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddressbookData::toString()
|
||||||
|
{
|
||||||
|
return m_firstName + " " + m_lastName + ", " + m_addressStreet + " " + m_addressHouseNumber + ", " + m_addressCity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include <odb/core.hxx>
|
#include <odb/core.hxx>
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#include <data/comboitem.h>
|
||||||
|
|
||||||
#if defined(ADDRESSBOOK_LIBRARY)
|
#if defined(ADDRESSBOOK_LIBRARY)
|
||||||
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
|
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
|
||||||
#else
|
#else
|
||||||
@@ -14,7 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma db object
|
#pragma db object
|
||||||
class ADDRESSBOOKSHARED_EXPORT AddressbookData : public QObject
|
class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString title READ title WRITE setTitle)
|
Q_PROPERTY(QString title READ title WRITE setTitle)
|
||||||
@@ -77,6 +79,11 @@ private:
|
|||||||
QString m_addressStreet;
|
QString m_addressStreet;
|
||||||
QString m_addressHouseNumber;
|
QString m_addressHouseNumber;
|
||||||
QString m_addressZipCode;
|
QString m_addressZipCode;
|
||||||
|
|
||||||
|
// ComboItem interface
|
||||||
|
public:
|
||||||
|
virtual bool eq(ComboItem *other);
|
||||||
|
virtual QString toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDRESSBOOKDATA_H
|
#endif // ADDRESSBOOKDATA_H
|
||||||
|
|||||||
@@ -1,14 +1,88 @@
|
|||||||
#include "receiptsaveform.h"
|
#include "receiptsaveform.h"
|
||||||
#include "ui_receiptsaveform.h"
|
#include "ui_receiptsaveform.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
#include <service.h>
|
||||||
|
#include <iplugin.h>
|
||||||
|
#include <addressbookservice.h>
|
||||||
|
#include <addressbookdata.h>
|
||||||
|
|
||||||
|
#include "data/voucher.h"
|
||||||
|
#include "shop-odb.hxx"
|
||||||
|
|
||||||
ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) :
|
ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ReceiptSaveForm)
|
ui(new Ui::ReceiptSaveForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_voucherModel = new AutoTableModel<Voucher>(this);
|
||||||
|
Service<Voucher> srv;
|
||||||
|
m_voucherModel->setData(srv.all());
|
||||||
|
m_voucherModel->setTranslations(Context::instance().plugin("SHOP")->translations());
|
||||||
|
ui->tabVouchers->setModel(m_voucherModel);
|
||||||
|
ui->tabVouchers->hideColumn(3);
|
||||||
|
ui->tabVouchers->hideColumn(4);
|
||||||
|
ui->tabVouchers->hideColumn(5);
|
||||||
|
ui->tabVouchers->hideColumn(6);
|
||||||
|
ui->tabVouchers->hideColumn(7);
|
||||||
|
ui->tabVouchers->hideColumn(8);
|
||||||
|
ui->tabVouchers->hideColumn(10);
|
||||||
|
ui->tabVouchers->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||||
|
ui->tabVouchers->setColumnWidth(0, 190);
|
||||||
|
ui->tabVouchers->setColumnWidth(2, 200);
|
||||||
|
|
||||||
|
AddressBookService srvAdb;
|
||||||
|
QList<ComboData> comboData;
|
||||||
|
foreach (QSharedPointer<AddressbookData> adb, srvAdb.all()) {
|
||||||
|
comboData << ComboData(adb);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_binder.setData(new Voucher);
|
||||||
|
m_binder.registerBinding(ui->contact, comboData);
|
||||||
|
m_binder.bindToUi();
|
||||||
|
|
||||||
|
ui->contact->completer()->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
|
ui->contact->setCurrentIndex(-1);
|
||||||
|
|
||||||
|
m_saveAsNew = false;
|
||||||
|
ui->groupBox_2->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiptSaveForm::~ReceiptSaveForm()
|
ReceiptSaveForm::~ReceiptSaveForm()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSortFilterProxyModel proxy;
|
||||||
|
proxy.setSourceModel(m_voucherModel);
|
||||||
|
proxy.setFilterKeyColumn(0);
|
||||||
|
proxy.setFilterFixedString(text);
|
||||||
|
|
||||||
|
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
|
||||||
|
if(matchingIndex.isValid()){
|
||||||
|
ui->tabVouchers->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);
|
||||||
|
ui->tabVouchers->setCurrentIndex(matchingIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
{
|
||||||
|
m_saveAsNew = false;
|
||||||
|
ui->groupBox_2->setEnabled(false);
|
||||||
|
ui->groupBox->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_saveAsNew = true;
|
||||||
|
ui->groupBox_2->setEnabled(true);
|
||||||
|
ui->groupBox->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#define RECEIPTSAVEFORM_H
|
#define RECEIPTSAVEFORM_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <objectbinder.h>
|
||||||
|
#include <autotablemodel.h>
|
||||||
|
#include "data/voucher.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ReceiptSaveForm;
|
class ReceiptSaveForm;
|
||||||
@@ -15,8 +18,16 @@ public:
|
|||||||
explicit ReceiptSaveForm(QWidget *parent = 0);
|
explicit ReceiptSaveForm(QWidget *parent = 0);
|
||||||
~ReceiptSaveForm();
|
~ReceiptSaveForm();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_lineEdit_textChanged(const QString &text);
|
||||||
|
|
||||||
|
void on_radioAdd_toggled(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ReceiptSaveForm *ui;
|
Ui::ReceiptSaveForm *ui;
|
||||||
|
ObjectBinder m_binder;
|
||||||
|
AutoTableModel<Voucher> *m_voucherModel;
|
||||||
|
bool m_saveAsNew;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECEIPTSAVEFORM_H
|
#endif // RECEIPTSAVEFORM_H
|
||||||
|
|||||||
+43
-12
@@ -6,14 +6,27 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>419</width>
|
<width>804</width>
|
||||||
<height>545</height>
|
<height>513</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Save receipt</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioAdd">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add to existing</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -30,18 +43,35 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QTableView" name="tableView"/>
|
<widget class="QTableView" name="tabVouchers">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>250</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioSave">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save as new</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>GroupBox</string>
|
<string>New receipt</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -50,7 +80,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
<widget class="QLineEdit" name="name"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
@@ -60,7 +90,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
<widget class="QLineEdit" name="description"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
@@ -70,10 +100,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_4"/>
|
<widget class="QComboBox" name="contact">
|
||||||
</item>
|
<property name="editable">
|
||||||
<item row="3" column="1">
|
<bool>true</bool>
|
||||||
<widget class="QTableView" name="tableView_2"/>
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddre
|
|||||||
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
|
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../addressbook/data
|
INCLUDEPATH += $$PWD/../addressbook/data
|
||||||
|
INCLUDEPATH += $$PWD/../addressbook
|
||||||
DEPENDPATH += $$PWD/../addressbook
|
DEPENDPATH += $$PWD/../addressbook
|
||||||
|
|
||||||
DESTDIR = ../plugins
|
DESTDIR = ../plugins
|
||||||
|
|||||||
Reference in New Issue
Block a user