Flexible models #76
4 changed files with 15 additions and 15 deletions
|
|
@ -1,15 +1,15 @@
|
|||
#include "HorizontalProxyModel.h"
|
||||
#include "PropertyProxyModel.h"
|
||||
/*
|
||||
* Code borrowed from: https://stackoverflow.com/questions/21653253/how-to-change-orientation-of-qt-tableview
|
||||
*/
|
||||
|
||||
|
||||
HorizontalProxyModel::HorizontalProxyModel(QObject *parent)
|
||||
PropertyProxyModel::PropertyProxyModel(QObject *parent)
|
||||
: QIdentityProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QModelIndex HorizontalProxyModel::mapToSource(const QModelIndex &proxyIndex) const
|
||||
QModelIndex PropertyProxyModel::mapToSource(const QModelIndex &proxyIndex) const
|
||||
{
|
||||
if (sourceModel()) {
|
||||
return sourceModel()->index(proxyIndex.column(), proxyIndex.row());
|
||||
|
|
@ -19,32 +19,32 @@ QModelIndex HorizontalProxyModel::mapToSource(const QModelIndex &proxyIndex) con
|
|||
}
|
||||
}
|
||||
|
||||
QModelIndex HorizontalProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
|
||||
QModelIndex PropertyProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
|
||||
{
|
||||
return index(sourceIndex.column(), sourceIndex.row());
|
||||
}
|
||||
|
||||
QModelIndex HorizontalProxyModel::index(int row, int column, const QModelIndex &) const
|
||||
QModelIndex PropertyProxyModel::index(int row, int column, const QModelIndex &) const
|
||||
{
|
||||
return createIndex(row, column, nullptr);
|
||||
}
|
||||
|
||||
QModelIndex HorizontalProxyModel::parent(const QModelIndex &) const
|
||||
QModelIndex PropertyProxyModel::parent(const QModelIndex &) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
int HorizontalProxyModel::rowCount(const QModelIndex &) const
|
||||
int PropertyProxyModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return sourceModel() ? sourceModel()->columnCount() : 0;
|
||||
}
|
||||
|
||||
int HorizontalProxyModel::columnCount(const QModelIndex &) const
|
||||
int PropertyProxyModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
return sourceModel() ? sourceModel()->rowCount() : 0;
|
||||
}
|
||||
|
||||
QVariant HorizontalProxyModel::headerData(
|
||||
QVariant PropertyProxyModel::headerData(
|
||||
int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (!sourceModel()) {
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include <QIdentityProxyModel>
|
||||
|
||||
class HorizontalProxyModel : public QIdentityProxyModel {
|
||||
class PropertyProxyModel : public QIdentityProxyModel {
|
||||
public:
|
||||
HorizontalProxyModel(QObject * parent = nullptr);
|
||||
PropertyProxyModel(QObject * parent = nullptr);
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#include "ResultTableModelUtil.h"
|
||||
#include "ColumnTableModel.h"
|
||||
#include "ConstraintModel.h"
|
||||
#include "HorizontalProxyModel.h"
|
||||
#include "PropertyProxyModel.h"
|
||||
#include "IconColumnDelegate.h"
|
||||
#include "IndexModel.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
|
|
@ -53,7 +53,7 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
ui->indexesTable->setItemDelegate(new PgLabItemDelegate(ui->indexesTable));
|
||||
ui->indexesTable->setItemDelegateForColumn(0, delegate);
|
||||
|
||||
HorizontalProxyModel* proxy_model = new HorizontalProxyModel(this);
|
||||
PropertyProxyModel* proxy_model = new PropertyProxyModel(this);
|
||||
proxy_model->setSourceModel(m_tablesModel);
|
||||
ui->tablePropertiesTable->setModel(proxy_model);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ SOURCES += main.cpp\
|
|||
EditorGutter.cpp \
|
||||
CodeEditor.cpp \
|
||||
PlgPage.cpp \
|
||||
HorizontalProxyModel.cpp
|
||||
PropertyProxyModel.cpp
|
||||
|
||||
HEADERS += \
|
||||
QueryResultModel.h \
|
||||
|
|
@ -121,7 +121,7 @@ HEADERS += \
|
|||
CodeEditor.h \
|
||||
PlgPage.h \
|
||||
AbstractCommand.h \
|
||||
HorizontalProxyModel.h
|
||||
PropertyProxyModel.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
ConnectionManagerWindow.ui \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue