mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-03 02:37:46 +01:00
allow repeated read/unread changing by clicking, same as switching starred
This commit is contained in:
parent
187c2f6cb0
commit
56d8144813
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user