From c112776bbebc61e18563660070b9c30b6e1b5afb Mon Sep 17 00:00:00 2001 From: Antoine Lambert Date: Fri, 22 Nov 2024 19:04:07 +0100 Subject: [PATCH] plugins/TableView: Improve performance by removing useless processing Visible rows and columns of the table are already resized to their content each time the table is painted so there is no need to do that processing each time the underlying model changes. This greatly improve performance when a large number of graph elements have their properties modified, using a Python script for instance, as each table row were resized to their content previoulsy. --- plugins/view/TableView/TableView.cpp | 14 -------------- plugins/view/TableView/TableView.h | 3 +-- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/plugins/view/TableView/TableView.cpp b/plugins/view/TableView/TableView.cpp index 2ed249cbae..02af6402a9 100644 --- a/plugins/view/TableView/TableView.cpp +++ b/plugins/view/TableView/TableView.cpp @@ -262,7 +262,6 @@ void TableView::readSettings() { sortModel->setSourceModel(_model); _ui->table->setModel(sortModel); connect(_model, &QAbstractItemModel::columnsInserted, this, &TableView::columnsInserted); - connect(_model, &QAbstractItemModel::dataChanged, this, &TableView::dataChanged); filterChanged(); } @@ -284,19 +283,6 @@ void TableView::readSettings() { _ui->columnsFilterEdit->setText(""); } -void TableView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { - auto *model = static_cast(sender()); - - for (int i = topLeft.row(); i <= bottomRight.row(); ++i) { - auto *pi = model->headerData(topLeft.column(), Qt::Horizontal, Model::PropertyRole) - .value(); - - if (pi->getTypename() == "string" && pi->getName() != "viewTexture" && - pi->getName() != "viewFont") - _ui->table->resizeRowToContents(i); - } -} - void TableView::columnsInserted(const QModelIndex &, int start, int end) { auto *model = static_cast(sender()); diff --git a/plugins/view/TableView/TableView.h b/plugins/view/TableView/TableView.h index b25a90a949..10832d30e5 100644 --- a/plugins/view/TableView/TableView.h +++ b/plugins/view/TableView/TableView.h @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2019-2022 The Talipot developers + * Copyright (C) 2019-2024 The Talipot developers * * Talipot is a fork of Tulip, created by David Auber * and the Tulip development Team from LaBRI, University of Bordeaux @@ -83,7 +83,6 @@ protected slots: void columnsInserted(const QModelIndex &, int, int); void showCustomContextMenu(const QPoint &pos); void showHorizontalHeaderCustomContextMenu(const QPoint &pos); - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void setZoomLevel(int); };