Merge branch 'terminal_strip'

This commit is contained in:
joshua
2025-10-15 23:30:54 +02:00
45 changed files with 1894 additions and 587 deletions

View File

@@ -32,16 +32,20 @@
*/
FreeTerminalEditor::FreeTerminalEditor(QETProject *project, QWidget *parent) :
QWidget(parent),
ui(new Ui::FreeTerminalEditor),
m_project(project)
ui(new Ui::FreeTerminalEditor),
m_project(project)
{
ui->setupUi(this);
ui->m_table_view->setItemDelegate(new FreeTerminalModelDelegate(ui->m_table_view));
m_model = new FreeTerminalModel(m_project, this);
m_model = new FreeTerminalModel(m_project, this);
ui->m_table_view->setModel(m_model);
ui->m_table_view->setCurrentIndex(m_model->index(0,0));
if (m_project) {
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
//Disabled the move if the table is currently edited (yellow cell)
connect(m_model, &FreeTerminalModel::dataChanged, this, [=] {
this->setDisabledMove();
@@ -135,6 +139,31 @@ void FreeTerminalEditor::apply()
reload();
}
/**
* @brief FreeTerminalEditor::setProject
* Set @project as project handled by this editor.
* If a previous project was setted, everything is clear.
* This function track the destruction of the project,
* that mean if the project pointer is deleted
* no need to call this function with a nullptr,
* everything is made inside this class.
* @param project
*/
void FreeTerminalEditor::setProject(QETProject *project)
{
if(m_project) {
disconnect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
m_project = project;
if (m_model) {
m_model->setProject(project);
}
if (m_project) {
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
reload();
}
void FreeTerminalEditor::on_m_type_cb_activated(int index)
{
if (m_model)

View File

@@ -19,8 +19,8 @@
#define FREETERMINALEDITOR_H
#include <QWidget>
#include "../../qetproject.h"
class QETProject;
class RealTerminal;
class FreeTerminalModel;
class QTableView;
@@ -40,6 +40,8 @@ class FreeTerminalEditor : public QWidget
void reload();
void apply();
void setProject(QETProject *project);
private slots:
void on_m_type_cb_activated(int index);
void on_m_function_cb_activated(int index);
@@ -52,7 +54,7 @@ class FreeTerminalEditor : public QWidget
private:
Ui::FreeTerminalEditor *ui;
QETProject *m_project = nullptr;
FreeTerminalModel *m_model = nullptr;
QPointer <QETProject> m_project;
FreeTerminalModel *m_model {nullptr};
};
#endif // FREETERMINALEDITOR_H

View File

@@ -56,10 +56,30 @@ FreeTerminalModel::Column FreeTerminalModel::columnTypeForIndex(const QModelInde
* @param parent
*/
FreeTerminalModel::FreeTerminalModel(QETProject *project, QObject *parent) :
QAbstractTableModel(parent),
m_project(project)
QAbstractTableModel(parent) {
setProject(project);
}
/**
* @brief FreeTerminalModel::setProject
* Set @project as project handled by this model.
* If a previous project was setted, everything is clear.
* This function track the destruction of the project,
* that mean if the project pointer is deleted
* no need to call this function with a nullptr,
* everything is made inside this class.
* @param project
*/
void FreeTerminalModel::setProject(QETProject *project)
{
fillTerminalVector();
if(m_project) {
disconnect(m_project, &QObject::destroyed, this, &FreeTerminalModel::clear);
}
m_project = project;
if (m_project) {
connect(m_project, &QObject::destroyed, this, &FreeTerminalModel::clear);
}
clear();
}
/**
@@ -305,20 +325,22 @@ QVector<QSharedPointer<RealTerminal> > FreeTerminalModel::realTerminalForIndex(c
*/
void FreeTerminalModel::fillTerminalVector()
{
ElementProvider provider_(m_project);
auto free_terminal_vector = provider_.freeTerminal();
if (m_project) {
ElementProvider provider_(m_project);
auto free_terminal_vector = provider_.freeTerminal();
std::sort(free_terminal_vector.begin(), free_terminal_vector.end(),
[](TerminalElement *a, TerminalElement *b)
{
return QETUtils::sortBeginIntString(a->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString(),
b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString());
});
std::sort(free_terminal_vector.begin(), free_terminal_vector.end(),
[](TerminalElement *a, TerminalElement *b)
{
return QETUtils::sortBeginIntString(a->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString(),
b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString());
});
for (const auto &terminal_ : free_terminal_vector) {
m_terminal_vector.append(terminal_->realTerminal());
m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal()));
}
for (const auto &terminal_ : free_terminal_vector) {
m_terminal_vector.append(terminal_->realTerminal());
m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal()));
}
}
}
/****************************************************************

View File

@@ -47,6 +47,7 @@ class FreeTerminalModel : public QAbstractTableModel
public:
explicit FreeTerminalModel(QETProject *project, QObject *parent = nullptr);
void setProject(QETProject *project);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;

View File

@@ -84,6 +84,12 @@ TerminalStripEditor::~TerminalStripEditor() {
delete ui;
}
void TerminalStripEditor::setProject(QETProject *project)
{
m_project = project;
setCurrentStrip(nullptr);
}
/**
* @brief TerminalStripEditor::setCurrentStrip
* Set the current terminal strip edited to \p strip_
@@ -98,27 +104,15 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
if (m_current_strip) {
disconnect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
disconnect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
disconnect(m_current_strip, &QObject::destroyed, this, &TerminalStripEditor::clear);
}
ui->m_move_to_cb->clear();
if (!strip_)
{
ui->m_installation_le ->clear();
ui->m_location_le ->clear();
ui->m_name_le ->clear();
ui->m_comment_le ->clear();
ui->m_description_te ->clear();
m_current_strip = nullptr;
ui->m_table_widget->setModel(nullptr);
if (m_model) {
m_model->deleteLater();
m_model = nullptr;
}
if (!strip_) {
clear();
}
else
{
else {
ui->m_installation_le ->setText(strip_->installation());
ui->m_location_le ->setText(strip_->location());
ui->m_name_le ->setText(strip_->name());
@@ -159,6 +153,7 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
connect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
connect(m_current_strip, &QObject::destroyed, this, &TerminalStripEditor::clear);
}
}
@@ -230,6 +225,22 @@ void TerminalStripEditor::apply()
reload();
}
void TerminalStripEditor::clear()
{
ui->m_installation_le ->clear();
ui->m_location_le ->clear();
ui->m_name_le ->clear();
ui->m_comment_le ->clear();
ui->m_description_te ->clear();
m_current_strip.clear();
ui->m_table_widget->setModel(nullptr);
if (m_model) {
m_model->deleteLater();
m_model = nullptr;
}
}
/**
* @brief TerminalStripEditor::spanMultiLevelTerminals
* Span row of m_table_widget for multi-level terminal

View File

@@ -41,11 +41,13 @@ class TerminalStripEditor : public QWidget
public:
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
~TerminalStripEditor() override;
void setProject(QETProject *project);
void setCurrentStrip(TerminalStrip *strip_);
void reload();
void apply();
private:
void clear();
void spanMultiLevelTerminals();
void selectionChanged();
QSize setUpBridgeCellWidth();
@@ -67,9 +69,9 @@ class TerminalStripEditor : public QWidget
private:
Ui::TerminalStripEditor *ui;
QETProject *m_project {nullptr};
TerminalStrip *m_current_strip {nullptr};
TerminalStripModel *m_model {nullptr};
QPointer<QETProject> m_project;
QPointer<TerminalStrip> m_current_strip;
TerminalStripModel *m_model {nullptr};
};
#endif // TERMINALSTRIPEDITOR_H

View File

@@ -51,10 +51,15 @@ void TerminalStripEditorWindow::edit(TerminalStrip *strip)
TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TerminalStripEditorWindow),
m_project(project)
ui(new Ui::TerminalStripEditorWindow),
m_project(project)
{
ui->setupUi(this);
if (auto diagram_editor = QETApp::diagramEditor(project)) {
ui->m_tool_bar->addSeparator();
ui->m_tool_bar->addAction(diagram_editor->undo);
ui->m_tool_bar->addAction(diagram_editor->redo);
}
ui->m_remove_terminal->setDisabled(true);
addTreeDockWidget();
@@ -76,6 +81,18 @@ TerminalStripEditorWindow::~TerminalStripEditorWindow()
delete ui;
}
/**
* @brief TerminalStripEditorWindow::setProject
* @param project
*/
void TerminalStripEditorWindow::setProject(QETProject *project)
{
m_project = project;
m_tree_dock->setProject(project);
m_free_terminal_editor->setProject(project);
m_terminal_strip_editor->setProject(project);
}
void TerminalStripEditorWindow::setCurrentStrip(TerminalStrip *strip) {
m_tree_dock->setSelectedStrip(strip);
}
@@ -200,4 +217,3 @@ void TerminalStripEditorWindow::on_m_button_box_clicked(QAbstractButton *button)
void TerminalStripEditorWindow::on_m_stacked_widget_currentChanged(int arg1) {
ui->m_button_box->setHidden(arg1 == EMPTY_PAGE);
}

View File

@@ -43,17 +43,19 @@ class TerminalStripEditorWindow : public QMainWindow
//instance in her destrucor and then window_ become a dangling pointer.
static QPointer<TerminalStripEditorWindow> window_;
public:
static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) {
static QMutex mutex_;
if (!window_) {
mutex_.lock();
if (!window_)
window_ = new TerminalStripEditorWindow{project, parent};
mutex_.unlock();
}
return window_;
}
public:
static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) {
static QMutex mutex_;
if (!window_) {
mutex_.lock();
if (!window_)
window_ = new TerminalStripEditorWindow{project, parent};
mutex_.unlock();
} else {
window_->setProject(project);
}
return window_;
}
static void dropInstance () {
static QMutex mutex;
@@ -71,7 +73,8 @@ class TerminalStripEditorWindow : public QMainWindow
explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr);
~TerminalStripEditorWindow();
void setCurrentStrip(TerminalStrip *strip);
void setProject(QETProject *project);
void setCurrentStrip(TerminalStrip *strip);
private slots:
void on_m_add_terminal_strip_triggered();
@@ -87,7 +90,7 @@ class TerminalStripEditorWindow : public QMainWindow
private:
Ui::TerminalStripEditorWindow *ui{nullptr};
QETProject *m_project {nullptr};
QPointer <QETProject> m_project;
TerminalStripTreeDockWidget *m_tree_dock{nullptr};
FreeTerminalEditor *m_free_terminal_editor {nullptr};
TerminalStripEditor *m_terminal_strip_editor {nullptr};

View File

@@ -33,12 +33,12 @@
<x>0</x>
<y>0</y>
<width>1364</width>
<height>21</height>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<widget class="QToolBar" name="m_tool_bar">
<property name="windowTitle">
<string>toolBar</string>
</property>

View File

@@ -15,6 +15,8 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QFontDialog>
#include "terminalstriplayouteditor.h"
#include "ui_terminalstriplayouteditor.h"
#include "../GraphicsItem/properties/terminalstriplayoutpattern.h"
@@ -54,12 +56,10 @@ void TerminalStripLayoutEditor::valueEdited()
return;
}
//auto *data_ = m_layout.data();
m_layout.data()->m_header_rect.setRect(0,
ui->m_y_header_sb->value(),
ui->m_width_header_sb->value(),
ui->m_height_header_sb->value());
m_layout.data()->m_header_rect.setRect(0,
ui->m_y_header_sb->value(),
ui->m_width_header_sb->value(),
ui->m_height_header_sb->value());
m_layout.data()->m_spacer_rect.setRect(0,
ui->m_y_spacer_sb->value(),
@@ -91,9 +91,13 @@ void TerminalStripLayoutEditor::valueEdited()
m_layout.data()->m_bridge_point_y_offset[2] = ui->m_bridge_point_2_sb->value();
m_layout.data()->m_bridge_point_y_offset[3] = ui->m_bridge_point_3_sb->value();
m_layout.data()->m_header_text_orientation = ui->m_header_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal :
Qt::Vertical;
auto font_ = ui->m_font_cb->currentFont();
font_.setPixelSize(ui->m_font_size_sb->value());
m_layout->setFont(font_);
m_layout.data()->m_header_text_orientation = ui->m_header_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal :
Qt::Vertical;
switch (ui->m_header_text_alignment_cb->currentIndex()) {
case 0:
@@ -104,34 +108,46 @@ void TerminalStripLayoutEditor::valueEdited()
m_layout.data()->setHeaderTextAlignment(Qt::AlignRight | Qt::AlignVCenter); break;
}
m_layout.data()->m_terminals_text_orientation[0] = ui->m_terminal_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal :
Qt::Vertical;
//Terminal text
m_layout.data()->m_terminals_text_orientation = ui->m_terminal_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal :
Qt::Vertical;
switch (ui->m_terminal_text_alignment_cb->currentIndex()) {
case 0:
m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter });
break;
case 1:
m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter });
break;
default:
m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter });
break;
switch (ui->m_terminal_text_alignment_cb->currentIndex()) {
case 0:
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment {Qt::AlignLeft | Qt::AlignVCenter});
break;
case 1:
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment { Qt::AlignHCenter | Qt::AlignVCenter});
break;
default:
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment { Qt::AlignRight | Qt::AlignVCenter});
break;
}
m_layout.data()->m_terminals_text_y = ui->m_terminal_text_y_sb->value();
m_layout.data()->m_terminals_text_height = ui->m_terminal_text_height_sb->value();
//Xref text
m_layout.data()->m_xref_text_orientation = ui->m_xref_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal :
Qt::Vertical;
switch (ui->m_xref_alignment_cb->currentIndex()) {
case 0:
m_layout.data()->setXrefTextAlignment(Qt::Alignment {Qt::AlignLeft | Qt::AlignVCenter});
break;
case 1:
m_layout.data()->setXrefTextAlignment(Qt::Alignment { Qt::AlignHCenter | Qt::AlignVCenter});
break;
default:
m_layout.data()->setXrefTextAlignment(Qt::Alignment { Qt::AlignRight | Qt::AlignVCenter});
break;
}
m_layout.data()->m_xref_text_y = ui->m_xref_y_sb->value();
m_layout.data()->m_xref_text_height = ui->m_xref_height_sb->value();
updateUi();
m_preview_strip_item.update();
}
@@ -180,17 +196,21 @@ void TerminalStripLayoutEditor::updateUi()
ui->m_bridge_point_2_sb->setValue(bridge_point[2]);
ui->m_bridge_point_3_sb->setValue(bridge_point[3]);
if (data->m_header_text_orientation == Qt::Horizontal) {
ui->m_header_text_orientation_cb->setCurrentIndex(0);
} else {
ui->m_header_text_orientation_cb->setCurrentIndex(1);
}
const auto font = m_layout->font();
ui->m_font_size_sb->setValue(font.pixelSize());
ui->m_font_cb->setCurrentFont(font);
if (data->m_terminals_text_orientation[0] == Qt::Horizontal) {
ui->m_terminal_text_orientation_cb->setCurrentIndex(0);
} else {
ui->m_terminal_text_orientation_cb->setCurrentIndex(1);
}
if (data->m_header_text_orientation == Qt::Horizontal) {
ui->m_header_text_orientation_cb->setCurrentIndex(0);
} else {
ui->m_header_text_orientation_cb->setCurrentIndex(1);
}
if (data->m_terminals_text_orientation == Qt::Horizontal) {
ui->m_terminal_text_orientation_cb->setCurrentIndex(0);
} else {
ui->m_terminal_text_orientation_cb->setCurrentIndex(1);
}
const auto header_alignment = data->headerTextAlignment();
if (header_alignment &Qt::AlignLeft) {
@@ -201,15 +221,38 @@ void TerminalStripLayoutEditor::updateUi()
ui->m_header_text_alignment_cb->setCurrentIndex(2);
}
const auto terminal_alignment = data->terminalsTextAlignment().at(0);
if (terminal_alignment &Qt::AlignLeft) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(0);
} else if (terminal_alignment &Qt::AlignHCenter) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(1);
} else if (terminal_alignment &Qt::AlignRight) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(2);
//Terminal text
const auto terminal_alignment = data->terminalsTextAlignment();
if (terminal_alignment &Qt::AlignLeft) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(0);
} else if (terminal_alignment &Qt::AlignHCenter) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(1);
} else if (terminal_alignment &Qt::AlignRight) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(2);
}
ui->m_terminal_text_y_sb->setValue(data->m_terminals_text_y);
ui->m_terminal_text_height_sb->setValue(data->m_terminals_text_height);
//Xref text
if (data->m_xref_text_orientation == Qt::Horizontal) {
ui->m_xref_orientation_cb->setCurrentIndex(0);
} else {
ui->m_xref_orientation_cb->setCurrentIndex(1);
}
const auto xref_alignment = data->xrefTextAlignment();
if (xref_alignment &Qt::AlignLeft) {
ui->m_xref_alignment_cb->setCurrentIndex(0);
} else if (xref_alignment &Qt::AlignHCenter) {
ui->m_xref_alignment_cb->setCurrentIndex(1);
} else if (xref_alignment &Qt::AlignRight) {
ui->m_xref_alignment_cb->setCurrentIndex(2);
}
ui->m_xref_y_sb->setValue(data->m_xref_text_y);
ui->m_xref_height_sb->setValue(data->m_xref_text_height);
m_ui_updating = false;
updatePreview();
}
@@ -225,4 +268,3 @@ void TerminalStripLayoutEditor::on_m_display_preview_help_clicked(bool checked)
m_preview_strip_item.m_drawer.setPreviewDraw(checked);
m_preview_strip_item.update();
}

View File

@@ -74,10 +74,9 @@ class TerminalStripLayoutEditor : public QWidget
void resizeEvent(QResizeEvent *event) override;
void showEvent(QShowEvent *event) override;
private slots:
void valueEdited();
void on_m_display_preview_help_clicked(bool checked);
private slots:
void valueEdited();
void on_m_display_preview_help_clicked(bool checked);
private:
void updateUi();

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<height>544</height>
<width>961</width>
<height>624</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,17 +17,17 @@
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Borne niveau 0 :</string>
<item row="4" column="2">
<widget class="QSpinBox" name="m_width_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>En tête :</string>
<item row="6" column="3">
<widget class="QSpinBox" name="m_height_terminal_2_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
@@ -38,37 +38,6 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="5">
<widget class="QGraphicsView" name="m_graphics_view"/>
</item>
<item row="3" column="4">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Point de pont</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="m_y_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="8" column="0" colspan="5">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="m_height_spacer_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
@@ -76,15 +45,43 @@
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QCheckBox" name="m_display_preview_help">
<property name="text">
<string>Afficher l'aide</string>
<item row="7" column="4">
<widget class="QSpinBox" name="m_bridge_point_3_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_width_header_sb">
<item row="5" column="3">
<widget class="QSpinBox" name="m_height_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Borne niveau 0 :</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QSpinBox" name="m_width_terminal_3_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QSpinBox" name="m_bridge_point_2_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QSpinBox" name="m_width_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
@@ -97,22 +94,39 @@
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QSpinBox" name="m_bridge_point_1_sb">
<item row="14" column="0" colspan="5">
<widget class="QGraphicsView" name="m_graphics_view"/>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="m_height_spacer_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<item row="7" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Largeur</string>
<string>Borne niveau 3 :</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QSpinBox" name="m_height_terminal_2_sb">
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Borne niveau 2 :</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="m_width_spacer_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="m_height_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
@@ -125,17 +139,48 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_5">
<item row="13" column="4">
<widget class="QCheckBox" name="m_display_preview_help">
<property name="text">
<string>Hauteur</string>
<string>Afficher l'aide</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_2">
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Prévisualisation :</string>
<string>Largeur</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QSpinBox" name="m_bridge_point_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Espace :</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="5">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QSpinBox" name="m_bridge_point_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
@@ -146,35 +191,14 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="m_y_terminal_3_sb">
<property name="maximum">
<number>1000</number>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Borne niveau 1 :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="m_y_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="m_width_spacer_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QSpinBox" name="m_width_terminal_2_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="9" column="0" colspan="5">
<item row="10" column="0" colspan="5">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
@@ -189,26 +213,21 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="3">
<widget class="QComboBox" name="m_terminal_text_alignment_cb">
<item row="5" column="3">
<widget class="QComboBox" name="m_header_text_orientation_cb">
<item>
<property name="text">
<string>Gauche</string>
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Centre</string>
</property>
</item>
<item>
<property name="text">
<string>Droite</string>
<string>Vertical</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<item row="6" column="3">
<widget class="QComboBox" name="m_header_text_alignment_cb">
<item>
<property name="text">
@@ -227,21 +246,136 @@
</item>
</widget>
</item>
<item row="0" column="2">
<item row="5" column="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Orientation</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Alignement du texte d'en tête :</string>
<string>Alignement</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_17">
<item row="1" column="2" colspan="4">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Police :</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="m_font_cb"/>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Taille :</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_font_size_sb">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Alignement du texte de borne :</string>
<string>Texte d'en tête</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="7" column="2">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Origine vertical</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Longueur maximal</string>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QSpinBox" name="m_terminal_text_y_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QSpinBox" name="m_terminal_text_height_sb">
<property name="minimum">
<number>30</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QComboBox" name="m_terminal_text_alignment_cb">
<item>
<property name="text">
<string>Gauche</string>
</property>
</item>
<item>
<property name="text">
<string>Centre</string>
</property>
</item>
<item>
<property name="text">
<string>Droite</string>
</property>
</item>
</widget>
</item>
<item row="5" column="4">
<widget class="QComboBox" name="m_terminal_text_orientation_cb">
<item>
<property name="text">
@@ -255,8 +389,28 @@
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_header_text_orientation_cb">
<item row="2" column="4">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Texte borne</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Référence croisée</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QComboBox" name="m_xref_orientation_cb">
<item>
<property name="text">
<string>Horizontal</string>
@@ -269,23 +423,66 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Orientation du texte de borne :</string>
<item row="6" column="5">
<widget class="QComboBox" name="m_xref_alignment_cb">
<item>
<property name="text">
<string>Gauche</string>
</property>
</item>
<item>
<property name="text">
<string>Centre</string>
</property>
</item>
<item>
<property name="text">
<string>Droite</string>
</property>
</item>
</widget>
</item>
<item row="7" column="5">
<widget class="QSpinBox" name="m_xref_y_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Orientation du texte d'en tête :</string>
<item row="8" column="5">
<widget class="QSpinBox" name="m_xref_height_sb">
<property name="minimum">
<number>30</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="2">
<widget class="QSpinBox" name="m_width_terminal_2_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_width_header_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>En tête :</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="m_height_header_sb">
<property name="maximum">
@@ -293,34 +490,6 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Borne niveau 2 :</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="m_width_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Espace :</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QSpinBox" name="m_width_terminal_3_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="m_y_terminal_2_sb">
<property name="maximum">
@@ -328,69 +497,55 @@
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QSpinBox" name="m_bridge_point_2_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QSpinBox" name="m_bridge_point_3_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QSpinBox" name="m_width_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="m_height_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QSpinBox" name="m_height_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Borne niveau 3 :</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QSpinBox" name="m_bridge_point_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Borne niveau 1 :</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="5">
<widget class="Line" name="line_2">
<item row="9" column="0" colspan="5">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="m_y_terminal_3_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="m_y_terminal_1_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Hauteur</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Point de pont</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="m_y_terminal_0_sb">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Prévisualisation :</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
@@ -811,6 +966,134 @@
</hint>
</hints>
</connection>
<connection>
<sender>m_font_cb</sender>
<signal>currentFontChanged(QFont)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>245</x>
<y>276</y>
</hint>
<hint type="destinationlabel">
<x>445</x>
<y>277</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_font_size_sb</sender>
<signal>valueChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>507</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>445</x>
<y>277</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_terminal_text_y_sb</sender>
<signal>valueChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>207</x>
<y>383</y>
</hint>
<hint type="destinationlabel">
<x>445</x>
<y>277</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_terminal_text_height_sb</sender>
<signal>valueChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>430</x>
<y>383</y>
</hint>
<hint type="destinationlabel">
<x>445</x>
<y>277</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_xref_alignment_cb</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>836</x>
<y>365</y>
</hint>
<hint type="destinationlabel">
<x>480</x>
<y>311</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_xref_height_sb</sender>
<signal>valueChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>836</x>
<y>431</y>
</hint>
<hint type="destinationlabel">
<x>480</x>
<y>311</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_xref_orientation_cb</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>836</x>
<y>333</y>
</hint>
<hint type="destinationlabel">
<x>480</x>
<y>311</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_xref_y_sb</sender>
<signal>valueChanged(int)</signal>
<receiver>TerminalStripLayoutEditor</receiver>
<slot>valueEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>836</x>
<y>398</y>
</hint>
<hint type="destinationlabel">
<x>480</x>
<y>311</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>valueEdited()</slot>

View File

@@ -30,11 +30,10 @@
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
QDockWidget(parent),
ui(new Ui::TerminalStripTreeDockWidget),
m_project(project)
ui(new Ui::TerminalStripTreeDockWidget)
{
ui->setupUi(this);
buildTree();
setProject(project);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
ui->m_tree_view->expandRecursively(ui->m_tree_view->rootIndex());
@@ -48,6 +47,32 @@ TerminalStripTreeDockWidget::~TerminalStripTreeDockWidget()
delete ui;
}
/**
* @brief TerminalStripTreeDockWidget::setProject
* Set @project as project handled by this tree dock.
* If a previous project was setted, everything is clear.
* This function track the destruction of the project,
* that mean if the project pointer is deleted
* no need to call this function with a nullptr,
* everything is made inside this class.
* @param project
*/
void TerminalStripTreeDockWidget::setProject(QETProject *project)
{
if(m_project && m_project_destroy_connection) {
disconnect(m_project_destroy_connection);
}
m_project = project;
if (m_project) {
m_project_destroy_connection = connect(m_project, &QObject::destroyed, [this](){
this->m_current_strip.clear();
this->reload();
});
}
m_current_strip.clear();
reload();
}
/**
* @brief TerminalStripTreeDockWidget::reload
*/
@@ -205,6 +230,9 @@ void TerminalStripTreeDockWidget::on_m_tree_view_currentItemChanged(QTreeWidgetI
*/
void TerminalStripTreeDockWidget::buildTree()
{
if(!m_project) {
return;
}
auto title_ = m_project->title();
if (title_.isEmpty()) {

View File

@@ -49,6 +49,7 @@ class TerminalStripTreeDockWidget : public QDockWidget
explicit TerminalStripTreeDockWidget(QETProject *project, QWidget *parent = nullptr);
~TerminalStripTreeDockWidget();
void setProject(QETProject *project = nullptr);
void reload();
bool currentIsStrip() const;
TerminalStrip* currentStrip() const;
@@ -74,11 +75,12 @@ class TerminalStripTreeDockWidget : public QDockWidget
QPointer<QETProject> m_project;
QPointer<TerminalStrip> m_current_strip;
QHash<QTreeWidgetItem *, TerminalStrip *> m_item_strip_H;
QHash<QTreeWidgetItem *, QPointer<TerminalStrip>> m_item_strip_H;
QHash<QUuid, QSharedPointer<RealTerminal>> m_uuid_terminal_H;
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
QVector<QMetaObject::Connection> m_strip_changed_connection;
bool m_current_is_free_terminal{false};
bool m_current_is_free_terminal{false};
QMetaObject::Connection m_project_destroy_connection;
};
#endif // TERMINALSTRIPTREEDOCKWIDGET_H