32 #include "colorSelectDialog.h" |
32 #include "colorSelectDialog.h" |
33 #include "history.h" |
33 #include "history.h" |
34 #include "widgets.h" |
34 #include "widgets.h" |
35 #include "misc.h" |
35 #include "misc.h" |
36 |
36 |
37 // ============================================================================= |
|
38 class SubfileListItem : public QTreeWidgetItem { |
37 class SubfileListItem : public QTreeWidgetItem { |
|
38 PROPERTY (PrimitiveInfo*, primInfo, setPrimInfo) |
|
39 |
39 public: |
40 public: |
40 SubfileListItem (QTreeWidgetItem* parent, int subfileID) : |
41 SubfileListItem (QTreeWidgetItem* parent, PrimitiveInfo* info) : |
41 QTreeWidgetItem (parent), subfileID (subfileID) {} |
42 QTreeWidgetItem (parent), m_primInfo (info) {} |
42 SubfileListItem (QTreeWidget* parent, int subfileID) : |
43 SubfileListItem (QTreeWidget* parent, PrimitiveInfo* info) : |
43 QTreeWidgetItem (parent), subfileID (subfileID) {} |
44 QTreeWidgetItem (parent), m_primInfo (info) {} |
44 |
|
45 int subfileID; |
|
46 }; |
45 }; |
47 |
46 |
48 // ============================================================================= |
47 // ============================================================================= |
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
50 // ============================================================================= |
49 // ============================================================================= |
90 if (obj) |
89 if (obj) |
91 rb_bfcType->setValue ((int) static_cast<LDBFC*> (obj)->type); |
90 rb_bfcType->setValue ((int) static_cast<LDBFC*> (obj)->type); |
92 break; |
91 break; |
93 |
92 |
94 case LDObject::Subfile: |
93 case LDObject::Subfile: |
95 coordCount = 3; |
94 { |
96 |
95 coordCount = 3; |
97 enum { |
96 |
98 Parts, |
97 tw_subfileList = new QTreeWidget (); |
99 Subparts, |
98 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
100 Primitives, |
99 parentItem->setText (0, "Primitives"); |
101 HiRes, |
100 QList<QTreeWidgetItem*> subfileItems; |
102 }; |
101 |
103 |
102 for (PrimitiveInfo& info : g_Primitives) { |
104 tw_subfileList = new QTreeWidget (); |
103 SubfileListItem* item = new SubfileListItem (parentItem, &info); |
105 /* |
104 item->setText (0, fmt ("%1 - %2", info.name, info.title)); |
106 for (int i : vector<int> ({Parts, Subparts, Primitives, HiRes})) { |
105 subfileItems << item; |
107 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, -1); |
|
108 parentItem->setText (0, (i == Parts) ? "Parts" : |
|
109 (i == Subparts) ? "Subparts" : |
|
110 (i == Primitives) ? "Primitives" : |
|
111 "Hi-Res"); |
|
112 |
|
113 ulong j = 0; |
|
114 for (partListEntry& part : g_PartList) { |
|
115 QList<QTreeWidgetItem*> subfileItems; |
|
116 |
|
117 str fileName = part.name; |
|
118 const bool isSubpart = fileName.mid (0, 2) == "s\\"; |
|
119 const bool isPrimitive = part.title.mid (0, 9) == "Primitive"; |
|
120 const bool isHiRes = fileName.mid (0, 3) == "48\\"; |
|
121 |
|
122 if ((i == Subparts && isSubpart) || |
|
123 (i == Primitives && isPrimitive) || |
|
124 (i == HiRes && isHiRes) || |
|
125 (i == Parts && !isSubpart && !isPrimitive && !isHiRes)) |
|
126 { |
|
127 SubfileListItem* item = new SubfileListItem (parentItem, j); |
|
128 item->setText (0, fmt ("%1 - %2", part.name, part.title)); |
|
129 subfileItems.append (item); |
|
130 } |
|
131 |
|
132 j++; |
|
133 } |
106 } |
134 |
107 |
135 tw_subfileList->addTopLevelItem (parentItem); |
108 tw_subfileList->addTopLevelItem (parentItem); |
136 } |
109 connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ())); |
137 */ |
110 lb_subfileName = new QLabel ("File:"); |
138 |
111 le_subfileName = new QLineEdit; |
139 connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ())); |
112 le_subfileName->setFocus (); |
140 lb_subfileName = new QLabel ("File:"); |
113 |
141 le_subfileName = new QLineEdit; |
114 if (obj) { |
142 le_subfileName->setFocus (); |
115 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
143 |
116 le_subfileName->setText (ref->fileInfo ()->name ()); |
144 if (obj) { |
117 } |
145 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
118 break; |
146 le_subfileName->setText (ref->fileInfo ()->name ()); |
119 } |
147 } |
|
148 break; |
|
149 |
120 |
150 case LDObject::Radial: |
121 case LDObject::Radial: |
151 coordCount = 3; |
122 coordCount = 3; |
152 |
123 |
153 lb_radType = new QLabel ("Type:"); |
124 lb_radType = new QLabel ("Type:"); |
309 |
280 |
310 // ============================================================================= |
281 // ============================================================================= |
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
312 // ============================================================================= |
283 // ============================================================================= |
313 str AddObjectDialog::currentSubfileName () { |
284 str AddObjectDialog::currentSubfileName () { |
314 return ""; |
285 SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem ()); |
|
286 |
|
287 if (item->primInfo () == null) |
|
288 return ""; // selected a heading |
|
289 |
|
290 return item->primInfo ()->name; |
315 } |
291 } |
316 |
292 |
317 // ============================================================================= |
293 // ============================================================================= |
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
319 // ============================================================================= |
295 // ============================================================================= |