Skip to content

Commit f630c52

Browse files
committed
feat: improve default operator output container names
also some general clean up in a few of the operator plugins that weren't using the newer features of OperatorResult and ActionProgress
1 parent 599a657 commit f630c52

File tree

15 files changed

+127
-221
lines changed

15 files changed

+127
-221
lines changed

src/hobbits-core/bitarray.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ BitArray::BitArray(const BitArray &other) :
7979
{
8080
}
8181

82+
BitArray::BitArray(const BitArray *other) :
83+
BitArray(other->dataReader(), other->sizeInBits())
84+
{
85+
}
86+
87+
8288
BitArray::~BitArray()
8389
{
8490
deleteCache();

src/hobbits-core/bitarray.h

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class HOBBITSCORESHARED_EXPORT BitArray
2020
BitArray(QIODevice *dataStream, qint64 sizeInBits);
2121
BitArray(const BitArray &other, qint64 sizeInBits);
2222
BitArray(const BitArray &other);
23+
BitArray(const BitArray *other);
2324

2425
BitArray& operator=(const BitArray &other);
2526

src/hobbits-core/bitcontainer.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
BitContainer::BitContainer(QObject *parent) :
88
QObject(parent),
99
m_name("Some Bits"),
10+
m_nameWasSet(false),
1011
m_id(QUuid::createUuid())
1112
{
1213
setBitInfo(QSharedPointer<BitInfo>(new BitInfo()));
@@ -135,11 +136,17 @@ QString BitContainer::name() const
135136
void BitContainer::setName(QString name)
136137
{
137138
m_mutex.lock();
139+
this->m_nameWasSet = true;
138140
this->m_name = name;
139141
m_mutex.unlock();
140142
emit changed();
141143
}
142144

145+
bool BitContainer::nameWasSet() const
146+
{
147+
return m_nameWasSet;
148+
}
149+
143150
QSharedPointer<const PluginActionLineage> BitContainer::getActionLineage() const
144151
{
145152
return m_actionLineage;

src/hobbits-core/bitcontainer.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public slots:
4949

5050
QString name() const;
5151
void setName(QString name);
52+
bool nameWasSet() const;
5253

5354
void setActionLineage(QSharedPointer<const PluginActionLineage> lineage);
5455
QSharedPointer<const PluginActionLineage> getActionLineage() const;
@@ -70,6 +71,7 @@ public slots:
7071

7172
private:
7273
QString m_name;
74+
bool m_nameWasSet;
7375
QSharedPointer<BitArray> m_bits;
7476
QSharedPointer<BitInfo> m_bitInfo;
7577

src/hobbits-core/operatoractor.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ QSharedPointer<ActionWatcher<QSharedPointer<const OperatorResult>>> OperatorActo
3838
}
3939
else if (pluginState.isEmpty()) {
4040
emit reportError(QString(
41-
"Plugin '%1' is in an invalid state and can't be excecuted. Double check the input fields.").arg(
41+
"Plugin '%1' is in an invalid state and can't be executed. Double check the input fields.").arg(
4242
op->getName()));
4343
}
4444
return QSharedPointer<ActionWatcher<QSharedPointer<const OperatorResult>>>();
@@ -132,23 +132,23 @@ void OperatorActor::postProcess()
132132

133133
// Add output containers to container manager
134134
if (result->getOutputContainers().size() > 0) {
135-
if (m_outputName.isEmpty()) {
136-
if (result->getPluginState().contains("container_name")
137-
&& result->getPluginState().value("container_name").isString()) {
138-
m_outputName = result->getPluginState().value("container_name").toString();
139-
}
140-
else {
141-
m_outputName = m_op->getName() + " Output";
142-
}
143-
}
144135
int number = 1;
145136
QModelIndex lastAdded;
146137
for (QSharedPointer<BitContainer> output : result->getOutputContainers()) {
138+
QString containerName = m_outputName;
139+
if (m_outputName.isEmpty()) {
140+
if (output->nameWasSet()) {
141+
containerName = output->name();
142+
}
143+
else {
144+
containerName = m_op->getName() + " Output";
145+
}
146+
}
147147
if (result->getOutputContainers().length() > 1) {
148-
output->setName(QString("%2: %1").arg(m_outputName).arg(number));
148+
output->setName(QString("%2: %1").arg(containerName).arg(number));
149149
}
150150
else {
151-
output->setName(m_outputName);
151+
output->setName(containerName);
152152
}
153153
number++;
154154
lastAdded = m_bitContainerManager->getTreeModel()->addContainer(output);

src/hobbits-gui/mainwindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ void MainWindow::requestOperatorRun(QString pluginName, QJsonObject pluginState)
714714
plugin,
715715
inputContainers,
716716
m_bitContainerManager,
717-
ui->le_outputName->text());
717+
QString());
718718
}
719719
}
720720
}

src/hobbits-gui/mainwindow.ui

+4-35
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1286</width>
10-
<height>772</height>
9+
<width>1299</width>
10+
<height>799</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -204,19 +204,6 @@
204204
</property>
205205
</spacer>
206206
</item>
207-
<item>
208-
<widget class="QLabel" name="label">
209-
<property name="text">
210-
<string>Output Name</string>
211-
</property>
212-
<property name="buddy">
213-
<cstring>le_outputName</cstring>
214-
</property>
215-
</widget>
216-
</item>
217-
<item>
218-
<widget class="QLineEdit" name="le_outputName"/>
219-
</item>
220207
<item>
221208
<widget class="QPushButton" name="pb_operate">
222209
<property name="text">
@@ -287,7 +274,7 @@
287274
<rect>
288275
<x>0</x>
289276
<y>0</y>
290-
<width>1286</width>
277+
<width>1299</width>
291278
<height>27</height>
292279
</rect>
293280
</property>
@@ -459,28 +446,10 @@
459446
<layoutdefault spacing="6" margin="11"/>
460447
<tabstops>
461448
<tabstop>operatorTabs</tabstop>
462-
<tabstop>le_outputName</tabstop>
463449
<tabstop>pb_operate</tabstop>
464450
</tabstops>
465451
<resources>
466452
<include location="icons.qrc"/>
467453
</resources>
468-
<connections>
469-
<connection>
470-
<sender>le_outputName</sender>
471-
<signal>returnPressed()</signal>
472-
<receiver>pb_operate</receiver>
473-
<slot>click()</slot>
474-
<hints>
475-
<hint type="sourcelabel">
476-
<x>944</x>
477-
<y>714</y>
478-
</hint>
479-
<hint type="destinationlabel">
480-
<x>1171</x>
481-
<y>721</y>
482-
</hint>
483-
</hints>
484-
</connection>
485-
</connections>
454+
<connections/>
486455
</ui>

0 commit comments

Comments
 (0)