Fixed barcode scanner issue on Windows with czech keyboard.

master
Josef Rokos 7 years ago
parent b8ed333c3a
commit b69637165d

@ -13,5 +13,6 @@
#include "settingsform.h" #include "settingsform.h"
#include "enums.h" #include "enums.h"
#include "objectbinder.h" #include "objectbinder.h"
#include "helper.h"
#endif // CORE_H #endif // CORE_H

@ -66,7 +66,8 @@ SOURCES += \
csvimporter.cpp \ csvimporter.cpp \
importdialog.cpp \ importdialog.cpp \
importprogress.cpp \ importprogress.cpp \
reporting/variablefiller.cpp reporting/variablefiller.cpp \
helper.cpp
HEADERS += core.h\ HEADERS += core.h\
core_global.h \ core_global.h \
@ -132,7 +133,8 @@ HEADERS += core.h\
iimportprogress.h \ iimportprogress.h \
importdialog.h \ importdialog.h \
importprogress.h \ importprogress.h \
reporting/variablefiller.h reporting/variablefiller.h \
helper.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib

@ -0,0 +1,39 @@
#include "helper.h"
#include "define.h"
const QMap<QString, QString> Helper::m_numMap{
{"+", "1"},
{"ě", "2"},
{"š", "3"},
{"č", "4"},
{"ř", "5"},
{"ž", "6"},
{"ý", "7"},
{"á", "8"},
{"í", "9"},
{"é", "0"}
};
Helper::Helper()
{
}
QString Helper::replaceByNumbers(const QString &str)
{
QString ret;
std::for_each(ALL(str), [&](QChar c){
QString replaced = m_numMap[c];
if (replaced.isEmpty())
{
ret.append(c);
}
else
{
ret.append(replaced);
}
});
return ret;
}

@ -0,0 +1,18 @@
#ifndef HELPER_H
#define HELPER_H
#include <QString>
#include <QMap>
class Helper
{
public:
Helper();
static QString replaceByNumbers(const QString &str);
private:
static const QMap<QString, QString> m_numMap;
};
#endif // HELPER_H

@ -541,11 +541,19 @@ void ShopForm::on_btnAddItem_clicked()
void ShopForm::on_commoditySearch_textChanged(const QString &text) void ShopForm::on_commoditySearch_textChanged(const QString &text)
{ {
QString replacedText = text;
if (ui->numOnly->isChecked())
{
replacedText = Helper::replaceByNumbers(text);
ui->commoditySearch->setText(replacedText);
}
QSortFilterProxyModel proxy; QSortFilterProxyModel proxy;
proxy.setSourceModel(m_commodityModel); proxy.setSourceModel(m_commodityModel);
proxy.setFilterKeyColumn(0); proxy.setFilterKeyColumn(0);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive); proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy.setFilterFixedString(text); proxy.setFilterFixedString(replacedText);
auto moveToIndex = [this](const QModelIndex &matchingIndex) { auto moveToIndex = [this](const QModelIndex &matchingIndex) {
ui->commodityTable->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible); ui->commodityTable->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>975</width> <width>988</width>
<height>643</height> <height>643</height>
</rect> </rect>
</property> </property>
@ -45,6 +45,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="numOnly">
<property name="text">
<string>Replace chars by numbers</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLineEdit" name="commoditySearch"/> <widget class="QLineEdit" name="commoditySearch"/>
</item> </item>

Loading…
Cancel
Save