Skip to content

Commit

Permalink
Fixed #46.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Aug 10, 2016
1 parent 9e34484 commit ef7afcc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/binaries
4 changes: 4 additions & 0 deletions resources/text/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
—————

Expand Down
26 changes: 20 additions & 6 deletions src/gui/messagesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Qt::SortOrder>(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) {
Expand All @@ -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 {
Expand Down

0 comments on commit ef7afcc

Please sign in to comment.