From a1106aff4621361437f41e22241387c393145a81 Mon Sep 17 00:00:00 2001 From: Brian Moran Date: Wed, 13 Jul 2022 21:36:07 -0700 Subject: [PATCH] no qso #. When date sorted, move to top or bottom --- models/CabrilloLog.cpp | 1 - widgets/AbstractLogWindow.cpp | 10 +++++----- widgets/CabrilloLogWindow.cpp | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/models/CabrilloLog.cpp b/models/CabrilloLog.cpp index cb13c0ec3..66c87ebfc 100644 --- a/models/CabrilloLog.cpp +++ b/models/CabrilloLog.cpp @@ -88,7 +88,6 @@ CabrilloLog::impl::impl (CabrilloLog * self, Configuration const * configuration setEditStrategy (QSqlTableModel::OnFieldChange); setTable ("cabrillo_log_v2"); - setHeaderData (fieldIndex ("id"), Qt::Horizontal, tr ("Qso #")); setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(MHz)")); setHeaderData (fieldIndex ("mode"), Qt::Horizontal, tr ("Mode")); setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)")); diff --git a/widgets/AbstractLogWindow.cpp b/widgets/AbstractLogWindow.cpp index 020e34bad..656eff7f1 100644 --- a/widgets/AbstractLogWindow.cpp +++ b/widgets/AbstractLogWindow.cpp @@ -105,12 +105,12 @@ AbstractLogWindow::AbstractLogWindow (QString const& settings_key, QSettings * s (void) (first); // UNUSED (void) (last); // UNUSED QTimer::singleShot(0, [=] { - // if we're sorting by the contact #, then show the most-recently logged contact. + // if we're sorting by the date, then show the most-recently logged contact. // Otherwise, leave the scroll alone auto horizontal_header = m_->log_view_->horizontalHeader (); - if (horizontal_header->sortIndicatorSection() == 0) { + if (horizontal_header->sortIndicatorSection() == 3) { // sorting on date? if (horizontal_header->sortIndicatorOrder() == Qt::AscendingOrder) { - // we're sorting 1->N, so go to bottom + // we're sorting oldes->newest, so go to bottom m_->log_view_->scrollToBottom(); } else { m_->log_view_->scrollToTop(); @@ -143,13 +143,13 @@ void AbstractLogWindow::set_log_view (QTableView * log_view) log_view->setVerticalScrollMode (QAbstractItemView::ScrollPerPixel); m_->model_.setSourceModel (log_view->model ()); log_view->setModel (&m_->model_); - log_view->setColumnHidden (0, false); // show the ID column, which is also QSO # + log_view->setColumnHidden (0, true); // hide the ID column auto horizontal_header = log_view->horizontalHeader (); horizontal_header->setResizeContentsPrecision (0); // visible region only horizontal_header->setSectionResizeMode (QHeaderView::ResizeToContents); horizontal_header->setSectionsMovable (true); - horizontal_header->setSortIndicator(0,Qt::AscendingOrder); // sort by the contact id. show 1->N + horizontal_header->setSortIndicator(3, Qt::AscendingOrder); // sort by the contact datetime oldest->newest auto vertical_header = log_view->horizontalHeader (); vertical_header->setResizeContentsPrecision (0); // visible region only diff --git a/widgets/CabrilloLogWindow.cpp b/widgets/CabrilloLogWindow.cpp index e31ed4700..16a38ef3d 100644 --- a/widgets/CabrilloLogWindow.cpp +++ b/widgets/CabrilloLogWindow.cpp @@ -70,8 +70,8 @@ CabrilloLogWindow::CabrilloLogWindow (QSettings * settings, Configuration const m_->ui_.log_table_view->setItemDelegateForColumn (3, new SQLiteDateTimeDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (4, new CallsignDelegate {this}); auto h_header = m_->ui_.log_table_view->horizontalHeader (); - m_->ui_.log_table_view->verticalHeader()->setVisible(false); // turn off line numbers for the table, use index - h_header->moveSection (7, 2); // band to 2nd column + m_->ui_.log_table_view->verticalHeader()->setVisible(false); // turn off line numbers for the table view + h_header->moveSection (7, 1); // band to first column } CabrilloLogWindow::~CabrilloLogWindow ()