Some preparations for #146.
This commit is contained in:
parent
e9b3b9b798
commit
3896fbd370
@ -60,11 +60,18 @@ void DiscoverFeedsButton::setFeedAddresses(const QStringList &addresses) {
|
||||
}
|
||||
|
||||
void DiscoverFeedsButton::linkTriggered(QAction *action) {
|
||||
// TODO: Obtain link and root.
|
||||
QString url = action->property("url").toString();
|
||||
ServiceRoot *root = static_cast<ServiceRoot*>(action->property("root").value<void*>());
|
||||
|
||||
root->addFeedByUrl(url);
|
||||
if (root->supportsFeedAddingByUrl()) {
|
||||
root->addFeedByUrl(url);
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(tr("Not supported"),
|
||||
tr("Give account does not support adding feeds."),
|
||||
QSystemTrayIcon::Warning,
|
||||
qApp->mainForm(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void DiscoverFeedsButton::fillMenu() {
|
||||
|
@ -19,11 +19,11 @@
|
||||
#include "network-web/adblock/adblocktreewidget.h"
|
||||
|
||||
#include "network-web/adblock/adblocksubscription.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QKeyEvent>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QInputDialog>
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ void AdBlockTreeWidget::copyFilter() {
|
||||
QTreeWidgetItem *item = currentItem();
|
||||
|
||||
if (item != NULL) {
|
||||
QApplication::clipboard()->setText(item->text(0));
|
||||
Application::clipboard()->setText(item->text(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,9 @@ class ServiceRoot : public RootItem {
|
||||
/////////////////////////////////////////
|
||||
|
||||
bool deleteViaGui();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
virtual bool supportsFeedAddingByUrl() const = 0;
|
||||
virtual void addFeedByUrl(const QString &url) = 0;
|
||||
|
||||
// Returns list of specific actions for "Add new item" main window menu.
|
||||
// So typical list of returned actions could look like:
|
||||
@ -160,6 +158,9 @@ class ServiceRoot : public RootItem {
|
||||
int accountId() const;
|
||||
void setAccountId(int account_id);
|
||||
|
||||
public slots:
|
||||
virtual void addFeedByUrl(const QString &url = QString()) = 0;
|
||||
|
||||
protected:
|
||||
// Takes lists of feeds/categories and assembles them into the tree structure.
|
||||
void assembleCategories(Assignment categories);
|
||||
|
@ -59,7 +59,7 @@ FormStandardFeedDetails::~FormStandardFeedDetails() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) {
|
||||
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url) {
|
||||
// Load categories.
|
||||
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
|
||||
|
||||
@ -90,8 +90,11 @@ int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_
|
||||
}
|
||||
}
|
||||
|
||||
if (qApp->clipboard()->mimeData()->hasText()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text());
|
||||
if (!url.isEmpty()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(url);
|
||||
}
|
||||
else if (Application::clipboard()->mimeData()->hasText()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -42,7 +42,7 @@ class FormStandardFeedDetails : public QDialog {
|
||||
|
||||
public slots:
|
||||
// Executes add/edit standard feed dialog.
|
||||
int exec(StandardFeed *input_feed, RootItem *parent_to_select);
|
||||
int exec(StandardFeed *input_feed, RootItem *parent_to_select, const QString &url = QString());
|
||||
|
||||
protected slots:
|
||||
// Applies changes.
|
||||
|
@ -130,8 +130,9 @@ bool StandardServiceRoot::supportsFeedAddingByUrl() const {
|
||||
}
|
||||
|
||||
void StandardServiceRoot::addFeedByUrl(const QString &url) {
|
||||
qApp->clipboard()->setText(url);
|
||||
addNewFeed();
|
||||
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(this, qApp->mainForm());
|
||||
form_pointer.data()->exec(NULL, NULL, url);
|
||||
delete form_pointer.data();
|
||||
}
|
||||
|
||||
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||
@ -299,8 +300,7 @@ void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
||||
|
||||
void StandardServiceRoot::checkArgumentForFeedAdding(const QString &argument) {
|
||||
if (argument.startsWith(QL1S("feed:"))) {
|
||||
qApp->clipboard()->setText(argument);
|
||||
addNewFeed();
|
||||
addFeedByUrl(argument);
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,12 +415,6 @@ void StandardServiceRoot::addNewCategory() {
|
||||
delete form_pointer.data();
|
||||
}
|
||||
|
||||
void StandardServiceRoot::addNewFeed() {
|
||||
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(this, qApp->mainForm());
|
||||
form_pointer.data()->exec(NULL, NULL);
|
||||
delete form_pointer.data();
|
||||
}
|
||||
|
||||
void StandardServiceRoot::importFeeds() {
|
||||
QPointer<FormStandardImportExport> form = new FormStandardImportExport(this, qApp->mainForm());
|
||||
form.data()->setMode(FeedsImportExportModel::Import);
|
||||
@ -452,7 +446,7 @@ QList<QAction*> StandardServiceRoot::addItemMenu() {
|
||||
connect(action_new_category, SIGNAL(triggered()), this, SLOT(addNewCategory()));
|
||||
|
||||
QAction *action_new_feed = new QAction(qApp->icons()->fromTheme("folder-feed"), tr("Add new feed"), this);
|
||||
connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addNewFeed()));
|
||||
connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addFeedByUrl()));
|
||||
|
||||
m_addItemMenu.append(action_new_category);
|
||||
m_addItemMenu.append(action_new_feed);
|
||||
|
@ -50,7 +50,6 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
bool supportsFeedAddingByUrl() const;
|
||||
void addFeedByUrl(const QString &url);
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
Qt::ItemFlags additionalFlags() const;
|
||||
@ -101,8 +100,8 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
void checkArgumentForFeedAdding(const QString &argument);
|
||||
|
||||
public slots:
|
||||
void addFeedByUrl(const QString &url = QString());
|
||||
void addNewCategory();
|
||||
void addNewFeed();
|
||||
void importFeeds();
|
||||
void exportFeeds();
|
||||
|
||||
|
@ -55,9 +55,12 @@ int FormEditFeed::execForEdit(TtRssFeed *input_feed) {
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
int FormEditFeed::execForAdd() {
|
||||
if (qApp->clipboard()->mimeData()->hasText()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text());
|
||||
int FormEditFeed::execForAdd(const QString &url) {
|
||||
if (!url.isEmpty()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(url);
|
||||
}
|
||||
else if (Application::clipboard()->mimeData()->hasText()) {
|
||||
m_ui->m_txtUrl->lineEdit()->setText(Application::clipboard()->text());
|
||||
}
|
||||
|
||||
loadCategories(m_root->getSubTreeCategories(), m_root);
|
||||
|
@ -40,7 +40,7 @@ class FormEditFeed : public QDialog {
|
||||
virtual ~FormEditFeed();
|
||||
|
||||
int execForEdit(TtRssFeed *input_feed);
|
||||
int execForAdd();
|
||||
int execForAdd(const QString &url);
|
||||
|
||||
private slots:
|
||||
void performAction();
|
||||
|
@ -114,8 +114,10 @@ bool TtRssServiceRoot::supportsFeedAddingByUrl() const {
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::addFeedByUrl(const QString &url) {
|
||||
qApp->clipboard()->setText(url);
|
||||
addNewFeed();
|
||||
QPointer<FormEditFeed> form_pointer = new FormEditFeed(this, qApp->mainForm());
|
||||
|
||||
form_pointer.data()->execForAdd(url);
|
||||
delete form_pointer.data();
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::canBeEdited() {
|
||||
@ -151,7 +153,7 @@ QVariant TtRssServiceRoot::data(int column, int role) const {
|
||||
QList<QAction*> TtRssServiceRoot::addItemMenu() {
|
||||
if (m_addItemMenu.isEmpty()) {
|
||||
QAction *action_new_feed = new QAction(qApp->icons()->fromTheme("folder-feed"), tr("Add new feed"), this);
|
||||
connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addNewFeed()));
|
||||
connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addFeedByUrl()));
|
||||
|
||||
m_addItemMenu.append(action_new_feed);
|
||||
}
|
||||
@ -605,13 +607,6 @@ void TtRssServiceRoot::syncIn() {
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::addNewFeed() {
|
||||
QPointer<FormEditFeed> form_pointer = new FormEditFeed(this, qApp->mainForm());
|
||||
|
||||
form_pointer.data()->execForAdd();
|
||||
delete form_pointer.data();
|
||||
}
|
||||
|
||||
QStringList TtRssServiceRoot::customIDsOfMessages(const QList<QPair<Message,RootItem::Importance> > &changes) {
|
||||
QStringList list;
|
||||
|
||||
|
@ -48,7 +48,6 @@ class TtRssServiceRoot : public ServiceRoot {
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
bool supportsFeedAddingByUrl() const;
|
||||
void addFeedByUrl(const QString &url);
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
|
||||
@ -86,11 +85,9 @@ class TtRssServiceRoot : public ServiceRoot {
|
||||
void completelyRemoveAllData();
|
||||
|
||||
public slots:
|
||||
void addFeedByUrl(const QString &url = QString());
|
||||
void syncIn();
|
||||
|
||||
private slots:
|
||||
void addNewFeed();
|
||||
|
||||
private:
|
||||
QStringList customIDsOfMessages(const QList<QPair<Message,Importance> > &changes);
|
||||
QStringList customIDsOfMessages(const QList<Message> &messages);
|
||||
|
Loading…
x
Reference in New Issue
Block a user