UI functions on Save receipt form.
parent
5035c4ce05
commit
4593161261
@ -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,14 +1,88 @@
|
||||
#include "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) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ReceiptSaveForm)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue