src/libraries.h

changeset 381
80bea7a6e84f
parent 380
16f6717a218b
equal deleted inserted replaced
380:16f6717a218b 381:80bea7a6e84f
22 #include "src/basics.h" 22 #include "src/basics.h"
23 #include "src/colors.h" 23 #include "src/colors.h"
24 24
25 class QSettings; 25 class QSettings;
26 26
27 enum class library_role_e
28 {
29 official,
30 unofficial,
31 working,
32 };
33
34 constexpr static const library_role_e all_library_roles[] =
35 {
36 library_role_e::official,
37 library_role_e::unofficial,
38 library_role_e::working
39 };
40
27 struct Library 41 struct Library
28 { 42 {
29 enum Role 43 library_role_e role;
30 {
31 OfficialLibrary,
32 UnofficialLibrary,
33 WorkingLibrary,
34 } role;
35 QDir path; 44 QDir path;
36 static QString libraryRoleName(const Role role);
37 static bool isValidRole(const Role role);
38 constexpr static const Role allRoles[] = {OfficialLibrary, UnofficialLibrary, WorkingLibrary};
39 }; 45 };
40 46
47 QString library_role_name(const library_role_e role);
41 bool operator==(const Library& one, const Library& other); 48 bool operator==(const Library& one, const Library& other);
42 49
43 Q_DECLARE_METATYPE(Library) 50 Q_DECLARE_METATYPE(Library)
44 Q_DECLARE_METATYPE(Library::Role) 51 Q_DECLARE_METATYPE(library_role_e)
45 QDataStream &operator<<(QDataStream&, const Library&); 52 QDataStream &operator<<(QDataStream&, const Library&);
46 QDataStream &operator>>(QDataStream&, Library&); 53 QDataStream &operator>>(QDataStream&, Library&);
47 using Libraries = QVector<Library>; 54 using Libraries = QVector<Library>;
48 55
49 class LibrariesModel : public QAbstractTableModel 56 class LibrariesModel : public QAbstractTableModel
56 QFileInfo findFile(QString fileName) const; 63 QFileInfo findFile(QString fileName) const;
57 void addLibrary(const Library& library); 64 void addLibrary(const Library& library);
58 void removeLibrary(const index_t libraryIndex); 65 void removeLibrary(const index_t libraryIndex);
59 const Library& library(index_t libraryIndex) const; 66 const Library& library(index_t libraryIndex) const;
60 void setLibraryPath(index_t libraryIndex, const QDir& path); 67 void setLibraryPath(index_t libraryIndex, const QDir& path);
61 void setLibraryRole(index_t libraryIndex, const Library::Role role); 68 void setLibraryRole(index_t libraryIndex, const library_role_e role);
62 void restoreFromSettings(); 69 void restoreFromSettings();
63 void storeToSettings(); 70 void storeToSettings();
64 index_t count() const; 71 index_t count() const;
65 void moveLibrary(const index_t libraryFromIndex, const index_t libraryToIndex); 72 void moveLibrary(const index_t libraryFromIndex, const index_t libraryToIndex);
66 // Definitions for QAbstractTableModel 73 // Definitions for QAbstractTableModel

mercurial