Mon, 06 Mar 2017 00:55:45 +0200
Grid is now a namespace.
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QLineEdit> |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QRadioButton> |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QCheckBox> |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1117
diff
changeset
|
22 | #include "../lddocument.h" |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
23 | #include "../mainwindow.h" |
1117
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1081
diff
changeset
|
24 | #include "../linetypes/comment.h" |
efcb47c64a72
Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents:
1081
diff
changeset
|
25 | #include "../linetypes/empty.h" |
1196
0908803938f9
NewPartDialog is no longer a HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1192
diff
changeset
|
26 | #include "../miscallenous.h" |
0908803938f9
NewPartDialog is no longer a HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1192
diff
changeset
|
27 | #include "newpartdialog.h" |
0908803938f9
NewPartDialog is no longer a HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1192
diff
changeset
|
28 | #include "ui_newpartdialog.h" |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | NewPartDialog::NewPartDialog (QWidget *parent) : |
1196
0908803938f9
NewPartDialog is no longer a HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1192
diff
changeset
|
31 | QDialog {parent}, |
0908803938f9
NewPartDialog is no longer a HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1192
diff
changeset
|
32 | ui {*new Ui_NewPart} |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | ui.setupUi (this); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
1192
317f4ce38f3f
Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents:
1187
diff
changeset
|
36 | QString authortext = configuration().defaultName(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
1192
317f4ce38f3f
Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents:
1187
diff
changeset
|
38 | if (not configuration().defaultUser().isEmpty()) |
317f4ce38f3f
Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents:
1187
diff
changeset
|
39 | authortext.append (format (" [%1]", configuration().defaultUser())); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | ui.author->setText (authortext); |
1192
317f4ce38f3f
Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents:
1187
diff
changeset
|
42 | ui.useCaLicense->setChecked (configuration().useCaLicense()); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
1197
e22cba39230a
Fixed NewPartDialog leaking the memory allocated by the user interface.
Teemu Piippo <teemu@hecknology.net>
parents:
1196
diff
changeset
|
45 | NewPartDialog::~NewPartDialog() |
e22cba39230a
Fixed NewPartDialog leaking the memory allocated by the user interface.
Teemu Piippo <teemu@hecknology.net>
parents:
1196
diff
changeset
|
46 | { |
e22cba39230a
Fixed NewPartDialog leaking the memory allocated by the user interface.
Teemu Piippo <teemu@hecknology.net>
parents:
1196
diff
changeset
|
47 | delete &ui; |
e22cba39230a
Fixed NewPartDialog leaking the memory allocated by the user interface.
Teemu Piippo <teemu@hecknology.net>
parents:
1196
diff
changeset
|
48 | } |
e22cba39230a
Fixed NewPartDialog leaking the memory allocated by the user interface.
Teemu Piippo <teemu@hecknology.net>
parents:
1196
diff
changeset
|
49 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
50 | BfcStatement NewPartDialog::getWinding() const |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | if (ui.windingCcw->isChecked()) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
53 | return BfcStatement::CertifyCCW; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | if (ui.windingCw->isChecked()) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
56 | return BfcStatement::CertifyCW; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
58 | return BfcStatement::NoCertify; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | bool NewPartDialog::useCaLicense() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | return ui.useCaLicense->isChecked(); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | QString NewPartDialog::author() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | return ui.author->text(); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | QString NewPartDialog::title() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | return ui.title->text(); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | void NewPartDialog::fillHeader (LDDocument* newdoc) const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | { |
1187
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
78 | newdoc->append<LDComment>(title()); |
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
79 | newdoc->append<LDComment>("Name: <untitled>.dat"); |
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
80 | newdoc->append<LDComment>("Author: " + author()); |
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
81 | newdoc->append<LDComment>("!LDRAW_ORG Unofficial_Part"); |
1028
5877e49e9a28
Moved PreferredLicenseText into HierarchyElement and made the config pointer be passed to LDPaths. Now I can finally remove the Config global pointer.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
82 | QString license = preferredLicenseText(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
1028
5877e49e9a28
Moved PreferredLicenseText into HierarchyElement and made the config pointer be passed to LDPaths. Now I can finally remove the Config global pointer.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
84 | if (not license.isEmpty()) |
1187
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
85 | newdoc->append<LDComment>(license); |
1028
5877e49e9a28
Moved PreferredLicenseText into HierarchyElement and made the config pointer be passed to LDPaths. Now I can finally remove the Config global pointer.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
86 | |
1187
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
87 | newdoc->append<LDEmpty>(); |
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
88 | newdoc->append<LDBfc>(getWinding()); |
46dc716238fd
Renamed some methods of the Model class to remove the 'emplace' word (however cromulent it is, being from STL...) from them.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
89 | newdoc->append<LDEmpty>(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | } |