##// END OF EJS Templates
Few rpath fixes on dmg build...
Few rpath fixes on dmg build Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1420:3c3e24550401
r1468:82521d75dedb
Show More
VisualizationTabWidget.cpp
415 lines | 13.0 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationTabWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationTabWidget.h"
Alexandre Leroux
Updates visitor interface...
r207 #include "Visualization/IVisualizationWidgetVisitor.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationTabWidget.h"
Integrates the drag&drop classes into the existing visualization classes.
r839 #include "Visualization/VisualizationGraphWidget.h"
Format changes
r844 #include "Visualization/VisualizationZoneWidget.h"
Integrates the drag&drop classes into the existing visualization classes.
r839
Thibaud Rabillard
New style on mac to keep the scrollbars visible
r930 #include "Visualization/MacScrollBarStyle.h"
drop of products in visu
r1287 #include "DataSource/DataSourceController.h"
All the codebase is modified to build with new Variable Controller...
r1348 #include "Variable/VariableController2.h"
Manage drag&drop of empty graphs
r841
Move Common MIME types constants in a Definition file in core module.
r848 #include "Common/MimeTypesDef.h"
Rename "DragDropHelper" in "DragDropGuiController"
r1075 #include "DragAndDrop/DragDropGuiController.h"
Format changes
r844 #include "SqpApplication.h"
Add the visualization gui classes
r118
Alexandre Leroux
Adds logs for null visitors
r219 Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget")
Switched to new TS impl but quite broken!...
r1420 namespace
{
Alexandre Leroux
Completes the method of creating a zone from a variable
r201
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 /**
* Applies a function to all zones of the tab represented by its layout
* @param layout the layout that contains zones
* @param fun the function to apply to each zone
*/
template <typename Fun>
Switched to new TS impl but quite broken!...
r1420 void processZones(QLayout& layout, Fun fun)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
Switched to new TS impl but quite broken!...
r1420 for (auto i = 0; i < layout.count(); ++i)
{
if (auto item = layout.itemAt(i))
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 if (auto visualizationZoneWidget
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationZoneWidget*>(item->widget()))
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 fun(*visualizationZoneWidget);
}
}
}
}
Ensures graph and zone names are not duplicated in the visualization
r1137 /// Generates a default name for a new zone, according to the number of zones already displayed in
/// the tab
Switched to new TS impl but quite broken!...
r1420 QString defaultZoneName(QLayout& layout)
Ensures graph and zone names are not duplicated in the visualization
r1137 {
QSet<QString> existingNames;
Switched to new TS impl but quite broken!...
r1420 processZones(
layout, [&existingNames](auto& zoneWidget) { existingNames.insert(zoneWidget.name()); });
Ensures graph and zone names are not duplicated in the visualization
r1137
int zoneNum = 1;
QString name;
Switched to new TS impl but quite broken!...
r1420 do
{
Ensures graph and zone names are not duplicated in the visualization
r1137 name = QObject::tr("Zone ").append(QString::number(zoneNum));
++zoneNum;
} while (existingNames.contains(name));
return name;
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r201 } // namespace
Switched to new TS impl but quite broken!...
r1420 struct VisualizationTabWidget::VisualizationTabWidgetPrivate
{
explicit VisualizationTabWidgetPrivate(const QString& name) : m_Name { name } {}
Add the visualization gui classes
r118
Alexandre Leroux
Adds a name for a tab...
r198 QString m_Name;
drop of variables in the visualization
r850
Thibaud Rabillard
New style on mac to keep the scrollbars visible
r930 #ifdef Q_OS_MAC
std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>();
#endif
Switched to new TS impl but quite broken!...
r1420 void dropGraph(int index, VisualizationTabWidget* tabWidget);
void dropZone(int index, VisualizationTabWidget* tabWidget);
void dropVariables(const std::vector<std::shared_ptr<Variable2>>& variables, int index,
VisualizationTabWidget* tabWidget);
void dropProducts(
const QVariantList& productsMetaData, int index, VisualizationTabWidget* tabWidget);
Alexandre Leroux
Adds a name for a tab...
r198 };
Switched to new TS impl but quite broken!...
r1420 VisualizationTabWidget::VisualizationTabWidget(const QString& name, QWidget* parent)
: QWidget { parent }
, ui { new Ui::VisualizationTabWidget }
, impl { spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name) }
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r267
Thibaud Rabillard
New style on mac to keep the scrollbars visible
r930 #ifdef Q_OS_MAC
impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true);
#endif
Rename "DragDropHelper" in "DragDropGuiController"
r1075 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone");
Increase spacing at the bottom of the visu to give more space for dropping in a new zone
r937 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
ui->dragDropContainer->layout()->setSpacing(0);
Switched to new TS impl but quite broken!...
r1420 ui->dragDropContainer->setMimeType(
MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
ui->dragDropContainer->setMimeType(
MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Inserted);
ui->dragDropContainer->setMimeType(
MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
ui->dragDropContainer->setMimeType(
MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
Drag of the time widget on a graph
r879
drop of variables in the visualization
r850 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
Switched to new TS impl but quite broken!...
r1420 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
mimeData, ui->dragDropContainer);
drop of variables in the visualization
r850 });
Drag of the time widget on a graph
r879
connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this,
Switched to new TS impl but quite broken!...
r1420 &VisualizationTabWidget::dropMimeData);
Drag of the time widget on a graph
r879
Rename "DragDropHelper" in "DragDropGuiController"
r1075 sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea);
Integrates the drag&drop classes into the existing visualization classes.
r839
Alexandre Leroux
Updates tab widget so it can be deleted when closed
r267 // Widget is deleted when closed
setAttribute(Qt::WA_DeleteOnClose);
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationTabWidget::~VisualizationTabWidget()
{
Rename "DragDropHelper" in "DragDropGuiController"
r1075 sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea);
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 delete ui;
}
Add the visualization gui classes
r118
Switched to new TS impl but quite broken!...
r1420 void VisualizationTabWidget::addZone(VisualizationZoneWidget* zoneWidget)
Add the visualization gui classes
r118 {
Integrates the drag&drop classes into the existing visualization classes.
r839 ui->dragDropContainer->addDragWidget(zoneWidget);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget* zoneWidget)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Format changes
r844 ui->dragDropContainer->insertDragWidget(index, zoneWidget);
Add the visualization gui classes
r118 }
Retrieves zone names from the visualization
r1136 QStringList VisualizationTabWidget::availableZoneWidgets() const
{
QStringList zones;
Switched to new TS impl but quite broken!...
r1420 processZones(
tabLayout(), [&zones](VisualizationZoneWidget& zoneWidget) { zones << zoneWidget.name(); });
Retrieves zone names from the visualization
r1136
return zones;
}
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* VisualizationTabWidget::getZoneWithName(const QString& zoneName)
Time Zone Mode + prepare graph mode
r1138 {
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* result = nullptr;
processZones(tabLayout(), [&zoneName, &result](VisualizationZoneWidget& zoneWidget) {
if (!result && zoneWidget.name() == zoneName)
{
Time Zone Mode + prepare graph mode
r1138 result = &zoneWidget;
}
});
return result;
}
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* VisualizationTabWidget::createZone(std::shared_ptr<Variable2> variable)
Add the visualization gui classes
r118 {
Switched to new TS impl but quite broken!...
r1420 return createZone({ variable }, -1);
Integrates the drag&drop classes into the existing visualization classes.
r839 }
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* VisualizationTabWidget::createZone(
const std::vector<std::shared_ptr<Variable2>>& variables, int index)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Manage drag&drop of empty graphs
r841 auto zoneWidget = createEmptyZone(index);
Add the visualization gui classes
r118
Alexandre Leroux
Completes the method of creating a zone from a variable
r201 // Creates a new graph into the zone
Integrates the drag&drop classes into the existing visualization classes.
r839 zoneWidget->createGraph(variables, index);
Alexandre Leroux
Completes the method of creating a zone from a variable
r201
Add the visualization gui classes
r118 return zoneWidget;
}
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget* VisualizationTabWidget::createEmptyZone(int index)
Manage drag&drop of empty graphs
r841 {
Format changes
r844 auto zoneWidget
Switched to new TS impl but quite broken!...
r1420 = new VisualizationZoneWidget { defaultZoneName(*ui->dragDropContainer->layout()), this };
Manage drag&drop of empty graphs
r841 this->insertZone(index, zoneWidget);
return zoneWidget;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationTabWidget::accept(IVisualizationWidgetVisitor* visitor)
Add the visualization gui classes
r118 {
Switched to new TS impl but quite broken!...
r1420 if (visitor)
{
Alexandre Leroux
Implements accept() method of visualization widgets
r208 visitor->visitEnter(this);
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 // Apply visitor to zone children: widgets different from zones are not visited (no action)
Switched to new TS impl but quite broken!...
r1420 processZones(tabLayout(),
[visitor](VisualizationZoneWidget& zoneWidget) { zoneWidget.accept(visitor); });
Alexandre Leroux
Implements accept() method of visualization widgets
r208
visitor->visitLeave(this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Adds logs for null visitors
r219 qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r118 }
Switched to new TS impl but quite broken!...
r1420 bool VisualizationTabWidget::canDrop(Variable2& variable) const
Alexandre Leroux
Creates a interface that defines a variable container...
r209 {
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Switched to new TS impl but quite broken!...
r1420 bool VisualizationTabWidget::contains(Variable2& variable) const
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 {
Q_UNUSED(variable);
return false;
}
Add const and override
r119 QString VisualizationTabWidget::name() const
Add the visualization gui classes
r118 {
Alexandre Leroux
Adds a name for a tab...
r198 return impl->m_Name;
Add the visualization gui classes
r118 }
Alexandre Leroux
Adds scrollbar to tabs
r307
Switched to new TS impl but quite broken!...
r1420 void VisualizationTabWidget::closeEvent(QCloseEvent* event)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
// Closes zones in the tab
Switched to new TS impl but quite broken!...
r1420 processZones(tabLayout(), [](VisualizationZoneWidget& zoneWidget) { zoneWidget.close(); });
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738
QWidget::closeEvent(event);
}
Switched to new TS impl but quite broken!...
r1420 QLayout& VisualizationTabWidget::tabLayout() const noexcept
Alexandre Leroux
Adds scrollbar to tabs
r307 {
Integrates the drag&drop classes into the existing visualization classes.
r839 return *ui->dragDropContainer->layout();
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationTabWidget::dropMimeData(int index, const QMimeData* mimeData)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Switched to new TS impl but quite broken!...
r1420 if (mimeData->hasFormat(MIME_TYPE_GRAPH))
{
drop of variables in the visualization
r850 impl->dropGraph(index, this);
}
Switched to new TS impl but quite broken!...
r1420 else if (mimeData->hasFormat(MIME_TYPE_ZONE))
{
drop of variables in the visualization
r850 impl->dropZone(index, this);
}
Switched to new TS impl but quite broken!...
r1420 else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
{
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
Switched to new TS impl but quite broken!...
r1420 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
drop of variables in the visualization
r850 impl->dropVariables(variables, index, this);
}
Switched to new TS impl but quite broken!...
r1420 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST))
{
drop of products in visu
r1287 auto productsData = sqpApp->dataSourceController().productsDataForMimeData(
mimeData->data(MIME_TYPE_PRODUCT_LIST));
impl->dropProducts(productsData, index, this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropMimeData, unknown MIME data received.");
}
}
void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
Switched to new TS impl but quite broken!...
r1420 int index, VisualizationTabWidget* tabWidget)
drop of variables in the visualization
r850 {
Switched to new TS impl but quite broken!...
r1420 auto& helper = sqpApp->dragDropGuiController();
drop of variables in the visualization
r850
Switched to new TS impl but quite broken!...
r1420 auto graphWidget = qobject_cast<VisualizationGraphWidget*>(helper.getCurrentDragWidget());
if (!graphWidget)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropGraph, drop aborted, the dropped graph is not "
"found or invalid.");
Q_ASSERT(false);
return;
}
auto parentDragDropContainer
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationDragDropContainer*>(graphWidget->parentWidget());
if (!parentDragDropContainer)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropGraph, drop aborted, the parent container of "
"the dropped graph is not found.");
Q_ASSERT(false);
return;
}
auto nbGraph = parentDragDropContainer->countDragWidget();
Manage drag&drop of empty graphs
r841
Switched to new TS impl but quite broken!...
r1420 const auto& variables = graphWidget->variables();
drop of variables in the visualization
r850
Switched to new TS impl but quite broken!...
r1420 if (!variables.empty())
{
drop of variables in the visualization
r850 // Abort the requests for the variables (if any)
// Commented, because it's not sure if it's needed or not
// for (const auto& var : variables)
//{
// sqpApp->variableController().onAbortProgressRequested(var);
//}
Switched to new TS impl but quite broken!...
r1420 if (nbGraph == 1)
{
drop of variables in the visualization
r850 // This is the only graph in the previous zone, close the zone
Thibaud Rabillard
Fix for D&D bug on mac
r911 helper.delayedCloseWidget(graphWidget->parentZoneWidget());
Integrates the drag&drop classes into the existing visualization classes.
r839 }
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 // Close the graph
Thibaud Rabillard
Fix for D&D bug on mac
r911 helper.delayedCloseWidget(graphWidget);
drop of variables in the visualization
r850 }
Integrates the drag&drop classes into the existing visualization classes.
r839
Keep the selection zones when a graph is dropped in another synchro zone
r1048 auto zoneWidget = tabWidget->createZone(variables, index);
auto firstGraph = zoneWidget->firstGraph();
Switched to new TS impl but quite broken!...
r1420 if (firstGraph)
{
Keep the selection zones when a graph is dropped in another synchro zone
r1048 firstGraph->addSelectionZones(graphWidget->selectionZoneRanges());
}
Switched to new TS impl but quite broken!...
r1420 else
{
Keep the selection zones when a graph is dropped in another synchro zone
r1048 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropGraph, no graph added in the widget.");
Q_ASSERT(false);
}
drop of variables in the visualization
r850 }
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 // The graph is empty, create an empty zone and move the graph inside
Manage drag&drop of empty graphs
r841
drop of variables in the visualization
r850 auto parentZoneWidget = graphWidget->parentZoneWidget();
Manage drag&drop of empty graphs
r841
drop of variables in the visualization
r850 parentDragDropContainer->layout()->removeWidget(graphWidget);
Manage drag&drop of empty graphs
r841
drop of variables in the visualization
r850 auto zoneWidget = tabWidget->createEmptyZone(index);
zoneWidget->addGraph(graphWidget);
// Close the old zone if it was the only graph inside
Switched to new TS impl but quite broken!...
r1420 if (nbGraph == 1)
{
Thibaud Rabillard
Fix for D&D bug on mac
r911 helper.delayedCloseWidget(parentZoneWidget);
Manage drag&drop of empty graphs
r841 }
Integrates the drag&drop classes into the existing visualization classes.
r839 }
drop of variables in the visualization
r850 }
Integrates the drag&drop classes into the existing visualization classes.
r839
drop of variables in the visualization
r850 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone(
Switched to new TS impl but quite broken!...
r1420 int index, VisualizationTabWidget* tabWidget)
drop of variables in the visualization
r850 {
Switched to new TS impl but quite broken!...
r1420 auto& helper = sqpApp->dragDropGuiController();
drop of variables in the visualization
r850
Switched to new TS impl but quite broken!...
r1420 auto zoneWidget = qobject_cast<VisualizationZoneWidget*>(helper.getCurrentDragWidget());
if (!zoneWidget)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropZone, drop aborted, the dropped zone is not "
"found or invalid.");
Q_ASSERT(false);
return;
}
auto parentDragDropContainer
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationDragDropContainer*>(zoneWidget->parentWidget());
if (!parentDragDropContainer)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropZone, drop aborted, the parent container of "
"the dropped zone is not found.");
Q_ASSERT(false);
return;
Integrates the drag&drop classes into the existing visualization classes.
r839 }
drop of variables in the visualization
r850
// Simple move of the zone, no variable operation associated
parentDragDropContainer->layout()->removeWidget(zoneWidget);
tabWidget->ui->dragDropContainer->insertDragWidget(index, zoneWidget);
}
void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables(
Switched to new TS impl but quite broken!...
r1420 const std::vector<std::shared_ptr<Variable2>>& variables, int index,
VisualizationTabWidget* tabWidget)
drop of variables in the visualization
r850 {
Drag of product
r868 // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
Switched to new TS impl but quite broken!...
r1420 if (variables.size() > 1)
{
Drag of product
r868 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation "
"aborted.");
return;
Drop of product in variables
r870 }
Drag of product
r868
drop of variables in the visualization
r850 tabWidget->createZone(variables, index);
Alexandre Leroux
Adds scrollbar to tabs
r307 }
drop of products in visu
r1287
void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropProducts(
Switched to new TS impl but quite broken!...
r1420 const QVariantList& productsMetaData, int index, VisualizationTabWidget* tabWidget)
drop of products in visu
r1287 {
// Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
Switched to new TS impl but quite broken!...
r1420 if (productsMetaData.count() != 1)
{
drop of products in visu
r1287 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropProducts, dropping multiple products, operation "
"aborted.");
return;
}
Switched to new TS impl but quite broken!...
r1420 auto context = new QObject { tabWidget };
All the codebase is modified to build with new Variable Controller...
r1348 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
Switched to new TS impl but quite broken!...
r1420 [this, index, tabWidget, context](auto variable) {
tabWidget->createZone({ variable }, index);
delete context; // removes the connection
},
Qt::QueuedConnection);
Creates graph when dropping a product in the visu
r1288
drop of products in visu
r1287 auto productData = productsMetaData.first().toHash();
QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
Switched to new TS impl but quite broken!...
r1420 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
drop of products in visu
r1287 }