Commit fb263da3 authored by Eugene Pin's avatar Eugene Pin
Browse files

Avancement dans le widget neighborhood #55

parent dd944119
Pipeline #79242 canceled 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 @@
</layout>
</item>
<item>
<widget class="QPushButton" name="validationButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Validate</string>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
......
#ifndef NEIGHBORHOODWIDGET_HPP
#define NEIGHBORHOODWIDGET_HPP
#ifndef NEIGHBORHOODDIALOG_HPP
#define NEIGHBORHOODDIALOG_HPP
#include <QDialog>
#include "neighborhood.hpp"
#include "gridview.hpp"
namespace Ui {
class NeighborhoodWidget;
class NeighborhoodDialog;
}
//! \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
Coord currentPoint;
public:
explicit NeighborhoodWidget(QWidget *parent = nullptr);
~NeighborhoodWidget();
explicit NeighborhoodDialog(QWidget *parent = nullptr);
~NeighborhoodDialog();
//! \brief Retourne le voisinage
Neighborhood* getVoisinage() const;
QPushButton* getValidateButton() const;
GridView& getGridView() const ;
public slots:
Neighborhood& getNeighborhood() const;
protected:
void done(int r);
private slots:
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,
#include "coord.hpp"
#include "neighborhood.hpp"
#include "neighborhoodWidget.hpp"
#include "neighborhoodDialog.hpp"
struct StringProperty;
struct IntegerProperty;
......
......@@ -10,7 +10,7 @@
#include "propertyvisitors.hpp"
#include "modelloadingdialog.hpp"
#include "configurationloadingdialog.hpp"
#include "neighborhoodWidget.hpp"
#include "neighborhoodDialog.hpp"
#include <QJsonArray>
#include <QDate>
......
#include "neighborhoodWidget.hpp"
#include "ui_neighborhoodWidget.h"
#include "neighborhoodDialog.hpp"
#include "ui_neighborhoodDialog.h"
#include <QDate>
#include <QMessageBox>
NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) :
QWidget(parent), ui(new Ui::NeighborhoodWidget)
NeighborhoodDialog::NeighborhoodDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::NeighborhoodDialog)
{
ui->setupUi(this);
GridView& gv = *(*ui).grid_view;
......@@ -33,25 +33,34 @@ NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) :
// TODO le clic sur la cellule centrale
}
NeighborhoodWidget::~NeighborhoodWidget()
NeighborhoodDialog::~NeighborhoodDialog()
{
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 {
return ui->validationButton;
Neighborhood* NeighborhoodDialog::getVoisinage() const
{
return nullptr;
}
GridView& NeighborhoodWidget::getGridView() const{
GridView& NeighborhoodDialog::getGridView() const{
return *(ui->grid_view);
}
Neighborhood& NeighborhoodWidget::getNeighborhood() const
Neighborhood& NeighborhoodDialog::getNeighborhood() const
{
Neighborhood* newNeighborhood = new Neighborhood;
Grid currentGrid = ui->grid_view->get_grid();
......
......@@ -18,7 +18,7 @@ SOURCES += \
neighborhood_rules/arbitraryneighborhoodrule.cpp \
automaton.cpp \
gridview.cpp \
neighborhoodWidget.cpp \
neighborhoodDialog.cpp \
savingdialog.cpp \
transition_rules/circulartransition.cpp \
transition_rules/lifegametransition.cpp \
......@@ -71,7 +71,7 @@ HEADERS += \
../include/transition_rules/circulartransition.hpp \
../include/transition_rules/totalistictransition.hpp \
../include/modelloadingdialog.hpp \
../include/neighborhoodWidget.hpp \
../include/neighborhoodDialog.hpp \
../include/configurationloadingdialog.hpp \
../include/transition_rules/nonisotropictransition.hpp
......@@ -82,6 +82,7 @@ FORMS += \
../forms/structurelibraryview.ui \
../forms/modelloadingdialog.ui \
../forms/neighborhoodWidget.ui \
../forms/neighborhoodDialog.ui \
../forms/configurationloadingdialog.ui
......
#include "propertyvisitors.hpp"
#include "neighborhoodWidget.hpp"
#include "neighborhoodDialog.hpp"
#include <QGroupBox>
#include <QPushButton>
......@@ -186,17 +186,17 @@ void UIBuilderVisitor::visit(PropertyList &list)
}
});
QObject::connect(widgetGridNeighborhoodButton, &QPushButton::pressed, [&list]() {
NeighborhoodWidget* nw = new NeighborhoodWidget;
nw->show();
QPushButton* validateButton = nw->getValidateButton();
NeighborhoodDialog* nw = new NeighborhoodDialog;
nw->exec();
/*
QObject::connect(validateButton, &QPushButton::pressed, [&list, &nw] () {
list.clear();
Neighborhood newNeighborhood = nw->getNeighborhood();
// TODO a finir
list.push_back();
});
QObject::connect(validateButton, &QPushButton::pressed, nw, &QWidget::close );
});*/
// QObject::connect(validateButton, &QPushButton::pressed, nw, &QDialog::done );
});
}
......
Markdown is supported
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