UI functions on Save receipt form.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define RECEIPTSAVEFORM_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <objectbinder.h>
|
||||
#include <autotablemodel.h>
|
||||
#include "data/voucher.h"
|
||||
|
||||
namespace Ui {
|
||||
class ReceiptSaveForm;
|
||||
@@ -15,8 +18,16 @@ public:
|
||||
explicit ReceiptSaveForm(QWidget *parent = 0);
|
||||
~ReceiptSaveForm();
|
||||
|
||||
private slots:
|
||||
void on_lineEdit_textChanged(const QString &text);
|
||||
|
||||
void on_radioAdd_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::ReceiptSaveForm *ui;
|
||||
ObjectBinder m_binder;
|
||||
AutoTableModel<Voucher> *m_voucherModel;
|
||||
bool m_saveAsNew;
|
||||
};
|
||||
|
||||
#endif // RECEIPTSAVEFORM_H
|
||||
|
||||
+43
-12
@@ -6,14 +6,27 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>419</width>
|
||||
<height>545</height>
|
||||
<width>804</width>
|
||||
<height>513</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Save receipt</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
@@ -30,18 +43,35 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTableView" name="tabVouchers">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioSave">
|
||||
<property name="text">
|
||||
<string>Save as new</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>GroupBox</string>
|
||||
<string>New receipt</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@@ -50,7 +80,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
<widget class="QLineEdit" name="name"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@@ -60,7 +90,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
||||
<widget class="QLineEdit" name="description"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
@@ -70,10 +100,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_4"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QTableView" name="tableView_2"/>
|
||||
<widget class="QComboBox" name="contact">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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
|
||||
|
||||
INCLUDEPATH += $$PWD/../addressbook/data
|
||||
INCLUDEPATH += $$PWD/../addressbook
|
||||
DEPENDPATH += $$PWD/../addressbook
|
||||
|
||||
DESTDIR = ../plugins
|
||||
|
||||
Reference in New Issue
Block a user