From bd056a00ceb7bdfe69f845b1dbce0e601c42ab54 Mon Sep 17 00:00:00 2001 From: Bent Witthold Date: Mon, 12 Jan 2026 09:57:44 +0100 Subject: [PATCH] Using the new QSortFilterProxyModel subclass of the core for the TableView. --- mainwindow.cpp | 6 +++++- mainwindow.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index d1e405d..797a5db 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -13,6 +13,7 @@ #include "dialogs/edititemdialog.h" #include "dialogs/newitemdialog.h" #include "genericcore.h" +#include "model/generalsortfiltermodel.h" #include "model/tablemodel.h" static QStandardPaths::StandardLocation standardLocation = QStandardPaths::HomeLocation; @@ -45,7 +46,10 @@ MainWindow::MainWindow(QWidget* parent) restoreState(settings.value("windowState").toByteArray()); m_tableModel = m_core->getModel(); - ui->tableView->setModel(m_tableModel.get()); + // ui->tableView->setModel(m_tableModel.get()); + m_sortModel = m_core->getSortFilterModel(); + ui->tableView->setModel((QAbstractItemModel*)m_sortModel.get()); + ui->tableView->setSortingEnabled(true); createActions(); createHelpMenu(); diff --git a/mainwindow.h b/mainwindow.h index 03a1103..195f6ca 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -16,6 +16,7 @@ QT_END_NAMESPACE class GenericCore; class TableModel; +class GeneralSortFilterModel; class NewItemDialog; class EditItemDialog; @@ -65,6 +66,7 @@ class MainWindow : public QMainWindow { // GenericCore* m_core; unique_ptr m_core; shared_ptr m_tableModel; + shared_ptr m_sortModel; QUndoStack* m_modelUndoStack; unique_ptr m_modelUndoView;