small refactoring
This commit is contained in:
parent
40402f6c7a
commit
0b2e1df83d
@ -72,8 +72,23 @@ QList<QAction*> ServiceRoot::contextMenu() {
|
|||||||
return serviceMenu();
|
return serviceMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QAction*> ServiceRoot::contextMenuForMessages(const QList<Message*>& messages) {
|
||||||
|
Q_UNUSED(messages)
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
QList<QAction*> ServiceRoot::serviceMenu() {
|
QList<QAction*> ServiceRoot::serviceMenu() {
|
||||||
return QList<QAction*>();
|
if (m_serviceMenu.isEmpty() && isSyncable()) {
|
||||||
|
m_actionSyncIn = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Sync in"), this);
|
||||||
|
connect(m_actionSyncIn, &QAction::triggered, this, &ServiceRoot::syncIn);
|
||||||
|
m_serviceMenu.append(m_actionSyncIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_serviceMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServiceRoot::isSyncable() const {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceRoot::start(bool freshly_activated) {
|
void ServiceRoot::start(bool freshly_activated) {
|
||||||
|
@ -54,13 +54,17 @@ class ServiceRoot : public RootItem {
|
|||||||
virtual QList<QAction*> addItemMenu();
|
virtual QList<QAction*> addItemMenu();
|
||||||
|
|
||||||
// Returns actions to display as context menu.
|
// Returns actions to display as context menu.
|
||||||
QList<QAction*> contextMenu();
|
virtual QList<QAction*> contextMenu();
|
||||||
|
virtual QList<QAction*> contextMenuForMessages(const QList<Message*>& messages);
|
||||||
|
|
||||||
// Returns list of specific actions to be shown in main window menu
|
// Returns list of specific actions to be shown in main window menu
|
||||||
// bar in sections "Services -> 'this service'".
|
// bar in sections "Services -> 'this service'".
|
||||||
// NOTE: Caller does NOT take ownership of created menu!
|
// NOTE: Caller does NOT take ownership of created menu!
|
||||||
virtual QList<QAction*> serviceMenu();
|
virtual QList<QAction*> serviceMenu();
|
||||||
|
|
||||||
|
// If plugin uses online synchronization, then returns true.
|
||||||
|
virtual bool isSyncable() const;
|
||||||
|
|
||||||
// Start/stop services.
|
// Start/stop services.
|
||||||
// Start method is called when feed model gets initialized OR after user adds new service.
|
// Start method is called when feed model gets initialized OR after user adds new service.
|
||||||
// Account should synchronously initialize its children (load them from DB is recommended
|
// Account should synchronously initialize its children (load them from DB is recommended
|
||||||
@ -204,10 +208,12 @@ class ServiceRoot : public RootItem {
|
|||||||
virtual QMap<QString, QVariantMap> storeCustomFeedsData();
|
virtual QMap<QString, QVariantMap> storeCustomFeedsData();
|
||||||
virtual void restoreCustomFeedsData(const QMap<QString, QVariantMap>& data, const QHash<QString, Feed*>& feeds);
|
virtual void restoreCustomFeedsData(const QMap<QString, QVariantMap>& data, const QHash<QString, Feed*>& feeds);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
RecycleBin* m_recycleBin;
|
RecycleBin* m_recycleBin;
|
||||||
ImportantNode* m_importantNode;
|
ImportantNode* m_importantNode;
|
||||||
int m_accountId;
|
int m_accountId;
|
||||||
|
QAction* m_actionSyncIn;
|
||||||
|
QList<QAction*> m_serviceMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERVICEROOT_H
|
#endif // SERVICEROOT_H
|
||||||
|
@ -130,6 +130,8 @@ bool GmailServiceRoot::downloadAttachmentOnMyOwn(const QUrl& url) const {
|
|||||||
|
|
||||||
QList<QAction*> GmailServiceRoot::serviceMenu() {
|
QList<QAction*> GmailServiceRoot::serviceMenu() {
|
||||||
if (m_serviceMenu.isEmpty()) {
|
if (m_serviceMenu.isEmpty()) {
|
||||||
|
ServiceRoot::serviceMenu();
|
||||||
|
|
||||||
QAction* act_new_email = new QAction(qApp->icons()->fromTheme(QSL("mail-message-new")), tr("Write new e-mail message"), this);
|
QAction* act_new_email = new QAction(qApp->icons()->fromTheme(QSL("mail-message-new")), tr("Write new e-mail message"), this);
|
||||||
|
|
||||||
connect(act_new_email, &QAction::triggered, this, &GmailServiceRoot::writeNewEmail);
|
connect(act_new_email, &QAction::triggered, this, &GmailServiceRoot::writeNewEmail);
|
||||||
@ -139,6 +141,10 @@ QList<QAction*> GmailServiceRoot::serviceMenu() {
|
|||||||
return m_serviceMenu;
|
return m_serviceMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GmailServiceRoot::isSyncable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool GmailServiceRoot::canBeEdited() const {
|
bool GmailServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
GmailNetworkFactory* network() const;
|
GmailNetworkFactory* network() const;
|
||||||
|
|
||||||
QList<QAction*> serviceMenu();
|
QList<QAction*> serviceMenu();
|
||||||
|
bool isSyncable() const;
|
||||||
bool canBeEdited() const;
|
bool canBeEdited() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool canBeDeleted() const;
|
bool canBeDeleted() const;
|
||||||
@ -48,9 +49,7 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QAction*> m_serviceMenu;
|
|
||||||
GmailNetworkFactory* m_network;
|
GmailNetworkFactory* m_network;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void GmailServiceRoot::setNetwork(GmailNetworkFactory* network) {
|
inline void GmailServiceRoot::setNetwork(GmailNetworkFactory* network) {
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
#include "services/gmail/gui/emailrecipientcontrol.h"
|
#include "services/gmail/gui/emailrecipientcontrol.h"
|
||||||
#include "services/gmail/network/gmailnetworkfactory.h"
|
#include "services/gmail/network/gmailnetworkfactory.h"
|
||||||
|
|
||||||
FormAddEditEmail::FormAddEditEmail(GmailServiceRoot* root, QWidget* parent) : QDialog(parent), m_root(root) {
|
FormAddEditEmail::FormAddEditEmail(GmailServiceRoot* root, QWidget* parent)
|
||||||
|
: QDialog(parent), m_root(root), m_originalMessage(nullptr) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("mail-message-new")));
|
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("mail-message-new")));
|
||||||
@ -39,6 +40,14 @@ void FormAddEditEmail::execForAdd() {
|
|||||||
exec();
|
exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormAddEditEmail::execForReply(Message* original_message) {
|
||||||
|
m_originalMessage = original_message;
|
||||||
|
|
||||||
|
addRecipientRow(m_originalMessage->m_author);
|
||||||
|
m_ui.m_txtSubject->setText(QSL("Re:%1").arg(m_originalMessage->m_title));
|
||||||
|
exec();
|
||||||
|
}
|
||||||
|
|
||||||
void FormAddEditEmail::removeRecipientRow() {
|
void FormAddEditEmail::removeRecipientRow() {
|
||||||
auto* sndr = static_cast<EmailRecipientControl*>(sender());
|
auto* sndr = static_cast<EmailRecipientControl*>(sender());
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ class FormAddEditEmail : public QDialog {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void execForAdd();
|
void execForAdd();
|
||||||
|
void execForReply(Message* original_message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void removeRecipientRow();
|
void removeRecipientRow();
|
||||||
|
@ -82,6 +82,10 @@ void InoreaderServiceRoot::saveAccountDataToDatabase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InoreaderServiceRoot::isSyncable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool InoreaderServiceRoot::canBeEdited() const {
|
bool InoreaderServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -119,17 +123,6 @@ void InoreaderServiceRoot::stop() {
|
|||||||
saveCacheToFile(accountId());
|
saveCacheToFile(accountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> InoreaderServiceRoot::serviceMenu() {
|
|
||||||
if (m_serviceMenu.isEmpty()) {
|
|
||||||
QAction* act_sync_in = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Sync in"), this);
|
|
||||||
|
|
||||||
connect(act_sync_in, &QAction::triggered, this, &InoreaderServiceRoot::syncIn);
|
|
||||||
m_serviceMenu.append(act_sync_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_serviceMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString InoreaderServiceRoot::code() const {
|
QString InoreaderServiceRoot::code() const {
|
||||||
return InoreaderEntryPoint().code();
|
return InoreaderEntryPoint().code();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
void setNetwork(InoreaderNetworkFactory* network);
|
void setNetwork(InoreaderNetworkFactory* network);
|
||||||
InoreaderNetworkFactory* network() const;
|
InoreaderNetworkFactory* network() const;
|
||||||
|
|
||||||
|
bool isSyncable() const;
|
||||||
bool canBeEdited() const;
|
bool canBeEdited() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool canBeDeleted() const;
|
bool canBeDeleted() const;
|
||||||
@ -43,10 +44,8 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
QList<QAction*> serviceMenu();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QAction*> m_serviceMenu;
|
|
||||||
InoreaderNetworkFactory* m_network;
|
InoreaderNetworkFactory* m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "services/owncloud/owncloudserviceentrypoint.h"
|
#include "services/owncloud/owncloudserviceentrypoint.h"
|
||||||
|
|
||||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem* parent)
|
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem* parent)
|
||||||
: ServiceRoot(parent), m_actionSyncIn(nullptr), m_network(new OwnCloudNetworkFactory()) {
|
: ServiceRoot(parent), m_network(new OwnCloudNetworkFactory()) {
|
||||||
setIcon(OwnCloudServiceEntryPoint().icon());
|
setIcon(OwnCloudServiceEntryPoint().icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +25,10 @@ OwnCloudServiceRoot::~OwnCloudServiceRoot() {
|
|||||||
delete m_network;
|
delete m_network;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OwnCloudServiceRoot::isSyncable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool OwnCloudServiceRoot::canBeEdited() const {
|
bool OwnCloudServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -59,16 +63,6 @@ bool OwnCloudServiceRoot::supportsCategoryAdding() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> OwnCloudServiceRoot::serviceMenu() {
|
|
||||||
if (m_serviceMenu.isEmpty()) {
|
|
||||||
m_actionSyncIn = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Sync in"), this);
|
|
||||||
connect(m_actionSyncIn, &QAction::triggered, this, &OwnCloudServiceRoot::syncIn);
|
|
||||||
m_serviceMenu.append(m_actionSyncIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_serviceMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OwnCloudServiceRoot::start(bool freshly_activated) {
|
void OwnCloudServiceRoot::start(bool freshly_activated) {
|
||||||
Q_UNUSED(freshly_activated)
|
Q_UNUSED(freshly_activated)
|
||||||
loadFromDatabase();
|
loadFromDatabase();
|
||||||
|
@ -18,13 +18,13 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
explicit OwnCloudServiceRoot(RootItem* parent = nullptr);
|
explicit OwnCloudServiceRoot(RootItem* parent = nullptr);
|
||||||
virtual ~OwnCloudServiceRoot();
|
virtual ~OwnCloudServiceRoot();
|
||||||
|
|
||||||
|
bool isSyncable() const;
|
||||||
bool canBeEdited() const;
|
bool canBeEdited() const;
|
||||||
bool canBeDeleted() const;
|
bool canBeDeleted() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
bool supportsFeedAdding() const;
|
bool supportsFeedAdding() const;
|
||||||
bool supportsCategoryAdding() const;
|
bool supportsCategoryAdding() const;
|
||||||
QList<QAction*> serviceMenu();
|
|
||||||
|
|
||||||
void start(bool freshly_activated);
|
void start(bool freshly_activated);
|
||||||
void stop();
|
void stop();
|
||||||
@ -42,12 +42,8 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem* obtainNewTreeForSyncIn() const;
|
RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
|
|
||||||
QAction* m_actionSyncIn;
|
|
||||||
|
|
||||||
QList<QAction*> m_serviceMenu;
|
|
||||||
OwnCloudNetworkFactory* m_network;
|
OwnCloudNetworkFactory* m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ StandardServiceRoot* StandardFeed::serviceRoot() const {
|
|||||||
|
|
||||||
bool StandardFeed::editViaGui() {
|
bool StandardFeed::editViaGui() {
|
||||||
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(serviceRoot(), qApp->mainFormWidget()));
|
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(serviceRoot(), qApp->mainFormWidget()));
|
||||||
|
|
||||||
form_pointer.data()->addEditFeed(this, nullptr);
|
form_pointer.data()->addEditFeed(this, nullptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ QString StandardFeed::typeToString(StandardFeed::Type type) {
|
|||||||
void StandardFeed::fetchMetadataForItself() {
|
void StandardFeed::fetchMetadataForItself() {
|
||||||
QPair<StandardFeed*, QNetworkReply::NetworkError> metadata = guessFeed(url(), username(), password());
|
QPair<StandardFeed*, QNetworkReply::NetworkError> metadata = guessFeed(url(), username(), password());
|
||||||
|
|
||||||
if (metadata.first != nullptr && metadata.second == QNetworkReply::NoError) {
|
if (metadata.first != nullptr && metadata.second == QNetworkReply::NetworkError::NoError) {
|
||||||
// Some properties are not updated when new metadata are fetched.
|
// Some properties are not updated when new metadata are fetched.
|
||||||
metadata.first->setParent(parent());
|
metadata.first->setParent(parent());
|
||||||
metadata.first->setUrl(url());
|
metadata.first->setUrl(url());
|
||||||
@ -138,10 +139,11 @@ QPair<StandardFeed*, QNetworkReply::NetworkError> StandardFeed::guessFeed(const
|
|||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& password) {
|
const QString& password) {
|
||||||
QPair<StandardFeed*, QNetworkReply::NetworkError> result;
|
QPair<StandardFeed*, QNetworkReply::NetworkError> result;
|
||||||
|
|
||||||
result.first = nullptr;
|
result.first = nullptr;
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
|
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
|
||||||
headers << NetworkFactory::generateBasicAuthHeader(username, password);
|
headers << NetworkFactory::generateBasicAuthHeader(username, password);
|
||||||
|
|
||||||
NetworkResult network_result = NetworkFactory::performNetworkOperation(url,
|
NetworkResult network_result = NetworkFactory::performNetworkOperation(url,
|
||||||
@ -208,8 +210,8 @@ QPair<StandardFeed*, QNetworkReply::NetworkError> StandardFeed::guessFeed(const
|
|||||||
|
|
||||||
QDomElement root_element = xml_document.documentElement();
|
QDomElement root_element = xml_document.documentElement();
|
||||||
QString root_tag_name = root_element.tagName();
|
QString root_tag_name = root_element.tagName();
|
||||||
|
|
||||||
QList<QString> icon_possible_locations;
|
QList<QString> icon_possible_locations;
|
||||||
|
|
||||||
icon_possible_locations.append(url);
|
icon_possible_locations.append(url);
|
||||||
|
|
||||||
if (root_tag_name == QL1S("rdf:RDF")) {
|
if (root_tag_name == QL1S("rdf:RDF")) {
|
||||||
@ -308,8 +310,8 @@ bool StandardFeed::addItself(RootItem* parent) {
|
|||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
bool ok;
|
bool ok;
|
||||||
int new_id = DatabaseQueries::addStandardFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(),
|
int new_id = DatabaseQueries::addStandardFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(),
|
||||||
description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
|
description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
|
||||||
username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);
|
username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// Query failed.
|
// Query failed.
|
||||||
@ -329,12 +331,13 @@ bool StandardFeed::editItself(StandardFeed* new_feed_data) {
|
|||||||
RootItem* new_parent = new_feed_data->parent();
|
RootItem* new_parent = new_feed_data->parent();
|
||||||
|
|
||||||
if (!DatabaseQueries::editStandardFeed(database, new_parent->id(), original_feed->id(), new_feed_data->title(),
|
if (!DatabaseQueries::editStandardFeed(database, new_parent->id(), original_feed->id(), new_feed_data->title(),
|
||||||
new_feed_data->description(), new_feed_data->icon(),
|
new_feed_data->description(), new_feed_data->icon(),
|
||||||
new_feed_data->encoding(), new_feed_data->url(), new_feed_data->passwordProtected(),
|
new_feed_data->encoding(), new_feed_data->url(), new_feed_data->passwordProtected(),
|
||||||
new_feed_data->username(), new_feed_data->password(),
|
new_feed_data->username(), new_feed_data->password(),
|
||||||
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
||||||
new_feed_data->type())) {
|
new_feed_data->type())) {
|
||||||
// Persistent storage update failed, no way to continue now.
|
// Persistent storage update failed, no way to continue now.
|
||||||
|
qWarning("Self-editing of standard feed failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,8 +402,8 @@ void StandardFeed::setEncoding(const QString& encoding) {
|
|||||||
QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
|
||||||
headers << NetworkFactory::generateBasicAuthHeader(username(), password());
|
headers << NetworkFactory::generateBasicAuthHeader(username(), password());
|
||||||
|
|
||||||
m_networkError = NetworkFactory::performNetworkOperation(url(),
|
m_networkError = NetworkFactory::performNetworkOperation(url(),
|
||||||
|
@ -27,15 +27,13 @@
|
|||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
|
||||||
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
||||||
: ServiceRoot(parent),
|
: ServiceRoot(parent) {
|
||||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_actionFeedFetchMetadata(nullptr) {
|
|
||||||
setTitle(qApp->system()->loggedInUser() + QSL(" (RSS/RDF/ATOM)"));
|
setTitle(qApp->system()->loggedInUser() + QSL(" (RSS/RDF/ATOM)"));
|
||||||
setIcon(StandardServiceEntryPoint().icon());
|
setIcon(StandardServiceEntryPoint().icon());
|
||||||
setDescription(tr("This is obligatory service account for standard RSS/RDF/ATOM feeds."));
|
setDescription(tr("This is obligatory service account for standard RSS/RDF/ATOM feeds."));
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardServiceRoot::~StandardServiceRoot() {
|
StandardServiceRoot::~StandardServiceRoot() {
|
||||||
qDeleteAll(m_serviceMenu);
|
|
||||||
qDeleteAll(m_feedContextMenu);
|
qDeleteAll(m_feedContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,13 +174,19 @@ void StandardServiceRoot::checkArgumentForFeedAdding(const QString& argument) {
|
|||||||
QList<QAction*> StandardServiceRoot::getContextMenuForFeed(StandardFeed* feed) {
|
QList<QAction*> StandardServiceRoot::getContextMenuForFeed(StandardFeed* feed) {
|
||||||
if (m_feedContextMenu.isEmpty()) {
|
if (m_feedContextMenu.isEmpty()) {
|
||||||
// Initialize.
|
// Initialize.
|
||||||
m_actionFeedFetchMetadata = new QAction(qApp->icons()->fromTheme(QSL("emblem-downloads")), tr("Fetch metadata"), nullptr);
|
auto* action_metadata = new QAction(qApp->icons()->fromTheme(QSL("emblem-downloads")),
|
||||||
m_feedContextMenu.append(m_actionFeedFetchMetadata);
|
tr("Fetch metadata"),
|
||||||
|
this);
|
||||||
|
|
||||||
|
m_feedContextMenu.append(action_metadata);
|
||||||
|
|
||||||
|
connect(action_metadata, &QAction::triggered, this, [this]() {
|
||||||
|
m_feedForMetadata->fetchMetadataForItself();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make connections.
|
m_feedForMetadata = feed;
|
||||||
disconnect(m_actionFeedFetchMetadata, &QAction::triggered, nullptr, nullptr);
|
|
||||||
connect(m_actionFeedFetchMetadata, &QAction::triggered, feed, &StandardFeed::fetchMetadataForItself);
|
|
||||||
return m_feedContextMenu;
|
return m_feedContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,12 +310,16 @@ void StandardServiceRoot::exportFeeds() {
|
|||||||
|
|
||||||
QList<QAction*> StandardServiceRoot::serviceMenu() {
|
QList<QAction*> StandardServiceRoot::serviceMenu() {
|
||||||
if (m_serviceMenu.isEmpty()) {
|
if (m_serviceMenu.isEmpty()) {
|
||||||
m_actionExportFeeds = new QAction(qApp->icons()->fromTheme("document-export"), tr("Export feeds"), this);
|
ServiceRoot::serviceMenu();
|
||||||
m_actionImportFeeds = new QAction(qApp->icons()->fromTheme("document-import"), tr("Import feeds"), this);
|
|
||||||
connect(m_actionExportFeeds, &QAction::triggered, this, &StandardServiceRoot::exportFeeds);
|
auto* action_export_feeds = new QAction(qApp->icons()->fromTheme("document-export"), tr("Export feeds"), this);
|
||||||
connect(m_actionImportFeeds, &QAction::triggered, this, &StandardServiceRoot::importFeeds);
|
auto* action_import_feeds = new QAction(qApp->icons()->fromTheme("document-import"), tr("Import feeds"), this);
|
||||||
m_serviceMenu.append(m_actionExportFeeds);
|
|
||||||
m_serviceMenu.append(m_actionImportFeeds);
|
connect(action_export_feeds, &QAction::triggered, this, &StandardServiceRoot::exportFeeds);
|
||||||
|
connect(action_import_feeds, &QAction::triggered, this, &StandardServiceRoot::importFeeds);
|
||||||
|
|
||||||
|
m_serviceMenu.append(action_export_feeds);
|
||||||
|
m_serviceMenu.append(action_import_feeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_serviceMenu;
|
return m_serviceMenu;
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
|
#include "services/standard/standardfeed.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
class StandardCategory;
|
class StandardCategory;
|
||||||
class StandardFeed;
|
|
||||||
class FeedsImportExportModel;
|
class FeedsImportExportModel;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
|
||||||
@ -58,12 +59,8 @@ class StandardServiceRoot : public ServiceRoot {
|
|||||||
QString processFeedUrl(const QString& feed_url);
|
QString processFeedUrl(const QString& feed_url);
|
||||||
void checkArgumentsForFeedAdding();
|
void checkArgumentsForFeedAdding();
|
||||||
|
|
||||||
QAction* m_actionExportFeeds;
|
QPointer<StandardFeed> m_feedForMetadata = {};
|
||||||
QAction* m_actionImportFeeds;
|
QList<QAction*> m_feedContextMenu = {};
|
||||||
|
|
||||||
QList<QAction*> m_serviceMenu;
|
|
||||||
QList<QAction*> m_feedContextMenu;
|
|
||||||
QAction* m_actionFeedFetchMetadata;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STANDARDSERVICEROOT_H
|
#endif // STANDARDSERVICEROOT_H
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
|
|
||||||
TtRssServiceRoot::TtRssServiceRoot(RootItem* parent)
|
TtRssServiceRoot::TtRssServiceRoot(RootItem* parent)
|
||||||
: ServiceRoot(parent), m_actionSyncIn(nullptr), m_network(new TtRssNetworkFactory()) {
|
: ServiceRoot(parent), m_network(new TtRssNetworkFactory()) {
|
||||||
setIcon(TtRssServiceEntryPoint().icon());
|
setIcon(TtRssServiceEntryPoint().icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +52,10 @@ QString TtRssServiceRoot::code() const {
|
|||||||
return TtRssServiceEntryPoint().code();
|
return TtRssServiceEntryPoint().code();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TtRssServiceRoot::isSyncable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TtRssServiceRoot::editViaGui() {
|
bool TtRssServiceRoot::editViaGui() {
|
||||||
QScopedPointer<FormEditTtRssAccount> form_pointer(new FormEditTtRssAccount(qApp->mainFormWidget()));
|
QScopedPointer<FormEditTtRssAccount> form_pointer(new FormEditTtRssAccount(qApp->mainFormWidget()));
|
||||||
|
|
||||||
@ -148,16 +152,6 @@ void TtRssServiceRoot::saveAllCachedData(bool async) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> TtRssServiceRoot::serviceMenu() {
|
|
||||||
if (m_serviceMenu.isEmpty()) {
|
|
||||||
m_actionSyncIn = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Sync in"), this);
|
|
||||||
connect(m_actionSyncIn, &QAction::triggered, this, &TtRssServiceRoot::syncIn);
|
|
||||||
m_serviceMenu.append(m_actionSyncIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_serviceMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TtRssServiceRoot::additionalTooltip() const {
|
QString TtRssServiceRoot::additionalTooltip() const {
|
||||||
return tr("Username: %1\nServer: %2\n"
|
return tr("Username: %1\nServer: %2\n"
|
||||||
"Last error: %3\nLast login on: %4").arg(m_network->username(),
|
"Last error: %3\nLast login on: %4").arg(m_network->username(),
|
||||||
|
@ -22,13 +22,14 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
void start(bool freshly_activated);
|
void start(bool freshly_activated);
|
||||||
void stop();
|
void stop();
|
||||||
QString code() const;
|
QString code() const;
|
||||||
|
|
||||||
|
bool isSyncable() const;
|
||||||
bool canBeEdited() const;
|
bool canBeEdited() const;
|
||||||
bool canBeDeleted() const;
|
bool canBeDeleted() const;
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
bool supportsFeedAdding() const;
|
bool supportsFeedAdding() const;
|
||||||
bool supportsCategoryAdding() const;
|
bool supportsCategoryAdding() const;
|
||||||
QList<QAction*> serviceMenu();
|
|
||||||
|
|
||||||
QString additionalTooltip() const;
|
QString additionalTooltip() const;
|
||||||
|
|
||||||
@ -46,12 +47,8 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RootItem* obtainNewTreeForSyncIn() const;
|
RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
|
|
||||||
QAction* m_actionSyncIn;
|
|
||||||
|
|
||||||
QList<QAction*> m_serviceMenu;
|
|
||||||
TtRssNetworkFactory* m_network;
|
TtRssNetworkFactory* m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user