Skip to content

Commit 71fb707

Browse files
committed
Refactor
1 parent a49d67e commit 71fb707

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

app/elementmapping.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ void ElementMapping::generateMap()
4040

4141
void ElementMapping::generateLogic(GraphicElement *elm)
4242
{
43-
auto logicElm = ElementFactory::buildLogicElement(elm);
44-
elm->setLogic(logicElm.get());
45-
m_logicElms.append(logicElm);
43+
auto logic = ElementFactory::buildLogicElement(elm);
44+
elm->setLogic(logic.get());
45+
m_logicElms.append(logic);
4646
}
4747

4848
void ElementMapping::connectElements()
@@ -56,32 +56,32 @@ void ElementMapping::connectElements()
5656

5757
void ElementMapping::applyConnection(GraphicElement *elm, QNEInputPort *inputPort)
5858
{
59-
LogicElement *currentLogElm;
59+
LogicElement *currentLogic;
6060
int inputIndex = 0;
6161

6262
if (elm->elementType() == ElementType::IC) {
6363
auto *ic = qobject_cast<IC *>(elm);
64-
currentLogElm = ic->inputLogic(inputPort->index());
64+
currentLogic = ic->inputLogic(inputPort->index());
6565
} else {
66-
currentLogElm = elm->logic();
66+
currentLogic = elm->logic();
6767
inputIndex = inputPort->index();
6868
}
6969

7070
const auto connections = inputPort->connections();
7171

7272
if ((connections.size() == 0) && !inputPort->isRequired()) {
7373
auto *predecessorLogic = (inputPort->defaultValue() == Status::Active) ? &m_globalVCC : &m_globalGND;
74-
currentLogElm->connectPredecessor(inputIndex, predecessorLogic, 0);
74+
currentLogic->connectPredecessor(inputIndex, predecessorLogic, 0);
7575
}
7676

7777
if (connections.size() == 1) {
7878
if (auto *outputPort = connections.constFirst()->startPort()) {
7979
if (auto *predecessorElement = outputPort->graphicElement()) {
8080
if (predecessorElement->elementType() == ElementType::IC) {
81-
auto *logic = qobject_cast<IC *>(predecessorElement)->outputLogic(outputPort->index());
82-
currentLogElm->connectPredecessor(inputIndex, logic, 0);
81+
auto *predecessorLogic = qobject_cast<IC *>(predecessorElement)->outputLogic(outputPort->index());
82+
currentLogic->connectPredecessor(inputIndex, predecessorLogic, 0);
8383
} else {
84-
currentLogElm->connectPredecessor(inputIndex, predecessorElement->logic(), outputPort->index());
84+
currentLogic->connectPredecessor(inputIndex, predecessorElement->logic(), outputPort->index());
8585
}
8686
}
8787
}

app/ic.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ void IC::loadFile(const QString &fileName)
145145
}
146146

147147
m_fileWatcher.addPath(fileInfo.absoluteFilePath());
148+
m_file = fileInfo.absoluteFilePath();
149+
setToolTip(m_file);
148150

149151
// ----------------------------------------------
150152

@@ -186,19 +188,15 @@ void IC::loadFile(const QString &fileName)
186188
sortPorts(m_icOutputs);
187189
loadInputsLabels();
188190
loadOutputsLabels();
191+
loadInputs();
192+
loadOutputs();
189193

190194
// ----------------------------------------------
191195

192-
m_file = fileInfo.absoluteFilePath();
193-
setToolTip(m_file);
194-
195196
if (label().isEmpty()) {
196197
setLabel(fileInfo.baseName().toUpper());
197198
}
198199

199-
loadInputs();
200-
loadOutputs();
201-
202200
const qreal bottom = portsBoundingRect().united(QRectF(0, 0, 64, 64)).bottom();
203201
m_label->setPos(30, bottom + 5);
204202

0 commit comments

Comments
 (0)