diff --git a/src/librssguard/core/messagesproxymodel.cpp b/src/librssguard/core/messagesproxymodel.cpp
index 74d7a37cd..682021044 100644
--- a/src/librssguard/core/messagesproxymodel.cpp
+++ b/src/librssguard/core/messagesproxymodel.cpp
@@ -128,7 +128,7 @@ bool MessagesProxyModel::filterAcceptsMessage(int msg_row_index) const {
return false;
}
-QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_row) {
+QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_row) const {
const bool started_from_zero = default_row == 0;
QModelIndex next_index = getNextImportantItemIndex(default_row, rowCount() - 1);
@@ -140,7 +140,7 @@ QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_ro
return next_index;
}
-QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) {
+QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) const {
const bool started_from_zero = default_row == 0;
QModelIndex next_index = getNextUnreadItemIndex(default_row, rowCount() - 1);
@@ -152,6 +152,21 @@ QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row)
return next_index;
}
+QModelIndex MessagesProxyModel::indexFromMessage(const Message& msg) const {
+ for (int i = 0; i < rowCount(); i++) {
+ auto idx = index(i, 0);
+ auto id =
+ m_sourceModel->data(m_sourceModel->index(mapToSource(idx).row(), MSG_DB_ID_INDEX), Qt::ItemDataRole::EditRole)
+ .toInt();
+
+ if (id == msg.m_id) {
+ return idx;
+ }
+ }
+
+ return QModelIndex();
+}
+
QModelIndex MessagesProxyModel::getNextImportantItemIndex(int default_row, int max_row) const {
while (default_row <= max_row) {
// Get info if the message is read or not.
diff --git a/src/librssguard/core/messagesproxymodel.h b/src/librssguard/core/messagesproxymodel.h
index 0747a4445..ff1075651 100644
--- a/src/librssguard/core/messagesproxymodel.h
+++ b/src/librssguard/core/messagesproxymodel.h
@@ -31,8 +31,10 @@ class MessagesProxyModel : public QSortFilterProxyModel {
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
virtual ~MessagesProxyModel();
- QModelIndex getNextPreviousImportantItemIndex(int default_row);
- QModelIndex getNextPreviousUnreadItemIndex(int default_row);
+ QModelIndex getNextPreviousImportantItemIndex(int default_row) const;
+ QModelIndex getNextPreviousUnreadItemIndex(int default_row) const;
+
+ QModelIndex indexFromMessage(const Message& msg) const;
// Maps list of indexes.
QModelIndexList mapListToSource(const QModelIndexList& indexes) const;
diff --git a/src/librssguard/gui/feedmessageviewer.cpp b/src/librssguard/gui/feedmessageviewer.cpp
index f517493bb..8e18b8903 100644
--- a/src/librssguard/gui/feedmessageviewer.cpp
+++ b/src/librssguard/gui/feedmessageviewer.cpp
@@ -2,6 +2,7 @@
#include "gui/feedmessageviewer.h"
+#include "core/feedsproxymodel.h"
#include "core/messagesproxymodel.h"
#include "gui/dialogs/formmain.h"
#include "gui/feedsview.h"
@@ -218,6 +219,46 @@ void FeedMessageViewer::displayMessage(const Message& message, RootItem* root) {
}
}
+void FeedMessageViewer::loadMessageToFeedAndArticleList(Feed* feed, const Message& message) {
+ auto idx_src = m_feedsView->sourceModel()->indexForItem(feed);
+ auto idx_map = m_feedsView->model()->mapFromSource(idx_src);
+ auto is_visible = !m_feedsView->isIndexHidden(idx_map);
+
+ if (!idx_map.isValid() || !is_visible) {
+ qApp->showGuiMessage(Notification::Event::GeneralEvent,
+ GuiMessage(tr("Filtered feed list"),
+ tr("Cannot select article in article list as your feed is filtered out from feed "
+ "list."),
+ QSystemTrayIcon::MessageIcon::Warning),
+ GuiMessageDestination(true, true));
+ return;
+ }
+
+ // TODO: expand properly
+ m_feedsView->setExpanded(idx_map, true);
+
+ m_feedsView->selectionModel()->select(idx_map,
+ QItemSelectionModel::SelectionFlag::ClearAndSelect |
+ QItemSelectionModel::SelectionFlag::Rows);
+
+ qApp->processEvents();
+
+ auto idx_map_msg = m_messagesView->model()->indexFromMessage(message);
+ auto msg_is_visible = !m_messagesView->isRowHidden(idx_map_msg.row(), idx_map_msg);
+
+ if (!idx_map_msg.isValid() || !msg_is_visible) {
+ qApp->showGuiMessage(Notification::Event::GeneralEvent,
+ GuiMessage(tr("Filtered article list"),
+ tr("Cannot select article as it seems your article list is filtered."),
+ QSystemTrayIcon::MessageIcon::Warning),
+ GuiMessageDestination(true, true));
+ return;
+ }
+
+ // m_messagesView->selectionModel()->select(idx_map_msg, QItemSelectionModel::SelectionFlag::Clear);
+ m_messagesView->setCurrentIndex(idx_map_msg);
+}
+
void FeedMessageViewer::onMessageRemoved(RootItem* root) {
if (m_articleViewerAlwaysVisible) {
m_messagesBrowser->showItemDetails(root);
diff --git a/src/librssguard/gui/feedmessageviewer.h b/src/librssguard/gui/feedmessageviewer.h
index 46692b5e0..0cc53bcd9 100644
--- a/src/librssguard/gui/feedmessageviewer.h
+++ b/src/librssguard/gui/feedmessageviewer.h
@@ -67,6 +67,8 @@ class RSSGUARD_DLLSPEC FeedMessageViewer : public TabContent {
void alternateRowColorsInLists();
void respondToMainWindowResizes();
+ void loadMessageToFeedAndArticleList(Feed* feed, const Message& message);
+
private slots:
void onFeedSplitterResized();
void onMessageSplitterResized();
diff --git a/src/librssguard/gui/feedsview.cpp b/src/librssguard/gui/feedsview.cpp
index aae832c43..6415bf03b 100644
--- a/src/librssguard/gui/feedsview.cpp
+++ b/src/librssguard/gui/feedsview.cpp
@@ -1032,7 +1032,6 @@ void FeedsView::drawRow(QPainter* painter, const QStyleOptionViewItem& options,
auto opts = options;
opts.decorationAlignment = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter;
- // opts.decorationSize = {options.decorationSize.height(), 70};
BaseTreeView::drawRow(painter, opts, index);
}
diff --git a/src/librssguard/gui/notifications/articlelistnotification.cpp b/src/librssguard/gui/notifications/articlelistnotification.cpp
index 159dc233a..d8035abdc 100644
--- a/src/librssguard/gui/notifications/articlelistnotification.cpp
+++ b/src/librssguard/gui/notifications/articlelistnotification.cpp
@@ -51,11 +51,9 @@ ArticleListNotification::ArticleListNotification(QWidget* parent)
m_ui.m_treeArticles->setAttribute(Qt::WA_NoSystemBackground, true);
- auto pal = m_ui.m_treeArticles->palette();
-
// Make background transparent.
+ auto pal = m_ui.m_treeArticles->palette();
pal.setColor(QPalette::ColorRole::Base, Qt::transparent);
-
m_ui.m_treeArticles->setPalette(pal);
connect(m_ui.m_cmbFeeds,
@@ -90,7 +88,9 @@ void ArticleListNotification::openArticleInArticleList() {
}
void ArticleListNotification::onMessageSelected(const QModelIndex& current, const QModelIndex& previous) {
- m_ui.m_btnOpenArticleList->setEnabled(current.isValid());
+ Q_UNUSED(previous)
+
+ m_ui.m_btnOpenArticleList->setEnabled(m_ui.m_treeArticles->currentIndex().isValid());
try {
Message msg = selectedMessage();
diff --git a/src/librssguard/gui/notifications/articlelistnotification.ui b/src/librssguard/gui/notifications/articlelistnotification.ui
index dccd7e787..bcbaa5d63 100644
--- a/src/librssguard/gui/notifications/articlelistnotification.ui
+++ b/src/librssguard/gui/notifications/articlelistnotification.ui
@@ -84,22 +84,6 @@
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Minimum
-
-
-
- 40
- 20
-
-
-
-
-
diff --git a/src/librssguard/gui/notifications/toastnotification.ui b/src/librssguard/gui/notifications/toastnotification.ui
index c2b3731e3..43ef64cb9 100644
--- a/src/librssguard/gui/notifications/toastnotification.ui
+++ b/src/librssguard/gui/notifications/toastnotification.ui
@@ -58,6 +58,12 @@
-
+
+
+ 0
+ 1
+
+
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp
index de05eb3cd..adbf0a072 100644
--- a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp
+++ b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp
@@ -109,10 +109,6 @@ void ToastNotificationsManager::showNotification(Notification::Event event,
m_activeNotifications.prepend(notif);
}
-void ToastNotificationsManager::openArticleInArticleList(Feed* feed, const Message& msg) {
- // qApp -, ao
-}
-
void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) {
auto notif_idx = m_activeNotifications.indexOf(notif);
@@ -169,7 +165,7 @@ void ToastNotificationsManager::initializeArticleListNotification() {
connect(m_articleListNotification,
&ArticleListNotification::openingArticleInArticleListRequested,
this,
- &ToastNotificationsManager::openArticleInArticleList);
+ &ToastNotificationsManager::openingArticleInArticleListRequested);
}
void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) {
diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.h b/src/librssguard/gui/notifications/toastnotificationsmanager.h
index d7d6962bf..4f233c83a 100644
--- a/src/librssguard/gui/notifications/toastnotificationsmanager.h
+++ b/src/librssguard/gui/notifications/toastnotificationsmanager.h
@@ -47,9 +47,11 @@ class ToastNotificationsManager : public QObject {
void showNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action);
private slots:
- void openArticleInArticleList(Feed* feed, const Message& msg);
void closeNotification(BaseToastNotification* notif, bool delete_from_memory);
+ signals:
+ void openingArticleInArticleListRequested(Feed* feed, const Message& msg);
+
private:
QScreen* activeScreen() const;
QScreen* moveToProperScreen(BaseToastNotification* notif);
diff --git a/src/librssguard/gui/reusable/basetreeview.cpp b/src/librssguard/gui/reusable/basetreeview.cpp
index 72d452fb4..d5f60819e 100644
--- a/src/librssguard/gui/reusable/basetreeview.cpp
+++ b/src/librssguard/gui/reusable/basetreeview.cpp
@@ -23,6 +23,10 @@ BaseTreeView::BaseTreeView(QWidget* parent) : QTreeView(parent) {
Qt::Key::Key_PageDown};
}
+bool BaseTreeView::isIndexHidden(const QModelIndex& idx) const {
+ return QTreeView::isIndexHidden(idx);
+}
+
void BaseTreeView::keyPressEvent(QKeyEvent* event) {
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::OnlyBasicShortcutsInLists)).toBool() &&
!m_allowedKeyboardKeys.contains(event->key()) && !event->matches(QKeySequence::StandardKey::SelectAll)) {
diff --git a/src/librssguard/gui/reusable/basetreeview.h b/src/librssguard/gui/reusable/basetreeview.h
index e22de6696..ebf641f24 100644
--- a/src/librssguard/gui/reusable/basetreeview.h
+++ b/src/librssguard/gui/reusable/basetreeview.h
@@ -6,11 +6,13 @@
#include
class BaseTreeView : public QTreeView {
- Q_OBJECT
+ Q_OBJECT
public:
explicit BaseTreeView(QWidget* parent = nullptr);
+ bool isIndexHidden(const QModelIndex& idx) const;
+
protected:
virtual void keyPressEvent(QKeyEvent* event);
diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp
index f4ae62f14..b13da5cd9 100644
--- a/src/librssguard/miscellaneous/application.cpp
+++ b/src/librssguard/miscellaneous/application.cpp
@@ -16,6 +16,7 @@
#include "gui/dialogs/formabout.h"
#include "gui/dialogs/formlog.h"
#include "gui/dialogs/formmain.h"
+#include "gui/feedmessageviewer.h"
#include "gui/messagebox.h"
#include "gui/notifications/toastnotificationsmanager.h"
#include "gui/toolbars/statusbar.h"
@@ -495,6 +496,13 @@ QWidget* Application::mainFormWidget() {
void Application::setMainForm(FormMain* main_form) {
m_mainForm = main_form;
+
+ if (m_toastNotifications != nullptr) {
+ connect(m_toastNotifications,
+ &ToastNotificationsManager::openingArticleInArticleListRequested,
+ m_mainForm->tabWidget()->feedMessageViewer(),
+ &FeedMessageViewer::loadMessageToFeedAndArticleList);
+ }
}
QString Application::configFolder() const {