mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-24 22:09:58 +01:00
@@ -27,7 +27,6 @@
|
||||
#include "../UndoCommand/changeterminalstripdata.h"
|
||||
#include "terminalstriptreewidget.h"
|
||||
#include "../../qeticons.h"
|
||||
#include "terminalstripmodel.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
@@ -236,46 +235,16 @@ void TerminalStripEditor::addFreeTerminal()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::setCurrentStrip
|
||||
* Set the current terminal strip edited to \p strip_
|
||||
* @param strip_
|
||||
* @brief TerminalStripEditor::clearDataTab
|
||||
*/
|
||||
void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
||||
void TerminalStripEditor::clearDataTab()
|
||||
{
|
||||
if (strip_ == m_current_strip) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->m_installation_le ->setText(strip_->installation());
|
||||
ui->m_location_le ->setText(strip_->location());
|
||||
ui->m_name_le ->setText(strip_->name());
|
||||
ui->m_comment_le ->setText(strip_->comment());
|
||||
ui->m_description_te ->setPlainText(strip_->description());
|
||||
m_current_strip = strip_;
|
||||
|
||||
if (m_model)
|
||||
m_model->deleteLater();
|
||||
|
||||
m_model = new TerminalStripModel(strip_, this);
|
||||
ui->m_table_widget->setModel(m_model);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +310,7 @@ void TerminalStripEditor::on_m_reload_pb_clicked()
|
||||
m_uuid_terminal_H.clear();
|
||||
m_uuid_strip_H.clear();
|
||||
|
||||
qDeleteAll(m_item_strip_H.keyBegin(), m_item_strip_H.keyEnd());
|
||||
qDeleteAll(m_item_strip_H.keys());
|
||||
|
||||
buildTree();
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
@@ -363,7 +332,7 @@ void TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetI
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (!current) {
|
||||
setCurrentStrip(nullptr);
|
||||
clearDataTab();
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
@@ -382,7 +351,16 @@ void TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetI
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
}
|
||||
|
||||
setCurrentStrip(strip_);
|
||||
if (strip_) {
|
||||
m_current_strip = strip_;
|
||||
ui->m_installation_le ->setText(strip_->installation());
|
||||
ui->m_location_le ->setText(strip_->location());
|
||||
ui->m_name_le ->setText(strip_->name());
|
||||
ui->m_comment_le ->setText(strip_->comment());
|
||||
ui->m_description_te ->setPlainText(strip_->description());
|
||||
} else {
|
||||
clearDataTab();
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripEditor::on_m_apply_data_pb_clicked(QAbstractButton *button)
|
||||
|
||||
@@ -29,7 +29,6 @@ class TerminalStrip;
|
||||
class QTreeWidgetItem;
|
||||
class TerminalElement;
|
||||
class QAbstractButton;
|
||||
class TerminalStripModel;
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripEditor class
|
||||
@@ -49,7 +48,7 @@ class TerminalStripEditor : public QDialog
|
||||
void buildTree();
|
||||
QTreeWidgetItem* addTerminalStrip(TerminalStrip *terminal_strip);
|
||||
void addFreeTerminal();
|
||||
void setCurrentStrip(TerminalStrip *strip_);
|
||||
void clearDataTab();
|
||||
|
||||
private slots:
|
||||
void on_m_add_terminal_strip_pb_clicked();
|
||||
@@ -66,7 +65,6 @@ class TerminalStripEditor : public QDialog
|
||||
QHash<QUuid, QPointer<TerminalElement>> m_uuid_terminal_H;
|
||||
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
|
||||
TerminalStrip *m_current_strip = nullptr;
|
||||
TerminalStripModel *m_model = nullptr;
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPEDITOR_H
|
||||
|
||||
@@ -130,19 +130,13 @@
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="m_table_widget">
|
||||
<widget class="QTableView" name="tableView">
|
||||
<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>
|
||||
@@ -268,7 +262,7 @@
|
||||
<tabstop>m_name_le</tabstop>
|
||||
<tabstop>m_comment_le</tabstop>
|
||||
<tabstop>m_description_te</tabstop>
|
||||
<tabstop>m_table_widget</tabstop>
|
||||
<tabstop>tableView</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../qelectrotech.qrc"/>
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "terminalstripmodel.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include <QDebug>
|
||||
|
||||
/**
|
||||
* @brief TerminalStripModel::TerminalStripModel
|
||||
* @param terminal_strip
|
||||
* @param parent
|
||||
*/
|
||||
TerminalStripModel::TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent) :
|
||||
QAbstractTableModel(parent),
|
||||
m_terminal_strip(terminal_strip)
|
||||
{
|
||||
fillRealTerminalData();
|
||||
}
|
||||
|
||||
int TerminalStripModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if (!m_terminal_strip) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_terminal_strip->realTerminalCount();
|
||||
}
|
||||
|
||||
int TerminalStripModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 9;
|
||||
}
|
||||
|
||||
QVariant TerminalStripModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole ||
|
||||
index.row() >= m_real_terminal_data.size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
auto rtd = m_real_terminal_data.at(index.row());
|
||||
switch (index.column()) {
|
||||
case 0 : return rtd.pos_;
|
||||
case 1 : return rtd.level_;
|
||||
case 2 : return rtd.label_;
|
||||
case 3 : return rtd.Xref_;
|
||||
case 4 : return rtd.cable_;
|
||||
case 5 : return rtd.cable_wire_;
|
||||
case 6 : return ElementData::translatedTerminalType(rtd.type_);
|
||||
case 7 : return rtd.led_;
|
||||
case 8 : return rtd.conductor_;
|
||||
default : return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant TerminalStripModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation != Qt::Horizontal ||
|
||||
role != Qt::DisplayRole) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (section) {
|
||||
case 0: return tr("Position");
|
||||
case 1: return tr("Étage");
|
||||
case 2: return tr("Label");
|
||||
case 3: return tr("Référence croisé");
|
||||
case 4: return tr("Câble");
|
||||
case 5: return tr("Couleur / numéro de fil câble");
|
||||
case 6: return tr("Type");
|
||||
case 7: return tr("led");
|
||||
case 8: return tr("Numéro de conducteur");
|
||||
default : return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripModel::fillRealTerminalData()
|
||||
{
|
||||
if (m_terminal_strip) {
|
||||
for (int i=0 ; i < m_terminal_strip->realTerminalCount() ; ++i) {
|
||||
m_real_terminal_data.append(m_terminal_strip->realTerminalData(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef TERMINALSTRIPMODEL_H
|
||||
#define TERMINALSTRIPMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include "../terminalstrip.h"
|
||||
|
||||
class TerminalStrip;
|
||||
|
||||
class TerminalStripModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent = nullptr);
|
||||
|
||||
virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual int columnCount (const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
void fillRealTerminalData();
|
||||
|
||||
private:
|
||||
QPointer<TerminalStrip> m_terminal_strip;
|
||||
QVector<RealTerminalData> m_real_terminal_data;
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPMODEL_H
|
||||
Reference in New Issue
Block a user