Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #ifndef GUIBACKEND_HPP
10 : #define GUIBACKEND_HPP
11 :
12 : #include "treeviewmodel.hpp"
13 : #include <QObject>
14 : #include <QStringList>
15 : #include <backendbuilder.hpp>
16 :
17 : /**
18 : * @brief The GUIBackend class. It interacts with the wizard in the GUI to create new backends.
19 : */
20 :
21 0 : class GUIBackend : public QObject
22 : {
23 0 : Q_OBJECT
24 :
25 : public:
26 : /**
27 : * @brief GUIBackend The default constructor.
28 : * @param parentBackend An optional parent backend.
29 : */
30 : explicit GUIBackend (QObject * parentBackend = nullptr);
31 :
32 : /**
33 : * @brief GUIBackend The mandatory copy constructor.
34 : */
35 0 : GUIBackend (const GUIBackend & other)
36 0 : : QObject (){ Q_UNUSED (other) }
37 :
38 : /**
39 : * @brief Creates a new backend on a mountpoint.
40 : *
41 : * @param mountpoint The mountpoint of the new backend.
42 : */
43 : Q_INVOKABLE void createBackend (const QString & mountpoint);
44 :
45 : /**
46 : * @brief Add path to a backend fallback file.
47 : *
48 : * @param path The path to a backend fallback file.
49 : */
50 : Q_INVOKABLE void addPath (const QString & path);
51 :
52 : /**
53 : * @brief Add a plugin to a backend.
54 : *
55 : * @param name The name of the plugin.
56 : * @param recommended Wether to include recommended plugins.
57 : */
58 : Q_INVOKABLE void addPlugin (QString plugin, bool recommended);
59 :
60 : /**
61 : * @brief Remove a plugin from a backend.
62 : *
63 : * @param name The name of the plugin.
64 : */
65 : Q_INVOKABLE void removePlugin (QString plugin);
66 :
67 : /**
68 : * @brief Provides information about a plugin.
69 : *
70 : * @param plugin The plugin.
71 : * @return The information about the plugin.
72 : */
73 : Q_INVOKABLE QString pluginInfo (QString plugin) const;
74 :
75 : /**
76 : * @brief Returns a list of currently used mountpoints.
77 : *
78 : * @return A list of currently used mountpoints.
79 : */
80 : Q_INVOKABLE QString mountPoints () const;
81 :
82 : /**
83 : * @brief Returns a list of all currently available plugins.
84 : *
85 : * @param includeStorage Determines if storage plugins should be included in the list.
86 : * @param includeResolver Determines if resolver plugins should be included in the list.
87 : *
88 : * @return A list of all currently available plugins.
89 : */
90 : Q_INVOKABLE QStringList availablePlugins (bool includeStorage, bool includeResolver) const;
91 :
92 : /**
93 : * @brief Returns a list of all currently available namefilters.
94 : *
95 : * @return A list of all currently available namefilters.
96 : */
97 : Q_INVOKABLE QStringList nameFilters ();
98 :
99 : /**
100 : * @brief Writes the current backend permanently to storage.
101 : */
102 : Q_INVOKABLE void serialise (TreeViewModel * model);
103 :
104 : /**
105 : * @brief Returns if the current backend is validated.
106 : *
107 : * @return If the current backend is validated.
108 : */
109 : Q_INVOKABLE bool validated ();
110 :
111 : /**
112 : * @brief pluginConfigModel Contains all keys that provide additonal configuration for a plugin.
113 : * @return All keys that provide additonal configuration for a plugin.
114 : */
115 : Q_INVOKABLE TreeViewModel * pluginConfigModel () const;
116 :
117 : /**
118 : * @brief Return the already added plugins of the backend as QStringList.
119 : *
120 : * @return The already added plugins of the backend as QStringList.
121 : */
122 : Q_INVOKABLE QStringList addedPlugins () const;
123 :
124 : /**
125 : * @brief Returns if a plugin is already added to the backend.
126 : *
127 : * @param plugin The plugin
128 : * @return true if the plugin is already added to the backend
129 : */
130 : Q_INVOKABLE bool pluginAlreadyAdded (QString plugin) const;
131 :
132 : /**
133 : * @brief Returns the type of a plugin.
134 : *
135 : * @param plugin The plugin
136 : * @return The type of a plugin.
137 : */
138 : Q_INVOKABLE QString pluginType (QString plugin) const;
139 :
140 : private:
141 : QSharedPointer<kdb::tools::MountBackendBuilder> m_backend;
142 : kdb::KeySet m_mountConf;
143 : kdb::KDB m_kdb;
144 : QString m_name;
145 : TreeViewModel * m_pluginConfigModel;
146 :
147 : /**
148 : * @brief resetModel Clears the TreeViewModel that contains the keys for additional configuration for a plugin.
149 : */
150 : void resetModel ();
151 :
152 : signals:
153 : /**
154 : * @brief Triggers a messagedialog in the GUI.
155 : * @param title The title of the messagedialog in the GUI.
156 : * @param text The text of the messagedialog in the GUI.This is the text that will be initially shown to the user.
157 : * @param detailedText The detailed text of the messagedialog in the GUI.The user will have to click on a button to access this
158 : * text.
159 : */
160 : void showMessage (QString title, QString text, QString detailedText) const;
161 : };
162 :
163 : #endif // GUIBACKEND_HPP
|