comparison src/viewtransactions.cpp @ 237:54ab3f3e28c0

Split EditPerson and ViewTransactions to separate source files.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 07 May 2018 19:19:13 +0300
parents
children 43a5e09bb832
comparison
equal deleted inserted replaced
236:2e0fcb3d0b95 237:54ab3f3e28c0
1 //
2 // Syntilista - debt list/management database program
3 // Programmed and designed by Matti Hämäläinen <ccr@tnsp.org>
4 // (C) Copyright 2017-2018 Tecnic Software productions (TNSP)
5 //
6 // Distributed under 3-clause BSD style license, refer to
7 // included file "COPYING" for exact terms.
8 //
9 #include "main.h"
10 #include "ui_viewtransactions.h"
11
12
13 ViewTransactions::ViewTransactions(QWidget *parent) :
14 QDialog(parent),
15 ui(new Ui::ViewTransactions)
16 {
17 ui->setupUi(this);
18
19 slSetCommonStyleSheet(this);
20
21 setModal(true);
22 setAttribute(Qt::WA_DeleteOnClose);
23 show();
24 activateWindow();
25 raise();
26 setFocus();
27
28 model_Transactions = new SLTransactionSQLModel();
29 ui->tableview_Transactions->setModel(model_Transactions);
30 ui->tableview_Transactions->setItemDelegate(new QSqlRelationalDelegate(ui->tableview_Transactions));
31 ui->tableview_Transactions->verticalHeader()->setVisible(false);
32 ui->tableview_Transactions->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
33
34 QSqlQuery query;
35 query.prepare(QStringLiteral(
36 "SELECT transactions.id,transactions.value,transactions.added,"
37 "people.last_name,people.first_name FROM transactions "
38 "LEFT JOIN people ON transactions.person=people.id ORDER BY transactions.added DESC"
39 ));
40
41 query.exec();
42 slCheckAndReportSQLError("SELECT transactions for tableview_Transactions", query.lastError());
43
44 model_Transactions->setQuery(query);
45
46 model_Transactions->setHeaderData(0, Qt::Horizontal, tr("ID"));
47 model_Transactions->setHeaderData(1, Qt::Horizontal, tr("Summa"));
48 model_Transactions->setHeaderData(2, Qt::Horizontal, tr("Aika"));
49 model_Transactions->setHeaderData(3, Qt::Horizontal, tr("Sukunimi"));
50 model_Transactions->setHeaderData(4, Qt::Horizontal, tr("Etunimi"));
51
52 ui->tableview_Transactions->setModel(model_Transactions);
53 ui->tableview_Transactions->setColumnHidden(0, true);
54 }
55
56
57 ViewTransactions::~ViewTransactions()
58 {
59 delete ui;
60 delete model_Transactions;
61 }
62
63
64 void ViewTransactions::on_button_Close_clicked()
65 {
66 close();
67 }