Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Hugo Hörnquist
Stupan
Commits
da769a8f
Commit
da769a8f
authored
Feb 16, 2018
by
Hugo Hörnquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin: added search bar to product listing
parent
a29a72ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
admin/mainwindow.cpp
admin/mainwindow.cpp
+31
-5
admin/mainwindow.h
admin/mainwindow.h
+3
-0
admin/mainwindow.ui
admin/mainwindow.ui
+7
-0
No files found.
admin/mainwindow.cpp
View file @
da769a8f
...
...
@@ -365,12 +365,9 @@ void MainWindow::on_acquisitionModel_dataChanged(QModelIndex topLeft, QModelInde
ui
->
totalPriceLabel
->
setText
(
QString
(
"%L1"
).
arg
(
total
));
}
void
MainWindow
::
on_checkBox_toggled
(
bool
checked
)
void
MainWindow
::
on_checkBox_toggled
(
bool
/*
checked
*/
)
{
if
(
checked
)
model
->
setFilter
(
"sale_status >= 0"
);
else
model
->
setFilter
(
"sale_status IN (0, 1)"
);
setProductFilter
();
}
// Add new row for new product
...
...
@@ -840,3 +837,32 @@ void MainWindow::setStockValues()
double
projVal
=
get_projected_stock_value
().
toDouble
()
/
100.0
;
ui
->
valueProjectedLabel
->
setText
(
QString
(
"%1"
).
arg
(
projVal
,
0
,
'f'
,
2
));
}
void
MainWindow
::
setProductFilter
()
{
QString
searchStr
=
ui
->
productListSearch
->
text
();
bool
isNumber
;
searchStr
.
toInt
(
&
isNumber
,
10
);
QString
filter
=
QString
(
isNumber
?
"bar_code = '%1'"
:
"name LIKE '\%%1\%' "
).
arg
(
searchStr
);
if
(
ui
->
checkBox
->
isChecked
())
{
filter
.
append
(
"AND sale_status >= 0"
);
}
else
{
filter
.
append
(
"AND sale_status IN (0, 1)"
);
}
QSqlTableModel
*
model
=
((
QSqlTableModel
*
)
ui
->
tableView
->
model
());
model
->
setFilter
(
filter
);
model
->
select
();
}
void
MainWindow
::
on_productListSearch_textChanged
(
const
QString
&
arg1
)
{
setProductFilter
();
}
admin/mainwindow.h
View file @
da769a8f
...
...
@@ -73,6 +73,8 @@ private slots:
void
on_stockDiffReset_clicked
();
void
on_productListSearch_textChanged
(
const
QString
&
arg1
);
private:
Ui
::
MainWindow
*
ui
;
QSqlTableModel
*
model
;
...
...
@@ -91,6 +93,7 @@ private:
void
toVaultDrawer_shared
(
QString
from
,
QString
to
);
void
addRemoveCommon
(
QString
from
,
QString
to
);
void
clear_stockDiffTemp
();
void
setProductFilter
();
QVariant
get_projected_stock_value
();
QVariant
get_acquistion_stock_value
();
...
...
admin/mainwindow.ui
View file @
da769a8f
...
...
@@ -31,6 +31,13 @@
<string>
Produktlista
</string>
</attribute>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<item>
<widget
class=
"QLineEdit"
name=
"productListSearch"
>
<property
name=
"placeholderText"
>
<string>
Sök...
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QTableView"
name=
"tableView"
>
<property
name=
"sizeIncrement"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment