Skip to content

Commit

Permalink
feat: improve default operator output container names
Browse files Browse the repository at this point in the history
also some general clean up in a few of the operator plugins that weren't using the newer features of OperatorResult and ActionProgress
  • Loading branch information
hello-adam committed May 4, 2020
1 parent 599a657 commit f630c52
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 221 deletions.
6 changes: 6 additions & 0 deletions src/hobbits-core/bitarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ BitArray::BitArray(const BitArray &other) :
{
}

BitArray::BitArray(const BitArray *other) :
BitArray(other->dataReader(), other->sizeInBits())
{
}


BitArray::~BitArray()
{
deleteCache();
Expand Down
1 change: 1 addition & 0 deletions src/hobbits-core/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class HOBBITSCORESHARED_EXPORT BitArray
BitArray(QIODevice *dataStream, qint64 sizeInBits);
BitArray(const BitArray &other, qint64 sizeInBits);
BitArray(const BitArray &other);
BitArray(const BitArray *other);

BitArray& operator=(const BitArray &other);

Expand Down
7 changes: 7 additions & 0 deletions src/hobbits-core/bitcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
BitContainer::BitContainer(QObject *parent) :
QObject(parent),
m_name("Some Bits"),
m_nameWasSet(false),
m_id(QUuid::createUuid())
{
setBitInfo(QSharedPointer<BitInfo>(new BitInfo()));
Expand Down Expand Up @@ -135,11 +136,17 @@ QString BitContainer::name() const
void BitContainer::setName(QString name)
{
m_mutex.lock();
this->m_nameWasSet = true;
this->m_name = name;
m_mutex.unlock();
emit changed();
}

bool BitContainer::nameWasSet() const
{
return m_nameWasSet;
}

QSharedPointer<const PluginActionLineage> BitContainer::getActionLineage() const
{
return m_actionLineage;
Expand Down
2 changes: 2 additions & 0 deletions src/hobbits-core/bitcontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public slots:

QString name() const;
void setName(QString name);
bool nameWasSet() const;

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

private:
QString m_name;
bool m_nameWasSet;
QSharedPointer<BitArray> m_bits;
QSharedPointer<BitInfo> m_bitInfo;

Expand Down
24 changes: 12 additions & 12 deletions src/hobbits-core/operatoractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ QSharedPointer<ActionWatcher<QSharedPointer<const OperatorResult>>> OperatorActo
}
else if (pluginState.isEmpty()) {
emit reportError(QString(
"Plugin '%1' is in an invalid state and can't be excecuted. Double check the input fields.").arg(
"Plugin '%1' is in an invalid state and can't be executed. Double check the input fields.").arg(
op->getName()));
}
return QSharedPointer<ActionWatcher<QSharedPointer<const OperatorResult>>>();
Expand Down Expand Up @@ -132,23 +132,23 @@ void OperatorActor::postProcess()

// Add output containers to container manager
if (result->getOutputContainers().size() > 0) {
if (m_outputName.isEmpty()) {
if (result->getPluginState().contains("container_name")
&& result->getPluginState().value("container_name").isString()) {
m_outputName = result->getPluginState().value("container_name").toString();
}
else {
m_outputName = m_op->getName() + " Output";
}
}
int number = 1;
QModelIndex lastAdded;
for (QSharedPointer<BitContainer> output : result->getOutputContainers()) {
QString containerName = m_outputName;
if (m_outputName.isEmpty()) {
if (output->nameWasSet()) {
containerName = output->name();
}
else {
containerName = m_op->getName() + " Output";
}
}
if (result->getOutputContainers().length() > 1) {
output->setName(QString("%2: %1").arg(m_outputName).arg(number));
output->setName(QString("%2: %1").arg(containerName).arg(number));
}
else {
output->setName(m_outputName);
output->setName(containerName);
}
number++;
lastAdded = m_bitContainerManager->getTreeModel()->addContainer(output);
Expand Down
2 changes: 1 addition & 1 deletion src/hobbits-gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void MainWindow::requestOperatorRun(QString pluginName, QJsonObject pluginState)
plugin,
inputContainers,
m_bitContainerManager,
ui->le_outputName->text());
QString());
}
}
}
Expand Down
39 changes: 4 additions & 35 deletions src/hobbits-gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1286</width>
<height>772</height>
<width>1299</width>
<height>799</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -204,19 +204,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Output Name</string>
</property>
<property name="buddy">
<cstring>le_outputName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_outputName"/>
</item>
<item>
<widget class="QPushButton" name="pb_operate">
<property name="text">
Expand Down Expand Up @@ -287,7 +274,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1286</width>
<width>1299</width>
<height>27</height>
</rect>
</property>
Expand Down Expand Up @@ -459,28 +446,10 @@
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>operatorTabs</tabstop>
<tabstop>le_outputName</tabstop>
<tabstop>pb_operate</tabstop>
</tabstops>
<resources>
<include location="icons.qrc"/>
</resources>
<connections>
<connection>
<sender>le_outputName</sender>
<signal>returnPressed()</signal>
<receiver>pb_operate</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>944</x>
<y>714</y>
</hint>
<hint type="destinationlabel">
<x>1171</x>
<y>721</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>
Loading

0 comments on commit f630c52

Please sign in to comment.