diff src/main.h @ 80:c8fd927cd2c4

Restructure the project by placing source code, images into appropriate subdirectories.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Apr 2017 12:12:39 +0300
parents main.h@f48b8fc1de64
children efab68769c75
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.h	Mon Apr 24 12:12:39 2017 +0300
@@ -0,0 +1,197 @@
+//
+// Syntilista - velkalistasovellus Kampus-kahvilaan
+// Programmed and designed by Matti Hämäläinen <ccr@tnsp.org>
+// (C) Copyright 2017 Tecnic Software productions (TNSP)
+//
+// Distributed under 3-clause BSD style license, refer to
+// included file "COPYING" for exact terms.
+//
+#ifndef SYNTILISTA_H
+#define SYNTILISTA_H
+
+#include <QMainWindow>
+#include <QShortcut>
+#include <QDialog>
+#include <QtSql>
+#include <QSqlQueryModel>
+
+
+//
+// Global application defines
+//
+#define APP_VENDOR        "TNSP"                    // Vendor ID (for settings, etc.)
+#define APP_ID            "Kampus Syntilista"       // Application ID (for settings)
+#define APP_NAME          "Café Kampus Syntilista"  // Application title/name
+#define APP_SQLITE_FILE   "syntilista.sqlite3"      // SQLite3 database file name (without path)
+
+
+//
+// Custom SQL models
+//
+class PersonInfo : public QObject
+{
+    Q_OBJECT
+    
+public:
+    explicit PersonInfo()
+    {
+        id = -1;
+        firstName = "";
+        lastName = "";
+        extraInfo = "";
+        balance = 0;
+    }
+
+    ~PersonInfo()
+    {
+    }
+
+    void dump();
+
+    qint64 id;
+    QString firstName, lastName, extraInfo;
+    double balance;
+    QDateTime added, updated;
+};
+
+
+
+class PersonSQLModel : public QSqlQueryModel
+{
+    Q_OBJECT
+
+private:
+
+public:
+    PersonSQLModel(QObject *parent = 0);
+
+    QVariant data(const QModelIndex &item, int role) const Q_DECL_OVERRIDE;
+
+    int  updatePerson(const PersonInfo &person);
+    int  addPerson(const PersonInfo &person);
+    int  deletePerson(qint64 id);
+    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);
+    int  addTransaction(qint64 id, double value, PersonInfo &info);
+    int  addTransactionGUI(qint64 id, bool debt, double value);
+    void updatePersonList();
+
+    PersonSQLModel *model_People;
+
+private slots:
+    void on_button_AddPerson_clicked();
+    void on_button_EditPerson_clicked();
+    void on_button_DeletePerson_clicked();
+
+    void on_edit_PersonFilter_textChanged(const QString &arg1);
+    void on_button_ClearFilter_clicked();
+
+    void on_button_Quit_clicked();
+    void on_button_About_clicked();
+    void on_button_Help_clicked();
+
+    void on_button_AddDebt_clicked();
+    void on_button_PayDebt_clicked();
+    void on_button_PayFullDebt_clicked();
+
+    void on_tableview_People_doubleClicked(const QModelIndex &index);
+
+    void selectedPersonChanged(const QModelIndex &, const QModelIndex &);
+
+    void focusDebtEdit();
+    void selectRowPrev();
+    void selectRowNext();
+
+    void changeUIZoomIn();
+    void changeUIZoomOut();
+    void changeUIZoomReset();
+    
+    void updateSortOrder(int index, Qt::SortOrder order);
+
+
+private:
+    Ui::SyntilistaMainWindow *ui;
+
+    TransactionSQLModel *model_Latest;
+    PersonInfo currPerson;
+
+    int peopleSortIndex;
+    Qt::SortOrder peopleSortOrder;
+    QString peopleFilter;
+};
+
+
+//
+// Person edit / new person dialog
+//
+class EditPerson : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit EditPerson(QWidget *parent = 0);
+    ~EditPerson();
+
+    void statusMsg(const QString &msg);
+
+    void clearForm();
+    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;
+
+    PersonInfo selPerson;
+    TransactionSQLModel *model_Transactions;
+};
+
+#endif // SYNTILISTA_H