selecting articles from notifications work
This commit is contained in:
parent
296493daae
commit
22c5cd56fa
@ -128,7 +128,7 @@ bool MessagesProxyModel::filterAcceptsMessage(int msg_row_index) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_row) {
|
QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_row) const {
|
||||||
const bool started_from_zero = default_row == 0;
|
const bool started_from_zero = default_row == 0;
|
||||||
QModelIndex next_index = getNextImportantItemIndex(default_row, rowCount() - 1);
|
QModelIndex next_index = getNextImportantItemIndex(default_row, rowCount() - 1);
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ QModelIndex MessagesProxyModel::getNextPreviousImportantItemIndex(int default_ro
|
|||||||
return next_index;
|
return next_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) {
|
QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row) const {
|
||||||
const bool started_from_zero = default_row == 0;
|
const bool started_from_zero = default_row == 0;
|
||||||
QModelIndex next_index = getNextUnreadItemIndex(default_row, rowCount() - 1);
|
QModelIndex next_index = getNextUnreadItemIndex(default_row, rowCount() - 1);
|
||||||
|
|
||||||
@ -152,6 +152,21 @@ QModelIndex MessagesProxyModel::getNextPreviousUnreadItemIndex(int default_row)
|
|||||||
return next_index;
|
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 {
|
QModelIndex MessagesProxyModel::getNextImportantItemIndex(int default_row, int max_row) const {
|
||||||
while (default_row <= max_row) {
|
while (default_row <= max_row) {
|
||||||
// Get info if the message is read or not.
|
// Get info if the message is read or not.
|
||||||
|
@ -31,8 +31,10 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
|||||||
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
|
explicit MessagesProxyModel(MessagesModel* source_model, QObject* parent = nullptr);
|
||||||
virtual ~MessagesProxyModel();
|
virtual ~MessagesProxyModel();
|
||||||
|
|
||||||
QModelIndex getNextPreviousImportantItemIndex(int default_row);
|
QModelIndex getNextPreviousImportantItemIndex(int default_row) const;
|
||||||
QModelIndex getNextPreviousUnreadItemIndex(int default_row);
|
QModelIndex getNextPreviousUnreadItemIndex(int default_row) const;
|
||||||
|
|
||||||
|
QModelIndex indexFromMessage(const Message& msg) const;
|
||||||
|
|
||||||
// Maps list of indexes.
|
// Maps list of indexes.
|
||||||
QModelIndexList mapListToSource(const QModelIndexList& indexes) const;
|
QModelIndexList mapListToSource(const QModelIndexList& indexes) const;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "gui/feedmessageviewer.h"
|
#include "gui/feedmessageviewer.h"
|
||||||
|
|
||||||
|
#include "core/feedsproxymodel.h"
|
||||||
#include "core/messagesproxymodel.h"
|
#include "core/messagesproxymodel.h"
|
||||||
#include "gui/dialogs/formmain.h"
|
#include "gui/dialogs/formmain.h"
|
||||||
#include "gui/feedsview.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) {
|
void FeedMessageViewer::onMessageRemoved(RootItem* root) {
|
||||||
if (m_articleViewerAlwaysVisible) {
|
if (m_articleViewerAlwaysVisible) {
|
||||||
m_messagesBrowser->showItemDetails(root);
|
m_messagesBrowser->showItemDetails(root);
|
||||||
|
@ -67,6 +67,8 @@ class RSSGUARD_DLLSPEC FeedMessageViewer : public TabContent {
|
|||||||
void alternateRowColorsInLists();
|
void alternateRowColorsInLists();
|
||||||
void respondToMainWindowResizes();
|
void respondToMainWindowResizes();
|
||||||
|
|
||||||
|
void loadMessageToFeedAndArticleList(Feed* feed, const Message& message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFeedSplitterResized();
|
void onFeedSplitterResized();
|
||||||
void onMessageSplitterResized();
|
void onMessageSplitterResized();
|
||||||
|
@ -1032,7 +1032,6 @@ void FeedsView::drawRow(QPainter* painter, const QStyleOptionViewItem& options,
|
|||||||
auto opts = options;
|
auto opts = options;
|
||||||
|
|
||||||
opts.decorationAlignment = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter;
|
opts.decorationAlignment = Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter;
|
||||||
// opts.decorationSize = {options.decorationSize.height(), 70};
|
|
||||||
|
|
||||||
BaseTreeView::drawRow(painter, opts, index);
|
BaseTreeView::drawRow(painter, opts, index);
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,9 @@ ArticleListNotification::ArticleListNotification(QWidget* parent)
|
|||||||
|
|
||||||
m_ui.m_treeArticles->setAttribute(Qt::WA_NoSystemBackground, true);
|
m_ui.m_treeArticles->setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
|
||||||
auto pal = m_ui.m_treeArticles->palette();
|
|
||||||
|
|
||||||
// Make background transparent.
|
// Make background transparent.
|
||||||
|
auto pal = m_ui.m_treeArticles->palette();
|
||||||
pal.setColor(QPalette::ColorRole::Base, Qt::transparent);
|
pal.setColor(QPalette::ColorRole::Base, Qt::transparent);
|
||||||
|
|
||||||
m_ui.m_treeArticles->setPalette(pal);
|
m_ui.m_treeArticles->setPalette(pal);
|
||||||
|
|
||||||
connect(m_ui.m_cmbFeeds,
|
connect(m_ui.m_cmbFeeds,
|
||||||
@ -90,7 +88,9 @@ void ArticleListNotification::openArticleInArticleList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ArticleListNotification::onMessageSelected(const QModelIndex& current, const QModelIndex& previous) {
|
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 {
|
try {
|
||||||
Message msg = selectedMessage();
|
Message msg = selectedMessage();
|
||||||
|
@ -84,22 +84,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Minimum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="PlainToolButton" name="m_btnPreviousPage">
|
<widget class="PlainToolButton" name="m_btnPreviousPage">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -58,6 +58,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="m_lblBody">
|
<widget class="QLabel" name="m_lblBody">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
|
@ -109,10 +109,6 @@ void ToastNotificationsManager::showNotification(Notification::Event event,
|
|||||||
m_activeNotifications.prepend(notif);
|
m_activeNotifications.prepend(notif);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToastNotificationsManager::openArticleInArticleList(Feed* feed, const Message& msg) {
|
|
||||||
// qApp -, ao
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) {
|
void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) {
|
||||||
auto notif_idx = m_activeNotifications.indexOf(notif);
|
auto notif_idx = m_activeNotifications.indexOf(notif);
|
||||||
|
|
||||||
@ -169,7 +165,7 @@ void ToastNotificationsManager::initializeArticleListNotification() {
|
|||||||
connect(m_articleListNotification,
|
connect(m_articleListNotification,
|
||||||
&ArticleListNotification::openingArticleInArticleListRequested,
|
&ArticleListNotification::openingArticleInArticleListRequested,
|
||||||
this,
|
this,
|
||||||
&ToastNotificationsManager::openArticleInArticleList);
|
&ToastNotificationsManager::openingArticleInArticleListRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) {
|
void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) {
|
||||||
|
@ -47,9 +47,11 @@ class ToastNotificationsManager : public QObject {
|
|||||||
void showNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action);
|
void showNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void openArticleInArticleList(Feed* feed, const Message& msg);
|
|
||||||
void closeNotification(BaseToastNotification* notif, bool delete_from_memory);
|
void closeNotification(BaseToastNotification* notif, bool delete_from_memory);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openingArticleInArticleListRequested(Feed* feed, const Message& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScreen* activeScreen() const;
|
QScreen* activeScreen() const;
|
||||||
QScreen* moveToProperScreen(BaseToastNotification* notif);
|
QScreen* moveToProperScreen(BaseToastNotification* notif);
|
||||||
|
@ -23,6 +23,10 @@ BaseTreeView::BaseTreeView(QWidget* parent) : QTreeView(parent) {
|
|||||||
Qt::Key::Key_PageDown};
|
Qt::Key::Key_PageDown};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseTreeView::isIndexHidden(const QModelIndex& idx) const {
|
||||||
|
return QTreeView::isIndexHidden(idx);
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTreeView::keyPressEvent(QKeyEvent* event) {
|
void BaseTreeView::keyPressEvent(QKeyEvent* event) {
|
||||||
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::OnlyBasicShortcutsInLists)).toBool() &&
|
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::OnlyBasicShortcutsInLists)).toBool() &&
|
||||||
!m_allowedKeyboardKeys.contains(event->key()) && !event->matches(QKeySequence::StandardKey::SelectAll)) {
|
!m_allowedKeyboardKeys.contains(event->key()) && !event->matches(QKeySequence::StandardKey::SelectAll)) {
|
||||||
|
@ -6,11 +6,13 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
class BaseTreeView : public QTreeView {
|
class BaseTreeView : public QTreeView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseTreeView(QWidget* parent = nullptr);
|
explicit BaseTreeView(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
bool isIndexHidden(const QModelIndex& idx) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent(QKeyEvent* event);
|
virtual void keyPressEvent(QKeyEvent* event);
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "gui/dialogs/formabout.h"
|
#include "gui/dialogs/formabout.h"
|
||||||
#include "gui/dialogs/formlog.h"
|
#include "gui/dialogs/formlog.h"
|
||||||
#include "gui/dialogs/formmain.h"
|
#include "gui/dialogs/formmain.h"
|
||||||
|
#include "gui/feedmessageviewer.h"
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
#include "gui/notifications/toastnotificationsmanager.h"
|
#include "gui/notifications/toastnotificationsmanager.h"
|
||||||
#include "gui/toolbars/statusbar.h"
|
#include "gui/toolbars/statusbar.h"
|
||||||
@ -495,6 +496,13 @@ QWidget* Application::mainFormWidget() {
|
|||||||
|
|
||||||
void Application::setMainForm(FormMain* main_form) {
|
void Application::setMainForm(FormMain* main_form) {
|
||||||
m_mainForm = 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 {
|
QString Application::configFolder() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user