QueryTool now uses the same DataGrid as the CRUD tool.

This commit is contained in:
eelke 2026-10-18 10:29:24 +02:00
parent bbe52c9db8
commit 5e7fb68c55
15 changed files with 135 additions and 203 deletions

View file

@ -0,0 +1,34 @@
#include "DataGridWidget.h"
#include "CustomDataRole.h"
#include "ResultTableModelUtil.h"
#include "util/PgLabItemDelegate.h"
#include <QSortFilterProxyModel>
#include <QTableView>
#include <QVBoxLayout>
DataGridWidget::DataGridWidget(QWidget *parent)
: QWidget(parent)
{
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
m_view = new QTableView(this);
layout->addWidget(m_view);
SetTableViewDefault(m_view);
auto delegate = new PgLabItemDelegate(m_view);
m_view->setItemDelegate(delegate);
}
void DataGridWidget::setSourceModel(QAbstractItemModel *model)
{
if (!m_proxy) {
m_proxy = new QSortFilterProxyModel(this);
m_proxy->setSortRole(CustomSortRole);
}
m_proxy->setSourceModel(model);
m_view->setModel(m_proxy);
m_view->setSortingEnabled(true);
m_proxy->sort(0, Qt::AscendingOrder);
}