mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-25 13:29:35 -06:00
Add custom model for tree view in Database Structure tab
Use a custom model for the tree view in the "Database Structure" tab in the main window, i.e. change from a QTreeWidget to a QTreeView and do all the item management stuff manually. This might add some code and complexity but also offers some more flexibility for us.
This commit is contained in:
30
src/DbStructureModel.h
Normal file
30
src/DbStructureModel.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef __DBSTRUCTUREMODEL_H__
|
||||
#define __DBSTRUCTUREMODEL_H__
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
class DBBrowserDB;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
class DbStructureModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DbStructureModel(QObject* parent = 0);
|
||||
~DbStructureModel();
|
||||
|
||||
void reloadData(DBBrowserDB* db);
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
QTreeWidgetItem* rootItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user