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:
Martin Kleusberg
2013-07-19 20:36:48 +02:00
parent afc53f72c6
commit 64a938716f
6 changed files with 220 additions and 104 deletions

30
src/DbStructureModel.h Normal file
View 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