File indexing completed on 2024-05-12 05:06:13
0001 /* 0002 SPDX-FileCopyrightText: 2020 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef SELECTEDOBJECTS_H 0007 #define SELECTEDOBJECTS_H 0008 0009 #include <kmm_selections_export.h> 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Headers 0013 0014 #include <QHash> 0015 #include <QString> 0016 #include <QStringList> 0017 0018 // ---------------------------------------------------------------------------- 0019 // KDE Headers 0020 0021 // ---------------------------------------------------------------------------- 0022 // Project Headers 0023 0024 0025 class KMM_SELECTIONS_EXPORT SelectedObjects 0026 { 0027 public: 0028 typedef enum { 0029 Account, 0030 Institution, 0031 Payee, 0032 JournalEntry, 0033 Schedule, 0034 Tag, 0035 Budget, 0036 OnlineJob, 0037 Report, 0038 ReconciliationAccount, 0039 Security, 0040 } Object_t; 0041 SelectedObjects(); 0042 0043 void addSelections(Object_t type, const QStringList& ids); 0044 void addSelection(Object_t type, const QString& id); 0045 void removeSelection(Object_t type, const QString& id); 0046 void setSelection(Object_t type, const QStringList& ids); 0047 void setSelection(Object_t type, const QString& id); 0048 0049 void clearSelections(Object_t type); 0050 void clearSelections(); 0051 QStringList selection(Object_t type) const; 0052 0053 /** 0054 * This method returns the first id of the corresponding 0055 * selection set for @a type or an empty QString in 0056 * case the selection is empty. 0057 */ 0058 QString firstSelection(Object_t type) const; 0059 0060 int count(Object_t type) const; 0061 /** 0062 * Returns @c true if the selected @a type has no 0063 * selected objects, @c false otherwise. 0064 */ 0065 bool isEmpty(Object_t type) const; 0066 0067 /** 0068 * Returns @c true if no object is selected @c false otherwise. 0069 */ 0070 bool isEmpty() const; 0071 0072 bool operator!=(const SelectedObjects& right) const; 0073 0074 private: 0075 QHash<Object_t, QStringList> m_selections; 0076 }; 0077 0078 typedef QHash<SelectedObjects::Object_t, QStringList> ObjectSelections; 0079 typedef const ObjectSelections& (*selectedObjectsFunction)(); 0080 0081 #endif