Examples should show idiomatic use of Qt and C++, so mark the custom widget constructors in this example as explicit and their destructors are override. Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however, inherited the missing explicit from older code. Pick-to: 6.9 6.8 Change-Id: I5b5b49f69330c6f139345bed7264c85a36c36e9b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
41 lines
917 B
C++
41 lines
917 B
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#ifndef CONNECTIONWIDGET_H
|
|
#define CONNECTIONWIDGET_H
|
|
|
|
#include <QWidget>
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QTreeWidget)
|
|
QT_FORWARD_DECLARE_CLASS(QTreeWidgetItem)
|
|
QT_FORWARD_DECLARE_CLASS(QSqlDatabase)
|
|
|
|
class ConnectionWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ConnectionWidget(QWidget *parent = nullptr);
|
|
~ConnectionWidget() override;
|
|
|
|
QSqlDatabase currentDatabase() const;
|
|
|
|
signals:
|
|
void tableActivated(const QString &table);
|
|
void metaDataRequested(const QString &tableName);
|
|
|
|
public slots:
|
|
void refresh();
|
|
void showMetaData();
|
|
void onItemActivated(QTreeWidgetItem *item);
|
|
void onCurrentItemChanged(QTreeWidgetItem *current);
|
|
|
|
private:
|
|
void setActive(QTreeWidgetItem *);
|
|
|
|
QTreeWidget *tree;
|
|
QAction *metaDataAction;
|
|
QString activeDb;
|
|
};
|
|
|
|
#endif
|