Skip to content

Commit 1c31cfe

Browse files
committed
remove example implementation code
1 parent 318f0b2 commit 1c31cfe

5 files changed

Lines changed: 8 additions & 92 deletions

File tree

examples/calculator/LongProcessingRandomNumber.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class RandomNumberModel : public MathOperationDataModel
1616
{
1717
public:
1818
RandomNumberModel() {
19-
setFrozenMenu(true);
20-
2119
this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::Empty);
2220

2321

@@ -46,9 +44,6 @@ class RandomNumberModel : public MathOperationDataModel
4644
private:
4745
void compute() override
4846
{
49-
if (frozen())
50-
return;
51-
5247
Q_EMIT computingStarted();
5348
PortIndex const outPortIndex = 0;
5449

include/QtNodes/internal/BasicGraphicsScene.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
110110
*/
111111
virtual QMenu *createSceneMenu(QPointF const scenePos);
112112

113-
QMenu *createFreezeMenu();
114-
115113
void freezeModelAndConnections(bool isFreeze);
116114

117115
Q_SIGNALS:

include/QtNodes/internal/NodeDelegateModel.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
137137

138138
void setFrozenState(bool state) { _frozen = state; }
139139

140-
bool frozenMenu() const { return _frozenMenu; }
141-
142-
void setFrozenMenu(bool state) { _frozenMenu = state; }
143-
144140
public Q_SLOTS:
145141
virtual void inputConnectionCreated(ConnectionId const &) {}
146142
virtual void inputConnectionDeleted(ConnectionId const &) {}
@@ -196,8 +192,6 @@ public Q_SLOTS:
196192

197193
bool _frozen{false};
198194

199-
bool _frozenMenu{false};
200-
201195
NodeValidationState _nodeValidationState;
202196

203197
NodeProcessingStatus _processingStatus{NodeProcessingStatus::NoStatus};

src/BasicGraphicsScene.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -209,68 +209,6 @@ QMenu *BasicGraphicsScene::createSceneMenu(QPointF const scenePos)
209209
return nullptr;
210210
}
211211

212-
QMenu *BasicGraphicsScene::createFreezeMenu()
213-
{
214-
QMenu *menu = new QMenu();
215-
216-
auto *txtBox = new QLineEdit(menu);
217-
txtBox->setPlaceholderText(QStringLiteral("Filter"));
218-
txtBox->setClearButtonEnabled(true);
219-
220-
auto *txtBoxAction = new QWidgetAction(menu);
221-
txtBoxAction->setDefaultWidget(txtBox);
222-
menu->addAction(txtBoxAction);
223-
224-
QTreeWidget *treeView = new QTreeWidget(menu);
225-
treeView->header()->close();
226-
227-
treeView->setMaximumHeight(100);
228-
treeView->setMaximumWidth(150);
229-
230-
auto *treeViewAction = new QWidgetAction(menu);
231-
treeViewAction->setDefaultWidget(treeView);
232-
menu->addAction(treeViewAction);
233-
234-
auto freezeItem = new QTreeWidgetItem(treeView);
235-
freezeItem->setText(0, "Freeze");
236-
237-
auto unfreezeItem = new QTreeWidgetItem(treeView);
238-
unfreezeItem->setText(0, "Unfreeze");
239-
240-
treeView->expandAll();
241-
242-
connect(treeView, &QTreeWidget::itemClicked, [this, menu](QTreeWidgetItem *item, int) {
243-
if (item->text(0) == "Freeze") {
244-
freezeModelAndConnections(true);
245-
246-
menu->close();
247-
return;
248-
}
249-
if (item->text(0) == "Unfreeze") {
250-
freezeModelAndConnections(false);
251-
252-
menu->close();
253-
return;
254-
}
255-
});
256-
257-
// Filtro
258-
connect(txtBox, &QLineEdit::textChanged, [treeView](const QString &text) {
259-
QTreeWidgetItemIterator it(treeView);
260-
while (*it) {
261-
auto modelName = (*it)->text(0);
262-
const bool match = (modelName.contains(text, Qt::CaseInsensitive));
263-
(*it)->setHidden(!match);
264-
++it;
265-
}
266-
});
267-
268-
txtBox->setFocus();
269-
menu->setAttribute(Qt::WA_DeleteOnClose);
270-
271-
return menu;
272-
}
273-
274212
void BasicGraphicsScene::traverseGraphAndPopulateGraphicsObjects()
275213
{
276214
auto allNodeIds = _graphModel.allNodeIds();

src/GraphicsView.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,30 +185,21 @@ void GraphicsView::centerScene()
185185

186186
void GraphicsView::contextMenuEvent(QContextMenuEvent *event)
187187
{
188-
QGraphicsView::contextMenuEvent(event);
189-
QMenu *menu = nullptr;
188+
if (itemAt(event->pos())) {
189+
QGraphicsView::contextMenuEvent(event);
190+
return;
191+
}
190192

191-
bool isFrozenMenu;
193+
if (!nodeScene())
194+
return;
192195

193-
if (auto *dfModel = dynamic_cast<DataFlowGraphModel *>(&nodeScene()->graphModel())) {
194-
if (auto n = qgraphicsitem_cast<NodeGraphicsObject *>(itemAt(event->pos()))) {
195-
if (auto *delegate = dfModel->delegateModel<NodeDelegateModel>(n->nodeId())) {
196-
isFrozenMenu = delegate->frozenMenu();
197-
}
198-
}
199-
}
196+
auto const scenePos = mapToScene(event->pos());
200197

201-
if (itemAt(event->pos()) && isFrozenMenu) {
202-
menu = nodeScene()->createFreezeMenu();
203-
} else if (!itemAt(event->pos())) {
204-
menu = nodeScene()->createSceneMenu(mapToScene(event->pos()));
205-
}
198+
QMenu *menu = nodeScene()->createSceneMenu(scenePos);
206199

207200
if (menu) {
208201
menu->exec(event->globalPos());
209202
}
210-
211-
return;
212203
}
213204

214205
void GraphicsView::wheelEvent(QWheelEvent *event)

0 commit comments

Comments
 (0)