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
00d0ed5e
Commit
00d0ed5e
authored
Apr 08, 2018
by
Hugo Hörnquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Diff GUI buttons work again
parent
db889ed2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
13 deletions
+4
-13
admin/mainwindow.cpp
admin/mainwindow.cpp
+4
-13
No files found.
admin/mainwindow.cpp
View file @
00d0ed5e
...
...
@@ -237,13 +237,11 @@ MainWindow::MainWindow(QWidget *parent) :
// ==================================================
// TODO
clear_stockDiffTemp
();
QList
<
int
>
inventoryCheckDisabled
;
inventoryCheckDisabled
<<
0
<<
1
<<
2
<<
3
<<
4
<<
6
;
DisablingModel
*
inventoryModel
=
new
DisablingModel
(
inventoryCheckDisabled
);
// inventoryModel->setTable("stock_diff_temp");
inventoryModel
->
setTable
(
"diff_view"
);
inventoryModel
->
setHeaderData
(
0
,
Qt
::
Horizontal
,
"id"
);
inventoryModel
->
setHeaderData
(
1
,
Qt
::
Horizontal
,
"product id"
);
...
...
@@ -253,14 +251,11 @@ MainWindow::MainWindow(QWidget *parent) :
inventoryModel
->
setHeaderData
(
5
,
Qt
::
Horizontal
,
"Faktiskt"
);
inventoryModel
->
setHeaderData
(
6
,
Qt
::
Horizontal
,
"Diff"
);
qDebug
()
<<
"Primary key"
<<
inventoryModel
->
primaryKey
();
inventoryModel
->
setEditStrategy
(
QSqlTableModel
::
OnFieldChange
);
QObject
::
connect
(
inventoryModel
,
&
QAbstractItemModel
::
dataChanged
,
this
,
&
MainWindow
::
on_inventoryModel_dataChanged
);
// inventoryModel->setRelation(1, QSqlRelation("products", "id", "name"));
inventoryModel
->
select
();
ui
->
inventoryCheckView
->
setModel
(
inventoryModel
);
ui
->
inventoryCheckView
->
horizontalHeader
()
->
setSectionResizeMode
(
QHeaderView
::
ResizeToContents
);
...
...
@@ -738,7 +733,7 @@ void MainWindow::on_diffDrawer_textChanged(const QString &arg1)
void
MainWindow
::
on_submitStockDiff_clicked
()
{
QSqlQuery
(
"DELETE FROM
stock_
diff_
temp
"
);
QSqlQuery
(
"DELETE FROM diff_
view
"
);
((
QSqlRelationalTableModel
*
)
ui
->
inventoryCheckView
->
model
())
->
select
();
}
...
...
@@ -775,23 +770,19 @@ void MainWindow::open_till()
port_write
(
port_name
,
'1'
);
}
// TODO this function does what it should on the db layer
// but doesn't update the ui as expected
void
MainWindow
::
on_stockDiffReset_clicked
()
{
clear_stockDiffTemp
();
// TODO TODO this doesn't update the ui for some reason!
if
(
!
((
QSqlRelationalTableModel
*
)
ui
->
stockView
->
model
())
->
select
())
qDebug
()
<<
__LINE__
;
((
QSqlTableModel
*
)
ui
->
inventoryCheckView
->
model
())
->
select
();
}
// this also inserts the new needed data into
stock_
diff_
tem
p
// this also inserts the new needed data into diff_
hel
p
void
MainWindow
::
clear_stockDiffTemp
()
{
// TODO transaction
QSqlQuery
(
"UPDATE my_db_settings SET value = 0 WHERE name = 'stock_diff_temp_transfer'"
);
QSqlQuery
(
"DELETE FROM
stock_
diff_
tem
p"
);
QSqlQuery
(
"DELETE FROM diff_
hel
p"
);
QSqlQuery
(
"UPDATE my_db_settings SET value = 1 WHERE name = 'stock_diff_temp_transfer'"
);
}
...
...
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