Some refactoring + #112.
This commit is contained in:
parent
45f417ceea
commit
3e040377b6
@ -17,11 +17,12 @@
|
||||
Added:
|
||||
<ul>
|
||||
<li style="color: red;">Brand new "service plugin system" - HIGHLY EXPERIMENTAL and REWRITTEN from scratch. Expect bugs and misunderstandings now! Major parts of RSS Guard were completely rewritten.</li>
|
||||
<li>Added ability to completely disable notifications (bug #128).</li>
|
||||
<li>Added ability to go to next <font style="font-weight: bold;">unread</font> message. (partially bug #112)</li>
|
||||
</ul>
|
||||
|
||||
Fixed:
|
||||
<ul>
|
||||
<li>Added ability to completely disable notifications (bug #128).</li>
|
||||
<li>Better info in popup notification when many feeds are updated.</li>
|
||||
<li>Fixed obtaining of contents in RSS 2.0 feed entries. (bug #130)</li>
|
||||
<li>Improved popup informing about changes in newly installed version.</li>
|
||||
|
@ -38,6 +38,38 @@ MessagesProxyModel::~MessagesProxyModel() {
|
||||
qDebug("Destroying MessagesProxyModel instance.");
|
||||
}
|
||||
|
||||
QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) {
|
||||
bool started_from_zero = default_row == 0;
|
||||
QModelIndex next_index = getNextUnreadItemIndex(default_row, rowCount() - 1);
|
||||
|
||||
// There is no next message, check previous.
|
||||
if (!next_index.isValid() && !started_from_zero) {
|
||||
next_index = getNextUnreadItemIndex(0, default_row - 1);
|
||||
}
|
||||
|
||||
return next_index;
|
||||
}
|
||||
|
||||
QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_row) {
|
||||
while (default_row <= max_row) {
|
||||
// Get info if the message is read or not.
|
||||
QModelIndex proxy_index = index(default_row, 0);
|
||||
|
||||
bool is_read = m_sourceModel->data(mapToSource(proxy_index).row(),
|
||||
MSG_DB_READ_INDEX, Qt::EditRole).toInt() == 1;
|
||||
|
||||
if (!is_read) {
|
||||
// We found unread message, mark it.
|
||||
return proxy_index;
|
||||
}
|
||||
else {
|
||||
default_row++;
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
if (left.column() == MSG_DB_TITLE_INDEX && right.column() == MSG_DB_TITLE_INDEX) {
|
||||
return QString::localeAwareCompare(m_sourceModel->data(left).toString(),
|
||||
|
@ -36,6 +36,8 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
return m_sourceModel;
|
||||
}
|
||||
|
||||
QModelIndex getNextPreviousUnreadItemIndex(int default_row);
|
||||
|
||||
// Maps list of indexes.
|
||||
QModelIndexList mapListToSource(const QModelIndexList &indexes);
|
||||
QModelIndexList mapListFromSource(const QModelIndexList &indexes, bool deep = false);
|
||||
@ -44,6 +46,8 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const;
|
||||
|
||||
private:
|
||||
QModelIndex getNextUnreadItemIndex(int default_row, int max_row);
|
||||
|
||||
// Compares two rows of data.
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
|
||||
|
@ -135,6 +135,7 @@ QList<QAction*> FormMain::allActions() {
|
||||
actions << m_ui->m_actionSelectPreviousItem;
|
||||
actions << m_ui->m_actionSelectNextMessage;
|
||||
actions << m_ui->m_actionSelectPreviousMessage;
|
||||
actions << m_ui->m_actionSelectNextUnreadMessage;
|
||||
actions << m_ui->m_actionExpandCollapseItem;
|
||||
|
||||
return actions;
|
||||
@ -361,6 +362,7 @@ void FormMain::setupIcons() {
|
||||
m_ui->m_actionSelectPreviousItem->setIcon(icon_theme_factory->fromTheme(QSL("go-up")));
|
||||
m_ui->m_actionSelectNextMessage->setIcon(icon_theme_factory->fromTheme(QSL("go-down")));
|
||||
m_ui->m_actionSelectPreviousMessage->setIcon(icon_theme_factory->fromTheme(QSL("go-up")));
|
||||
m_ui->m_actionSelectNextUnreadMessage->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread")));
|
||||
m_ui->m_actionShowOnlyUnreadItems->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread")));
|
||||
m_ui->m_actionExpandCollapseItem->setIcon(icon_theme_factory->fromTheme(QSL("expand-collapse")));
|
||||
m_ui->m_actionRestoreSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("recycle-bin-restore-one")));
|
||||
|
@ -125,7 +125,7 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuFeeds">
|
||||
<property name="title">
|
||||
<string>Fee&ds && categories</string>
|
||||
<string>Feeds && categories && accounts</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="m_menuAddItem">
|
||||
<property name="title">
|
||||
@ -165,6 +165,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionSelectNextMessage"/>
|
||||
<addaction name="m_actionSelectPreviousMessage"/>
|
||||
<addaction name="m_actionSelectNextUnreadMessage"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionMarkSelectedMessagesAsRead"/>
|
||||
<addaction name="m_actionMarkSelectedMessagesAsUnread"/>
|
||||
@ -174,7 +175,7 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuRecycleBin">
|
||||
<property name="title">
|
||||
<string>&Recycle bin</string>
|
||||
<string>&Recycle bin(s)</string>
|
||||
</property>
|
||||
<addaction name="m_actionRestoreAllRecycleBins"/>
|
||||
<addaction name="m_actionEmptyAllRecycleBins"/>
|
||||
@ -729,6 +730,17 @@
|
||||
<property name="text">
|
||||
<string>&Empty all recycle bins</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionSelectNextUnreadMessage">
|
||||
<property name="text">
|
||||
<string>Select next &unread message</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -304,6 +304,8 @@ void FeedMessageViewer::createConnections() {
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(selectPreviousItem()));
|
||||
connect(form_main->m_ui->m_actionSelectNextMessage,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(selectNextItem()));
|
||||
connect(form_main->m_ui->m_actionSelectNextUnreadMessage,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(selectNextUnreadItem()));
|
||||
connect(form_main->m_ui->m_actionSelectPreviousMessage,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(selectPreviousItem()));
|
||||
connect(form_main->m_ui->m_actionSwitchMessageListOrientation, SIGNAL(triggered()),
|
||||
|
@ -98,16 +98,6 @@ RootItem *FeedsView::selectedItem() const {
|
||||
}
|
||||
}
|
||||
|
||||
Category *FeedsView::selectedCategory() const {
|
||||
QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex());
|
||||
return m_sourceModel->categoryForIndex(current_mapped);
|
||||
}
|
||||
|
||||
Feed *FeedsView::selectedFeed() const {
|
||||
QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex());
|
||||
return m_sourceModel->feedForIndex(current_mapped);
|
||||
}
|
||||
|
||||
void FeedsView::saveExpandedStates() {
|
||||
Settings *settings = qApp->settings();
|
||||
QList<RootItem*> expandable_items;
|
||||
|
@ -56,8 +56,6 @@ class FeedsView : public QTreeView {
|
||||
// Returns pointers to selected feed/category if they are really
|
||||
// selected.
|
||||
RootItem *selectedItem() const;
|
||||
Category *selectedCategory() const;
|
||||
Feed *selectedFeed() const;
|
||||
|
||||
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
|
||||
void saveExpandedStates();
|
||||
|
@ -481,20 +481,13 @@ void MessagesView::selectNextUnreadItem() {
|
||||
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);
|
||||
QModelIndex next_unread = m_proxyModel->getNextPreviousUnreadItemIndex(active_row);
|
||||
|
||||
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;
|
||||
}
|
||||
if (next_unread.isValid()) {
|
||||
// We found unread message, mark it.
|
||||
setCurrentIndex(next_unread);
|
||||
selectionModel()->select(next_unread, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user