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
9616397b
Commit
9616397b
authored
Apr 13, 2018
by
Hugo Hörnquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
money transfer submit button should now update money stats
parent
01a523df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
admin/mainwindow.cpp
admin/mainwindow.cpp
+24
-17
admin/mainwindow.h
admin/mainwindow.h
+1
-0
No files found.
admin/mainwindow.cpp
View file @
9616397b
...
...
@@ -312,11 +312,6 @@ MainWindow::MainWindow(QWidget *parent) :
// ==================================================
// QIntValidator* pIntVal = new QIntValidator(0, INT_MAX);
// ui->moneyMoveAmount->setValidator(pIntVal);
// ui->addMoneyEdit->setValidator(pIntVal);
// updateMoneyString();
QSqlTableModel
*
accModel
=
new
QSqlTableModel
();
ui
->
accTreeView
->
setModel
(
accModel
);
accModel
->
setTable
(
"money_simple"
);
...
...
@@ -325,17 +320,7 @@ MainWindow::MainWindow(QWidget *parent) :
accModel
->
setHeaderData
(
1
,
Qt
::
Horizontal
,
"Kronor"
);
accModel
->
setEditStrategy
(
QSqlTableModel
::
OnManualSubmit
);
QSqlRecord
rec
=
accModel
->
record
();
rec
.
setValue
(
"name"
,
QVariant
(
"Lager (projicerat)"
));
rec
.
setValue
(
"amount"
,
QVariant
(
QString
(
"%1"
).
arg
(
get_projected_stock_value
().
toDouble
()
/
100.0
,
0
,
'f'
,
2
)));
accModel
->
insertRecord
(
-
1
,
rec
);
rec
.
setValue
(
"name"
,
QVariant
(
"Lager (inköp)"
));
rec
.
setValue
(
"amount"
,
QVariant
(
QString
(
"%1"
).
arg
(
get_acquistion_stock_value
().
toDouble
()
/
100.0
,
0
,
'f'
,
2
)));
accModel
->
insertRecord
(
-
1
,
rec
);
setMoneyAccountValues
();
QSqlQuery
accQuery
(
"SELECT id, name FROM money"
);
while
(
accQuery
.
next
())
{
...
...
@@ -351,7 +336,26 @@ MainWindow::~MainWindow()
void
MainWindow
::
updateMoneyString
()
{
qDebug
()
<<
"Updating Money Strings"
;
setMoneyDiffLabels
();
setMoneyAccountValues
();
}
void
MainWindow
::
setMoneyAccountValues
()
{
QSqlTableModel
*
accModel
=
(
QSqlTableModel
*
)
ui
->
accTreeView
->
model
();
accModel
->
select
();
QSqlRecord
rec
=
accModel
->
record
();
rec
.
setValue
(
"name"
,
QVariant
(
"Lager (projicerat)"
));
rec
.
setValue
(
"amount"
,
QVariant
(
QString
(
"%1"
).
arg
(
get_projected_stock_value
().
toDouble
()
/
100.0
,
0
,
'f'
,
2
)));
accModel
->
insertRecord
(
-
1
,
rec
);
rec
.
setValue
(
"name"
,
QVariant
(
"Lager (inköp)"
));
rec
.
setValue
(
"amount"
,
QVariant
(
QString
(
"%1"
).
arg
(
get_acquistion_stock_value
().
toDouble
()
/
100.0
,
0
,
'f'
,
2
)));
accModel
->
insertRecord
(
-
1
,
rec
);
}
/*
...
...
@@ -694,6 +698,7 @@ int MainWindow::setMoneyDiffLabels()
ui
->
diffExpected
->
setText
(
diff_text
);
ui
->
diffTotal
->
setText
(
diff_text
);
ui
->
diffDrawer
->
setText
(
""
);
return
expected
;
}
...
...
@@ -860,4 +865,6 @@ void MainWindow::on_accTransferSubmit_clicked()
ui
->
accTransferText
->
setText
(
""
);
// TODO update money values
updateMoneyString
();
}
admin/mainwindow.h
View file @
9616397b
...
...
@@ -100,6 +100,7 @@ private:
void
addRemoveCommon
(
QString
from
,
QString
to
);
void
clear_stockDiffTemp
();
void
setProductFilter
();
void
setMoneyAccountValues
();
QVariant
get_projected_stock_value
();
QVariant
get_acquistion_stock_value
();
...
...
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