Skip to content

Commit

Permalink
allow repeated read/unread changing by clicking, same as switching st…
Browse files Browse the repository at this point in the history
…arred
  • Loading branch information
martinrotter committed Oct 10, 2024
1 parent 187c2f6 commit 56d8144
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/librssguard/core/messagesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,15 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
}
}

bool MessagesModel::switchMessageReadUnread(int row_index) {
RootItem::ReadStatus current_read =
RootItem::ReadStatus(data(row_index, MSG_DB_READ_INDEX, Qt::ItemDataRole::EditRole).toInt());

return setMessageRead(row_index,
current_read == RootItem::ReadStatus::Read ? RootItem::ReadStatus::Unread
: RootItem::ReadStatus::Read);
}

bool MessagesModel::setMessageRead(int row_index, RootItem::ReadStatus read) {
if (data(row_index, MSG_DB_READ_INDEX, Qt::ItemDataRole::EditRole).toInt() == int(read)) {
// Read status is the same is the one currently set.
Expand Down
1 change: 1 addition & 0 deletions src/librssguard/core/messagesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {

// SINGLE message manipulators.
bool switchMessageImportance(int row_index);
bool switchMessageReadUnread(int row_index);
bool setMessageRead(int row_index, RootItem::ReadStatus read);

// BATCH messages manipulators.
Expand Down
5 changes: 5 additions & 0 deletions src/librssguard/gui/messagesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ void MessagesView::mousePressEvent(QMouseEvent* event) {
emit currentMessageChanged(m_sourceModel->messageAt(mapped_index.row()), m_sourceModel->loadedItem());
}
}
else if (mapped_index.column() == MSG_DB_READ_INDEX) {
if (m_sourceModel->switchMessageReadUnread(mapped_index.row())) {
emit currentMessageChanged(m_sourceModel->messageAt(mapped_index.row()), m_sourceModel->loadedItem());
}
}
}

break;
Expand Down

0 comments on commit 56d8144

Please sign in to comment.