Commit 7a041595 authored by Yann Boucher's avatar Yann Boucher
Browse files
parents dc4a5568 fb263da3
Pipeline #79243 failed with stage
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NeighborhoodDialog</class>
<widget class="QDialog" name="NeighborhoodDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>894</width>
<height>441</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="mainLayout" stretch="1,0">
<item>
<widget class="QWidget" name="grid" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="GridView" name="grid_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="settingsLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QFormLayout" name="gridDimLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="widthLabel_2">
<property name="text">
<string>Width :</string>
</property>
<property name="buddy">
<cstring>widthSpinBox</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="widthSpinBox_2">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="heightLabel_2">
<property name="text">
<string>Height :</string>
</property>
<property name="buddy">
<cstring>heightSpinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="heightSpinBox_2">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="validateGridDim_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GridView</class>
<extends>QFrame</extends>
<header>gridview.hpp</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NeighborhoodDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NeighborhoodDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
...@@ -116,15 +116,9 @@ ...@@ -116,15 +116,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="validationButton"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy"> <property name="standardButtons">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Validate</string>
</property> </property>
</widget> </widget>
</item> </item>
......
#ifndef NEIGHBORHOODWIDGET_HPP #ifndef NEIGHBORHOODDIALOG_HPP
#define NEIGHBORHOODWIDGET_HPP #define NEIGHBORHOODDIALOG_HPP
#include <QDialog> #include <QDialog>
#include "neighborhood.hpp" #include "neighborhood.hpp"
#include "gridview.hpp" #include "gridview.hpp"
namespace Ui { namespace Ui {
class NeighborhoodWidget; class NeighborhoodDialog;
} }
//! \brief Fenêtre de dialogue permettant de choisir les voisins d'une cellule de manière graphique. //! \brief Fenêtre de dialogue permettant de choisir les voisins d'une cellule de manière graphique.
class NeighborhoodWidget : public QWidget class NeighborhoodDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Coord currentPoint; Coord currentPoint;
public: public:
explicit NeighborhoodWidget(QWidget *parent = nullptr); explicit NeighborhoodDialog(QWidget *parent = nullptr);
~NeighborhoodWidget(); ~NeighborhoodDialog();
//! \brief Retourne le voisinage //! \brief Retourne le voisinage
Neighborhood* getVoisinage() const; Neighborhood* getVoisinage() const;
QPushButton* getValidateButton() const;
GridView& getGridView() const ; GridView& getGridView() const ;
public slots: public slots:
Neighborhood& getNeighborhood() const; Neighborhood& getNeighborhood() const;
protected:
void done(int r);
private slots: private slots:
private: private:
Ui::NeighborhoodWidget *ui; Ui::NeighborhoodDialog *ui;
}; };
#endif // NEIGHBORHOODWIDGET_HPP #endif // NEIGHBORHOODDIALOG_HPP
...@@ -33,7 +33,7 @@ Fichier définissant la classe Property représentant une propriété chargable, ...@@ -33,7 +33,7 @@ Fichier définissant la classe Property représentant une propriété chargable,
#include "coord.hpp" #include "coord.hpp"
#include "neighborhood.hpp" #include "neighborhood.hpp"
#include "neighborhoodWidget.hpp" #include "neighborhoodDialog.hpp"
struct StringProperty; struct StringProperty;
struct IntegerProperty; struct IntegerProperty;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "propertyvisitors.hpp" #include "propertyvisitors.hpp"
#include "modelloadingdialog.hpp" #include "modelloadingdialog.hpp"
#include "configurationloadingdialog.hpp" #include "configurationloadingdialog.hpp"
#include "neighborhoodWidget.hpp" #include "neighborhoodDialog.hpp"
#include <QJsonArray> #include <QJsonArray>
#include <QDate> #include <QDate>
......
#include "neighborhoodWidget.hpp" #include "neighborhoodDialog.hpp"
#include "ui_neighborhoodWidget.h" #include "ui_neighborhoodDialog.h"
#include <QDate> #include <QDate>
#include <QMessageBox> #include <QMessageBox>
NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) : NeighborhoodDialog::NeighborhoodDialog(QWidget *parent) :
QWidget(parent), ui(new Ui::NeighborhoodWidget) QDialog(parent), ui(new Ui::NeighborhoodDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
GridView& gv = *(*ui).grid_view; GridView& gv = *(*ui).grid_view;
...@@ -33,25 +33,34 @@ NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) : ...@@ -33,25 +33,34 @@ NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) :
// TODO le clic sur la cellule centrale // TODO le clic sur la cellule centrale
} }
NeighborhoodWidget::~NeighborhoodWidget() NeighborhoodDialog::~NeighborhoodDialog()
{ {
delete ui; delete ui;
} }
Neighborhood* NeighborhoodWidget::getVoisinage() const void NeighborhoodDialog::done(int r)
{ {
return nullptr; if(QDialog::Accepted == r) // ok was pressed
{
}
else // cancel, close or exc was pressed
{
QDialog::done(r);
return;
}
} }
QPushButton* NeighborhoodWidget::getValidateButton() const { Neighborhood* NeighborhoodDialog::getVoisinage() const
return ui->validationButton; {
return nullptr;
} }
GridView& NeighborhoodWidget::getGridView() const{ GridView& NeighborhoodDialog::getGridView() const{
return *(ui->grid_view); return *(ui->grid_view);
} }
Neighborhood& NeighborhoodWidget::getNeighborhood() const Neighborhood& NeighborhoodDialog::getNeighborhood() const
{ {
Neighborhood* newNeighborhood = new Neighborhood; Neighborhood* newNeighborhood = new Neighborhood;
Grid currentGrid = ui->grid_view->get_grid(); Grid currentGrid = ui->grid_view->get_grid();
......
...@@ -18,7 +18,7 @@ SOURCES += \ ...@@ -18,7 +18,7 @@ SOURCES += \
neighborhood_rules/arbitraryneighborhoodrule.cpp \ neighborhood_rules/arbitraryneighborhoodrule.cpp \
automaton.cpp \ automaton.cpp \
gridview.cpp \ gridview.cpp \
neighborhoodWidget.cpp \ neighborhoodDialog.cpp \
savingdialog.cpp \ savingdialog.cpp \
transition_rules/circulartransition.cpp \ transition_rules/circulartransition.cpp \
transition_rules/lifegametransition.cpp \ transition_rules/lifegametransition.cpp \
...@@ -71,7 +71,7 @@ HEADERS += \ ...@@ -71,7 +71,7 @@ HEADERS += \
../include/transition_rules/circulartransition.hpp \ ../include/transition_rules/circulartransition.hpp \
../include/transition_rules/totalistictransition.hpp \ ../include/transition_rules/totalistictransition.hpp \
../include/modelloadingdialog.hpp \ ../include/modelloadingdialog.hpp \
../include/neighborhoodWidget.hpp \ ../include/neighborhoodDialog.hpp \
../include/configurationloadingdialog.hpp \ ../include/configurationloadingdialog.hpp \
../include/transition_rules/nonisotropictransition.hpp ../include/transition_rules/nonisotropictransition.hpp
...@@ -82,6 +82,7 @@ FORMS += \ ...@@ -82,6 +82,7 @@ FORMS += \
../forms/structurelibraryview.ui \ ../forms/structurelibraryview.ui \
../forms/modelloadingdialog.ui \ ../forms/modelloadingdialog.ui \
../forms/neighborhoodWidget.ui \ ../forms/neighborhoodWidget.ui \
../forms/neighborhoodDialog.ui \
../forms/configurationloadingdialog.ui ../forms/configurationloadingdialog.ui
......
#include "propertyvisitors.hpp" #include "propertyvisitors.hpp"
#include "neighborhoodWidget.hpp" #include "neighborhoodDialog.hpp"
#include <QGroupBox> #include <QGroupBox>
#include <QPushButton> #include <QPushButton>
...@@ -186,17 +186,17 @@ void UIBuilderVisitor::visit(PropertyList &list) ...@@ -186,17 +186,17 @@ void UIBuilderVisitor::visit(PropertyList &list)
} }
}); });
QObject::connect(widgetGridNeighborhoodButton, &QPushButton::pressed, [&list]() { QObject::connect(widgetGridNeighborhoodButton, &QPushButton::pressed, [&list]() {
NeighborhoodWidget* nw = new NeighborhoodWidget; NeighborhoodDialog* nw = new NeighborhoodDialog;
nw->show(); nw->exec();
QPushButton* validateButton = nw->getValidateButton(); /*
QObject::connect(validateButton, &QPushButton::pressed, [&list, &nw] () { QObject::connect(validateButton, &QPushButton::pressed, [&list, &nw] () {
list.clear(); list.clear();
Neighborhood newNeighborhood = nw->getNeighborhood(); Neighborhood newNeighborhood = nw->getNeighborhood();
// TODO a finir // TODO a finir
list.push_back(); list.push_back();
}); });*/
QObject::connect(validateButton, &QPushButton::pressed, nw, &QWidget::close ); // QObject::connect(validateButton, &QPushButton::pressed, nw, &QDialog::done );
}); });
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment