Skip to content

Commit 8dbfb44

Browse files
committed
Hook up signal/slots to distinguish actions
1 parent 4089514 commit 8dbfb44

File tree

7 files changed

+44
-8
lines changed

7 files changed

+44
-8
lines changed

src/Interface/Application/Connection.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C
291291
connect(menu_->disableAction_, SIGNAL(triggered()), this, SLOT(toggleDisabled()));
292292

293293
connect(this, SIGNAL(insertNewModule(const SCIRun::Dataflow::Networks::PortDescriptionInterface*, const std::string&, const SCIRun::Dataflow::Networks::PortDescriptionInterface*)),
294-
fromPort_, SIGNAL(connectNewModule(const SCIRun::Dataflow::Networks::PortDescriptionInterface*, const std::string&)));
294+
fromPort_, SLOT(insertNewModule(const SCIRun::Dataflow::Networks::PortDescriptionInterface*, const std::string&, const SCIRun::Dataflow::Networks::PortDescriptionInterface*)));
295+
setProperty(addNewModuleActionTypePropertyName(), QString("insertModule"));
295296

296297
menu_->setStyleSheet(fromPort->styleSheet());
297298

@@ -446,7 +447,7 @@ QVariant ConnectionLine::itemChange(GraphicsItemChange change, const QVariant& v
446447
//Position drag movement relative to movement in network. Otherwise CL moves relative to modules as though they are the whole scene (faster, CL moves out of modules).
447448
if (change == ItemPositionChange && scene())
448449
{
449-
QPointF newPos = value.toPointF();
450+
auto newPos = value.toPointF();
450451
newPos.setX(0);
451452
newPos.setY(0);
452453
return newPos;

src/Interface/Application/GuiCommands.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ QPointF SCIRun::Gui::findCenterOfNetwork(const ModulePositions& positions)
171171
return centroidOfPointRange(pointRange.begin(), pointRange.end());
172172
}
173173

174+
const char* SCIRun::Gui::addNewModuleActionTypePropertyName()
175+
{
176+
return "connectNewModuleSource";
177+
}
178+
174179
namespace std
175180
{
176181
template <typename T1, typename T2>

src/Interface/Application/ModuleWidget.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,17 @@ void ModuleWidget::duplicate()
13121312

13131313
void ModuleWidget::connectNewModule(const PortDescriptionInterface* portToConnect, const std::string& newModuleName)
13141314
{
1315+
auto prop = sender()->property(addNewModuleActionTypePropertyName());
1316+
qDebug() << sender();
1317+
qDebug() << "ModuleWidget SENDER PROPERTY:" << prop;
1318+
if (prop.value<QString>() == "addNew")
1319+
{
1320+
qDebug() << "Action is done.";
1321+
}
1322+
else
1323+
{
1324+
qDebug() << "Action is not done, need to change a connection.";
1325+
}
13151326
Q_EMIT connectNewModule(theModule_, portToConnect, newModuleName);
13161327
}
13171328

src/Interface/Application/NetworkEditor.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,16 @@ void NetworkEditor::paste()
570570

571571
void NetworkEditor::contextMenuEvent(QContextMenuEvent *event)
572572
{
573-
auto items = scene_->items(mapToScene(event->pos()));
574-
if (items.isEmpty())
573+
//TODO: this menu needs to check for certain editing conditions. Disabling for now.
574+
if (false)
575575
{
576-
QMenu menu(this);
577-
menu.addActions(actions());
578-
menu.exec(event->globalPos());
576+
auto items = scene_->items(mapToScene(event->pos()));
577+
if (items.isEmpty())
578+
{
579+
QMenu menu(this);
580+
menu.addActions(actions());
581+
menu.exec(event->globalPos());
582+
}
579583
}
580584
}
581585

src/Interface/Application/Port.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace SCIRun {
6161
auto isInput = parent->isInput();
6262
return fillMenuWithFilteredModuleActions(menu, moduleMap,
6363
[portTypeToMatch, isInput](const ModuleDescription& m) { return portTypeMatches(portTypeToMatch, isInput, m); },
64-
[parent](QAction* action) { QObject::connect(action, SIGNAL(triggered()), parent, SLOT(connectNewModule())); },
64+
[parent](QAction* action) { QObject::connect(action, SIGNAL(triggered()), parent, SLOT(connectNewModule())); action->setProperty(addNewModuleActionTypePropertyName(), QString("addNew")); },
6565
parent);
6666
}
6767

@@ -600,9 +600,21 @@ void PortWidget::connectNewModule()
600600
{
601601
auto action = qobject_cast<QAction*>(sender());
602602
auto moduleToAddName = action->text();
603+
qDebug() << "OLD SLOT:" << sender();
604+
qDebug() << "PortWidget SENDER PROPERTY:" << action->property(addNewModuleActionTypePropertyName());
605+
setProperty(addNewModuleActionTypePropertyName(), action->property(addNewModuleActionTypePropertyName()));
603606
Q_EMIT connectNewModule(this, moduleToAddName.toStdString());
604607
}
605608

609+
void PortWidget::insertNewModule(const SCIRun::Dataflow::Networks::PortDescriptionInterface* output, const std::string& newModuleName, const SCIRun::Dataflow::Networks::PortDescriptionInterface* input)
610+
{
611+
qDebug() << "NEW SLOT:" << sender();
612+
//auto action = qobject_cast<QAction*>(sender());
613+
qDebug() << "PortWidget SENDER PROPERTY:" << sender()->property(addNewModuleActionTypePropertyName());
614+
setProperty(addNewModuleActionTypePropertyName(), sender()->property(addNewModuleActionTypePropertyName()));
615+
Q_EMIT connectNewModule(output, newModuleName);
616+
}
617+
606618
InputPortWidget::InputPortWidget(const QString& name, const QColor& color, const std::string& datatype,
607619
const ModuleId& moduleId, const PortId& portId, size_t index, bool isDynamic,
608620
boost::shared_ptr<ConnectionFactory> connectionFactory,

src/Interface/Application/Port.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public Q_SLOTS:
151151
void portCachingChanged(bool checked);
152152
void connectNewModule();
153153
void clearPotentialConnections();
154+
void insertNewModule(const SCIRun::Dataflow::Networks::PortDescriptionInterface* output, const std::string& newModuleName, const SCIRun::Dataflow::Networks::PortDescriptionInterface* input);
154155
Q_SIGNALS:
155156
void requestConnection(const SCIRun::Dataflow::Networks::PortDescriptionInterface* from, const SCIRun::Dataflow::Networks::PortDescriptionInterface* to);
156157
void connectionDeleted(const SCIRun::Dataflow::Networks::ConnectionId& id);

src/Interface/Application/Utility.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ namespace Gui
7777
QList<QAction*> fillMenuWithFilteredModuleActions(QMenu* menu, const Dataflow::Networks::ModuleDescriptionMap& moduleMap, ModulePredicate modulePred, QActionHookup hookup, QWidget* parent);
7878
bool portTypeMatches(const std::string& portTypeToMatch, bool isInput, const Dataflow::Networks::ModuleDescription& module);
7979
QPointF findCenterOfNetwork(const Dataflow::Networks::ModulePositions& positions);
80+
81+
const char* addNewModuleActionTypePropertyName();
8082
}
8183

8284
}

0 commit comments

Comments
 (0)