From a08c6215b1ad7fe684344db3cd40c6aa9903ee6e 2017-06-08 08:06:30 From: mperrinel Date: 2017-06-08 08:06:30 Subject: [PATCH] Widget of the tab widget are now of type VisualizationTabWidget Add addTabView and removeTabView lambda method connecter to their correspondant button in the VisuaizationWidget --- diff --git a/gui/include/visualization/VisualizationWidget.h b/gui/include/visualization/VisualizationWidget.h index 645d5df..280783a 100644 --- a/gui/include/visualization/VisualizationWidget.h +++ b/gui/include/visualization/VisualizationWidget.h @@ -1,8 +1,11 @@ #ifndef SCIQLOP_VISUALIZATIONWIDGET_H #define SCIQLOP_VISUALIZATIONWIDGET_H +#include #include +Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) + namespace Ui { class VisualizationWidget; } // namespace Ui diff --git a/gui/src/visualization/VisualizationWidget.cpp b/gui/src/visualization/VisualizationWidget.cpp index ccea179..4ce2803 100644 --- a/gui/src/visualization/VisualizationWidget.cpp +++ b/gui/src/visualization/VisualizationWidget.cpp @@ -1,10 +1,40 @@ #include "visualization/VisualizationWidget.h" #include "ui_VisualizationWidget.h" +#include "visualization/VisualizationTabWidget.h" + +#include +#include + +#include "iostream" + +Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") VisualizationWidget::VisualizationWidget(QWidget *parent) : QWidget(parent), ui(new Ui::VisualizationWidget) { ui->setupUi(this); + + auto *addTabViewButton = new QToolButton(ui->tabWidget); + addTabViewButton->setText("Add View"); + addTabViewButton->setCursor(Qt::ArrowCursor); + addTabViewButton->setAutoRaise(true); + ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); + + auto addTabView = [&](bool checked) { + auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), + QString("View %1").arg(ui->tabWidget->count() + 1)); + qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); + }; + + auto removeTabView = [&](int index) { + ui->tabWidget->removeTab(index); + qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); + }; + + ui->tabWidget->setTabsClosable(true); + + connect(addTabViewButton, &QToolButton::clicked, addTabView); + connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); } VisualizationWidget::~VisualizationWidget() diff --git a/gui/ui/visualization/VisualizationWidget.ui b/gui/ui/visualization/VisualizationWidget.ui index 182401d..3a9cbd6 100644 --- a/gui/ui/visualization/VisualizationWidget.ui +++ b/gui/ui/visualization/VisualizationWidget.ui @@ -19,20 +19,23 @@ 0 - + View 1 - - - + - - + + + VisualizationTabWidget + QWidget +
visualization/VisualizationTabWidget.h
+ 1 +
+