src/libraries.cpp

changeset 41
0abada2a9802
parent 35
98906a94732f
child 100
43ce3672648a
equal deleted inserted replaced
40:30cb5e836736 41:0abada2a9802
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 */
378 QDataStream& result = stream >> path >> role; 378 QDataStream& result = stream >> path >> role;
379 library.path = path; 379 library.path = path;
380 library.role = static_cast<Library::Role>(role); 380 library.role = static_cast<Library::Role>(role);
381 return result; 381 return result;
382 } 382 }
383
384 bool operator==(const Library& one, const Library& other)
385 {
386 return one.role == other.role and one.path == other.path;
387 }

mercurial