mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-03 10:47:47 +01:00
Some preps for #112.
This commit is contained in:
parent
51f6edd33a
commit
45f417ceea
@ -467,6 +467,37 @@ void MessagesView::selectPreviousItem() {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::selectNextUnreadItem() {
|
||||
// FIXME: Use this to solve #112.
|
||||
|
||||
QModelIndexList selected_rows = selectionModel()->selectedRows();
|
||||
int active_row;
|
||||
|
||||
if (!selected_rows.isEmpty()) {
|
||||
// Okay, something is selected, start from it.
|
||||
active_row = selected_rows.at(0).row();
|
||||
}
|
||||
else {
|
||||
active_row = 0;
|
||||
}
|
||||
|
||||
while (++active_row < m_proxyModel->rowCount()) {
|
||||
// Get info if the message is read or not.
|
||||
QModelIndex proxy_index = m_proxyModel->index(active_row, 0);
|
||||
|
||||
bool is_read = m_sourceModel->data(m_proxyModel->mapToSource(proxy_index).row(),
|
||||
MSG_DB_READ_INDEX, Qt::EditRole).toInt() == 1;
|
||||
|
||||
if (!is_read) {
|
||||
// We found unread message, mark it.
|
||||
setCurrentIndex(proxy_index);
|
||||
selectionModel()->select(proxy_index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
setFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::searchMessages(const QString &pattern) {
|
||||
m_proxyModel->setFilterRegExp(pattern);
|
||||
|
||||
|
@ -76,6 +76,7 @@ class MessagesView : public QTreeView {
|
||||
|
||||
void selectNextItem();
|
||||
void selectPreviousItem();
|
||||
void selectNextUnreadItem();
|
||||
|
||||
// Searchs the visible message according to given pattern.
|
||||
void searchMessages(const QString &pattern);
|
||||
|
Loading…
x
Reference in New Issue
Block a user