From ef7afcc839868177eed6c7b05065808f691f7acb Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 10 Aug 2016 08:10:41 +0200 Subject: [PATCH] Fixed #46. --- resources/binaries | 2 +- resources/text/CHANGELOG | 4 ++++ src/gui/messagesview.cpp | 26 ++++++++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/resources/binaries b/resources/binaries index 75fe8e091..ecbdd80f5 160000 --- a/resources/binaries +++ b/resources/binaries @@ -1 +1 @@ -Subproject commit 75fe8e091b186711a5a7864f23ffea720a8832fe +Subproject commit ecbdd80f5fd70a10c9f84206ec85c73ae10e08a1 diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index fb7607273..34b16c14d 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -7,8 +7,12 @@ Added: ▪ Application settings now offers "Apply" button which saves settings without closing the dialog. (issue #16) Fixed: +▪ Correct message is now selected after some feed gets updated. (bug #46) ▪ RSS Guard correctly saves windows size/position when maximized on exit. (bug #45) +Changed: +▪ MariaDB binary DLL file updated to 10.1.16 (Windows only). + 3.3.2 ————— diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index d1d76b033..afcbda794 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -70,18 +70,31 @@ void MessagesView::keyboardSearch(const QString &search) { void MessagesView::reloadSelections(bool mark_current_index_read) { const QDateTime dt1 = QDateTime::currentDateTime(); - const QModelIndex current_index = selectionModel()->currentIndex(); + QModelIndex current_index = selectionModel()->currentIndex(); const QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index); const Message selected_message = m_sourceModel->messageAt(mapped_current_index.row()); - const int col = qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnMessages)).toInt(); const Qt::SortOrder ord = static_cast(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortOrderMessages)).toInt()); // Reload the model now. m_sourceModel->sort(col, ord); - selected_indexes = m_proxyModel->mapListFromSource(mapped_indexes, true); - current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(), mapped_current_index.column())); + // Now, we must find the same previously focused message. + if (selected_message.m_id > 0) { + for (int i = 0; i < m_proxyModel->rowCount(); i++) { + QModelIndex msg_idx = m_proxyModel->index(i, MSG_DB_TITLE_INDEX); + Message msg = m_sourceModel->messageAt(m_proxyModel->mapToSource(msg_idx).row()); + + if (msg.m_id == selected_message.m_id) { + current_index = msg_idx; + break; + } + + if (i == m_proxyModel->rowCount() - 1) { + current_index = QModelIndex(); + } + } + } if (current_index.isValid()) { if (!mark_current_index_read) { @@ -90,9 +103,10 @@ void MessagesView::reloadSelections(bool mark_current_index_read) { m_batchUnreadSwitch = true; } - setCurrentIndex(current_index); + scrollTo(current_index); - reselectIndexes(selected_indexes); + setCurrentIndex(current_index); + reselectIndexes(QModelIndexList() << current_index); m_batchUnreadSwitch = false; } else {