Messagelib

manager.h
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#pragma once
10
11#include "core/sortorder.h"
12#include <QList>
13#include <QMap>
14#include <QObject>
15
16#include <Akonadi/Collection>
17
18namespace MessageCore
19{
20class DateFormatter;
21}
22
23namespace MessageList
24{
25namespace Core
26{
27class Aggregation;
28class Theme;
29class StorageModel;
30class Widget;
31
32/**
33 * @brief: The manager for all the existing MessageList::Widget objects.
34 *
35 * This class is the "central" object of the whole MessageList framework.
36 * It's a singleton that can be accessed only by the means of static methods,
37 * is created automatically when the first MessageList::Widget object is created
38 * and destroyed automatically when the last MessageList::Widget object is destroyed.
39 *
40 * This class takes care of loading/storing/maintaining the settings for the
41 * whole MessageList framework. It also keeps track of all the existing
42 * MessageList::Widget objects and takes care of updating them when settings change.
43 */
44class Manager : public QObject
45{
47protected:
48 explicit Manager();
49 ~Manager() override;
50
51private:
52 static Manager *mInstance;
53 QList<Widget *> mWidgetList;
54 QMap<QString, Aggregation *> mAggregations;
56 std::unique_ptr<MessageCore::DateFormatter> mDateFormatter;
57 const QString mCachedLocalizedUnknownText;
58
59public:
60 // instance management
61 static Manager *instance()
62 {
63 return mInstance;
64 }
65
66 // widget registration
67 static void registerWidget(Widget *pWidget);
68 static void unregisterWidget(Widget *pWidget);
69
70 const MessageCore::DateFormatter *dateFormatter() const
71 {
72 return mDateFormatter.get();
73 }
74
75 const QString &cachedLocalizedUnknownText() const
76 {
77 return mCachedLocalizedUnknownText;
78 }
79
80 // aggregation sets management
81 const Aggregation *aggregationForStorageModel(const StorageModel *storageModel, bool *storageUsesPrivateAggregation);
82 const Aggregation *aggregationForStorageModel(const QString &storageModel, bool *storageUsesPrivateAggregation);
83 const Aggregation *aggregationForStorageModel(const Akonadi::Collection &storageModel, bool *storageUsesPrivateAggregation);
84
85 void saveAggregationForStorageModel(const StorageModel *storageModel, const QString &id, bool storageUsesPrivateAggregation);
86 void saveAggregationForStorageModel(const QString &index, const QString &id, bool storageUsesPrivateAggregation);
87 void saveAggregationForStorageModel(const Akonadi::Collection &col, const QString &id, bool storageUsesPrivateAggregation);
88
89 const Aggregation *defaultAggregation();
90 const Aggregation *aggregation(const QString &id);
91
92 void addAggregation(Aggregation *set);
93 void removeAllAggregations();
94
95 const QMap<QString, Aggregation *> &aggregations() const
96 {
97 return mAggregations;
98 }
99
100 /**
101 * This is called by the aggregation configuration dialog
102 * once the sets have been changed.
103 */
105
106 // sort order management
107 const SortOrder sortOrderForStorageModel(const StorageModel *storageModel, bool *storageUsesPrivateSortOrder);
108 void saveSortOrderForStorageModel(const StorageModel *storageModel, SortOrder order, bool storageUsesPrivateSortOrder);
109
110 // theme sets management
111 const Theme *themeForStorageModel(const Akonadi::Collection &col, bool *storageUsesPrivateTheme);
112 const Theme *themeForStorageModel(const StorageModel *storageModel, bool *storageUsesPrivateTheme);
113 const Theme *themeForStorageModel(const QString &id, bool *storageUsesPrivateTheme);
114
115 void saveThemeForStorageModel(const StorageModel *storageModel, const QString &id, bool storageUsesPrivateTheme);
116 void saveThemeForStorageModel(int index, const QString &id, bool storageUsesPrivateTheme);
117 void saveThemeForStorageModel(const QString &storageModelIndex, const QString &id, bool storageUsesPrivateTheme);
118
119 const Theme *defaultTheme();
120 const Theme *theme(const QString &id);
121
122 void addTheme(Theme *set);
123 void removeAllThemes();
124
125 const QMap<QString, Theme *> &themes() const
126 {
127 return mThemes;
128 }
129
130 /**
131 * This is called by the theme configuration dialog
132 * once the sets have been changed.
133 */
135
136protected Q_SLOTS:
137 /**
138 * Reloads the global configuration from the config files (so we assume it has changed)
139 * The settings private to MessageList (like Themes or Aggregations) aren't reloaded.
140 * If the global configuration has changed then all the views are reloaded.
141 */
143
144 /**
145 * Explicitly reloads the contents of all the widgets.
146 */
147 void reloadAllWidgets();
148
150 void aggregationsChanged();
151 void themesChanged();
152
153private:
154 // internal configuration stuff
155 void loadConfiguration();
156 void saveConfiguration();
157 void loadGlobalConfiguration();
158 void saveGlobalConfiguration();
159
160 // internal option set management
161 void createDefaultAggregations();
162 void createDefaultThemes();
163};
164} // namespace Core
165} // namespace MessageList
A class for abstracting date formatting.
A set of aggregation options that can be applied to the MessageList::Model in a single shot.
Definition aggregation.h:29
: The manager for all the existing MessageList::Widget objects.
Definition manager.h:45
void reloadAllWidgets()
Explicitly reloads the contents of all the widgets.
Definition manager.cpp:823
void themesConfigurationCompleted()
This is called by the theme configuration dialog once the sets have been changed.
Definition manager.cpp:811
void reloadGlobalConfiguration()
Reloads the global configuration from the config files (so we assume it has changed) The settings pri...
Definition manager.cpp:833
void aggregationsConfigurationCompleted()
This is called by the aggregation configuration dialog once the sets have been changed.
Definition manager.cpp:327
A class which holds information about sorting, e.g.
Definition sortorder.h:23
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
The Theme class defines the visual appearance of the MessageList.
Definition theme.h:48
Provides a widget which has the messagelist and the most important helper widgets,...
Definition widgetbase.h:41
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.