| 1 | /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 | |
| 3 | This file is part of Dekko email client for Ubuntu devices |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU General Public License as |
| 7 | published by the Free Software Foundation; either version 2 of |
| 8 | the License or (at your option) version 3 |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | #ifndef MESSAGEFILTERCOLLECTION_H |
| 19 | #define MESSAGEFILTERCOLLECTION_H |
| 20 | |
| 21 | #include <QObject> |
| 22 | #include <QmlObjectListModel.h> |
| 23 | #include "MessageSet.h" |
| 24 | |
| 25 | // This component create a list of message sets based on some predefined criteria |
| 26 | class MessageFilterCollection : public QObject |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | Q_PROPERTY(QObject *children READ children NOTIFY childrenChanged) |
| 30 | Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged) |
| 31 | |
| 32 | Q_ENUMS(Filter) |
| 33 | public: |
| 34 | explicit MessageFilterCollection(QObject *parent = 0); |
| 35 | |
| 36 | enum Filter { |
| 37 | None, |
| 38 | // Creates a list of merged standard folders |
| 39 | // The StandardFolderSet has a childAccounts list model that can be used to select |
| 40 | // a specific account inbox. |
| 41 | StandardFolders, |
| 42 | // Creates a list of smart folders. |
| 43 | // Defaults are Todo, Done, Today and Custom smart folders |
| 44 | SmartFolders |
| 45 | }; |
| 46 | |
| 47 | QObject *children() { return m_children; } |
| 48 | |
| 49 | Filter filter() const { return m_filter; } |
| 50 | |
| 51 | signals: |
| 52 | void filterChanged(Filter filter); |
| 53 | void childrenChanged(); |
| 54 | |
| 55 | public slots: |
| 56 | |
| 57 | void setFilter(Filter filter); |
| 58 | void reset(); |
| 59 | |
| 60 | protected: |
| 61 | void createStandardFolderCollection(); |
| 62 | void createSmartFolderCollection(); |
| 63 | |
| 64 | private: |
| 65 | QQmlObjectListModel<MessageSet> *m_children; |
| 66 | Filter m_filter; |
| 67 | bool m_firstRun; |
| 68 | }; |
| 69 | |
| 70 | #endif // MESSAGEFILTERCOLLECTION_H |