From 0883709f5833f085882dd3a95fdd6542bb06db52 Mon Sep 17 00:00:00 2001 From: semant1ka Date: Thu, 26 Oct 2017 21:55:51 +0300 Subject: [PATCH] enbale sorting for main window and isotp --- mainwindow.cpp | 11 ++++++----- mainwindow.h | 2 +- re/isotp_interpreterwindow.cpp | 7 +++++++ re/isotp_interpreterwindow.h | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c017a60..d691243 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -41,7 +41,10 @@ MainWindow::MainWindow(QWidget *parent) : model = new CANFrameModel(this); // set parent to mainwindow to prevent canframemodel to change thread (might be done by setModel but just in case) - ui->canFramesView->setModel(model); + QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel; + proxyModel->setSourceModel(model); + + ui->canFramesView->setModel(proxyModel); readSettings(); @@ -54,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->canFramesView->setColumnWidth(6, 225); QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview - connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(on_sectionClicked(int))); + connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int))); graphingWindow = NULL; frameInfoWindow = NULL; @@ -235,10 +238,8 @@ void MainWindow::closeEvent(QCloseEvent *event) exitApp(); } -void MainWindow::on_sectionClicked ( int logicalIndex ) +void MainWindow::headerClicked(int logicalIndex) { - QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader(); - HorzHdr->setSortIndicator(logicalIndex, Qt::AscendingOrder); ui->canFramesView->sortByColumn(logicalIndex); } diff --git a/mainwindow.h b/mainwindow.h index bade9bf..abdd0a2 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -95,6 +95,7 @@ private slots: void filterListItemChanged(QListWidgetItem *item); void filterSetAll(); void filterClearAll(); + void headerClicked (int logicalIndex); public slots: void gotFrames(int); @@ -102,7 +103,6 @@ public slots: void readUpdateableSettings(); void gotCenterTimeID(int32_t ID, double timestamp); void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1); - void on_sectionClicked ( int logicalIndex ); signals: void sendCANFrame(const CANFrame *, int); diff --git a/re/isotp_interpreterwindow.cpp b/re/isotp_interpreterwindow.cpp index 0907be2..440311a 100644 --- a/re/isotp_interpreterwindow.cpp +++ b/re/isotp_interpreterwindow.cpp @@ -42,12 +42,19 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector *frames ui->tableIsoFrames->setHorizontalHeaderLabels(headers); QHeaderView *HorzHdr = ui->tableIsoFrames->horizontalHeader(); HorzHdr->setStretchLastSection(true); + connect(HorzHdr, SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int))); decoder->setReception(true); decoder->setFlowCtrl(false); decoder->setProcessAll(true); } +void ISOTP_InterpreterWindow::headerClicked(int logicalIndex) +{ + ui->tableIsoFrames->sortByColumn(logicalIndex); +} + + ISOTP_InterpreterWindow::~ISOTP_InterpreterWindow() { delete decoder; diff --git a/re/isotp_interpreterwindow.h b/re/isotp_interpreterwindow.h index 76c8ce5..753347f 100644 --- a/re/isotp_interpreterwindow.h +++ b/re/isotp_interpreterwindow.h @@ -31,6 +31,7 @@ private slots: void filterNone(); void interpretCapturedFrames(); void useExtendedAddressing(bool checked); + void headerClicked(int logicalIndex); private: Ui::ISOTP_InterpreterWindow *ui;