Some more changes to entry points.

This commit is contained in:
Martin Rotter 2015-11-24 10:52:53 +01:00
parent bd6c5390b4
commit cfabf56e44
8 changed files with 16 additions and 49 deletions

View File

@ -390,7 +390,7 @@ QList<ServiceRoot*> FeedsModel::serviceRoots() {
} }
StandardServiceRoot *FeedsModel::standardServiceRoot() { StandardServiceRoot *FeedsModel::standardServiceRoot() {
foreach (RootItem *root, m_rootItem->childItems()) { foreach (RootItem *root, serviceRoots()) {
StandardServiceRoot *std_service_root; StandardServiceRoot *std_service_root;
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != NULL) { if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != NULL) {

View File

@ -39,6 +39,8 @@ class FeedsModel : public QAbstractItemModel {
explicit FeedsModel(QObject *parent = 0); explicit FeedsModel(QObject *parent = 0);
virtual ~FeedsModel(); virtual ~FeedsModel();
DatabaseCleaner *databaseCleaner();
// Model implementation. // Model implementation.
inline QVariant data(const QModelIndex &index, int role) const { inline QVariant data(const QModelIndex &index, int role) const {
// Return data according to item. // Return data according to item.
@ -139,8 +141,6 @@ class FeedsModel : public QAbstractItemModel {
// Schedules all feeds from all accounts for update. // Schedules all feeds from all accounts for update.
void updateAllFeeds(); void updateAllFeeds();
DatabaseCleaner *databaseCleaner();
// Adds given service root account. // Adds given service root account.
bool addServiceAccount(ServiceRoot *root); bool addServiceAccount(ServiceRoot *root);

View File

@ -215,7 +215,19 @@ void WebBrowser::onIconChanged() {
void WebBrowser::addFeedFromWebsite(const QString &feed_link) { void WebBrowser::addFeedFromWebsite(const QString &feed_link) {
qApp->clipboard()->setText(feed_link); qApp->clipboard()->setText(feed_link);
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot()->addNewFeed();
StandardServiceRoot *service = qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot();
if (service != NULL) {
service->addNewFeed();
}
else {
qApp->showGuiMessage(tr("Cannot add feed"),
tr("You cannot add this feed to %1 because standard RSS/ATOM account is not enabled. Enable it first.").arg(APP_NAME),
QSystemTrayIcon::Warning,
qApp->mainForm(),
true);
}
} }
void WebBrowser::onTitleChanged(const QString &new_title) { void WebBrowser::onTitleChanged(const QString &new_title) {

View File

@ -39,26 +39,11 @@ class ServiceEntryPoint {
// to the global feed model. // to the global feed model.
virtual QList<ServiceRoot*> initializeSubtree(FeedsModel *main_model) = 0; virtual QList<ServiceRoot*> initializeSubtree(FeedsModel *main_model) = 0;
// Must this service account be activated by default?
// NOTE: This is true particularly for "standard" service
// which operates with normal RSS/ATOM feeds.
virtual bool isDefaultService() = 0;
// Can this service account be added just once? // Can this service account be added just once?
// NOTE: This is true particularly for "standard" service // NOTE: This is true particularly for "standard" service
// which operates with normal RSS/ATOM feeds. // which operates with normal RSS/ATOM feeds.
virtual bool isSingleInstanceService() = 0; virtual bool isSingleInstanceService() = 0;
// Can this service account be added by user via GUI?
// NOTE: This is true particularly for "standard" service
// which operates with normal RSS/ATOM feeds.
virtual bool canBeAdded() = 0;
// Can this service account by deleted by user via GUI?
// NOTE: This is false particularly for "standard" service
// which operates with normal RSS/ATOM feeds.
virtual bool canBeDeleted() = 0;
// Can properties of this service account be edited by user via GUI? // Can properties of this service account be edited by user via GUI?
virtual bool canBeEdited() = 0; virtual bool canBeEdited() = 0;

View File

@ -29,22 +29,10 @@ StandardServiceEntryPoint::StandardServiceEntryPoint() {
StandardServiceEntryPoint::~StandardServiceEntryPoint() { StandardServiceEntryPoint::~StandardServiceEntryPoint() {
} }
bool StandardServiceEntryPoint::isDefaultService() {
return true;
}
bool StandardServiceEntryPoint::isSingleInstanceService() { bool StandardServiceEntryPoint::isSingleInstanceService() {
return true; return true;
} }
bool StandardServiceEntryPoint::canBeAdded() {
return false;
}
bool StandardServiceEntryPoint::canBeDeleted() {
return false;
}
bool StandardServiceEntryPoint::canBeEdited() { bool StandardServiceEntryPoint::canBeEdited() {
return false; return false;
} }

View File

@ -26,10 +26,7 @@ class StandardServiceEntryPoint : public ServiceEntryPoint {
explicit StandardServiceEntryPoint(); explicit StandardServiceEntryPoint();
virtual ~StandardServiceEntryPoint(); virtual ~StandardServiceEntryPoint();
bool isDefaultService();
bool isSingleInstanceService(); bool isSingleInstanceService();
bool canBeAdded();
bool canBeDeleted();
bool canBeEdited(); bool canBeEdited();
QString name(); QString name();
QString description(); QString description();

View File

@ -29,22 +29,10 @@ TtRssServiceEntryPoint::~TtRssServiceEntryPoint() {
} }
bool TtRssServiceEntryPoint::isDefaultService() {
return false;
}
bool TtRssServiceEntryPoint::isSingleInstanceService() { bool TtRssServiceEntryPoint::isSingleInstanceService() {
return false; return false;
} }
bool TtRssServiceEntryPoint::canBeAdded() {
return true;
}
bool TtRssServiceEntryPoint::canBeDeleted() {
return true;
}
bool TtRssServiceEntryPoint::canBeEdited() { bool TtRssServiceEntryPoint::canBeEdited() {
return true; return true;
} }

View File

@ -27,10 +27,7 @@ class TtRssServiceEntryPoint : public ServiceEntryPoint {
explicit TtRssServiceEntryPoint(); explicit TtRssServiceEntryPoint();
virtual ~TtRssServiceEntryPoint(); virtual ~TtRssServiceEntryPoint();
bool isDefaultService();
bool isSingleInstanceService(); bool isSingleInstanceService();
bool canBeAdded();
bool canBeDeleted();
bool canBeEdited(); bool canBeEdited();
QString name(); QString name();
QString description(); QString description();