##// END OF EJS Templates
Vera corrections
Vera corrections

File last commit:

r471:d00d6fd96c10
r614:976817e9ad15
Show More
MainWindow.cpp
254 lines | 9.3 KiB | text/x-c | CppLexer
Initialisation de l'application multithread avec le spimpl....
r21 /*------------------------------------------------------------------------------
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 -- This file is a part of the SciQLop Software
-- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
Initialisation de l'application multithread avec le spimpl....
r21 --
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 #include "MainWindow.h"
#include "ui_MainWindow.h"
Alexandre Leroux
Connects data source widget to data source controller
r83
#include <DataSource/DataSourceController.h>
#include <DataSource/DataSourceWidget.h>
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 #include <Settings/SqpSettingsDialog.h>
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r429 #include <Settings/SqpSettingsGeneralWidget.h>
Add button on the SidePane widgets to open left or right inspectors
r98 #include <SidePane/SqpSidePane.h>
Alexandre Leroux
Connects data source widget to data source controller
r83 #include <SqpApplication.h>
add TimeWidget connection
r178 #include <Time/TimeController.h>
Modificaiton of the sidepane :...
r125 #include <TimeWidget/TimeWidget.h>
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r162 #include <Variable/Variable.h>
Temporal parameters of the selected variables can be updated using the...
r281 #include <Variable/VariableController.h>
Alexandre Leroux
Creates the slot to display the created variable in the Visualization widget...
r162 #include <Visualization/VisualizationController.h>
Alexandre Leroux
Connects data source widget to data source controller
r83
Initialisation de l'application multithread avec le spimpl....
r21 #include <QAction>
#include <QDate>
#include <QDir>
#include <QFileDialog>
Add button on the SidePane widgets to open left or right inspectors
r98 #include <QToolBar>
Factorisation of the lambda connected to the side pane button
r130 #include <QToolButton>
Add button on the SidePane widgets to open left or right inspectors
r98 #include <memory.h>
#include "iostream"
Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
PRC: add tr on text...
r99 namespace {
const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
const auto VIEWPLITTERINDEX = 2;
const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
}
Add button on the SidePane widgets to open left or right inspectors
r98 class MainWindow::MainWindowPrivate {
public:
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 explicit MainWindowPrivate(MainWindow *mainWindow)
: m_LastOpenLeftInspectorSize{},
m_LastOpenRightInspectorSize{},
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r429 m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}},
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 m_SettingsDialog{new SqpSettingsDialog{mainWindow}}
{
}
Add button on the SidePane widgets to open left or right inspectors
r98 QSize m_LastOpenLeftInspectorSize;
QSize m_LastOpenRightInspectorSize;
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r429 /// General settings widget. MainWindow has the ownership
SqpSettingsGeneralWidget *m_GeneralSettingsWidget;
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 /// Settings dialog. MainWindow has the ownership
SqpSettingsDialog *m_SettingsDialog;
Add button on the SidePane widgets to open left or right inspectors
r98 };
MainWindow::MainWindow(QWidget *parent)
: QMainWindow{parent},
m_Ui{new Ui::MainWindow},
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
Initialisation de l'application multithread avec le spimpl....
r21 {
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 m_Ui->setupUi(this);
Add skelleton of the gui
r56
PRC: add tr on text...
r99 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
Add button on the SidePane widgets to open left or right inspectors
r98
Modificaiton of the sidepane :...
r125
auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
Correction MR
r131 auto openLeftInspectorAction = new QAction{QIcon{
":/icones/previous.png",
},
tr("Show/hide the left inspector"), this};
Modificaiton of the sidepane :...
r125
Correction MR
r131 auto spacerLeftTop = new QWidget{};
Modificaiton of the sidepane :...
r125 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Correction MR
r131 auto spacerLeftBottom = new QWidget{};
Modificaiton of the sidepane :...
r125 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
leftSidePane->addWidget(spacerLeftTop);
leftSidePane->addAction(openLeftInspectorAction);
leftSidePane->addWidget(spacerLeftBottom);
auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
Correction MR
r131 auto openRightInspectorAction = new QAction{QIcon{
":/icones/next.png",
},
tr("Show/hide the right inspector"), this};
Modificaiton of the sidepane :...
r125
Correction MR
r131 auto spacerRightTop = new QWidget{};
Modificaiton of the sidepane :...
r125 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Correction MR
r131 auto spacerRightBottom = new QWidget{};
Modificaiton of the sidepane :...
r125 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
rightSidePane->addWidget(spacerRightTop);
rightSidePane->addAction(openRightInspectorAction);
rightSidePane->addWidget(spacerRightBottom);
openLeftInspectorAction->setCheckable(true);
openRightInspectorAction->setCheckable(true);
Factorisation of the lambda connected to the side pane button
r130 auto openInspector = [this](bool checked, bool right, auto action) {
Modificaiton of the sidepane :...
r125
Factorisation of the lambda connected to the side pane button
r130 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
Modificaiton of the sidepane :...
r125
Factorisation of the lambda connected to the side pane button
r130 auto &lastInspectorSize
= right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
: m_Ui->leftMainInspectorWidget->size();
Add button on the SidePane widgets to open left or right inspectors
r98
// Update of the last opened geometry
if (checked) {
Factorisation of the lambda connected to the side pane button
r130 lastInspectorSize = nextInspectorSize;
Add button on the SidePane widgets to open left or right inspectors
r98 }
Factorisation of the lambda connected to the side pane button
r130 auto startSize = lastInspectorSize;
Add button on the SidePane widgets to open left or right inspectors
r98 auto endSize = startSize;
endSize.setWidth(0);
Factorisation of the lambda connected to the side pane button
r130 auto splitterInspectorIndex
= right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
PRC: add tr on text...
r99 auto currentSizes = m_Ui->splitter->sizes();
Add button on the SidePane widgets to open left or right inspectors
r98 if (checked) {
// adjust sizes individually here, e.g.
Factorisation of the lambda connected to the side pane button
r130 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
Add button on the SidePane widgets to open left or right inspectors
r98 m_Ui->splitter->setSizes(currentSizes);
}
else {
// adjust sizes individually here, e.g.
Factorisation of the lambda connected to the side pane button
r130 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
Add button on the SidePane widgets to open left or right inspectors
r98 m_Ui->splitter->setSizes(currentSizes);
}
};
Modificaiton of the sidepane :...
r125
Factorisation of the lambda connected to the side pane button
r130 connect(openLeftInspectorAction, &QAction::triggered,
[openInspector, openLeftInspectorAction](bool checked) {
openInspector(checked, false, openLeftInspectorAction);
Modificaiton of the sidepane :...
r125 });
Factorisation of the lambda connected to the side pane button
r130 connect(openRightInspectorAction, &QAction::triggered,
[openInspector, openRightInspectorAction](bool checked) {
openInspector(checked, true, openRightInspectorAction);
Modificaiton of the sidepane :...
r125 });
Add button on the SidePane widgets to open left or right inspectors
r98
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 // //// //
// Menu //
// //// //
PRC: add tr on text...
r99 this->menuBar()->addAction(tr("File"));
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
toolsMenu->addAction(tr("Settings..."), [this]() {
Alexandre Leroux
Settings binding (4)...
r433 // Loads settings
impl->m_SettingsDialog->loadSettings();
// Open settings dialog and save settings if the dialog is accepted
if (impl->m_SettingsDialog->exec() == QDialog::Accepted) {
impl->m_SettingsDialog->saveSettings();
}
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 });
PRC: add tr on text...
r99 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
Modificaiton of the sidepane :...
r125
add TimeWidget connection
r178 auto timeWidget = new TimeWidget{};
mainToolBar->addWidget(timeWidget);
Alexandre Leroux
Connects data source widget to data source controller
r83
Alexandre Leroux
Creates widget for "general settings" and registers it to the dialog
r429 // //////// //
// Settings //
// //////// //
// Registers "general settings" widget to the settings dialog
impl->m_SettingsDialog->registerWidget(QStringLiteral("General"),
impl->m_GeneralSettingsWidget);
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r427 // /////////// //
// Connections //
// /////////// //
Alexandre Leroux
Variable deletion (7)...
r310 // Controllers / controllers connections
Change SqpRange for SqpDateTime
r471 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(),
SLOT(onDateTimeOnSelection(SqpRange)));
Alexandre Leroux
Variable deletion (7)...
r310
Alexandre Leroux
Connects data source widget to data source controller
r83 // Widgets / controllers connections
add TimeWidget connection
r178
// DataSource
Alexandre Leroux
Change signal/slot signature for data source
r90 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
Alexandre Leroux
Connects data source widget to data source controller
r83
add TimeWidget connection
r178 // Time
Change SqpRange for SqpDateTime
r471 connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(),
SLOT(onTimeToUpdate(SqpRange)));
add TimeWidget connection
r178
Alexandre Leroux
Variable deletion (7)...
r310 // Visualization
connect(&sqpApp->visualizationController(),
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
Temporal parameters of the selected variables can be updated using the...
r281
Add connection logical for the rescale operation
r403 connect(&sqpApp->visualizationController(),
Change SqpRange for SqpDateTime
r471 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view,
SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
Add connection logical for the rescale operation
r403
Alexandre Leroux
Connects variable widget to visualization widget...
r232 // Widgets / widgets connections
// For the following connections, we use DirectConnection to allow each widget that can
// potentially attach a menu to the variable's menu to do so before this menu is displayed.
// The order of connections is also important, since it determines the order in which each
// widget will attach its menu
Alexandre Leroux
Changes signal to pass a list of variables...
r266 connect(
m_Ui->variableInspectorWidget,
SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
Qt::DirectConnection);
Initialisation de l'application multithread avec le spimpl....
r21 }
MainWindow::~MainWindow()
{
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
Refactoring of app module to avoir vera++ warning and to dispatch sources files in the corrects paths
r54 m_Ui->retranslateUi(this);
Initialisation de l'application multithread avec le spimpl....
r21 break;
default:
break;
}
}