mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Change terminal strip editor class
Change parent class from QDialog to QWidget. Terminal strip editor is now embedded in TerminalStripEditorWindow.
This commit is contained in:
@@ -17,17 +17,10 @@
|
||||
*/
|
||||
#include "terminalstripeditor.h"
|
||||
#include "ui_terminalstripeditor.h"
|
||||
#include "terminalstripcreatordialog.h"
|
||||
#include "../../qetproject.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "../../elementprovider.h"
|
||||
#include "../qetgraphicsitem/terminalelement.h"
|
||||
#include "../UndoCommand/addterminalstripcommand.h"
|
||||
#include "../UndoCommand/addterminaltostripcommand.h"
|
||||
#include "../UndoCommand/changeterminalstripdata.h"
|
||||
#include "../undocommand/changeelementdatacommand.h"
|
||||
#include "terminalstriptreewidget.h"
|
||||
#include "../../qeticons.h"
|
||||
#include "terminalstripmodel.h"
|
||||
#include "../diagram.h"
|
||||
#include "../UndoCommand/sortterminalstripcommand.h"
|
||||
@@ -36,11 +29,7 @@
|
||||
#include "../UndoCommand/bridgeterminalscommand.h"
|
||||
#include "../UndoCommand/changeterminalstripcolor.h"
|
||||
#include "../physicalterminal.h"
|
||||
#include "../realterminal.h"
|
||||
#include "../terminalstripbridge.h"
|
||||
#include "freeterminaleditor.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::TerminalStripEditor
|
||||
@@ -48,35 +37,20 @@
|
||||
* @param parent : paent widget
|
||||
*/
|
||||
TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TerminalStripEditor),
|
||||
m_project(project)
|
||||
QWidget{parent},
|
||||
ui{new Ui::TerminalStripEditor},
|
||||
m_project{project}
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->m_table_widget->setItemDelegate(new TerminalStripModelDelegate(ui->m_terminal_strip_tw));
|
||||
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
buildTree();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
#else
|
||||
ui->m_terminal_strip_tw->expandAll();
|
||||
#endif
|
||||
ui->m_table_widget->setItemDelegate(new TerminalStripModelDelegate{this});
|
||||
|
||||
//Setup the bridge color
|
||||
ui->m_bridge_color_cb->setColors(TerminalStripBridge::bridgeColor().toList());
|
||||
|
||||
m_free_terminal_editor = new FreeTerminalEditor(project, this);
|
||||
ui->verticalLayout_2->insertWidget(1, m_free_terminal_editor);
|
||||
|
||||
setUpUndoConnections();
|
||||
|
||||
//Call for update the state of child widgets
|
||||
selectionChanged();
|
||||
|
||||
updateWidget();
|
||||
|
||||
//Go the diagram of double clicked terminal
|
||||
connect(ui->m_table_widget, &QAbstractItemView::doubleClicked, this, [=](const QModelIndex &index)
|
||||
{
|
||||
@@ -109,200 +83,6 @@ TerminalStripEditor::~TerminalStripEditor() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TerminalStripEditor::setUpUndoConnections()
|
||||
{
|
||||
connect(ui->m_terminal_strip_tw, &TerminalStripTreeWidget::terminalAddedToStrip, this,
|
||||
[=](QUuid terminal_uuid, QUuid strip_uuid)
|
||||
{
|
||||
auto terminal = m_uuid_terminal_H.value(terminal_uuid);
|
||||
auto strip = m_uuid_strip_H.value(strip_uuid);
|
||||
|
||||
if (!terminal || !strip) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto undo = new AddTerminalToStripCommand(terminal, strip);
|
||||
m_project->undoStack()->push(undo);
|
||||
});
|
||||
|
||||
connect(ui->m_terminal_strip_tw, &TerminalStripTreeWidget::terminalMovedFromStripToStrip, this,
|
||||
[=] (QUuid terminal_uuid, QUuid old_strip_uuid, QUuid new_strip_uuid)
|
||||
{
|
||||
auto old_strip = m_uuid_strip_H.value(old_strip_uuid);
|
||||
auto new_strip = m_uuid_strip_H.value(new_strip_uuid);
|
||||
|
||||
if (!old_strip || !new_strip) {
|
||||
return;
|
||||
}
|
||||
auto terminal = old_strip->physicalTerminal(terminal_uuid);
|
||||
if (!terminal) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto undo = new MoveTerminalCommand(terminal, old_strip, new_strip);
|
||||
m_project->undoStack()->push(undo);
|
||||
});
|
||||
|
||||
connect(ui->m_terminal_strip_tw, &TerminalStripTreeWidget::terminalRemovedFromStrip, this,
|
||||
[=] (QUuid terminal_uuid, QUuid old_strip_uuid)
|
||||
{
|
||||
auto strip_ = m_uuid_strip_H.value(old_strip_uuid);
|
||||
if (!strip_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto terminal_ = strip_->physicalTerminal(terminal_uuid);
|
||||
if (!terminal_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto undo = new RemoveTerminalFromStripCommand(terminal_, strip_);
|
||||
m_project->undoStack()->push(undo);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::buildTree
|
||||
* Build the tree widget use to explore terminal strip
|
||||
*/
|
||||
void TerminalStripEditor::buildTree()
|
||||
{
|
||||
ui->m_terminal_strip_tw->clear();
|
||||
|
||||
auto title = m_project->title();
|
||||
if (title.isEmpty()) {
|
||||
title = tr("Projet sans titre");
|
||||
}
|
||||
|
||||
QStringList strl{title};
|
||||
new QTreeWidgetItem(ui->m_terminal_strip_tw, strl, TerminalStripTreeWidget::Root);
|
||||
|
||||
QStringList ftstrl(tr("Bornes indépendante"));
|
||||
new QTreeWidgetItem(ui->m_terminal_strip_tw, ftstrl, TerminalStripTreeWidget::FreeTerminal);
|
||||
|
||||
auto ts_vector = m_project->terminalStrip();
|
||||
std::sort(ts_vector.begin(), ts_vector.end(), [](TerminalStrip *a, TerminalStrip *b) {
|
||||
return a->name() < b->name();});
|
||||
|
||||
for (const auto ts : qAsConst(ts_vector)) {
|
||||
addTerminalStrip(ts);
|
||||
}
|
||||
addFreeTerminal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::addTerminalStrip
|
||||
* Add a new terminal strip to the list of displayed terminal strip
|
||||
* in the tree widget
|
||||
* @param terminal_strip
|
||||
* @return the QTreeWidgetItem who represent the terminal strip
|
||||
* both if created or already exist
|
||||
*/
|
||||
QTreeWidgetItem* TerminalStripEditor::addTerminalStrip(TerminalStrip *terminal_strip)
|
||||
{
|
||||
if (auto item = m_item_strip_H.key(terminal_strip)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
auto root_item = ui->m_terminal_strip_tw->topLevelItem(0);
|
||||
|
||||
//Check if installation already exist
|
||||
//if not create a new one
|
||||
auto installation_str = terminal_strip->installation();
|
||||
QTreeWidgetItem *inst_qtwi = nullptr;
|
||||
for (int i = 0 ; i<root_item->childCount() ; ++i) {
|
||||
auto child_inst = root_item->child(i);
|
||||
if (child_inst->data(0, Qt::DisplayRole).toString() == installation_str) {
|
||||
inst_qtwi = child_inst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inst_qtwi) {
|
||||
QStringList inst_strl{installation_str};
|
||||
inst_qtwi = new QTreeWidgetItem(root_item, inst_strl, TerminalStripTreeWidget::Installation);
|
||||
}
|
||||
|
||||
//Check if location already exist
|
||||
//if not create a new one
|
||||
auto location_str = terminal_strip->location();
|
||||
QTreeWidgetItem *loc_qtwi = nullptr;
|
||||
for (int i = 0 ; i<inst_qtwi->childCount() ; ++i) {
|
||||
auto child_loc = inst_qtwi->child(i);
|
||||
if (child_loc->data(0, Qt::DisplayRole).toString() == location_str) {
|
||||
loc_qtwi = child_loc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!loc_qtwi) {
|
||||
QStringList loc_strl{location_str};
|
||||
loc_qtwi = new QTreeWidgetItem(inst_qtwi, loc_strl, TerminalStripTreeWidget::Location);
|
||||
}
|
||||
|
||||
//Add the terminal strip
|
||||
QStringList name{terminal_strip->name()};
|
||||
auto strip_item = new QTreeWidgetItem(loc_qtwi, name, TerminalStripTreeWidget::Strip);
|
||||
strip_item->setData(0, TerminalStripTreeWidget::UUID_USER_ROLE, terminal_strip->uuid());
|
||||
strip_item->setIcon(0, QET::Icons::TerminalStrip);
|
||||
|
||||
//Add child terminal of the strip
|
||||
for (auto i=0 ; i<terminal_strip->physicalTerminalCount() ; ++i)
|
||||
{
|
||||
auto phy_t = terminal_strip->physicalTerminal(i);
|
||||
if (phy_t->realTerminalCount())
|
||||
{
|
||||
QString text_;
|
||||
for (const auto &real_t : phy_t->realTerminals())
|
||||
{
|
||||
if (text_.isEmpty())
|
||||
text_ = real_t->label();
|
||||
else
|
||||
text_.append(QStringLiteral(", ")).append(real_t->label());
|
||||
}
|
||||
const auto real_t = phy_t->realTerminals().at(0);
|
||||
auto terminal_item = new QTreeWidgetItem(strip_item, QStringList(text_), TerminalStripTreeWidget::Terminal);
|
||||
terminal_item->setData(0, TerminalStripTreeWidget::UUID_USER_ROLE, phy_t->uuid());
|
||||
terminal_item->setIcon(0, QET::Icons::ElementTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
m_item_strip_H.insert(strip_item, terminal_strip);
|
||||
m_uuid_strip_H.insert(terminal_strip->uuid(), terminal_strip);
|
||||
return strip_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::addFreeTerminal
|
||||
* Add free terminal (aka terminal which not belong to a terminal strip)
|
||||
* in the tree widget
|
||||
*/
|
||||
void TerminalStripEditor::addFreeTerminal()
|
||||
{
|
||||
ElementProvider ep(m_project);
|
||||
auto vector_ = ep.freeTerminal();
|
||||
|
||||
if (vector_.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Sort the terminal element by label
|
||||
std::sort(vector_.begin(), vector_.end(), [](TerminalElement *a, TerminalElement *b) {
|
||||
return a->actualLabel() < b->actualLabel();
|
||||
});
|
||||
|
||||
auto free_terminal_item = ui->m_terminal_strip_tw->topLevelItem(1);
|
||||
|
||||
for (const auto terminal : qAsConst(vector_))
|
||||
{
|
||||
QUuid uuid_ = terminal->uuid();
|
||||
QStringList strl{terminal->actualLabel()};
|
||||
auto item = new QTreeWidgetItem(free_terminal_item, strl, TerminalStripTreeWidget::Terminal);
|
||||
item->setData(0, TerminalStripTreeWidget::UUID_USER_ROLE, uuid_.toString());
|
||||
item->setIcon(0, QET::Icons::ElementTerminal);
|
||||
|
||||
m_uuid_terminal_H.insert(uuid_, terminal->realTerminal());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::setCurrentStrip
|
||||
* Set the current terminal strip edited to \p strip_
|
||||
@@ -315,8 +95,8 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
||||
}
|
||||
|
||||
if (m_current_strip) {
|
||||
disconnect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::on_m_reload_pb_clicked);
|
||||
disconnect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::on_m_reload_pb_clicked);
|
||||
disconnect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
||||
disconnect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
||||
}
|
||||
|
||||
if (!strip_)
|
||||
@@ -344,20 +124,90 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
||||
m_current_strip = strip_;
|
||||
|
||||
if (m_model)
|
||||
m_model->deleteLater();
|
||||
|
||||
m_model = new TerminalStripModel(strip_, this);
|
||||
{
|
||||
m_model->setTerminalStrip(strip_);
|
||||
connect(ui->m_table_widget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TerminalStripEditor::selectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_model = new TerminalStripModel{strip_, this};
|
||||
ui->m_table_widget->setModel(m_model);
|
||||
m_model->buildBridgePixmap(setUpBridgeCellWidth());
|
||||
}
|
||||
|
||||
spanMultiLevelTerminals();
|
||||
selectionChanged(); //Used to update child widgets
|
||||
|
||||
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::on_m_reload_pb_clicked);
|
||||
connect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::on_m_reload_pb_clicked);
|
||||
connect(ui->m_table_widget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TerminalStripEditor::selectionChanged);
|
||||
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
||||
connect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::reload
|
||||
* Reload this editor and and reset all
|
||||
* unapplied change.
|
||||
*/
|
||||
void TerminalStripEditor::reload()
|
||||
{
|
||||
if (m_current_strip)
|
||||
{
|
||||
ui->m_installation_le ->setText(m_current_strip->installation());
|
||||
ui->m_location_le ->setText(m_current_strip->location());
|
||||
ui->m_name_le ->setText(m_current_strip->name());
|
||||
ui->m_comment_le ->setText(m_current_strip->comment());
|
||||
ui->m_description_te ->setPlainText(m_current_strip->description());
|
||||
}
|
||||
if (m_model)
|
||||
{
|
||||
m_model->reload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::apply
|
||||
* Apply current edited values.
|
||||
*/
|
||||
void TerminalStripEditor::apply()
|
||||
{
|
||||
|
||||
if (m_current_strip)
|
||||
{
|
||||
m_project->undoStack()->beginMacro(tr("Modifier des propriétés de borniers"));
|
||||
|
||||
TerminalStripData data;
|
||||
data.m_installation = ui->m_installation_le->text();
|
||||
data.m_location = ui->m_location_le->text();
|
||||
data.m_name = ui->m_name_le->text();
|
||||
data.m_comment = ui->m_comment_le->text();
|
||||
data.m_description = ui->m_description_te->toPlainText();
|
||||
|
||||
m_project->undoStack()->push(new ChangeTerminalStripData(m_current_strip, data, nullptr));
|
||||
|
||||
if (m_model)
|
||||
{
|
||||
for (const auto &data_ : m_model->modifiedmodelRealTerminalData())
|
||||
{
|
||||
if (auto element = data_.element_)
|
||||
{
|
||||
auto current_data = element->elementData();
|
||||
current_data.setTerminalType(data_.type_);
|
||||
current_data.setTerminalFunction(data_.function_);
|
||||
current_data.setTerminalLED(data_.led_);
|
||||
current_data.m_informations.addValue(QStringLiteral("label"), data_.label_);
|
||||
|
||||
if (element->elementData() != current_data)
|
||||
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data));
|
||||
if (data_.level_ != data_.real_terminal.toStrongRef()->level())
|
||||
m_project->undoStack()->push(new ChangeTerminalLevel(m_current_strip, data_.real_terminal, data_.level_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateWidget();
|
||||
m_project->undoStack()->endMacro();
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,173 +395,6 @@ QPair<TerminalStripModel::Column, QVector<modelRealTerminalData> > TerminalStrip
|
||||
return qMakePair(TerminalStripModel::Invalid, QVector<modelRealTerminalData>());
|
||||
}
|
||||
|
||||
void TerminalStripEditor::updateWidget()
|
||||
{
|
||||
ui->m_tab_widget->setVisible(m_current_strip);
|
||||
m_free_terminal_editor->setHidden(m_current_strip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::on_m_add_terminal_strip_pb_clicked
|
||||
* Action when user click on add terminal strip button
|
||||
*/
|
||||
void TerminalStripEditor::on_m_add_terminal_strip_pb_clicked()
|
||||
{
|
||||
QScopedPointer<TerminalStripCreatorDialog> dialog(new TerminalStripCreatorDialog(m_project, this));
|
||||
|
||||
if (auto item = ui->m_terminal_strip_tw->currentItem())
|
||||
{
|
||||
if (item->type() == TerminalStripTreeWidget::Strip) {
|
||||
item = item->parent();
|
||||
}
|
||||
if (item->type() == TerminalStripTreeWidget::Location) {
|
||||
dialog->setLocation(item->data(0, Qt::DisplayRole).toString());
|
||||
item = item->parent();
|
||||
}
|
||||
if (item->type() == TerminalStripTreeWidget::Installation) {
|
||||
dialog->setInstallation(item->data(0, Qt::DisplayRole).toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
auto ts = dialog->generatedTerminalStrip();
|
||||
m_project->undoStack()->push(new AddTerminalStripCommand(ts, m_project));
|
||||
|
||||
auto item = addTerminalStrip(ts);
|
||||
ui->m_terminal_strip_tw->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::on_m_remove_terminal_strip_pb_clicked
|
||||
* Action when user click on remove terminal strip button
|
||||
*/
|
||||
void TerminalStripEditor::on_m_remove_terminal_strip_pb_clicked()
|
||||
{
|
||||
auto item = ui->m_terminal_strip_tw->currentItem();
|
||||
if (auto strip = m_item_strip_H.value(item))
|
||||
{
|
||||
m_item_strip_H.remove(item);
|
||||
m_uuid_strip_H.remove(strip->uuid());
|
||||
delete item;
|
||||
|
||||
m_project->undoStack()->push(new RemoveTerminalStripCommand(strip, m_project));
|
||||
}
|
||||
|
||||
on_m_reload_pb_clicked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::on_m_reload_pb_clicked
|
||||
*/
|
||||
void TerminalStripEditor::on_m_reload_pb_clicked()
|
||||
{
|
||||
auto current_ = m_current_strip;
|
||||
|
||||
ui->m_terminal_strip_tw->clear();
|
||||
m_item_strip_H.clear();
|
||||
m_uuid_terminal_H.clear();
|
||||
m_uuid_strip_H.clear();
|
||||
|
||||
qDeleteAll(m_item_strip_H.keyBegin(), m_item_strip_H.keyEnd());
|
||||
|
||||
buildTree();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
#else
|
||||
ui->m_terminal_strip_tw->expandAll();
|
||||
#endif
|
||||
|
||||
//Reselect the tree widget item of the current edited strip
|
||||
auto item = m_item_strip_H.key(current_);
|
||||
if (item) {
|
||||
ui->m_terminal_strip_tw->setCurrentItem(item);
|
||||
}
|
||||
|
||||
m_free_terminal_editor->reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged
|
||||
* @param current
|
||||
* @param previous
|
||||
*/
|
||||
void TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (!current) {
|
||||
setCurrentStrip(nullptr);
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
TerminalStrip *strip_ = nullptr;
|
||||
if (current->type() == TerminalStripTreeWidget::Strip) {
|
||||
strip_ = m_item_strip_H.value(current);
|
||||
ui->m_remove_terminal_strip_pb->setEnabled(true);
|
||||
}
|
||||
else if (current->type() == TerminalStripTreeWidget::Terminal
|
||||
&& current->parent()
|
||||
&& current->parent()->type() == TerminalStripTreeWidget::Strip) {
|
||||
strip_ = m_item_strip_H.value(current->parent());
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
} else {
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
}
|
||||
|
||||
setCurrentStrip(strip_);
|
||||
}
|
||||
|
||||
void TerminalStripEditor::on_m_dialog_button_box_clicked(QAbstractButton *button)
|
||||
{
|
||||
Q_UNUSED(button)
|
||||
|
||||
auto role = ui->m_dialog_button_box->buttonRole(button);
|
||||
|
||||
if (role == QDialogButtonBox::ApplyRole)
|
||||
{
|
||||
if (m_current_strip)
|
||||
{
|
||||
m_project->undoStack()->beginMacro(tr("Modifier des propriétés de borniers"));
|
||||
|
||||
TerminalStripData data;
|
||||
data.m_installation = ui->m_installation_le->text();
|
||||
data.m_location = ui->m_location_le->text();
|
||||
data.m_name = ui->m_name_le->text();
|
||||
data.m_comment = ui->m_comment_le->text();
|
||||
data.m_description = ui->m_description_te->toPlainText();
|
||||
|
||||
m_project->undoStack()->push(new ChangeTerminalStripData(m_current_strip, data, nullptr));
|
||||
|
||||
if (m_model)
|
||||
{
|
||||
for (const auto &data_ : m_model->modifiedmodelRealTerminalData())
|
||||
{
|
||||
if (auto element = data_.element_)
|
||||
{
|
||||
auto current_data = element->elementData();
|
||||
current_data.setTerminalType(data_.type_);
|
||||
current_data.setTerminalFunction(data_.function_);
|
||||
current_data.setTerminalLED(data_.led_);
|
||||
current_data.m_informations.addValue(QStringLiteral("label"), data_.label_);
|
||||
|
||||
if (element->elementData() != current_data)
|
||||
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data));
|
||||
if (data_.level_ != data_.real_terminal.toStrongRef()->level())
|
||||
m_project->undoStack()->push(new ChangeTerminalLevel(m_current_strip, data_.real_terminal, data_.level_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_project->undoStack()->endMacro();
|
||||
}
|
||||
}
|
||||
|
||||
on_m_reload_pb_clicked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::on_m_auto_pos_pb_clicked
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef TERMINALSTRIPEDITOR_H
|
||||
#define TERMINALSTRIPEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
||||
#include "terminalstripmodel.h"
|
||||
|
||||
@@ -28,43 +28,31 @@ namespace Ui {
|
||||
|
||||
class QETProject;
|
||||
class TerminalStrip;
|
||||
class QTreeWidgetItem;
|
||||
class TerminalElement;
|
||||
class QAbstractButton;
|
||||
class FreeTerminalEditor;
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripEditor class
|
||||
* Main dialog used to edit terminal strip
|
||||
* of a project
|
||||
*/
|
||||
class TerminalStripEditor : public QDialog
|
||||
class TerminalStripEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
||||
~TerminalStripEditor() override;
|
||||
void setCurrentStrip(TerminalStrip *strip_);
|
||||
void reload();
|
||||
void apply();
|
||||
|
||||
private:
|
||||
void setUpUndoConnections();
|
||||
void buildTree();
|
||||
QTreeWidgetItem* addTerminalStrip(TerminalStrip *terminal_strip);
|
||||
void addFreeTerminal();
|
||||
void setCurrentStrip(TerminalStrip *strip_);
|
||||
void spanMultiLevelTerminals();
|
||||
void selectionChanged();
|
||||
QSize setUpBridgeCellWidth();
|
||||
TerminalStripModel::Column isSingleColumnSelected() const;
|
||||
QPair<TerminalStripModel::Column, QVector<modelRealTerminalData>> singleColumnData() const;
|
||||
void updateWidget();
|
||||
|
||||
private slots:
|
||||
void on_m_add_terminal_strip_pb_clicked();
|
||||
void on_m_remove_terminal_strip_pb_clicked();
|
||||
void on_m_reload_pb_clicked();
|
||||
void on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_m_dialog_button_box_clicked(QAbstractButton *button);
|
||||
void on_m_auto_ordering_pb_clicked();
|
||||
void on_m_group_terminals_pb_clicked();
|
||||
void on_m_ungroup_pb_clicked();
|
||||
@@ -78,15 +66,9 @@ class TerminalStripEditor : public QDialog
|
||||
|
||||
private:
|
||||
Ui::TerminalStripEditor *ui;
|
||||
QETProject *m_project = nullptr;
|
||||
|
||||
QHash<QTreeWidgetItem *, TerminalStrip *> m_item_strip_H;
|
||||
QHash<QUuid, QSharedPointer<RealTerminal>> m_uuid_terminal_H;
|
||||
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
|
||||
TerminalStrip *m_current_strip = nullptr;
|
||||
TerminalStripModel *m_model = nullptr;
|
||||
FreeTerminalEditor *m_free_terminal_editor = nullptr;
|
||||
|
||||
QETProject *m_project {nullptr};
|
||||
TerminalStrip *m_current_strip {nullptr};
|
||||
TerminalStripModel *m_model {nullptr};
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPEDITOR_H
|
||||
|
||||
@@ -1,22 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TerminalStripEditor</class>
|
||||
<widget class="QDialog" name="TerminalStripEditor">
|
||||
<widget class="QWidget" name="TerminalStripEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1206</width>
|
||||
<height>645</height>
|
||||
<width>922</width>
|
||||
<height>516</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Gestionnaire de borniers</string>
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="m_tab_widget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_layout_tab">
|
||||
<attribute name="title">
|
||||
<string>Disposition</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="m_table_widget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_data_tab">
|
||||
<attribute name="title">
|
||||
<string>Propriétés</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Nom :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Commentaire :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Installation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_location_le"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_installation_le"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_comment_le"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Localisation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_name_le"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="m_description_te"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Type :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Fonction :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_bridge_terminals_pb">
|
||||
<property name="text">
|
||||
<string>Ponter les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_auto_ordering_pb">
|
||||
<property name="text">
|
||||
@@ -24,60 +126,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_ungroup_pb">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_unbridge_terminals_pb">
|
||||
<property name="text">
|
||||
<string>Degrouper les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Couleur pont :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="m_function_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Générique</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Phase</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Neutre</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_bridge_terminals_pb">
|
||||
<property name="text">
|
||||
<string>Ponter les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>LED :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="m_level_sb"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Fonction :</string>
|
||||
<string>Déponter les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -88,34 +140,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QComboBox" name="m_led_cb">
|
||||
<item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Sans</string>
|
||||
<string>Étage :</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Avec</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="KColorCombo" name="m_bridge_color_cb"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>LED :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="m_type_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
@@ -144,97 +186,76 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="m_function_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Générique</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Phase</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Neutre</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="KColorCombo" name="m_bridge_color_cb"/>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="m_level_sb">
|
||||
<property name="maximum">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_ungroup_pb">
|
||||
<property name="text">
|
||||
<string>Étage :</string>
|
||||
<string>Degrouper les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Type :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_unbridge_terminals_pb">
|
||||
<property name="text">
|
||||
<string>Déponter les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<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 row="6" column="1">
|
||||
<widget class="QComboBox" name="m_led_cb">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_add_terminal_strip_pb">
|
||||
<property name="text">
|
||||
<string>Ajouter un bornier</string>
|
||||
<string>Sans</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/list-add.png</normaloff>:/ico/16x16/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_remove_terminal_strip_pb">
|
||||
<property name="text">
|
||||
<string>Supprimer le bornier</string>
|
||||
<string>Avec</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/list-remove.png</normaloff>:/ico/16x16/list-remove.png</iconset>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Couleur pont :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_reload_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<item row="11" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@@ -242,167 +263,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="TerminalStripTreeWidget" name="m_terminal_strip_tw">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="autoExpandDelay">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Explorateur de bornier</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<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="QTabWidget" name="m_tab_widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_layout_tab">
|
||||
<attribute name="title">
|
||||
<string>Disposition</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="m_table_widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_data_tab">
|
||||
<attribute name="title">
|
||||
<string>Propriétés</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Nom :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_name_le"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="m_description_te"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_installation_le"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Commentaire</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_comment_le"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Installation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_location_le"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Localisation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_dialog_button_box">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Reset</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
@@ -411,31 +271,7 @@
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TerminalStripTreeWidget</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header location="global">terminalstriptreewidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_add_terminal_strip_pb</tabstop>
|
||||
<tabstop>m_remove_terminal_strip_pb</tabstop>
|
||||
<tabstop>m_reload_pb</tabstop>
|
||||
<tabstop>m_auto_ordering_pb</tabstop>
|
||||
<tabstop>m_group_terminals_pb</tabstop>
|
||||
<tabstop>m_ungroup_pb</tabstop>
|
||||
<tabstop>m_level_sb</tabstop>
|
||||
<tabstop>m_terminal_strip_tw</tabstop>
|
||||
<tabstop>m_table_widget</tabstop>
|
||||
<tabstop>m_description_te</tabstop>
|
||||
<tabstop>m_comment_le</tabstop>
|
||||
<tabstop>m_name_le</tabstop>
|
||||
<tabstop>m_tab_widget</tabstop>
|
||||
<tabstop>m_installation_le</tabstop>
|
||||
<tabstop>m_location_le</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../qelectrotech.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "freeterminaleditor.h"
|
||||
#include "terminalstripeditorwindow.h"
|
||||
#include "ui_terminalstripeditorwindow.h"
|
||||
#include "terminalstriptreedockwidget.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "terminalstripcreatordialog.h"
|
||||
|
||||
#include "../UndoCommand/addterminalstripcommand.h"
|
||||
#include "freeterminaleditor.h"
|
||||
#include "../../qetproject.h"
|
||||
#include "../realterminal.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "terminalstripcreatordialog.h"
|
||||
#include "terminalstripeditor.h"
|
||||
#include "terminalstripeditorwindow.h"
|
||||
#include "terminalstriptreedockwidget.h"
|
||||
|
||||
static int EMPTY_PAGE = 0;
|
||||
static int FREE_TERMINAL_PAGE = 1;
|
||||
@@ -43,11 +45,13 @@ TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidge
|
||||
addTreeDockWidget();
|
||||
|
||||
m_free_terminal_editor = new FreeTerminalEditor(m_project, this);
|
||||
m_terminal_strip_editor = new TerminalStripEditor{m_project, this};
|
||||
|
||||
connect(m_tree_dock, &TerminalStripTreeDockWidget::currentStripChanged, this, &TerminalStripEditorWindow::currentStripChanged);
|
||||
|
||||
ui->m_stacked_widget->insertWidget(EMPTY_PAGE, new QWidget(ui->m_stacked_widget));
|
||||
ui->m_stacked_widget->insertWidget(FREE_TERMINAL_PAGE, m_free_terminal_editor);
|
||||
ui->m_stacked_widget->insertWidget(TERMINAL_STRIP_PAGE, m_terminal_strip_editor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +97,9 @@ void TerminalStripEditorWindow::updateUi()
|
||||
ui->m_stacked_widget->setCurrentIndex(FREE_TERMINAL_PAGE);
|
||||
m_free_terminal_editor->reload();
|
||||
}
|
||||
} else if (auto strip_ = m_tree_dock->currentStrip()) {
|
||||
ui->m_stacked_widget->setCurrentIndex(TERMINAL_STRIP_PAGE);
|
||||
m_terminal_strip_editor->setCurrentStrip(strip_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,11 +140,12 @@ void TerminalStripEditorWindow::on_m_remove_terminal_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditorWindow::on_m_reload_triggered
|
||||
*/
|
||||
void TerminalStripEditorWindow::on_m_reload_triggered() {
|
||||
m_tree_dock->reload();
|
||||
m_terminal_strip_editor->reload();
|
||||
m_free_terminal_editor->reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class QETProject;
|
||||
class TerminalStripTreeDockWidget;
|
||||
class TerminalStrip;
|
||||
class FreeTerminalEditor;
|
||||
class TerminalStripEditor;
|
||||
|
||||
namespace Ui {
|
||||
class TerminalStripEditorWindow;
|
||||
@@ -48,10 +49,11 @@ class TerminalStripEditorWindow : public QMainWindow
|
||||
void updateUi();
|
||||
|
||||
private:
|
||||
Ui::TerminalStripEditorWindow *ui;
|
||||
Ui::TerminalStripEditorWindow *ui{nullptr};
|
||||
QETProject *m_project {nullptr};
|
||||
TerminalStripTreeDockWidget *m_tree_dock;
|
||||
TerminalStripTreeDockWidget *m_tree_dock{nullptr};
|
||||
FreeTerminalEditor *m_free_terminal_editor {nullptr};
|
||||
TerminalStripEditor *m_terminal_strip_editor {nullptr};
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPEDITORWINDOW_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<width>1364</width>
|
||||
<height>868</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -32,7 +32,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>1364</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -116,6 +116,17 @@ TerminalStripModel::TerminalStripModel(TerminalStrip *terminal_strip, QObject *p
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripModel::setTerminalStrip
|
||||
* set the current terminal strip of this model to @a terminal_strip.
|
||||
* @param terminal_strip
|
||||
*/
|
||||
void TerminalStripModel::setTerminalStrip(TerminalStrip *terminal_strip)
|
||||
{
|
||||
m_terminal_strip = terminal_strip;
|
||||
reload();
|
||||
}
|
||||
|
||||
int TerminalStripModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
@@ -479,6 +490,19 @@ void TerminalStripModel::buildBridgePixmap(const QSize &pixmap_size)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripModel::reload
|
||||
* Reload (reset) the model
|
||||
*/
|
||||
void TerminalStripModel::reload()
|
||||
{
|
||||
beginResetModel();
|
||||
m_physical_data.clear();
|
||||
m_modified_cell.clear();
|
||||
fillPhysicalTerminalData();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void TerminalStripModel::fillPhysicalTerminalData()
|
||||
{
|
||||
//Get all physical terminal
|
||||
|
||||
@@ -70,6 +70,7 @@ class TerminalStripModel : public QAbstractTableModel
|
||||
Q_OBJECT
|
||||
public:
|
||||
TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent = nullptr);
|
||||
void setTerminalStrip(TerminalStrip *terminal_strip);
|
||||
|
||||
virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual int columnCount (const QModelIndex &parent = QModelIndex()) const override;
|
||||
@@ -85,6 +86,8 @@ class TerminalStripModel : public QAbstractTableModel
|
||||
|
||||
void buildBridgePixmap(const QSize &pixmap_size);
|
||||
|
||||
void reload();
|
||||
|
||||
private:
|
||||
void fillPhysicalTerminalData();
|
||||
modelRealTerminalData dataAtRow(int row) const;
|
||||
|
||||
@@ -370,6 +370,6 @@ void TerminalStripTreeDockWidget::setupUndoConnections()
|
||||
|
||||
void TerminalStripTreeDockWidget::setCurrentStrip(TerminalStrip *strip)
|
||||
{
|
||||
emit currentStripChanged(strip);
|
||||
m_current_strip = strip;
|
||||
emit currentStripChanged(strip);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "undocommand/rotateselectioncommand.h"
|
||||
#include "undocommand/rotatetextscommand.h"
|
||||
#include "diagram.h"
|
||||
#include "TerminalStrip/ui/terminalstripeditor.h"
|
||||
#include "TerminalStrip/ui/terminalstripeditorwindow.h"
|
||||
#include "ui/diagrameditorhandlersizewidget.h"
|
||||
|
||||
@@ -428,7 +427,7 @@ void QETDiagramEditor::setUpActions()
|
||||
|
||||
//Add a nomenclature item
|
||||
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
|
||||
connect(m_add_nomenclature, &QAction::triggered, [this]() {
|
||||
connect(m_add_nomenclature, &QAction::triggered, this, [=]() {
|
||||
if(this->currentDiagramView()) {
|
||||
QetGraphicsTableFactory::createAndAddNomenclature(this->currentDiagramView()->diagram());
|
||||
}
|
||||
@@ -436,21 +435,18 @@ void QETDiagramEditor::setUpActions()
|
||||
|
||||
//Add a summary item
|
||||
m_add_summary = new QAction(QET::Icons::TableOfContent, tr("Ajouter un sommaire"), this);
|
||||
connect(m_add_summary, &QAction::triggered, [this]() {
|
||||
connect(m_add_summary, &QAction::triggered, this, [=]() {
|
||||
if(this->currentDiagramView()) {
|
||||
QetGraphicsTableFactory::createAndAddSummary(this->currentDiagramView()->diagram());
|
||||
}
|
||||
});
|
||||
|
||||
m_terminal_strip_dialog = new QAction(QET::Icons::TerminalStrip, tr("Gestionnaire de borniers (DEV)"), this);
|
||||
connect(m_terminal_strip_dialog, &QAction::triggered, [this]()
|
||||
connect(m_terminal_strip_dialog, &QAction::triggered, this, [=]()
|
||||
{
|
||||
if (auto project = this->currentProject())
|
||||
{
|
||||
auto str = new TerminalStripEditor(project, this);
|
||||
str->show();
|
||||
|
||||
auto tsew = new TerminalStripEditorWindow(project, this);
|
||||
auto tsew {new TerminalStripEditorWindow{project, this}};
|
||||
tsew->show();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user