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>
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#ifndef DIALOG_H
|
|
#define DIALOG_H
|
|
|
|
#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, const QDomDocument &details,
|
|
QFile *output, QWidget *parent = nullptr);
|
|
static void setInitialAlbumAndArtistId(int albumId, int artistId);
|
|
|
|
private slots:
|
|
void revert();
|
|
void submit();
|
|
|
|
private:
|
|
int addNewAlbum(const QString &title, int artistId);
|
|
int addNewArtist(const QString &name);
|
|
void addTracks(int albumId, const QStringList &tracks);
|
|
QDialogButtonBox *createButtons();
|
|
QGroupBox *createInputWidgets();
|
|
int findArtistId(const QString &artist);
|
|
void increaseAlbumCount(const QModelIndex &artistIndex);
|
|
QModelIndex indexOfArtist(const QString &artist) const;
|
|
|
|
QSqlRelationalTableModel *model;
|
|
QDomDocument albumDetails;
|
|
QFile *outputFile;
|
|
|
|
QLineEdit *artistEditor;
|
|
QLineEdit *titleEditor;
|
|
QSpinBox *yearEditor;
|
|
QLineEdit *tracksEditor;
|
|
|
|
static int generateAlbumId();
|
|
static int generateArtistId();
|
|
static int s_artistId;
|
|
static int s_albumId;
|
|
};
|
|
|
|
#endif
|