Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/payeeidentifier/payeeidentifierloader.h
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #ifndef PAYEEIDENTIFIERLOADER_H | 18 | #ifndef PAYEEIDENTIFIERLOADER_H | ||
19 | #define PAYEEIDENTIFIERLOADER_H | 19 | #define PAYEEIDENTIFIERLOADER_H | ||
20 | 20 | | |||
21 | #include "payeeidentifier.h" | 21 | #include "kmm_payeeidentifier_loader_export.h" | ||
22 | | ||||
23 | #include <QHash> | | |||
24 | #include <QDomElement> | | |||
25 | 22 | | |||
26 | class QAbstractItemDelegate; | 23 | class QAbstractItemDelegate; | ||
24 | class QString; | ||||
25 | class QObject; | ||||
26 | class QStringList; | ||||
27 | 27 | | |||
28 | /** | 28 | /** | ||
29 | * | 29 | * | ||
30 | * @todo Load delegates dynamically | 30 | * @todo Load delegates dynamically | ||
31 | */ | 31 | */ | ||
32 | class payeeIdentifierLoader | 32 | class KMM_PAYEEIDENTIFIER_LOADER_EXPORT payeeIdentifierLoader | ||
33 | { | 33 | { | ||
34 | public: | 34 | public: | ||
35 | payeeIdentifierLoader(); | 35 | payeeIdentifierLoader(); | ||
36 | ~payeeIdentifierLoader(); | 36 | ~payeeIdentifierLoader(); | ||
37 | 37 | | |||
38 | payeeIdentifier createPayeeIdentifier(const QString& payeeIdentifierId); | | |||
39 | payeeIdentifier createPayeeIdentifierFromXML(const QDomElement& element); | | |||
40 | | ||||
41 | /** | 38 | /** | ||
42 | * @brief Create a delegate to show/edit | 39 | * @brief Create a delegate to show/edit | ||
43 | * | 40 | * | ||
44 | * The payeeIdentifier to edit is identified by payeeIdentifierId. parent is set as parent of the created | 41 | * The payeeIdentifier to edit is identified by payeeIdentifierId. parent is set as parent of the created | ||
45 | * Delegate. | 42 | * Delegate. | ||
46 | * | 43 | * | ||
47 | * @return a pointer to a delegate or null_ptr. Caller takes ownership. | 44 | * @return a pointer to a delegate or null_ptr. Caller takes ownership. | ||
48 | */ | 45 | */ | ||
49 | QAbstractItemDelegate* createItemDelegate(const QString& payeeIdentifierId, QObject* parent = 0); | 46 | QAbstractItemDelegate* createItemDelegate(const QString& payeeIdentifierId, QObject* parent = 0); | ||
50 | 47 | | |||
51 | /** | 48 | /** | ||
52 | * @brief Test if a delegate for editing is available | 49 | * @brief Test if a delegate for editing is available | ||
53 | */ | 50 | */ | ||
54 | bool hasItemEditDelegate(const QString& payeeIdentifierId); | 51 | bool hasItemEditDelegate(const QString& payeeIdentifierId); | ||
55 | 52 | | |||
56 | /** | 53 | /** | ||
57 | * @brief List availableDelegates delegates | 54 | * @brief List availableDelegates delegates | ||
58 | * | 55 | * | ||
59 | * @return a list of payeeIdentifierIds for which a delegate exists. | 56 | * @return a list of payeeIdentifierIds for which a delegate exists. | ||
60 | * @see createItemDelegate() | 57 | * @see createItemDelegate() | ||
61 | */ | 58 | */ | ||
62 | QStringList availableDelegates(); | 59 | QStringList availableDelegates(); | ||
63 | 60 | | |||
64 | /** | | |||
65 | * @brief Human readable name of a delegate for a given payeeIdentifierId | | |||
66 | */ | | |||
67 | QString translatedDelegateName(const QString& payeeIdentifierId); | | |||
68 | | ||||
69 | /** I take ownership */ | | |||
70 | void addPayeeIdentifier(payeeIdentifierData *const identifier); | | |||
71 | | ||||
72 | static payeeIdentifierLoader* instance() { | 61 | static payeeIdentifierLoader* instance() { | ||
73 | return &m_self; | 62 | return &m_self; | ||
74 | } | 63 | } | ||
75 | 64 | | |||
76 | private: | 65 | private: | ||
77 | QHash<QString, payeeIdentifierData*> m_identifiers; | | |||
78 | static payeeIdentifierLoader m_self; | 66 | static payeeIdentifierLoader m_self; | ||
79 | }; | 67 | }; | ||
80 | 68 | | |||
81 | #endif // PAYEEIDENTIFIERLOADER_H | 69 | #endif // PAYEEIDENTIFIERLOADER_H |