1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BROWSER_H
#define BROWSER_H
#include <QWidget>
#include <QSqlTableModel>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QSqlError)
QT_BEGIN_NAMESPACE
namespace Ui
{
class Browser;
}
QT_END_NAMESPACE
class Browser : public QWidget
{
Q_OBJECT
public:
explicit Browser(QWidget *parent = nullptr);
~Browser() override;
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
const QString &user, const QString &passwd, int port);
public slots:
void openNewConnectionDialog();
void about();
protected:
void insertRow();
void deleteRow();
void updateActions();
protected slots:
void exec();
void showTable(const QString &table);
void showMetaData(const QString &table);
void onFieldStrategyAction();
void onRowStrategyAction();
void onManualStrategyAction();
void onSubmitButton();
void onClearButton();
signals:
void statusMessage(const QString &message);
private:
const std::unique_ptr<Ui::Browser> m_ui;
};
class CustomModel : public QSqlTableModel
{
Q_OBJECT
public:
using QSqlTableModel::QSqlTableModel;
QVariant data(const QModelIndex &idx, int role) const override
{
if (role == Qt::BackgroundRole && isDirty(idx))
return QBrush(QColor(Qt::yellow));
return QSqlTableModel::data(idx, role);
}
};
#endif
|