MCPcopy Create free account
hub / github.com/Kitware/ParaView / pqPythonTabWidget

Method pqPythonTabWidget

Qt/Python/pqPythonTabWidget.cxx:25–73  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

23
24//-----------------------------------------------------------------------------
25pqPythonTabWidget::pqPythonTabWidget(QWidget* parent)
26 : QTabWidget(parent)
27{
28 this->addNewTabWidget();
29 this->createNewEmptyTab();
30 this->setMovable(false);
31
32 this->connect(this, &QTabWidget::tabCloseRequested,
33 [this](int index)
34 {
35 pqPythonTextArea* widget = this->getWidget<pqPythonTextArea>(index);
36 if (widget)
37 {
38 // First focus to the tab the user wants to delete
39 // and update the QTabBar
40 const int widgetId = this->indexOf(widget);
41 this->setCurrentIndex(widgetId);
42 this->repaint();
43
44 // We stop all display updates
45 // to avoid segfaults
46 this->setUpdatesEnabled(false);
47 if (this->count() == 2)
48 {
49 // Only delete the widget if it's not empty
50 if (widget->isEmpty())
51 {
52 this->setUpdatesEnabled(true);
53 return;
54 }
55
56 this->createNewEmptyTab();
57 }
58
59 if (widget->saveOnClose())
60 {
61 if (this->currentIndex() == index)
62 {
63 this->setCurrentIndex((index + 1) % (this->count() - 1));
64 this->lastFocus = this->getWidget<pqPythonTextArea>(this->currentIndex());
65 }
66
67 this->removeTab(index);
68 widget->deleteLater();
69 }
70 this->setUpdatesEnabled(true);
71 }
72 });
73}
74
75//-----------------------------------------------------------------------------
76void pqPythonTabWidget::connectActions(pqPythonEditorActions& actions)

Callers

nothing calls this directly

Calls 11

addNewTabWidgetMethod · 0.95
createNewEmptyTabMethod · 0.95
removeTabMethod · 0.80
deleteLaterMethod · 0.80
connectMethod · 0.45
indexOfMethod · 0.45
setCurrentIndexMethod · 0.45
countMethod · 0.45
isEmptyMethod · 0.45
saveOnCloseMethod · 0.45
currentIndexMethod · 0.45

Tested by

no test coverage detected