Enable sorting for CRUD
This commit is contained in:
parent
6d08b40309
commit
53997f94da
2 changed files with 8 additions and 2 deletions
|
|
@ -29,7 +29,11 @@ CrudTab::CrudTab(IDatabaseWindow *context, QWidget *parent)
|
||||||
ui->tableView->setItemDelegate(delegate);
|
ui->tableView->setItemDelegate(delegate);
|
||||||
|
|
||||||
m_crudModel = new CrudModel(parent);
|
m_crudModel = new CrudModel(parent);
|
||||||
ui->tableView->setModel(m_crudModel);
|
|
||||||
|
m_SortFilterProxy = new QSortFilterProxyModel(this);
|
||||||
|
m_SortFilterProxy->setSourceModel(m_crudModel);
|
||||||
|
ui->tableView->setModel(m_SortFilterProxy);
|
||||||
|
ui->tableView->setSortingEnabled(true);
|
||||||
|
|
||||||
ui->tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui->tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
|
@ -62,7 +66,7 @@ void CrudTab::refresh()
|
||||||
void CrudTab::on_actionRemove_rows_triggered()
|
void CrudTab::on_actionRemove_rows_triggered()
|
||||||
{
|
{
|
||||||
std::set<IntegerRange<int>> row_ranges;
|
std::set<IntegerRange<int>> row_ranges;
|
||||||
auto selection = ui->tableView->selectionModel()->selection();
|
auto selection = m_SortFilterProxy->mapSelectionToSource(ui->tableView->selectionModel()->selection());
|
||||||
for (auto range : selection) {
|
for (auto range : selection) {
|
||||||
row_ranges.emplace(range.top(), range.height());
|
row_ranges.emplace(range.top(), range.height());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef CRUDTAB_H
|
#ifndef CRUDTAB_H
|
||||||
#define CRUDTAB_H
|
#define CRUDTAB_H
|
||||||
|
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include "catalog/PgClass.h"
|
#include "catalog/PgClass.h"
|
||||||
#include "IDatabaseWindow.h"
|
#include "IDatabaseWindow.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
@ -31,6 +32,7 @@ private:
|
||||||
std::optional<PgClass> m_table;
|
std::optional<PgClass> m_table;
|
||||||
|
|
||||||
CrudModel *m_crudModel = nullptr;
|
CrudModel *m_crudModel = nullptr;
|
||||||
|
QSortFilterProxyModel *m_SortFilterProxy = nullptr;
|
||||||
|
|
||||||
void initActions();
|
void initActions();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue