mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
When dragging and dropping a table from one instance of the application to the other, the tree structure representing the database was broken. We would show the 'Browsables' and 'All' nodes at the top level instead of the child nodes of the 'All' node. This happened because after dropping a table, we would reload the database structure and rebuild the tree structure but didn't notify the tree view in the main window about the update. This is fixed by this commit, so the main window's widgets are always notified about the new tree structure. See issue #1288.
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#ifndef DBSTRUCTUREMODEL_H
|
|
#define DBSTRUCTUREMODEL_H
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
class DBBrowserDB;
|
|
class QTreeWidgetItem;
|
|
namespace sqlb { class Object; typedef QSharedPointer<Object> ObjectPtr; }
|
|
|
|
class DbStructureModel : public QAbstractItemModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DbStructureModel(DBBrowserDB& db, QObject* parent = nullptr);
|
|
~DbStructureModel();
|
|
|
|
QVariant data(const QModelIndex& index, int role) const;
|
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
|
|
QModelIndex parent(const QModelIndex& index) const;
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
int columnCount(const QModelIndex& = QModelIndex()) const;
|
|
|
|
QStringList mimeTypes() const;
|
|
QMimeData* mimeData(const QModelIndexList& indices) const;
|
|
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
|
|
|
|
enum Columns
|
|
{
|
|
ColumnName,
|
|
ColumnObjectType,
|
|
ColumnDataType,
|
|
ColumnSQL,
|
|
ColumnSchema,
|
|
};
|
|
|
|
public slots:
|
|
void reloadData();
|
|
|
|
signals:
|
|
void structureUpdated();
|
|
|
|
private:
|
|
DBBrowserDB& m_db;
|
|
QTreeWidgetItem* rootItem;
|
|
QTreeWidgetItem* browsablesRootItem;
|
|
|
|
void buildTree(QTreeWidgetItem* parent, const QString& schema);
|
|
QTreeWidgetItem* addNode(QTreeWidgetItem* parent, const sqlb::ObjectPtr& object, const QString& schema);
|
|
};
|
|
|
|
#endif
|