From 61bca974eeb4f6385b501f9117f4c24b966762e1 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 19 Dec 2017 07:47:19 +0100 Subject: Keep sort order and column when gathering torrent data This was a bit more complicated than thought. Just calling writeHeaderData unconditionally doesn't work, because it saves the headers on startup, when the widget isn't visible yet, so all columns have the same width. Fix it by checking if we're visible first. That almost worked. Almost, because after startup some columns had a different height! Setting uniformRowHeights() to true helped. --- torrentwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/torrentwidget.cpp b/torrentwidget.cpp index f93115b..72afb30 100644 --- a/torrentwidget.cpp +++ b/torrentwidget.cpp @@ -68,6 +68,7 @@ void TorrentWidget::setupGui(){ mFileView->setSortingEnabled(true); mFileView->setSelectionBehavior(QAbstractItemView::SelectRows); mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection); + mFileView->setUniformRowHeights(true); mModel = new QStandardItemModel; mProxy = new FileSorter; @@ -153,6 +154,9 @@ void TorrentWidget::createActions(){ void TorrentWidget::gatherData(){ rememberSelection(); + if(isVisible()){ + writeHeaderData(); + } QSqlDatabase db = QSqlDatabase::database("shemovdb"); if(!db.isOpen()){ db.open(); -- cgit v1.2.3-70-g09d2