@@ -16,6 +16,15 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::fromLineage(QSharedPointer<
16
16
QQueue<QPair<QSharedPointer<const PluginActionLineage>, int >> lineageQueue;
17
17
QQueue<QSharedPointer<const PluginActionLineage>> stageTwoQueue;
18
18
19
+ auto firstLineage = lineage;
20
+ while (firstLineage->getPluginAction ()->pluginType () == PluginAction::Analyzer) {
21
+ auto input = firstLineage->getInputs ().at (0 );
22
+ if (input->getPluginAction ()->pluginType () == PluginAction::Analyzer) {
23
+ lineageQueue.enqueue ({input, (Mode::Inclusive | (batchMode & Mode::IncludeImportersFull))});
24
+ }
25
+ firstLineage = input;
26
+ }
27
+
19
28
lineageQueue.enqueue ({lineage, batchMode});
20
29
while (!lineageQueue.isEmpty ()) {
21
30
auto lineageModePair = lineageQueue.dequeue ();
@@ -86,10 +95,9 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::fromLineage(QSharedPointer<
86
95
}
87
96
alreadyAssigned.insert (currLineage->getPluginAction ());
88
97
89
- // If it's a "no action" step, it will get a null QUuid input
98
+ // If it's a "no action" step (anonymous input) , it doesn't have inputs
90
99
if (stepMap[currLineage->getPluginAction ()]->action ->pluginType () == PluginAction::NoAction) {
91
- // TODO: what if there's a "no action" that isn't in the beginning?
92
- stepMap[currLineage->getPluginAction ()]->inputs = {{QUuid (), 0 }};
100
+ stepMap[currLineage->getPluginAction ()]->inputs = {};
93
101
continue ;
94
102
}
95
103
@@ -103,15 +111,21 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::fromLineage(QSharedPointer<
103
111
inputs.append ({stepMap.value (input->getPluginAction ())->stepId , input->getOutputPosition ()});
104
112
}
105
113
else {
106
- inputs.append ({QUuid (), 0 });
114
+ auto anonymousInput = PluginAction::noAction ();
115
+ auto step = createStep (QUuid::createUuid (), anonymousInput);
116
+ stepMap.insert (anonymousInput, step);
117
+ inputs.append ({step->stepId , 0 });
107
118
}
108
119
}
109
120
stepMap[currLineage->getPluginAction ()]->inputs = inputs;
110
121
}
111
122
112
123
113
124
QList<QSharedPointer<const ActionStep>> constSteps;
125
+ int stepCount = 0 ;
114
126
for (auto step: stepMap.values ()) {
127
+ step->editorPosition = QPointF (300 * (stepCount % 4 ), 200 * (stepCount / 4 ));
128
+ stepCount++;
115
129
constSteps.append (step);
116
130
}
117
131
@@ -145,6 +159,12 @@ QJsonObject PluginActionBatch::serialize() const
145
159
stepInputs.append (inputObject);
146
160
}
147
161
stepObject.insert (" inputs" , stepInputs);
162
+
163
+ QJsonObject stepPos;
164
+ stepPos.insert (" x" , step->editorPosition .x ());
165
+ stepPos.insert (" y" , step->editorPosition .y ());
166
+ stepObject.insert (" editorPosition" , stepPos);
167
+
148
168
steps.append (stepObject);
149
169
}
150
170
obj.insert (" steps" , steps);
@@ -162,6 +182,7 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::deserialize(QJsonObject dat
162
182
163
183
QSharedPointer<PluginActionBatch> deserialized;
164
184
QList<QSharedPointer<ActionStep>> steps;
185
+ int stepCount = 0 ;
165
186
for (auto step : data.value (" steps" ).toArray ()) {
166
187
if (!step.isObject ()) {
167
188
return nullBatch;
@@ -206,6 +227,19 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::deserialize(QJsonObject dat
206
227
deserializedStep->inputs .append ({inputId, outputPosition});
207
228
}
208
229
}
230
+
231
+ bool posSet = false ;
232
+ if (stepObject.contains (" editorPosition" ) && stepObject.value (" editorPosition" ).isObject ()) {
233
+ QJsonObject posObj = stepObject.value (" editorPosition" ).toObject ();
234
+ if (posObj.contains (" x" ) && posObj.contains (" y" )) {
235
+ deserializedStep->editorPosition = QPointF (posObj.value (" x" ).toDouble (), posObj.value (" y" ).toDouble ());
236
+ posSet = true ;
237
+ }
238
+ }
239
+ if (!posSet) {
240
+ deserializedStep->editorPosition = QPointF (300 * (stepCount % 4 ), 200 * (stepCount / 4 ));
241
+ }
242
+ stepCount++;
209
243
}
210
244
211
245
QList<QSharedPointer<const ActionStep>> constSteps;
@@ -216,41 +250,12 @@ QSharedPointer<PluginActionBatch> PluginActionBatch::deserialize(QJsonObject dat
216
250
return QSharedPointer<PluginActionBatch>(new PluginActionBatch (constSteps));
217
251
}
218
252
219
- int PluginActionBatch::getMinRequiredInputs (QSharedPointer< const HobbitsPluginManager> pluginManager ) const
253
+ int PluginActionBatch::getRequiredInputs ( ) const
220
254
{
221
255
int inputTotal = 0 ;
222
256
for (auto step : m_actionSteps) {
223
257
if (step->action ->pluginType () == PluginAction::NoAction) {
224
- inputTotal += 1 ;
225
- continue ;
226
- }
227
- int actionInputs = step->action ->minPossibleInputs (pluginManager);
228
- int internalInputs = 0 ;
229
- for (auto input : step->inputs ) {
230
- if (!input.first .isNull ()) {
231
- internalInputs++;
232
- }
233
- }
234
- if (actionInputs > internalInputs) {
235
- inputTotal += actionInputs - internalInputs;
236
- }
237
- }
238
- return inputTotal;
239
- }
240
-
241
- int PluginActionBatch::getMaxPossibleInputs (QSharedPointer<const HobbitsPluginManager> pluginManager) const
242
- {
243
- int inputTotal = 0 ;
244
- for (auto step : m_actionSteps) {
245
- int actionInputs = step->action ->maxPossibleInputs (pluginManager);
246
- int internalInputs = 0 ;
247
- for (auto input : step->inputs ) {
248
- if (!input.first .isNull ()) {
249
- internalInputs++;
250
- }
251
- }
252
- if (actionInputs > internalInputs) {
253
- inputTotal += actionInputs - internalInputs;
258
+ inputTotal ++;
254
259
}
255
260
}
256
261
return inputTotal;
0 commit comments