Fri, 01 Jan 2016 23:41:55 +0200
Happy new year 2016!
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 |
1014
f0a8ecb6a357
Happy new year 2016!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
3 | * Copyright (C) 2013 - 2016 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> |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
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" |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "newpartdialog.h" |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "ui_newpartdialog.h" |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | NewPartDialog::NewPartDialog (QWidget *parent) : |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | QDialog (parent), |
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
|
29 | HierarchyElement (parent), |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | ui (*new Ui_NewPart) |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | ui.setupUi (this); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
1012 | 34 | QString authortext = Config->defaultName(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
1012 | 36 | if (not Config->defaultUser().isEmpty()) |
37 | authortext.append (format (" [%1]", Config->defaultUser())); | |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | ui.author->setText (authortext); |
1012 | 40 | ui.useCaLicense->setChecked (Config->useCaLicense()); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
43 | BfcStatement NewPartDialog::getWinding() const |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | if (ui.windingCcw->isChecked()) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
46 | return BfcStatement::CertifyCCW; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | if (ui.windingCw->isChecked()) |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
49 | return BfcStatement::CertifyCW; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
51 | return BfcStatement::NoCertify; |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | bool NewPartDialog::useCaLicense() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | return ui.useCaLicense->isChecked(); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | QString NewPartDialog::author() const |
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 | return ui.author->text(); |
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 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | QString NewPartDialog::title() const |
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 | return ui.title->text(); |
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 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | void NewPartDialog::fillHeader (LDDocument* newdoc) const |
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 | LDObjectList objs; |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | objs << new LDComment (title()); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | objs << new LDComment ("Name: <untitled>.dat"); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | objs << new LDComment ("Author: " + author()); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | objs << new LDComment ("!LDRAW_ORG Unofficial_Part"); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | if (useCaLicense()) |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | objs << new LDComment (CALicenseText); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | objs << new LDEmpty(); |
988
ac4a2ae54f76
Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
81 | objs << new LDBfc (getWinding()); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | objs << new LDEmpty(); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | newdoc->addObjects (objs); |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | } |