src/libraries.h

changeset 41
0abada2a9802
parent 35
98906a94732f
child 201
5d201ee4a9c3
equal deleted inserted replaced
40:30cb5e836736 41:0abada2a9802
36 static QString libraryRoleName(const Role role); 36 static QString libraryRoleName(const Role role);
37 static bool isValidRole(const Role role); 37 static bool isValidRole(const Role role);
38 constexpr static const Role allRoles[] = {OfficialLibrary, UnofficialLibrary, WorkingLibrary}; 38 constexpr static const Role allRoles[] = {OfficialLibrary, UnofficialLibrary, WorkingLibrary};
39 }; 39 };
40 40
41 bool operator==(const Library& one, const Library& other);
42
41 Q_DECLARE_METATYPE(Library) 43 Q_DECLARE_METATYPE(Library)
42 Q_DECLARE_METATYPE(Library::Role) 44 Q_DECLARE_METATYPE(Library::Role)
43 QDataStream &operator<<(QDataStream&, const Library&); 45 QDataStream &operator<<(QDataStream&, const Library&);
44 QDataStream &operator>>(QDataStream&, Library&); 46 QDataStream &operator>>(QDataStream&, Library&);
45 47
46 using Libraries = QVector<Library>; 48 using Libraries = QVector<Library>;
47 Q_DECLARE_METATYPE(Libraries) 49 Q_DECLARE_METATYPE(Libraries)
48 50
51 class Configuration;
52
49 class LibraryManager : public QAbstractTableModel 53 class LibraryManager : public QAbstractTableModel
50 { 54 {
51 Q_OBJECT 55 Q_OBJECT
52 public: 56 public:
53 LibraryManager(QObject* parent = nullptr); 57 LibraryManager(QObject* parent = nullptr);
54 LibraryManager(QSettings* settings, QObject* parent = nullptr); 58 LibraryManager(Configuration* settings, QObject* parent = nullptr);
55 QVector<Library>::const_iterator begin() const; 59 QVector<Library>::const_iterator begin() const;
56 QVector<Library>::const_iterator end() const; 60 QVector<Library>::const_iterator end() const;
57 QString findFile(QString fileName) const; 61 QString findFile(QString fileName) const;
58 void addLibrary(const Library& library); 62 void addLibrary(const Library& library);
59 void removeLibrary(const int libraryIndex); 63 void removeLibrary(const int libraryIndex);
60 const Library& library(int libraryIndex) const; 64 const Library& library(int libraryIndex) const;
61 void setLibraryPath(int libraryIndex, const QDir& path); 65 void setLibraryPath(int libraryIndex, const QDir& path);
62 void setLibraryRole(int libraryIndex, const Library::Role role); 66 void setLibraryRole(int libraryIndex, const Library::Role role);
63 void restoreFromSettings(QSettings* settings); 67 void restoreFromSettings(Configuration* settings);
64 void storeToSettings(QSettings* settings); 68 void storeToSettings(Configuration* settings);
65 int count() const; 69 int count() const;
66 void moveLibrary(const int libraryFromIndex, const int libraryToIndex); 70 void moveLibrary(const int libraryFromIndex, const int libraryToIndex);
67 // Definitions for QAbstractTableModel 71 // Definitions for QAbstractTableModel
68 Qt::ItemFlags flags(const QModelIndex& index) const override; 72 Qt::ItemFlags flags(const QModelIndex& index) const override;
69 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 73 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;

mercurial