--- a/src/librarycollection.h Mon Mar 27 14:56:05 2017 +0300 +++ b/src/librarycollection.h Sun May 07 13:29:58 2017 +0300 @@ -20,8 +20,12 @@ #include <QDir> #include "main.h" -struct Library +/* + * Models an LDraw library. + */ +class Library { +public: class SubdirectoryNotFoundError : public std::exception {}; enum FileType @@ -33,18 +37,25 @@ LowResolutionPrimitive, }; - QDir path; - QString name; + Library(const QDir& path, const QString& name, bool frozen); + bool frozen() const; + QDir path() const; + QString name() const; QDir subdirectory(FileType type) const; static QString subdirectoryName(FileType type); + +private: + QDir _path; + QString _name; + bool _frozen; }; /* * Models a collection of libraries. A library is a folder containing directories named "p" and * "parts" that contains part and subpart files. */ -class LibraryCollection : public QObject, private QVector<Library> +class LibraryCollection : public QObject { Q_OBJECT using Super = QVector<Library>; @@ -56,10 +67,25 @@ Library::FileType type; }; - void addLibrary(QDir dir, QString name); + void addLibrary(QDir dir, QString name, bool frozen); QString find(QString relativePath) const; QString find(const QString& name, Library::FileType type) const; QString find(const FileSpec& spec) const; + std::vector<Library>::iterator begin(); + std::vector<Library>::iterator end(); static const QStringList directoryNames; + +private: + std::vector<Library> _libraries; }; + +#include <QAbstractTableModel> +class LibraryCollectionTableModel : public QAbstractTableModel +{ +public: + LibraryCollectionTableModel(LibraryCollection& collection, QObject* parent = nullptr); + +private: + LibraryCollection& _collection; +};