Thu, 09 Mar 2017 12:50:14 +0200
Laid groundwork for library collection support.
1209
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | #pragma once |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | #include <QDir> |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
3 | #include "main.h" |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
5 | /* |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
6 | * Models a collection of libraries. A library is a folder containing directories named "p" and |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
7 | * "parts" that contains part and subpart files. |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | */ |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | class LibraryCollection |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | { |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | public: |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | enum FileType |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | { |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
14 | Part, |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | Subpart, |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | Primitive, |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | HighResolutionPrimitive, |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | LowResolutionPrimitive, |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | }; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | struct FileSpec |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | { |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | QString name; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | FileType type; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | }; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | QString find(QString relativePath) const; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
28 | QString find(const QString& name, FileType type) const; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | QString find(const FileSpec& spec) const; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | static const QStringList directoryNames; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | private: |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
34 | class SubdirectoryNotFoundError : public std::exception {}; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
35 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
36 | struct Library |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
37 | { |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
38 | QDir path; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
39 | QString name; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
40 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
41 | QDir subdirectory(FileType type) const; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
42 | static QString subdirectoryName(FileType type); |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
43 | }; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
44 | |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
45 | QVector<Library> m_libraries; |
c2723022b173
Laid groundwork for library collection support.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | }; |