16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #include <QSettings> |
19 #include <QSettings> |
20 #include "libraries.h" |
20 #include "libraries.h" |
|
21 #include "configuration.h" |
21 |
22 |
22 /** |
23 /** |
23 * @brief Constructs a new library manager |
24 * @brief Constructs a new library manager |
24 * @param parent Parent object |
25 * @param parent Parent object |
25 */ |
26 */ |
31 /** |
32 /** |
32 * @brief Constructs a library manager from settings |
33 * @brief Constructs a library manager from settings |
33 * @param settings Settings to construct from |
34 * @param settings Settings to construct from |
34 * @param parent Parent object |
35 * @param parent Parent object |
35 */ |
36 */ |
36 LibraryManager::LibraryManager(QSettings* settings, QObject* parent) : |
37 LibraryManager::LibraryManager(Configuration* settings, QObject* parent) : |
37 QAbstractTableModel{parent} |
38 QAbstractTableModel{parent} |
38 { |
39 { |
39 this->restoreFromSettings(settings); |
40 this->restoreFromSettings(settings); |
40 } |
41 } |
41 |
42 |
158 /** |
159 /** |
159 * @brief Restores the libraries from the specified settings object. All unsaved |
160 * @brief Restores the libraries from the specified settings object. All unsaved |
160 * changes are lost. |
161 * changes are lost. |
161 * @param settings Settings object to restore from. |
162 * @param settings Settings object to restore from. |
162 */ |
163 */ |
163 void LibraryManager::restoreFromSettings(QSettings* settings) |
164 void LibraryManager::restoreFromSettings(Configuration* settings) |
164 { |
165 { |
165 this->libraries = settings->value("libraries").value<Libraries>(); |
166 this->libraries = settings->libraries(); |
166 } |
167 } |
167 |
168 |
168 /** |
169 /** |
169 * @brief Saves the libraries to the specified settings object. |
170 * @brief Saves the libraries to the specified settings object. |
170 * @param settings Settings object to modify. |
171 * @param settings Settings object to modify. |
171 */ |
172 */ |
172 void LibraryManager::storeToSettings(QSettings* settings) |
173 void LibraryManager::storeToSettings(Configuration* settings) |
173 { |
174 { |
174 QVariant librariesValue = QVariant::fromValue(this->libraries); |
175 settings->setLibraries(this->libraries); |
175 settings->setValue("libraries", librariesValue); |
|
176 } |
176 } |
177 |
177 |
178 /** |
178 /** |
179 * @returns the amount of libraries |
179 * @returns the amount of libraries |
180 */ |
180 */ |