2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef BROWSER_H
|
|
|
|
#define BROWSER_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2012-02-15 10:23:54 +00:00
|
|
|
#include <QSqlTableModel>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2024-12-31 09:03:41 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QSqlError)
|
|
|
|
|
2024-01-12 21:25:23 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class Browser;
|
|
|
|
}
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
class Browser : public QWidget
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-07-20 14:39:01 +00:00
|
|
|
Browser(QWidget *parent = nullptr);
|
2024-01-12 21:25:23 +00:00
|
|
|
~Browser();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
|
2024-01-12 21:25:23 +00:00
|
|
|
const QString &user, const QString &passwd, int port);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void openNewConnectionDialog();
|
|
|
|
void about();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2024-01-12 21:25:23 +00:00
|
|
|
protected:
|
2011-04-27 10:05:43 +00:00
|
|
|
void insertRow();
|
|
|
|
void deleteRow();
|
|
|
|
void updateActions();
|
|
|
|
|
2024-01-12 21:25:23 +00:00
|
|
|
protected slots:
|
2011-04-27 10:05:43 +00:00
|
|
|
void exec();
|
|
|
|
void showTable(const QString &table);
|
|
|
|
void showMetaData(const QString &table);
|
|
|
|
|
2024-01-12 21:25:23 +00:00
|
|
|
void onFieldStrategyAction();
|
|
|
|
void onRowStrategyAction();
|
|
|
|
void onManualStrategyAction();
|
|
|
|
void onSubmitButton();
|
|
|
|
void onClearButton();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void statusMessage(const QString &message);
|
2024-01-12 21:25:23 +00:00
|
|
|
|
|
|
|
private:
|
2024-12-31 09:03:41 +00:00
|
|
|
const std::unique_ptr<Ui::Browser> m_ui;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
2024-01-12 21:25:23 +00:00
|
|
|
class CustomModel : public QSqlTableModel
|
2012-02-15 10:23:54 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-01-12 21:25:23 +00:00
|
|
|
using QSqlTableModel::QSqlTableModel;
|
2016-06-15 08:12:35 +00:00
|
|
|
QVariant data(const QModelIndex &idx, int role) const override
|
2012-02-15 10:23:54 +00:00
|
|
|
{
|
|
|
|
if (role == Qt::BackgroundRole && isDirty(idx))
|
|
|
|
return QBrush(QColor(Qt::yellow));
|
|
|
|
return QSqlTableModel::data(idx, role);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#endif
|