src/librarycollection.h

Thu, 09 Mar 2017 12:50:14 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 09 Mar 2017 12:50:14 +0200
changeset 1209
c2723022b173
child 1210
0b3b35f560f2
permissions
-rw-r--r--

Laid groundwork for library collection support.

#pragma once
#include <QDir>
#include "main.h"

/*
 * 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:
	enum FileType
	{
		Part,
		Subpart,
		Primitive,
		HighResolutionPrimitive,
		LowResolutionPrimitive,
	};

	struct FileSpec
	{
		QString name;
		FileType type;
	};

	QString find(QString relativePath) const;
	QString find(const QString& name, FileType type) const;
	QString find(const FileSpec& spec) const;

	static const QStringList directoryNames;

private:
	class SubdirectoryNotFoundError : public std::exception {};

	struct Library
	{
		QDir path;
		QString name;

		QDir subdirectory(FileType type) const;
		static QString subdirectoryName(FileType type);
	};

	QVector<Library> m_libraries;
};

mercurial