Mercurial > hg > syntilista
comparison src/main.cpp @ 218:c3f47d489097
Implement global transactions viewer dialog.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Mar 2018 14:37:39 +0200 |
parents | 58af72da7f60 |
children | 5406b8664f00 |
comparison
equal
deleted
inserted
replaced
217:58af72da7f60 | 218:c3f47d489097 |
---|---|
12 #include <QStandardPaths> | 12 #include <QStandardPaths> |
13 #include "main.h" | 13 #include "main.h" |
14 #include "ui_mainwindow.h" | 14 #include "ui_mainwindow.h" |
15 #include "ui_editperson.h" | 15 #include "ui_editperson.h" |
16 #include "ui_aboutwindow.h" | 16 #include "ui_aboutwindow.h" |
17 #include "ui_viewtransactions.h" | |
17 | 18 |
18 | 19 |
19 // | 20 // |
20 // Application settings struct | 21 // Application settings struct |
21 // | 22 // |
840 | 841 |
841 | 842 |
842 void SyntilistaMainWindow::on_button_About_clicked() | 843 void SyntilistaMainWindow::on_button_About_clicked() |
843 { | 844 { |
844 new AboutWindow(this); | 845 new AboutWindow(this); |
846 } | |
847 | |
848 | |
849 void SyntilistaMainWindow::on_button_ViewTransactions_clicked() | |
850 { | |
851 new ViewTransactions(this); | |
845 } | 852 } |
846 | 853 |
847 | 854 |
848 void SyntilistaMainWindow::on_button_DeletePerson_clicked() | 855 void SyntilistaMainWindow::on_button_DeletePerson_clicked() |
849 { | 856 { |
1580 | 1587 |
1581 void AboutWindow::on_button_Close_clicked() | 1588 void AboutWindow::on_button_Close_clicked() |
1582 { | 1589 { |
1583 close(); | 1590 close(); |
1584 } | 1591 } |
1592 | |
1593 | |
1594 // | |
1595 // Global transactions list viewer | |
1596 // | |
1597 ViewTransactions::ViewTransactions(QWidget *parent) : | |
1598 QDialog(parent), | |
1599 ui(new Ui::ViewTransactions) | |
1600 { | |
1601 ui->setupUi(this); | |
1602 | |
1603 slSetCommonStyleSheet(this); | |
1604 | |
1605 setModal(true); | |
1606 setAttribute(Qt::WA_DeleteOnClose); | |
1607 show(); | |
1608 activateWindow(); | |
1609 raise(); | |
1610 setFocus(); | |
1611 | |
1612 model_Transactions = new SLTransactionSQLModel(); | |
1613 ui->tableview_Transactions->setModel(model_Transactions); | |
1614 ui->tableview_Transactions->setItemDelegate(new QSqlRelationalDelegate(ui->tableview_Transactions)); | |
1615 ui->tableview_Transactions->verticalHeader()->setVisible(false); | |
1616 ui->tableview_Transactions->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | |
1617 | |
1618 QSqlQuery query; | |
1619 query.prepare(QStringLiteral( | |
1620 "SELECT transactions.id,transactions.value,transactions.added," | |
1621 "people.last_name,people.first_name FROM transactions " | |
1622 "LEFT JOIN people ON transactions.person=people.id ORDER BY transactions.added DESC" | |
1623 )); | |
1624 | |
1625 query.exec(); | |
1626 slCheckAndReportSQLError("SELECT transactions for tableview_Transactions", query.lastError()); | |
1627 | |
1628 model_Transactions->setQuery(query); | |
1629 | |
1630 model_Transactions->setHeaderData(0, Qt::Horizontal, tr("ID")); | |
1631 model_Transactions->setHeaderData(1, Qt::Horizontal, tr("Summa")); | |
1632 model_Transactions->setHeaderData(2, Qt::Horizontal, tr("Aika")); | |
1633 model_Transactions->setHeaderData(3, Qt::Horizontal, tr("Sukunimi")); | |
1634 model_Transactions->setHeaderData(4, Qt::Horizontal, tr("Etunimi")); | |
1635 | |
1636 ui->tableview_Transactions->setModel(model_Transactions); | |
1637 ui->tableview_Transactions->setColumnHidden(0, true); | |
1638 } | |
1639 | |
1640 | |
1641 ViewTransactions::~ViewTransactions() | |
1642 { | |
1643 delete ui; | |
1644 delete model_Transactions; | |
1645 } | |
1646 | |
1647 | |
1648 void ViewTransactions::on_button_Close_clicked() | |
1649 { | |
1650 close(); | |
1651 } |