#ifndef DBSTRUCTUREVIEW_H
#define DBSTRUCTUREVIEW_H

#include <QTreeView>

class DatabaseManager;
class DBStructureView : public QTreeView
{
    Q_OBJECT

public:
    explicit DBStructureView(DatabaseManager* dbManager, QWidget* parent = nullptr);
    ~DBStructureView();

    void disconnectCurConnection();
    const QString curConnection();

protected:
    void mouseDoubleClickEvent(QMouseEvent* event) override;

private:
    DatabaseManager* m_dbManager;
    QString m_curConnection; //用来记录当前链接，只能存在一个链接

    void initView();
    void connectToDB(const QString&);
    void disconnectToDB(const QString&);

signals:
    void actionTrigger_addModel();

private slots:
    void itemDoubleClick(const QModelIndex&);
    void showContextMenu(const QPoint&);
};

#endif //DBSTRUCTUREVIEW_H
