From 420f9b5fcffe2da63613ac8595a96831d952f5eb Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Wed, 30 Dec 2015 21:59:13 -0500 Subject: 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. --- src/gui/historyform.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.2.3 From c0d7e4ae89989d9882152cca4e539dec01d23f13 Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Wed, 30 Dec 2015 22:46:53 -0500 Subject: historyform: Resize columns to contents Automatically resize columns based on entry text widths. --- src/gui/historyform.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/historyform.cpp b/src/gui/historyform.cpp index e836d73..1466110 100644 --- a/src/gui/historyform.cpp +++ b/src/gui/historyform.cpp @@ -79,8 +79,11 @@ void HistoryForm::init() m_model->setHorizontalHeaderLabels(QStringList() << tr("Time") << tr("In/Out") << tr("From/To") << tr("Subject") << tr("Status")); historyListView->horizontalHeader()->setSortIndicator(HISTCOL_TIMESTAMP, Qt::DescendingOrder); - historyListView->setColumnWidth(HISTCOL_FROMTO, 200); - historyListView->setColumnWidth(HISTCOL_SUBJECT, 200); +#if QT_VERSION >= 0x050000 + historyListView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); +#else + historyListView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); +#endif inCheckBox->setChecked(true); outCheckBox->setChecked(true); -- cgit v1.2.3 From 07991f06fe7404708a66537ad87a2f42a8f71565 Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Wed, 30 Dec 2015 23:09:09 -0500 Subject: historyform: Clear rows before loading history This avoids spurious entries when deselecting both incoming and outgoing calls. --- src/gui/historyform.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/historyform.cpp b/src/gui/historyform.cpp index 1466110..15b882a 100644 --- a/src/gui/historyform.cpp +++ b/src/gui/historyform.cpp @@ -125,6 +125,8 @@ void HistoryForm::loadHistory() unsigned long totalCallDuration = 0; unsigned long totalConversationDuration = 0; + m_model->setRowCount(0); + std::list history; call_history->get_history(history); -- cgit v1.2.3