mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-26 15:34:59 +01:00
API for custom article previwer per account
This commit is contained in:
parent
23b7089e75
commit
ded2ce26eb
@ -250,6 +250,8 @@ set(SOURCES
|
||||
services/abstract/gui/formcategorydetails.h
|
||||
services/abstract/gui/formfeeddetails.cpp
|
||||
services/abstract/gui/formfeeddetails.h
|
||||
services/abstract/gui/custommessagepreviewer.h
|
||||
services/abstract/gui/custommessagepreviewer.cpp
|
||||
services/abstract/importantnode.cpp
|
||||
services/abstract/importantnode.h
|
||||
services/abstract/label.cpp
|
||||
|
@ -126,8 +126,8 @@
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
@ -160,8 +160,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>691</width>
|
||||
<height>139</height>
|
||||
<width>685</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
@ -216,8 +216,8 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
@ -234,8 +234,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>87</width>
|
||||
<height>64</height>
|
||||
<width>83</width>
|
||||
<height>69</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -284,8 +284,8 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
@ -302,8 +302,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>87</width>
|
||||
<height>64</height>
|
||||
<width>83</width>
|
||||
<height>69</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -352,8 +352,8 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
@ -396,8 +396,8 @@ p, li { white-space: pre-wrap; }
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "gui/webbrowser.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "network-web/webfactory.h"
|
||||
#include "services/abstract/gui/custommessagepreviewer.h"
|
||||
#include "services/abstract/label.h"
|
||||
#include "services/abstract/labelsnode.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
@ -108,12 +109,22 @@ void MessagePreviewer::loadMessage(const Message& message, RootItem* root) {
|
||||
return it->kind() == RootItem::Kind::Feed && it->customId() == msg_feed_id;
|
||||
})->toFeed();
|
||||
|
||||
// TODO: tady místo na otevření skrze custom previewer, pokud
|
||||
// ho root má.
|
||||
|
||||
if (feed != nullptr && feed->openArticlesDirectly() && !m_message.m_url.isEmpty()) {
|
||||
m_msgBrowser->setVerticalScrollBarPosition(0.0);
|
||||
m_msgBrowser->loadUrl(m_message.m_url);
|
||||
}
|
||||
else {
|
||||
m_msgBrowser->loadMessages({ message }, m_root);
|
||||
CustomMessagePreviewer* custom_previewer = root->getParentServiceRoot()->customMessagePreviewer();
|
||||
|
||||
if (custom_previewer != nullptr) {
|
||||
custom_previewer->loadMessage(message, m_root);
|
||||
}
|
||||
else {
|
||||
m_msgBrowser->loadMessages({ message }, m_root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
src/librssguard/services/abstract/gui/custommessagepreviewer.cpp
Executable file
5
src/librssguard/services/abstract/gui/custommessagepreviewer.cpp
Executable file
@ -0,0 +1,5 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "services/abstract/gui/custommessagepreviewer.h"
|
||||
|
||||
CustomMessagePreviewer::CustomMessagePreviewer(QWidget* parent) : QWidget{parent} {}
|
27
src/librssguard/services/abstract/gui/custommessagepreviewer.h
Executable file
27
src/librssguard/services/abstract/gui/custommessagepreviewer.h
Executable file
@ -0,0 +1,27 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#ifndef CUSTOMMESSAGEPREVIEWER_H
|
||||
#define CUSTOMMESSAGEPREVIEWER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "core/message.h"
|
||||
|
||||
class RootItem;
|
||||
|
||||
class CustomMessagePreviewer : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomMessagePreviewer(QWidget* parent = nullptr);
|
||||
|
||||
public:
|
||||
|
||||
// Clears displayed message.
|
||||
virtual void clear() = 0;
|
||||
|
||||
// Displays the message.
|
||||
virtual void loadMessage(const Message& msg, RootItem* selected_item) = 0;
|
||||
};
|
||||
|
||||
#endif // CUSTOMMESSAGEPREVIEWER_H
|
@ -13,6 +13,7 @@
|
||||
#include "services/abstract/cacheforserviceroot.h"
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/gui/custommessagepreviewer.h"
|
||||
#include "services/abstract/importantnode.h"
|
||||
#include "services/abstract/labelsnode.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
@ -131,6 +132,10 @@ void ServiceRoot::start(bool freshly_activated) {
|
||||
|
||||
void ServiceRoot::stop() {}
|
||||
|
||||
CustomMessagePreviewer* ServiceRoot::customMessagePreviewer() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ServiceRoot::updateCounts(bool including_total_count) {
|
||||
QList<Feed*> feeds;
|
||||
auto str = getSubTree();
|
||||
|
@ -13,14 +13,15 @@
|
||||
#include <QNetworkProxy>
|
||||
#include <QPair>
|
||||
|
||||
class QAction;
|
||||
class FeedsModel;
|
||||
class RecycleBin;
|
||||
class ImportantNode;
|
||||
class UnreadNode;
|
||||
class LabelsNode;
|
||||
class Label;
|
||||
class QAction;
|
||||
class MessagesModel;
|
||||
class CustomMessagePreviewer;
|
||||
class CacheForServiceRoot;
|
||||
|
||||
// THIS IS the root node of the service.
|
||||
@ -112,11 +113,13 @@ class ServiceRoot : public RootItem {
|
||||
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
|
||||
const QHash<QString, QStringList>& tagged_messages) = 0;
|
||||
|
||||
// This method should prepare messages for given "item" (download them maybe?)
|
||||
// into predefined "Messages" table
|
||||
// and then use method QSqlTableModel::setFilter(....).
|
||||
// NOTE: It would be more preferable if all messages are downloaded
|
||||
// right when feeds are updated.
|
||||
// Returns special widget to display articles of this account type.
|
||||
// Caller does NOT free returned previewer after usage from memory,
|
||||
// it only may hide it.
|
||||
// Thus, account is responsible to free any custom previewers.
|
||||
virtual CustomMessagePreviewer* customMessagePreviewer();
|
||||
|
||||
// This method should load messages for given "item" into model.
|
||||
virtual bool loadMessagesForItem(RootItem* item, MessagesModel* model);
|
||||
|
||||
// Called BEFORE this read status update (triggered by user in message list) is stored in DB,
|
||||
|
Loading…
Reference in New Issue
Block a user