This commit is contained in:
Martin Rotter 2021-03-03 09:47:44 +01:00
parent f29ea98bbb
commit ddf5475b5f
2 changed files with 18 additions and 25 deletions

View File

@ -5,15 +5,10 @@
#include "services/abstract/category.h"
#include <QCoreApplication>
#include <QSqlRecord>
class FeedsModel;
class StandardServiceRoot;
// Base class for all categories contained in FeedsModel.
// NOTE: This class should be derived to create PARTICULAR category types.
// NOTE: This class should not be instantiated directly.
class StandardCategory : public Category {
Q_OBJECT
@ -25,16 +20,14 @@ class StandardCategory : public Category {
StandardServiceRoot* serviceRoot() const;
// Returns the actual data representation of standard category.
Qt::ItemFlags additionalFlags() const;
bool performDragDropChange(RootItem* target_item);
bool canBeEdited() const;
bool canBeDeleted() const;
bool editViaGui();
bool deleteViaGui();
virtual Qt::ItemFlags additionalFlags() const;
virtual bool performDragDropChange(RootItem* target_item);
virtual bool canBeEdited() const;
virtual bool editViaGui();
virtual bool canBeDeleted() const;
virtual bool deleteViaGui();
private:
bool removeItself();
};

View File

@ -20,6 +20,8 @@ class StandardServiceRoot;
class StandardFeed : public Feed {
Q_OBJECT
friend class StandardCategory;
public:
enum class SourceType {
Url = 0,
@ -35,16 +37,12 @@ class StandardFeed : public Feed {
Json = 4
};
// Constructors and destructors.
explicit StandardFeed(RootItem* parent_item = nullptr);
explicit StandardFeed(const StandardFeed& other);
explicit StandardFeed(const QSqlRecord& record);
virtual ~StandardFeed();
StandardServiceRoot* serviceRoot() const;
QList<QAction*> contextMenuFeedsList();
QString additionalTooltip() const;
bool canBeDeleted() const;
@ -59,8 +57,6 @@ class StandardFeed : public Feed {
Qt::ItemFlags additionalFlags() const;
bool performDragDropChange(RootItem* target_item);
bool removeItself();
// Other getters/setters.
Type type() const;
void setType(Type type);
@ -87,15 +83,11 @@ class StandardFeed : public Feed {
QList<Message> obtainNewMessages(bool* error_during_obtaining);
static QStringList prepareExecutionLine(const QString& execution_line);
static QString generateFeedFileWithScript(const QString& execution_line, int run_timeout);
static QString postProcessFeedFileWithScript(const QString& execution_line, const QString raw_feed_data, int run_timeout);
// Tries to guess feed hidden under given URL
// and uses given credentials.
// Returns pointer to guessed feed (if at least partially
// guessed) and retrieved error/status code from network layer
// or NULL feed.
// or nullptr feed.
static StandardFeed* guessFeed(SourceType source_type,
const QString& url,
const QString& post_process_script,
@ -112,6 +104,14 @@ class StandardFeed : public Feed {
void fetchMetadataForItself();
private:
StandardServiceRoot* serviceRoot() const;
bool removeItself();
static QStringList prepareExecutionLine(const QString& execution_line);
static QString generateFeedFileWithScript(const QString& execution_line, int run_timeout);
static QString postProcessFeedFileWithScript(const QString& execution_line,
const QString raw_feed_data,
int run_timeout);
static QString runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
int run_timeout, bool provide_input, const QString& input = {});