summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorPeter Colberg <peter@colberg.org>2015-12-30 21:59:13 -0500
committerPeter Colberg <peter@colberg.org>2015-12-30 21:59:13 -0500
commit420f9b5fcffe2da63613ac8595a96831d952f5eb (patch)
tree82a038120479c11d4c118fdfeab4439ad09e93fb /src/gui
parent4fe548615fc84c8e0cac0cd97b0946b5defe4492 (diff)
downloadtwinkle-420f9b5fcffe2da63613ac8595a96831d952f5eb.tar
twinkle-420f9b5fcffe2da63613ac8595a96831d952f5eb.tar.gz
twinkle-420f9b5fcffe2da63613ac8595a96831d952f5eb.tar.lz
twinkle-420f9b5fcffe2da63613ac8595a96831d952f5eb.tar.xz
twinkle-420f9b5fcffe2da63613ac8595a96831d952f5eb.zip
historyform: Sort entries after loading history data
Call QHeaderView::setSortIndicator() during initialization, which sets the sort column and order, but does not sort the (empty) table. After loading the history data call QTableView::sortByColumn() to sort the entries using the currently selected sort column and order.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/historyform.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/historyform.cpp b/src/gui/historyform.cpp
index e8e88ae..e836d73 100644
--- a/src/gui/historyform.cpp
+++ b/src/gui/historyform.cpp
@@ -77,7 +77,7 @@ void HistoryForm::init()
m_model->setColumnCount(5);
m_model->setHorizontalHeaderLabels(QStringList() << tr("Time") << tr("In/Out") << tr("From/To") << tr("Subject") << tr("Status"));
- historyListView->sortByColumn(HISTCOL_TIMESTAMP, Qt::DescendingOrder);
+ historyListView->horizontalHeader()->setSortIndicator(HISTCOL_TIMESTAMP, Qt::DescendingOrder);
historyListView->setColumnWidth(HISTCOL_FROMTO, 200);
historyListView->setColumnWidth(HISTCOL_SUBJECT, 200);
@@ -228,6 +228,8 @@ void HistoryForm::loadHistory()
durationText += ")";
totalDurationValueTextLabel->setText(durationText);
+ // Sort entries using currently selected sort column and order.
+ historyListView->sortByColumn(historyListView->horizontalHeader()->sortIndicatorSection(), historyListView->horizontalHeader()->sortIndicatorOrder());
// Make the first entry the selected entry.
historyListView->selectRow(0);