1 /* LibraryManager.h */ 2 3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras) 4 * 5 * This file is part of sayonara player 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef LIBRARYMANAGER_H 22 #define LIBRARYMANAGER_H 23 24 #include "Interfaces/LibraryInfoAccessor.h" 25 26 #include "Utils/Singleton.h" 27 #include "Utils/Pimpl.h" 28 29 #include <QObject> 30 31 class LocalLibrary; 32 class LibraryPlaylistInteractor; 33 34 namespace Library 35 { 36 class Info; 37 class Manager : 38 public QObject, 39 public LibraryInfoAccessor 40 { 41 Q_OBJECT 42 PIMPL(Manager) 43 44 friend class LocalLibrary; 45 46 signals: 47 void sigPathChanged(LibraryId id); 48 void sigAdded(LibraryId id); 49 void sigRenamed(LibraryId id); 50 void sigMoved(LibraryId id, int from, int to); 51 void sigRemoved(LibraryId id); 52 53 public: 54 Manager(LibraryPlaylistInteractor* playlistInteractor); 55 ~Manager() override; 56 57 LibraryId addLibrary(const QString& name, const QString& path); 58 bool renameLibrary(LibraryId id, const QString& newName); 59 bool removeLibrary(LibraryId id); 60 bool moveLibrary(int old_row, int new_row); 61 bool changeLibraryPath(LibraryId id, const QString& newPath); 62 63 QList<Info> allLibraries() const override; 64 Info libraryInfo(LibraryId id) const override; 65 Info libraryInfoByPath(const QString& path) const override; 66 int count() const override; 67 LocalLibrary* libraryInstance(LibraryId id) override; 68 69 static QString requestLibraryName(const QString& path); 70 71 private: 72 void reset(); 73 }; 74 } 75 76 #endif // LIBRARYMANAGER_H 77