##// END OF EJS Templates
Adds scrollbar to tabs
Alexandre Leroux -
r307:a48a71ab1c8a
parent child
Show More
@@ -41,6 +41,9 public:
41 41 QString name() const override;
42 42
43 43 private:
44 /// @return the layout of tab in which zones are added
45 QLayout &tabLayout() const noexcept;
46
44 47 Ui::VisualizationTabWidget *ui;
45 48
46 49 class VisualizationTabWidgetPrivate;
@@ -48,12 +48,12 VisualizationTabWidget::~VisualizationTabWidget()
48 48
49 49 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
50 50 {
51 this->layout()->addWidget(zoneWidget);
51 tabLayout().addWidget(zoneWidget);
52 52 }
53 53
54 54 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
55 55 {
56 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this};
56 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(tabLayout()), this};
57 57 this->addZone(zoneWidget);
58 58
59 59 // Creates a new graph into the zone
@@ -68,8 +68,9 void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor)
68 68 visitor->visitEnter(this);
69 69
70 70 // Apply visitor to zone children
71 for (auto i = 0; i < layout()->count(); ++i) {
72 if (auto item = layout()->itemAt(i)) {
71 auto &layout = tabLayout();
72 for (auto i = 0; i < layout.count(); ++i) {
73 if (auto item = layout.itemAt(i)) {
73 74 // Widgets different from zones are not visited (no action)
74 75 if (auto visualizationZoneWidget
75 76 = dynamic_cast<VisualizationZoneWidget *>(item->widget())) {
@@ -96,3 +97,8 QString VisualizationTabWidget::name() const
96 97 {
97 98 return impl->m_Name;
98 99 }
100
101 QLayout &VisualizationTabWidget::tabLayout() const noexcept
102 {
103 return *ui->scrollAreaWidgetContents->layout();
104 }
@@ -10,6 +10,9 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
10 10
11 11 namespace {
12 12
13 /// Minimum height for graph added in zones (in pixels)
14 const auto GRAPH_MINIMUM_HEIGHT = 300;
15
13 16 /// Generates a default name for a new graph, according to the number of graphs already displayed in
14 17 /// the zone
15 18 QString defaultGraphName(const QLayout &layout)
@@ -53,6 +56,11 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
53 56 {
54 57 auto graphWidget = new VisualizationGraphWidget{
55 58 defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
59
60 // Set graph properties
61 graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
62 graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT);
63
56 64 this->addGraph(graphWidget);
57 65
58 66 graphWidget->addVariable(variable);
@@ -13,7 +13,47
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout"/>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <property name="leftMargin">
18 <number>0</number>
19 </property>
20 <property name="topMargin">
21 <number>0</number>
22 </property>
23 <property name="rightMargin">
24 <number>0</number>
25 </property>
26 <property name="bottomMargin">
27 <number>0</number>
28 </property>
29 <item>
30 <widget class="QScrollArea" name="scrollArea">
31 <property name="styleSheet">
32 <string notr="true">background-color: transparent;</string>
33 </property>
34 <property name="frameShape">
35 <enum>QFrame::NoFrame</enum>
36 </property>
37 <property name="frameShadow">
38 <enum>QFrame::Sunken</enum>
39 </property>
40 <property name="widgetResizable">
41 <bool>true</bool>
42 </property>
43 <widget class="QWidget" name="scrollAreaWidgetContents">
44 <property name="geometry">
45 <rect>
46 <x>0</x>
47 <y>0</y>
48 <width>400</width>
49 <height>300</height>
50 </rect>
51 </property>
52 <layout class="QVBoxLayout" name="verticalLayout_3"/>
53 </widget>
54 </widget>
55 </item>
56 </layout>
17 57 </widget>
18 58 <resources/>
19 59 <connections/>
General Comments 0
You need to be logged in to leave comments. Login now