Removed redundant "numbers" field from Account model and database queries to simplify account structure. Introduced a TutorialWindow class for displaying application tutorials, integrated into the main window, and updated file paths accordingly. Improved string handling and logic in Payment routines and enhanced overall UI structure.
58 lines
2.1 KiB
C
58 lines
2.1 KiB
C
#pragma once
|
|
|
|
#include <QDateTime>
|
|
|
|
enum class AccountStatus {
|
|
Active,
|
|
Blocked
|
|
};
|
|
|
|
inline QString accountStatusToString(const AccountStatus status) {
|
|
switch (status) {
|
|
case AccountStatus::Active: return "active";
|
|
case AccountStatus::Blocked: return "blocked";
|
|
default: return "active";
|
|
}
|
|
}
|
|
|
|
inline AccountStatus accountStatusFromString(const QString &str) {
|
|
if (str == "active") return AccountStatus::Active;
|
|
if (str == "blocked") return AccountStatus::Blocked;
|
|
return AccountStatus::Active;
|
|
}
|
|
|
|
struct AccountInfo {
|
|
int id = -1;
|
|
QString deviceId;
|
|
QString appName;
|
|
QString lastNumbers;
|
|
double amount = 0.0;
|
|
QDateTime updateTime;
|
|
AccountStatus status = AccountStatus::Active;
|
|
QString description;
|
|
};
|
|
|
|
inline QString convertAccountToString(const AccountInfo &info) {
|
|
QStringList lines;
|
|
QStringList emptyFields;
|
|
|
|
lines << "AccountInfo {";
|
|
|
|
if (info.id != -1) lines << " id: " + QString::number(info.id); else emptyFields << "id";
|
|
if (!info.deviceId.isEmpty()) lines << " deviceId: " + info.deviceId; else emptyFields << "deviceId";
|
|
if (!info.appName.isEmpty()) lines << " appName: " + info.appName; else emptyFields << "appName";
|
|
if (!info.lastNumbers.isEmpty()) lines << " lastNumbers: " + info.lastNumbers; else emptyFields << "lastNumbers";
|
|
if (info.amount != 0.0) lines << " amount: " + QString::number(info.amount, 'f', 2); else emptyFields << "amount";
|
|
if (info.updateTime.isValid()) lines << " updateTime: " + info.updateTime.toString(Qt::ISODate); else emptyFields << "updateTime";
|
|
if (info.status != AccountStatus::Active) lines << " status: " + accountStatusToString(info.status); else emptyFields << "status";
|
|
if (!info.description.isEmpty()) lines << " description: " + info.description; else emptyFields << "description";
|
|
|
|
if (!emptyFields.isEmpty()) {
|
|
lines << " --- empty: " + emptyFields.join(", ");
|
|
}
|
|
|
|
lines << "}";
|
|
|
|
return lines.join('\n');
|
|
}
|