mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-06 13:40:52 +01:00
Add buttons to quickly edit the type, function and led of several terminal at once.
This commit is contained in:
@@ -50,12 +50,13 @@ TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
||||
|
||||
ui->m_table_widget->setItemDelegate(new TerminalStripModelDelegate(ui->m_terminal_strip_tw));
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
ui->m_group_terminals_pb->setDisabled(true);
|
||||
ui->m_ungroup_pb->setDisabled(true);
|
||||
buildTree();
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
setUpUndoConnections();
|
||||
|
||||
//Call for update the state of child widgets
|
||||
selectionChanged();
|
||||
|
||||
//Go the diagram of double clicked terminal
|
||||
connect(ui->m_table_widget, &QAbstractItemView::doubleClicked, [this](auto index)
|
||||
{
|
||||
@@ -313,6 +314,7 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
||||
m_model = new TerminalStripModel(strip_, this);
|
||||
ui->m_table_widget->setModel(m_model);
|
||||
spanMultiLevelTerminals();
|
||||
selectionChanged(); //Used to update child widgets
|
||||
|
||||
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::on_m_reload_pb_clicked);
|
||||
connect(ui->m_table_widget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TerminalStripEditor::selectionChanged);
|
||||
@@ -348,12 +350,31 @@ void TerminalStripEditor::spanMultiLevelTerminals()
|
||||
void TerminalStripEditor::selectionChanged()
|
||||
{
|
||||
if (!m_model) {
|
||||
ui->m_auto_ordering_pb ->setDisabled(true);
|
||||
ui->m_group_terminals_pb->setDisabled(true);
|
||||
ui->m_ungroup_pb ->setDisabled(true);
|
||||
ui->m_level_sb ->setDisabled(true);
|
||||
ui->m_type_cb ->setDisabled(true);
|
||||
ui->m_function_cb ->setDisabled(true);
|
||||
ui->m_led_cb ->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->m_auto_ordering_pb->setEnabled(true);
|
||||
|
||||
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
|
||||
|
||||
if (index_list.isEmpty()) {
|
||||
ui->m_type_cb ->setDisabled(true);
|
||||
ui->m_function_cb ->setDisabled(true);
|
||||
ui->m_led_cb ->setDisabled(true);
|
||||
} else {
|
||||
ui->m_type_cb ->setEnabled(true);
|
||||
ui->m_function_cb ->setEnabled(true);
|
||||
ui->m_led_cb ->setEnabled(true);
|
||||
}
|
||||
|
||||
const auto terminal_vector = m_model->physicalTerminalDataForIndex(index_list);
|
||||
const auto real_terminal_vector = m_model->realTerminalDataForIndex(index_list);
|
||||
|
||||
//Enable/disable group button
|
||||
ui->m_group_terminals_pb->setEnabled(terminal_vector.size() > 1 ? true : false);
|
||||
@@ -367,10 +388,18 @@ void TerminalStripEditor::selectionChanged()
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ui->m_ungroup_pb->setDisabled(it_ == terminal_vector.constEnd());
|
||||
|
||||
|
||||
//Enable/disable level spinbox
|
||||
bool enable_ = false;
|
||||
for (const auto &physical : terminal_vector)
|
||||
{
|
||||
if (physical.real_terminals_vector.size() > 1) {
|
||||
enable_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->m_level_sb->setEnabled(enable_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -589,3 +618,83 @@ void TerminalStripEditor::on_m_level_sb_valueChanged(int arg1)
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripEditor::on_m_type_cb_activated(int index)
|
||||
{
|
||||
if (m_model)
|
||||
{
|
||||
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
|
||||
|
||||
for (auto model_index : index_list)
|
||||
{
|
||||
auto type_index = m_model->index(model_index.row(), 6, model_index.parent());
|
||||
if (type_index.isValid())
|
||||
{
|
||||
ElementData::TerminalType override_type;
|
||||
switch (index) {
|
||||
case 0:
|
||||
override_type = ElementData::TTGeneric; break;
|
||||
case 1:
|
||||
override_type = ElementData::TTFuse; break;
|
||||
case 2:
|
||||
override_type = ElementData::TTSectional; break;
|
||||
case 3:
|
||||
override_type = ElementData::TTDiode; break;
|
||||
case 4:
|
||||
override_type = ElementData::TTGround; break;
|
||||
default:
|
||||
override_type = ElementData::TTGeneric; break;
|
||||
}
|
||||
m_model->setData(type_index, override_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TerminalStripEditor::on_m_function_cb_activated(int index)
|
||||
{
|
||||
if (m_model)
|
||||
{
|
||||
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
|
||||
|
||||
for (auto model_index : index_list)
|
||||
{
|
||||
auto function_index = m_model->index(model_index.row(), 7, model_index.parent());
|
||||
if (function_index.isValid())
|
||||
{
|
||||
ElementData::TerminalFunction override_function;
|
||||
switch (index) {
|
||||
case 0:
|
||||
override_function = ElementData::TFGeneric; break;
|
||||
case 1:
|
||||
override_function = ElementData::TFPhase; break;
|
||||
case 2:
|
||||
override_function = ElementData::TFNeutral; break;
|
||||
default:
|
||||
override_function = ElementData::TFGeneric; break;
|
||||
}
|
||||
m_model->setData(function_index, override_function);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TerminalStripEditor::on_m_led_cb_activated(int index)
|
||||
{
|
||||
if (m_model)
|
||||
{
|
||||
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
|
||||
|
||||
for (auto model_index : index_list)
|
||||
{
|
||||
auto led_index = m_model->index(model_index.row(), 8, model_index.parent());
|
||||
|
||||
if (led_index.isValid()) {
|
||||
m_model->setData(led_index,
|
||||
index == 0 ? false : true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ class TerminalStripEditor : public QDialog
|
||||
void on_m_group_terminals_pb_clicked();
|
||||
void on_m_ungroup_pb_clicked();
|
||||
void on_m_level_sb_valueChanged(int arg1);
|
||||
void on_m_type_cb_activated(int index);
|
||||
void on_m_function_cb_activated(int index);
|
||||
void on_m_led_cb_activated(int index);
|
||||
|
||||
private:
|
||||
Ui::TerminalStripEditor *ui;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1289</width>
|
||||
<width>1206</width>
|
||||
<height>645</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -178,14 +178,21 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Étage :</string>
|
||||
<string>Type :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_ungroup_pb">
|
||||
<property name="text">
|
||||
<string>Degrouper les bornes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -198,13 +205,68 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="m_type_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Générique</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Fusible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sectionnable</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Diode</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Terre</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="m_level_sb"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_ungroup_pb">
|
||||
<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="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_auto_ordering_pb">
|
||||
<property name="text">
|
||||
<string>Degrouper les bornes</string>
|
||||
<string>Position automatique</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Étage :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -215,10 +277,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="m_auto_ordering_pb">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Position automatique</string>
|
||||
<string>Fonction :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="m_led_cb">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sans</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Avec</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>LED :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
@@ -140,8 +140,7 @@ bool TerminalStripModel::setData(const QModelIndex &index, const QVariant &value
|
||||
modified_ = true;
|
||||
modified_cell = LEVEL_CELL;
|
||||
}
|
||||
else if (column_ == LED_CELL &&
|
||||
role == Qt::CheckStateRole)
|
||||
else if (column_ == LED_CELL)
|
||||
{
|
||||
rtd.led_ = value.toBool();
|
||||
modified_ = true;
|
||||
@@ -308,7 +307,10 @@ QVector<PhysicalTerminalData> TerminalStripModel::physicalTerminalDataForIndex(Q
|
||||
}
|
||||
|
||||
for (auto i : set_) {
|
||||
vector_.append(physicalDataAtIndex(i));
|
||||
const auto phy = physicalDataAtIndex(i);
|
||||
if (!vector_.contains(phy)) {
|
||||
vector_.append(phy);
|
||||
}
|
||||
}
|
||||
|
||||
return vector_;
|
||||
|
||||
Reference in New Issue
Block a user