diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-01-13 00:00:41 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-01-14 09:32:04 +0100 |
commit | 8bfebaa22f66d2cc32d6147611bcbaea3a85188c (patch) | |
tree | a16e191d3449dff288badb64b45cb517658bc2a4 /examples/sql/masterdetail/dialog.h | |
parent | 27dd17890060313d684b72c871be9da7eb2b74fe (diff) |
SQL examples: code cleanup
Misc code cleanup for the sql examples:
- don't include global Qt headers but only needed ones
- use proper tr() where possible
- pass parameters by const ref
- style fixes
Change-Id: I4fd4293948918b9d7b373b6d1e8eeecf6f25a622
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Diffstat (limited to 'examples/sql/masterdetail/dialog.h')
-rw-r--r-- | examples/sql/masterdetail/dialog.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/examples/sql/masterdetail/dialog.h b/examples/sql/masterdetail/dialog.h index 0c5a728ebb..2a4f5a0b8e 100644 --- a/examples/sql/masterdetail/dialog.h +++ b/examples/sql/masterdetail/dialog.h @@ -4,17 +4,25 @@ #ifndef DIALOG_H #define DIALOG_H -#include <QtWidgets> -#include <QtSql> -#include <QtXml> +#include <QDialog> +#include <QDomDocument> + +QT_FORWARD_DECLARE_CLASS(QDialogButtonBox) +QT_FORWARD_DECLARE_CLASS(QFile) +QT_FORWARD_DECLARE_CLASS(QGroupBox) +QT_FORWARD_DECLARE_CLASS(QLineEdit) +QT_FORWARD_DECLARE_CLASS(QModelIndex) +QT_FORWARD_DECLARE_CLASS(QSpinBox) +QT_FORWARD_DECLARE_CLASS(QSqlRelationalTableModel) class Dialog : public QDialog { Q_OBJECT public: - Dialog(QSqlRelationalTableModel *albums, QDomDocument details, + Dialog(QSqlRelationalTableModel *albums, const QDomDocument &details, QFile *output, QWidget *parent = nullptr); + static void setInitialAlbumAndArtistId(int albumId, int artistId); private slots: void revert(); @@ -27,10 +35,8 @@ private: QDialogButtonBox *createButtons(); QGroupBox *createInputWidgets(); int findArtistId(const QString &artist); - static int generateAlbumId(); - static int generateArtistId(); - void increaseAlbumCount(QModelIndex artistIndex); - QModelIndex indexOfArtist(const QString &artist); + void increaseAlbumCount(const QModelIndex &artistIndex); + QModelIndex indexOfArtist(const QString &artist) const; QSqlRelationalTableModel *model; QDomDocument albumDetails; @@ -40,6 +46,11 @@ private: QLineEdit *titleEditor; QSpinBox *yearEditor; QLineEdit *tracksEditor; + + static int generateAlbumId(); + static int generateArtistId(); + static int s_artistId; + static int s_albumId; }; #endif |