src/types/library.h

Sun, 10 Jun 2018 23:07:24 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 10 Jun 2018 23:07:24 +0300
changeset 1401
59b578c77111
parent 1326
69a90bd2dba2
permissions
-rw-r--r--

fixed bugs regarding circular primitives

1319
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 /*
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1319
diff changeset
3 * Copyright (C) 2013 - 2018 Teemu Piippo
1319
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 *
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 * (at your option) any later version.
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 *
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 * GNU General Public License for more details.
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 *
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 */
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 #include <QDataStream>
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 #include "generics/enums.h"
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 struct Library
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 {
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 QString path;
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 enum
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 {
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 ReadOnlyStorage, // for official files, etc
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 UnofficialFiles, // put downloaded files here
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 WorkingDirectory, // for editable documents
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 } role = ReadOnlyStorage;
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 bool operator==(const Library& other) const
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 {
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 return (this->path == other.path) and (this->role == other.role);
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 }
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 };
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 Q_DECLARE_METATYPE(Library)
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 using Libraries = QVector<Library>;
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 inline QDataStream& operator<<(QDataStream& out, const Library& library)
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
43 {
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
44 return out << library.path << library.role;
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 }
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47 inline QDataStream& operator>>(QDataStream &in, Library& library)
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 {
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49 return in >> library.path >> enum_cast(library.role);
39d7a9642eea reorganized headers
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
50 }

mercurial