view src/util.h @ 271:df3f902588af

Add parent window argument to slErrorMsg() and use it. Also use main window as parent for other static/modal dialogs.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 17 Mar 2023 13:09:43 +0200
parents 55581d90c55d
children 0f345852b3ed
line wrap: on
line source

//
// Syntilista - debt list/management database program
// Programmed and designed by Matti Hämäläinen <ccr@tnsp.org>
// (C) Copyright 2017-2018 Tecnic Software productions (TNSP)
//
// Distributed under 3-clause BSD style license, refer to
// included file "COPYING" for exact terms.
//
#ifndef SL_UTIL_H
#define SL_UTIL_H


#include <QWidget>


#define SQL_MAX_SCHEMA_INSERTS 16


//
// SQL schema / table definitions
//
typedef struct
{
    QString name;
    QString schema;
    QString inserts[SQL_MAX_SCHEMA_INSERTS];
} SLSQLSchemaDef;


//
// Various helper utility functions
//
double slMoneyStrToValue(const QString &str);
QString slMoneyValueToStr(double val);
QString slMoneyValueToStrSign(double val);

QString slCleanupStr(const QString &str);

const QDateTime slDateTimeToLocal(const QDateTime &val);
const QString slDateTimeToStr(const QDateTime &val);

void slLog(const QString &mtype, const QString &msg);
int slErrorMsg(QWidget *parent, const QString &title, const QString &msg);

bool slCheckAndReportSQLError(const QSqlQuery &query, const QString where, bool report = false);
bool slConditionallyCreateSQLTables(QSqlDatabase &db, const SLSQLSchemaDef *schema, const int nschema);


#endif // SL_UTIL_H