Mercurial > hg > syntilista
diff main.h @ 0:fec4d0c461f2
Initial import of the post-prototyping phase code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 30 Mar 2017 03:20:08 +0300 |
parents | |
children | edc1e8cf6e2c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Thu Mar 30 03:20:08 2017 +0300 @@ -0,0 +1,172 @@ +// +// Syntilista - velkalistasovellus Kampus-kahvilaan +// Programmed and designed by Matti Hämäläinen <ccr@tnsp.org> +// (C) Copyright 2017 Tecnic Software productions (TNSP) +// +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QDialog> +#include <QtSql> +#include <QSqlQueryModel> + + +// +// +// +#define APP_VENDOR "TNSP" +#define APP_NAME "Syntilista" +#define APP_VERSION "0.1" + + +// +// Custom SQL models +// +class PersonInfo : public QObject +{ + Q_OBJECT + +public: + explicit PersonInfo() + { + } + + ~PersonInfo() + { + } + + qint64 id; + QString firstName, lastName, extraInfo; +}; + + + +class PersonSQLModel : public QSqlQueryModel +{ + Q_OBJECT + +private: + +public: + PersonSQLModel(QObject *parent = 0); + + QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; + + void updatePerson(const QModelIndex &item, const PersonInfo &person); + void addPerson(const PersonInfo &person); + void updateModel(); +}; + + + +class TransactionSQLModel : public QSqlQueryModel +{ + Q_OBJECT + +private: + +public: + TransactionSQLModel(QObject *parent = 0); + + QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE; + + void updateModel(); +}; + + + +// +// Main window +// +namespace Ui { +class SyntilistaMainWindow; +class EditPerson; +} + +class SyntilistaMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit SyntilistaMainWindow(QWidget *parent = 0); + ~SyntilistaMainWindow(); + + void statusMsg(const QString &msg); + + void readSettings(); + void saveSettings(); + void setActivePerson(qint64 id); + bool addTransaction(bool debt, double value); + void updatePersonList(); + + PersonSQLModel *model_People; + +private slots: + void on_button_AddPerson_clicked(); + + void on_button_EditPerson_clicked(); + + void on_button_ClearFilter_clicked(); + + void on_button_Quit_clicked(); + + void on_button_XXX_clicked(); + + void on_button_AddDebt_clicked(); + + void on_button_SubDebt_clicked(); + + void on_edit_PersonFilter_textChanged(const QString &arg1); + + void on_tableview_People_doubleClicked(const QModelIndex &index); + + void selectedPersonChanged(const QModelIndex &, const QModelIndex &); + + void updatePersonData(qint64 id); + + void updateSortOrder(int index, Qt::SortOrder order); + +private: + Ui::SyntilistaMainWindow *ui; + + TransactionSQLModel *model_Latest; + qint64 personID; + int peopleSortIndex; + Qt::SortOrder peopleSortOrder; + QString peopleFilter; +}; + + +class EditPerson : public QDialog +{ + Q_OBJECT + +public: + explicit EditPerson(QWidget *parent = 0); + ~EditPerson(); + + void statusMsg(const QString &msg); + + void clearForm(); + bool validateForm(PersonInfo &info); + bool validateForm(); + void setPerson(qint64 id); + +private slots: + void on_button_OK_clicked(); + + void on_button_Cancel_clicked(); + + void on_edit_FirstName_textChanged(const QString &arg1); + + void on_edit_LastName_textChanged(const QString &arg1); + +private: + Ui::EditPerson *ui; + + qint64 personID; + TransactionSQLModel *model_Transactions; +}; + +#endif // MAINWINDOW_H