zz_setContentsDialog.cpp

Thu, 21 Mar 2013 02:48:09 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 21 Mar 2013 02:48:09 +0200
changeset 56
64899ff3bcb3
parent 39
110669124caf
child 61
109b07334fa0
permissions
-rw-r--r--

Simplify ForgeWindow::slot_splitQuads with the new methods

30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
1 /*
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
2 * LDForge: LDraw parts authoring CAD
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
3 * Copyright (C) 2013 Santeri `arezey` Piippo
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
4 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
5 * This program is free software: you can redistribute it and/or modify
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
6 * it under the terms of the GNU General Public License as published by
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
8 * (at your option) any later version.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
9 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
10 * This program is distributed in the hope that it will be useful,
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
13 * GNU General Public License for more details.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
14 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
15 * You should have received a copy of the GNU General Public License
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
17 */
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
18
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QAbstractButton>
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <qboxlayout.h>
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "zz_setContentsDialog.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
22 #include "file.h"
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "gui.h"
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
28 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 setWindowTitle (APPNAME_DISPLAY ": Set Contents");
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 qContentsLabel = new QLabel ("Set contents:", parent);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 qContents = new QLineEdit (parent);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 qContents->setText (obj->getContents ().chars());
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 qContents->setWhatsThis ("The LDraw code of this object. The code written "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 "here is expected to be valid LDraw code, invalid code here results "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 "the object being turned into an error object. Please do refer to the "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 "<a href=\"http://www.ldraw.org/article/218.html\">official file format "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 "standard</a> for further information.");
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 qContents->setMinimumWidth (384);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
42 IMPLEMENT_DIALOG_BUTTONS
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 QVBoxLayout* layout = new QVBoxLayout;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 layout->addWidget (qContentsLabel);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 layout->addWidget (qContents);
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
47 layout->addWidget (qButtons);
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 setLayout (layout);
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
49
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
50 setWindowTitle (APPNAME_DISPLAY " - setting contents");
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
51 setWindowIcon (QIcon ("icons/set-contents.png"));
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
57 void SetContentsDialog::slot_handleButtons (QAbstractButton* qButton) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 qButton = qButton;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
64 void SetContentsDialog::staticDialog (LDObject* obj, ForgeWindow* parent) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 if (!obj)
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 return;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
68 SetContentsDialog dlg (obj, parent);
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 if (dlg.exec ()) {
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 LDObject* oldobj = obj;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // Reinterpret it from the text of the input field
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
73 obj = parseLine (dlg.qContents->text ().toStdString ().c_str ());
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
74 oldobj->replace (obj);
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 // Rebuild stuff after this
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
77 parent->refresh ();
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 }

mercurial