diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 2f2cc28ae..9249df650 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -499,6 +499,16 @@ QList FeedsModel::serviceRoots() { return roots; } +bool FeedsModel::containsServiceRootFromEntryPoint(ServiceEntryPoint *point) { + foreach (RootItem *root, serviceRoots()) { + if (root->toServiceRoot()->code() == point->code()) { + return true; + } + } + + return false; +} + StandardServiceRoot *FeedsModel::standardServiceRoot() { foreach (RootItem *root, serviceRoots()) { StandardServiceRoot *std_service_root; diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 9a1ffb40c..d99ce010f 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -28,6 +28,7 @@ class DatabaseCleaner; class Category; class Feed; class ServiceRoot; +class ServiceEntryPoint; class StandardServiceRoot; class QTimer; @@ -85,6 +86,9 @@ class FeedsModel : public QAbstractItemModel { // the model root item. QList serviceRoots(); + // Determines if there is any account activated from given entry point. + bool containsServiceRootFromEntryPoint(ServiceEntryPoint *point); + // Direct and the only global accessor to standard service root. // NOTE: Standard service root is always activated. StandardServiceRoot *standardServiceRoot(); diff --git a/src/definitions/definitions.h.in b/src/definitions/definitions.h.in index c2249bbed..f084a00d9 100755 --- a/src/definitions/definitions.h.in +++ b/src/definitions/definitions.h.in @@ -38,6 +38,9 @@ #define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@") #define APP_DONATE_URL "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XMWPLPK893VH4" +#define SERVICE_CODE_STD_RSS "std-rss" +#define SERVICE_CODE_TT_RSS "tt-rss" + #define ENCLOSURES_OUTER_SEPARATOR '#' #define ECNLOSURES_INNER_SEPARATOR '&' #define URI_SCHEME_FEED "feed://" diff --git a/src/gui/dialogs/formaddaccount.cpp b/src/gui/dialogs/formaddaccount.cpp index e72c44400..1feefac7f 100755 --- a/src/gui/dialogs/formaddaccount.cpp +++ b/src/gui/dialogs/formaddaccount.cpp @@ -20,7 +20,7 @@ #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" #include "core/feedsmodel.h" - +#include "services/standard/standardserviceentrypoint.h" #if defined(Q_OS_OS2) #include "gui/messagebox.h" @@ -52,14 +52,24 @@ void FormAddAccount::displayActiveEntryPointDetails() { if (!selected_items.isEmpty()) { ServiceEntryPoint *point = static_cast(selected_items.at(0)->data(Qt::UserRole).value()); + + m_ui->m_txtAuthor->setText(point->author()); + m_ui->m_txtDescription->setText(point->description()); + m_ui->m_txtName->setText(point->name()); + m_ui->m_txtVersion->setText(point->version()); } } void FormAddAccount::loadEntryPoints() { foreach (ServiceEntryPoint *entry_point, m_entryPoints) { QListWidgetItem *item = new QListWidgetItem(entry_point->icon(), entry_point->name(), m_ui->m_listEntryPoints); - item->setData(Qt::UserRole, QVariant::fromValue((void*) entry_point)); + if (entry_point->isSingleInstanceService() && m_model->containsServiceRootFromEntryPoint(entry_point)) { + // Oops, this item cannot be added, it is single instance and is already added. + item->setFlags(Qt::NoItemFlags); + } } + + m_ui->m_listEntryPoints->setCurrentRow(m_entryPoints.size() - 1); } diff --git a/src/gui/dialogs/formaddaccount.ui b/src/gui/dialogs/formaddaccount.ui index 266532bd8..67026a6b3 100755 --- a/src/gui/dialogs/formaddaccount.ui +++ b/src/gui/dialogs/formaddaccount.ui @@ -6,8 +6,8 @@ 0 0 - 558 - 300 + 610 + 271 @@ -35,6 +35,70 @@ Details + + + + + Name + + + + + + + true + + + + + + + Version + + + + + + + true + + + + + + + Author + + + + + + + true + + + + + + + Description + + + + + + + + 0 + 1 + + + + true + + + + diff --git a/src/services/abstract/serviceentrypoint.h b/src/services/abstract/serviceentrypoint.h index 06f1bd83c..1429ceb90 100755 --- a/src/services/abstract/serviceentrypoint.h +++ b/src/services/abstract/serviceentrypoint.h @@ -44,12 +44,13 @@ class ServiceEntryPoint { // which operates with normal RSS/ATOM feeds. virtual bool isSingleInstanceService() = 0; - // Can properties of this service account be edited by user via GUI? - virtual bool canBeEdited() = 0; - // Human readable service name, for example "TT-RSS". virtual QString name() = 0; + // Some arbitrary string. + // NOTE: Keep in sync with ServiceRoot::code(). + virtual QString code() = 0; + // Human readable service description, for example "Services which offers TT-RSS integration.". virtual QString description() = 0; diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h index 34d30bd61..d335020de 100755 --- a/src/services/abstract/serviceroot.h +++ b/src/services/abstract/serviceroot.h @@ -64,6 +64,8 @@ class ServiceRoot : public RootItem { virtual void start() = 0; virtual void stop() = 0; + virtual QString code() = 0; + // This method should prepare messages for given "item" (download them maybe?) // into predefined "Messages" table // and then use method QSqlTableModel::setFilter(....). diff --git a/src/services/standard/standardserviceentrypoint.cpp b/src/services/standard/standardserviceentrypoint.cpp index e42076b30..b71298520 100755 --- a/src/services/standard/standardserviceentrypoint.cpp +++ b/src/services/standard/standardserviceentrypoint.cpp @@ -33,12 +33,8 @@ bool StandardServiceEntryPoint::isSingleInstanceService() { return true; } -bool StandardServiceEntryPoint::canBeEdited() { - return false; -} - QString StandardServiceEntryPoint::name() { - return QSL("Standard (RSS/RDF/ATOM)"); + return QSL("Standard online feeds (RSS/RDF/ATOM)"); } QString StandardServiceEntryPoint::description() { @@ -57,6 +53,10 @@ QIcon StandardServiceEntryPoint::icon() { return QIcon(APP_ICON_PATH); } +QString StandardServiceEntryPoint::code() { + return SERVICE_CODE_STD_RSS; +} + QList StandardServiceEntryPoint::initializeSubtree(FeedsModel *main_model) { StandardServiceRoot *root = new StandardServiceRoot(true, main_model); QList roots; diff --git a/src/services/standard/standardserviceentrypoint.h b/src/services/standard/standardserviceentrypoint.h index 0a719413f..088ff7294 100755 --- a/src/services/standard/standardserviceentrypoint.h +++ b/src/services/standard/standardserviceentrypoint.h @@ -27,12 +27,12 @@ class StandardServiceEntryPoint : public ServiceEntryPoint { virtual ~StandardServiceEntryPoint(); bool isSingleInstanceService(); - bool canBeEdited(); QString name(); QString description(); QString version(); QString author(); QIcon icon(); + QString code(); QList initializeSubtree(FeedsModel *main_model); }; diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 1af194217..3c6d63bb5 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -101,6 +101,10 @@ void StandardServiceRoot::stop() { qDebug("Stopping StandardServiceRoot instance."); } +QString StandardServiceRoot::code() { + return SERVICE_CODE_STD_RSS; +} + bool StandardServiceRoot::canBeEdited() { return false; } diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 2cf81b1ba..18945401b 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -47,6 +47,8 @@ class StandardServiceRoot : public ServiceRoot { void start(); void stop(); + QString code(); + bool canBeEdited(); bool canBeDeleted(); bool deleteViaGui(); diff --git a/src/services/tt-rss/ttrssserviceentrypoint.cpp b/src/services/tt-rss/ttrssserviceentrypoint.cpp index da2b7d854..28d1c2920 100755 --- a/src/services/tt-rss/ttrssserviceentrypoint.cpp +++ b/src/services/tt-rss/ttrssserviceentrypoint.cpp @@ -19,6 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/application.h" +#include "miscellaneous/iconfactory.h" TtRssServiceEntryPoint::TtRssServiceEntryPoint(){ @@ -33,20 +34,16 @@ bool TtRssServiceEntryPoint::isSingleInstanceService() { return false; } -bool TtRssServiceEntryPoint::canBeEdited() { - return true; -} - QString TtRssServiceEntryPoint::name() { - return QSL("TT-RSS (TinyTiny RSS)"); + return QSL("Tiny Tiny RSS"); } QString TtRssServiceEntryPoint::description() { - return QSL("This service offers integration with TinyTiny RSS."); + return QSL("This service offers integration with Tiny Tiny RSS.\n\nTiny Tiny RSS is an open source web-based news feed (RSS/Atom) reader and aggregator, designed to allow you to read news from any location, while feeling as close to a real desktop application as possible."); } QString TtRssServiceEntryPoint::version() { - return QSL("0.0.1"); + return QSL("0.0.2"); } QString TtRssServiceEntryPoint::author() { @@ -54,7 +51,11 @@ QString TtRssServiceEntryPoint::author() { } QIcon TtRssServiceEntryPoint::icon() { - return QIcon(APP_ICON_PATH); + return qApp->icons()->fromTheme(QSL("application-ttrss")); +} + +QString TtRssServiceEntryPoint::code() { + return SERVICE_CODE_TT_RSS; } QList TtRssServiceEntryPoint::initializeSubtree(FeedsModel *main_model) { diff --git a/src/services/tt-rss/ttrssserviceentrypoint.h b/src/services/tt-rss/ttrssserviceentrypoint.h index 6d04cf4d0..478f9c801 100755 --- a/src/services/tt-rss/ttrssserviceentrypoint.h +++ b/src/services/tt-rss/ttrssserviceentrypoint.h @@ -28,12 +28,12 @@ class TtRssServiceEntryPoint : public ServiceEntryPoint { virtual ~TtRssServiceEntryPoint(); bool isSingleInstanceService(); - bool canBeEdited(); QString name(); QString description(); QString version(); QString author(); QIcon icon(); + QString code(); QList initializeSubtree(FeedsModel *main_model); }; diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 8efae22ec..2654f6524 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -33,6 +33,10 @@ TtRssServiceRoot::TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent) : TtRssServiceRoot::~TtRssServiceRoot() { } +QString TtRssServiceRoot::code() { + return SERVICE_CODE_TT_RSS; +} + bool TtRssServiceRoot::editViaGui() { return false; } diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index 617d9a6da..68d0e4f3a 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -32,6 +32,8 @@ class TtRssServiceRoot : public ServiceRoot { explicit TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); virtual ~TtRssServiceRoot(); + QString code(); + bool canBeEdited(); bool canBeDeleted(); bool editViaGui();