// This file is part of RSS Guard. // // Copyright (C) 2011-2015 by Martin Rotter // // RSS Guard is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // RSS Guard is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . #ifndef STANDARDSERVICEROOT_H #define STANDARDSERVICEROOT_H #include "services/abstract/serviceroot.h" #include #include class StandardRecycleBin; class StandardCategory; class StandardFeed; class FeedsImportExportModel; class QMenu; typedef QList > CategoryAssignment; typedef QPair CategoryAssignmentItem; typedef QList > FeedAssignment; typedef QPair FeedAssignmentItem; class StandardServiceRoot : public ServiceRoot { Q_OBJECT public: explicit StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent = NULL); virtual ~StandardServiceRoot(); // Start/stop root. void start(); void stop(); bool canBeEdited(); bool canBeDeleted(); QVariant data(int column, int role) const; // Return "add feed" and "add category" items. QList addItemMenu(); // Return menu to be shown in "Services -> service" menu. QList serviceMenu(); // Message stuff. bool loadMessagesForItem(RootItem *item, QSqlTableModel *model); bool onBeforeSetMessagesRead(RootItem *selected_item, QList message_db_ids, ReadStatus read); bool onAfterSetMessagesRead(RootItem *selected_item, QList message_db_ids, ReadStatus read); bool onBeforeSwitchMessageImportance(RootItem *selected_item, QList > changes); bool onAfterSwitchMessageImportance(RootItem *selected_item, QList > changes); bool onBeforeMessagesDelete(RootItem *selected_item, QList message_db_ids); bool onAfterMessagesDelete(RootItem *selected_item, QList message_db_ids); // Returns all standard categories which are lying under given root node. // This does NOT include the root node even if the node is category. QHash categoriesForItem(RootItem *root); // Returns all categories from this root, each pair // consists of ID of parent item and pointer to category. QHash allCategories(); // Returns context specific menu actions for given feed. QList getContextMenuForFeed(StandardFeed *feed); // Access to standard recycle bin. StandardRecycleBin *recycleBin() const; // Takes structure residing under given root item and adds feeds/categories from // it to active structure. // NOTE: This is used for import/export of the model. bool mergeImportExportModel(FeedsImportExportModel *model, QString &output_message); bool markFeedsReadUnread(QList items, ReadStatus read); bool markRecycleBinReadUnread(ReadStatus read); bool cleanFeeds(QList items, bool clean_read_only); public slots: void addNewCategory(); void addNewFeed(); void importFeeds(); void exportFeeds(); private: // Returns converted ids of given feeds // which are suitable as IN clause for SQL queries. QStringList textualFeedIds(const QList &feeds); void loadFromDatabase(); // Takes lists of feeds/categories and assembles // them into the tree structure. void assembleCategories(CategoryAssignment categories); void assembleFeeds(FeedAssignment feeds); StandardRecycleBin *m_recycleBin; // Menus. QAction *m_actionExportFeeds; QAction *m_actionImportFeeds; QList m_serviceMenu; QList m_addItemMenu; QList m_feedContextMenu; QAction *m_actionFeedFetchMetadata; }; #endif // STANDARDSERVICEROOT_H