Mon, 18 Mar 2013 18:29:02 +0200
Added LDraw path setting dialog
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #include <QAbstractButton> |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | #include <qboxlayout.h> |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | #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
|
4 | #include "file.h" |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | #include "gui.h" |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | // ============================================================================= |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | // Dialog_SetContents (LDObject*) [constructor] |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | // |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | // Initializes the Set Contents dialog for the given LDObject |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | // ============================================================================= |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | Dialog_SetContents::Dialog_SetContents (LDObject* obj, QWidget* parent) : QDialog(parent) { |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | setWindowTitle (APPNAME_DISPLAY ": Set Contents"); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | qContentsLabel = new QLabel ("Set contents:", parent); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | qContents = new QLineEdit (parent); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | qContents->setText (obj->getContents ().chars()); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | 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
|
20 | "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
|
21 | "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
|
22 | "<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
|
23 | "standard</a> for further information."); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | qContents->setMinimumWidth (384); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | qOKCancel = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | Qt::Horizontal, parent); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | connect (qOKCancel, SIGNAL (accepted ()), this, SLOT (accept ())); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | connect (qOKCancel, SIGNAL (rejected ()), this, SLOT (reject ())); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | /* |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | connect (qOKCancel, SIGNAL (clicked (QAbstractButton*)), this, SLOT (slot_handleButtons (QAbstractButton*))); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | */ |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | QVBoxLayout* layout = new QVBoxLayout; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | layout->addWidget (qContentsLabel); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | layout->addWidget (qContents); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | layout->addWidget (qOKCancel); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | setLayout (layout); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | } |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | // ============================================================================= |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // void slot_handleButtons (QAbstractButton*) |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | // |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | // Handles a button.. this is used to reset the input field |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | // ============================================================================= |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | void Dialog_SetContents::slot_handleButtons (QAbstractButton* qButton) { |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | qButton = qButton; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | } |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | // ============================================================================= |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | // void staticDialog (LDObject*) [static method] |
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 | // Performs the Set Contents dialog on the given LDObject. Object's contents |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | // are exposed to the user and is reinterpreted if the user accepts the new |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | // contents. |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | // ============================================================================= |
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
|
58 | void Dialog_SetContents::staticDialog (LDObject* obj, ForgeWindow* parent) { |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | if (!obj) |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | return; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | Dialog_SetContents dlg (obj, parent); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | if (dlg.exec ()) { |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | LDObject* oldobj = obj; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | // 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
|
67 | obj = parseLine (dlg.qContents->text ().toStdString ().c_str ()); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
69 | oldobj->replace (obj); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | // Rebuild stuff after this |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | parent->buildObjList (); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | parent->R->hardRefresh (); |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | } |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | } |