Implemented search in shop items on ShopForm. Prepare for favorite buttons.
This commit is contained in:
@@ -23,7 +23,7 @@ Qt::ItemFlags ITableModel::flags(const QModelIndex &index) const
|
|||||||
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
|
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QAbstractTableModel::flags(index);
|
return QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITableModel::setEditableCols(const QList<int> cols)
|
void ITableModel::setEditableCols(const QList<int> cols)
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#include "favorititem.h"
|
||||||
|
#include <define.h>
|
||||||
|
|
||||||
|
FavoritItem::FavoritItem()
|
||||||
|
{
|
||||||
|
m_id = 0;
|
||||||
|
m_vatType = Enums::NONE;
|
||||||
|
m_unitPrice = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FavoritItem::id()
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setId(int id)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FavoritItem::name()
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setName(const QString &name)
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDecDouble FavoritItem::unitPrice()
|
||||||
|
{
|
||||||
|
return TO_DEC(m_unitPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setUnitPrice(QDecDouble unitPrice)
|
||||||
|
{
|
||||||
|
m_unitPrice = FROM_DEC(unitPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
Enums::VatType FavoritItem::vatType()
|
||||||
|
{
|
||||||
|
return m_vatType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setVatType(const Enums::VatType &vatType)
|
||||||
|
{
|
||||||
|
m_vatType = vatType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FavoritItem::pluginId()
|
||||||
|
{
|
||||||
|
return m_pluginId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setPluginId(const QString &pluginId)
|
||||||
|
{
|
||||||
|
m_pluginId = pluginId;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FavoritItem::favButtonName() const
|
||||||
|
{
|
||||||
|
return m_favButtonName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavoritItem::setFavButtonName(const QString &favButtonName)
|
||||||
|
{
|
||||||
|
m_favButtonName = favButtonName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#ifndef FAVORITITEM_H
|
||||||
|
#define FAVORITITEM_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QDecDouble.hh>
|
||||||
|
#include <enums.h>
|
||||||
|
#include <ishopitem.h>
|
||||||
|
#include <odb/core.hxx>
|
||||||
|
|
||||||
|
class IShopItem;
|
||||||
|
|
||||||
|
#pragma db object
|
||||||
|
class FavoritItem : public QObject, public IShopItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(int id READ id WRITE setId)
|
||||||
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
|
Q_PROPERTY(QDecDouble unitPrice READ unitPrice WRITE setUnitPrice)
|
||||||
|
Q_PROPERTY(Enums::VatType vatType READ vatType WRITE setVatType)
|
||||||
|
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
|
||||||
|
Q_PROPERTY(QString favButtonName READ favButtonName WRITE setFavButtonName)
|
||||||
|
|
||||||
|
public:
|
||||||
|
FavoritItem();
|
||||||
|
|
||||||
|
// IShopItem interface
|
||||||
|
public:
|
||||||
|
int id() override;
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
QString name() override;
|
||||||
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
QDecDouble unitPrice() override;
|
||||||
|
void setUnitPrice(QDecDouble unitPrice);
|
||||||
|
|
||||||
|
Enums::VatType vatType() override;
|
||||||
|
void setVatType(const Enums::VatType &vatType);
|
||||||
|
|
||||||
|
QString pluginId() override;
|
||||||
|
void setPluginId(const QString &pluginId);
|
||||||
|
|
||||||
|
QString favButtonName() const;
|
||||||
|
void setFavButtonName(const QString &favButtonName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class odb::access;
|
||||||
|
#pragma db id auto
|
||||||
|
int m_id;
|
||||||
|
QString m_name;
|
||||||
|
int m_unitPrice;
|
||||||
|
Enums::VatType m_vatType;
|
||||||
|
QString m_pluginId;
|
||||||
|
QString m_favButtonName;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QSharedPointer<FavoritItem> FavoritItemPtr;
|
||||||
|
|
||||||
|
#endif // FAVORITITEM_H
|
||||||
@@ -3,5 +3,6 @@
|
|||||||
|
|
||||||
#include "voucher.h"
|
#include "voucher.h"
|
||||||
#include "voucheritem.h"
|
#include "voucheritem.h"
|
||||||
|
#include "favorititem.h"
|
||||||
|
|
||||||
#endif // SHOPDATA_H
|
#endif // SHOPDATA_H
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "favoriteservice.h"
|
||||||
|
|
||||||
|
FavoriteService::FavoriteService()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FAVORITESERVICE_H
|
||||||
|
#define FAVORITESERVICE_H
|
||||||
|
|
||||||
|
#include <core.h>
|
||||||
|
#include "data/favorititem.h"
|
||||||
|
|
||||||
|
class FavoriteService : public Service<FavoritItem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FavoriteService();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FAVORITESERVICE_H
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "ui_shopsettingsform.h"
|
#include "ui_shopsettingsform.h"
|
||||||
|
|
||||||
#include <settingsservice.h>
|
#include <settingsservice.h>
|
||||||
|
#include "shopservice.h"
|
||||||
|
|
||||||
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
|
ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
|
||||||
FormBinder<ShopSettings>(parent),
|
FormBinder<ShopSettings>(parent),
|
||||||
@@ -12,6 +13,8 @@ ShopSettingsForm::ShopSettingsForm(QWidget *parent) :
|
|||||||
registerBinding(ui->output);
|
registerBinding(ui->output);
|
||||||
registerBinding(ui->lettersPerLine);
|
registerBinding(ui->lettersPerLine);
|
||||||
registerBinding(ui->byMessage);
|
registerBinding(ui->byMessage);
|
||||||
|
|
||||||
|
m_itemModel = new AutoTableModel<ShopItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopSettingsForm::~ShopSettingsForm()
|
ShopSettingsForm::~ShopSettingsForm()
|
||||||
@@ -24,6 +27,10 @@ void ShopSettingsForm::loadEntity()
|
|||||||
SettingsService srv("SHOP");
|
SettingsService srv("SHOP");
|
||||||
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
|
ShopSettingsPtr settings = srv.loadSettings<ShopSettings>();
|
||||||
setEntity(settings);
|
setEntity(settings);
|
||||||
|
|
||||||
|
ShopService srvShop;
|
||||||
|
m_itemModel->setData(srvShop.allSellableItems());
|
||||||
|
ui->tableItems->setModel(m_itemModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShopSettingsForm::saveRecord()
|
bool ShopSettingsForm::saveRecord()
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <formbinder.h>
|
#include <formbinder.h>
|
||||||
#include "shopsettings.h"
|
#include "shopsettings.h"
|
||||||
|
#include <core.h>
|
||||||
|
#include "shopitem.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ShopSettingsForm;
|
class ShopSettingsForm;
|
||||||
@@ -19,6 +21,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ShopSettingsForm *ui;
|
Ui::ShopSettingsForm *ui;
|
||||||
|
AutoTableModel<ShopItem> *m_itemModel;
|
||||||
|
|
||||||
// IForm interface
|
// IForm interface
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>608</width>
|
<width>645</width>
|
||||||
<height>450</height>
|
<height>463</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -15,11 +15,193 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="title">
|
<property name="currentIndex">
|
||||||
<string>Printer</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Favorite buttons</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableItems">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QToolButton" name="toolButton_9">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QToolButton" name="toolButton_10">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="toolButton_3">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QToolButton" name="toolButton_6">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QToolButton" name="toolButton_4">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QToolButton" name="toolButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QToolButton" name="toolButton_8">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButton_2">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QToolButton" name="toolButton_5">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButton_7">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Printer</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -30,28 +212,29 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="output"/>
|
<widget class="QLineEdit" name="output"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Letters per line</string>
|
<string>Letters per line</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="lettersPerLine"/>
|
<widget class="QSpinBox" name="lettersPerLine"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Footer text</string>
|
<string>Footer text</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="byMessage"/>
|
<widget class="QLineEdit" name="byMessage"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
+8
-3
@@ -28,7 +28,9 @@ SOURCES += shop.cpp \
|
|||||||
paydialog.cpp \
|
paydialog.cpp \
|
||||||
paydvouchersdialog.cpp \
|
paydvouchersdialog.cpp \
|
||||||
shopitem.cpp \
|
shopitem.cpp \
|
||||||
isellableservice.cpp
|
isellableservice.cpp \
|
||||||
|
data/favorititem.cpp \
|
||||||
|
settings/favoriteservice.cpp
|
||||||
|
|
||||||
HEADERS += shop.h\
|
HEADERS += shop.h\
|
||||||
shop_global.h \
|
shop_global.h \
|
||||||
@@ -49,7 +51,9 @@ HEADERS += shop.h\
|
|||||||
settings/shopsettingsform.h \
|
settings/shopsettingsform.h \
|
||||||
paydialog.h \
|
paydialog.h \
|
||||||
paydvouchersdialog.h \
|
paydvouchersdialog.h \
|
||||||
shopitem.h
|
shopitem.h \
|
||||||
|
data/favorititem.h \
|
||||||
|
settings/favoriteservice.h
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
@@ -75,6 +79,7 @@ else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
|
|||||||
|
|
||||||
INCLUDEPATH += $$PWD/../addressbook/data
|
INCLUDEPATH += $$PWD/../addressbook/data
|
||||||
INCLUDEPATH += $$PWD/../addressbook
|
INCLUDEPATH += $$PWD/../addressbook
|
||||||
|
INCLUDEPATH += $$PWD/
|
||||||
DEPENDPATH += $$PWD/../addressbook
|
DEPENDPATH += $$PWD/../addressbook
|
||||||
|
|
||||||
DESTDIR = ../plugins
|
DESTDIR = ../plugins
|
||||||
@@ -83,7 +88,7 @@ OTHER_FILES += shop.json
|
|||||||
|
|
||||||
ODB_FILES = shop/data/shop-data.h
|
ODB_FILES = shop/data/shop-data.h
|
||||||
H_DIR = $$PWD/data/*.h
|
H_DIR = $$PWD/data/*.h
|
||||||
ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data
|
ODB_OTHER_INCLUDES = -I $$PWD/../addressbook/data -I $$PWD/
|
||||||
include(../odb.pri)
|
include(../odb.pri)
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "isellableservice.h"
|
#include "isellableservice.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "shop-odb.hxx"
|
#include "shop-odb.hxx"
|
||||||
|
|
||||||
ShopForm::ShopForm(QWidget *parent) :
|
ShopForm::ShopForm(QWidget *parent) :
|
||||||
@@ -313,3 +315,31 @@ void ShopForm::on_btnAddItem_clicked()
|
|||||||
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
|
||||||
addItem(item, ui->spnCount->value());
|
addItem(item, ui->spnCount->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShopForm::on_commoditySearch_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSortFilterProxyModel proxy;
|
||||||
|
proxy.setSourceModel(m_commodityModel);
|
||||||
|
proxy.setFilterKeyColumn(0);
|
||||||
|
proxy.setFilterFixedString(text);
|
||||||
|
|
||||||
|
auto moveToIndex = [this](const QModelIndex &matchingIndex) {
|
||||||
|
ui->commodityTable->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);
|
||||||
|
ui->commodityTable->setCurrentIndex(matchingIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
|
||||||
|
if(matchingIndex.isValid()) {
|
||||||
|
moveToIndex(matchingIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
proxy.setFilterKeyColumn(1);
|
||||||
|
matchingIndex = proxy.mapToSource(proxy.index(0,0));
|
||||||
|
|
||||||
|
if (matchingIndex.isValid())
|
||||||
|
{
|
||||||
|
moveToIndex(matchingIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ private slots:
|
|||||||
|
|
||||||
void on_btnAddItem_clicked();
|
void on_btnAddItem_clicked();
|
||||||
|
|
||||||
|
void on_commoditySearch_textChanged(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ShopForm *ui;
|
Ui::ShopForm *ui;
|
||||||
QSharedPointer<Voucher> m_voucher;
|
QSharedPointer<Voucher> m_voucher;
|
||||||
|
|||||||
+171
-3
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>959</width>
|
<width>959</width>
|
||||||
<height>582</height>
|
<height>643</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -131,6 +131,11 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QToolButton" name="directSale">
|
<widget class="QToolButton" name="directSale">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Direct Sale</string>
|
<string>Direct Sale</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -177,7 +182,82 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="favorites2"/>
|
<widget class="QToolButton" name="toolFav1">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QToolButton" name="toolFav5">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QToolButton" name="toolFav2">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="toolFav3">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QToolButton" name="toolFav4">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -200,8 +280,96 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QToolButton" name="toolFav7">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="favorites3"/>
|
<widget class="QToolButton" name="toolFav6">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="toolFav8">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QToolButton" name="toolFav9">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QToolButton" name="toolFav10">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>75</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user