mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Add dialog to create terminal strip + display existing terminal strip
This commit is contained in:
parent
0a2ec297bf
commit
91db58bb64
@ -167,20 +167,13 @@ class PhysicalTerminal
|
|||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStrip::TerminalStrip
|
* @brief TerminalStrip::TerminalStrip
|
||||||
|
* @param installation
|
||||||
|
* @param location
|
||||||
* @param name
|
* @param name
|
||||||
* @param project
|
* @param project
|
||||||
*/
|
*/
|
||||||
TerminalStrip::TerminalStrip(const QString &name, QETProject *project) :
|
|
||||||
QObject(project),
|
|
||||||
m_project(project)
|
|
||||||
{
|
|
||||||
m_data.m_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminalStrip::TerminalStrip(const QString &installation, const QString &location, const QString &name, QETProject *project) :
|
TerminalStrip::TerminalStrip(const QString &installation, const QString &location, const QString &name, QETProject *project) :
|
||||||
QObject(project),
|
QObject(project),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
@ -202,6 +195,10 @@ void TerminalStrip::setName(const QString &name) {
|
|||||||
m_data.m_name = name;
|
m_data.m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalStrip::setDescription(const QString &description) {
|
||||||
|
m_data.m_description = description;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStrip::addTerminal
|
* @brief TerminalStrip::addTerminal
|
||||||
* Add terminal to this terminal strip
|
* Add terminal to this terminal strip
|
||||||
|
@ -39,8 +39,13 @@ class TerminalStrip : public QObject
|
|||||||
QETProject *project);
|
QETProject *project);
|
||||||
|
|
||||||
void setInstallation(const QString &installation);
|
void setInstallation(const QString &installation);
|
||||||
|
QString installation() const {return m_data.m_installation;}
|
||||||
void setLocation(const QString &location);
|
void setLocation(const QString &location);
|
||||||
|
QString location() const {return m_data.m_location;}
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
QString name() const {return m_data.m_name;}
|
||||||
|
void setDescription(const QString &description);
|
||||||
|
QString description() const {return m_data.m_description;}
|
||||||
|
|
||||||
bool addTerminal(Element *terminal);
|
bool addTerminal(Element *terminal);
|
||||||
bool removeTerminal(Element *terminal);
|
bool removeTerminal(Element *terminal);
|
||||||
|
@ -36,7 +36,8 @@ class TerminalStripData : public PropertiesInterface
|
|||||||
private :
|
private :
|
||||||
QString m_installation = QStringLiteral("="),
|
QString m_installation = QStringLiteral("="),
|
||||||
m_location = QStringLiteral("+"),
|
m_location = QStringLiteral("+"),
|
||||||
m_name;
|
m_name,
|
||||||
|
m_description;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
103
sources/TerminalStrip/ui/terminalstripcreatordialog.cpp
Normal file
103
sources/TerminalStrip/ui/terminalstripcreatordialog.cpp
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
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 "terminalstripcreatordialog.h"
|
||||||
|
#include "ui_terminalstripcreatordialog.h"
|
||||||
|
#include "../terminalstrip.h"
|
||||||
|
#include "../../qetproject.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::TerminalStripCreatorDialog
|
||||||
|
* @param project : Project to add a new terminal strip
|
||||||
|
* @param parent : parent widget
|
||||||
|
*/
|
||||||
|
TerminalStripCreatorDialog::TerminalStripCreatorDialog(QETProject *project, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TerminalStripCreatorDialog),
|
||||||
|
m_project(project)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::~TerminalStripCreatorDialog
|
||||||
|
*/
|
||||||
|
TerminalStripCreatorDialog::~TerminalStripCreatorDialog() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::setInstallation
|
||||||
|
* Set the installation field string
|
||||||
|
* @param installation
|
||||||
|
*/
|
||||||
|
void TerminalStripCreatorDialog::setInstallation(const QString &installation) {
|
||||||
|
ui->m_installation_le->setText(installation);
|
||||||
|
setCursorToEmptyLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::setLocation
|
||||||
|
* Set the location field string
|
||||||
|
* @param location
|
||||||
|
*/
|
||||||
|
void TerminalStripCreatorDialog::setLocation(const QString &location) {
|
||||||
|
ui->m_location_le->setText(location);
|
||||||
|
setCursorToEmptyLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::generatedTerminalStrip
|
||||||
|
* @return A new terminal Strip according to the value set by user.
|
||||||
|
* The terminal strip is already added to the terminalStrip list of the project
|
||||||
|
* so it's ready to use.
|
||||||
|
*/
|
||||||
|
TerminalStrip *TerminalStripCreatorDialog::generatedTerminalStrip() const
|
||||||
|
{
|
||||||
|
QString installation_ = ui->m_installation_le->text();
|
||||||
|
QString location_ = ui->m_location_le->text();
|
||||||
|
QString name_ = ui->m_name_le->text();
|
||||||
|
|
||||||
|
if (installation_.isEmpty()) {
|
||||||
|
installation_ = QStringLiteral("=INST"); }
|
||||||
|
if (location_.isEmpty()) {
|
||||||
|
location_ = QStringLiteral("+LOC"); }
|
||||||
|
if (name_.isEmpty()) {
|
||||||
|
name_ = QStringLiteral("X"); }
|
||||||
|
|
||||||
|
return m_project->newTerminalStrip(installation_,
|
||||||
|
location_,
|
||||||
|
name_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripCreatorDialog::setCursorToEmptyLine
|
||||||
|
* Set the cursor to the first empty field.
|
||||||
|
* It's usefull when user create a new terminal strip
|
||||||
|
* with some value prefilled, to increase productivity.
|
||||||
|
*/
|
||||||
|
void TerminalStripCreatorDialog::setCursorToEmptyLine()
|
||||||
|
{
|
||||||
|
if (ui->m_installation_le->text().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ui->m_location_le->text().isEmpty()) {
|
||||||
|
ui->m_location_le->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->m_name_le->setFocus();
|
||||||
|
}
|
54
sources/TerminalStrip/ui/terminalstripcreatordialog.h
Normal file
54
sources/TerminalStrip/ui/terminalstripcreatordialog.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
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 TERMINALSTRIPCREATORDIALOG_H
|
||||||
|
#define TERMINALSTRIPCREATORDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class TerminalStrip;
|
||||||
|
class QETProject;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TerminalStripCreatorDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripCreatorDialog class
|
||||||
|
* A simple dialog for create a new terminal strip
|
||||||
|
*/
|
||||||
|
class TerminalStripCreatorDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TerminalStripCreatorDialog(QETProject *project, QWidget *parent = nullptr);
|
||||||
|
~TerminalStripCreatorDialog() override;
|
||||||
|
|
||||||
|
void setInstallation(const QString &installation);
|
||||||
|
void setLocation(const QString &location);
|
||||||
|
TerminalStrip *generatedTerminalStrip() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setCursorToEmptyLine();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TerminalStripCreatorDialog *ui;
|
||||||
|
QETProject *m_project = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPCREATORDIALOG_H
|
135
sources/TerminalStrip/ui/terminalstripcreatordialog.ui
Normal file
135
sources/TerminalStrip/ui/terminalstripcreatordialog.ui
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TerminalStripCreatorDialog</class>
|
||||||
|
<widget class="QDialog" name="TerminalStripCreatorDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>744</width>
|
||||||
|
<height>321</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Création groupe de bornes</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="3" 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_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Nom :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Installation :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLineEdit" name="m_name_le"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLineEdit" name="m_location_le"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="m_installation_le"/>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||||
|
<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_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Description :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="2">
|
||||||
|
<widget class="QPlainTextEdit" name="m_description_te"/>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_installation_le</tabstop>
|
||||||
|
<tabstop>m_location_le</tabstop>
|
||||||
|
<tabstop>m_name_le</tabstop>
|
||||||
|
<tabstop>m_description_te</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>TerminalStripCreatorDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>TerminalStripCreatorDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -17,16 +17,128 @@
|
|||||||
*/
|
*/
|
||||||
#include "terminalstripeditor.h"
|
#include "terminalstripeditor.h"
|
||||||
#include "ui_terminalstripeditor.h"
|
#include "ui_terminalstripeditor.h"
|
||||||
|
#include "terminalstripcreatordialog.h"
|
||||||
|
#include "../../qetproject.h"
|
||||||
|
#include "../terminalstrip.h"
|
||||||
|
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripEditor::TerminalStripEditor
|
||||||
|
* @param project : Project to manage the terminal strip
|
||||||
|
* @param parent : paent widget
|
||||||
|
*/
|
||||||
TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::TerminalStripEditor),
|
ui(new Ui::TerminalStripEditor),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
buildTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalStripEditor::~TerminalStripEditor()
|
/**
|
||||||
{
|
* @brief TerminalStripEditor::~TerminalStripEditor
|
||||||
|
*/
|
||||||
|
TerminalStripEditor::~TerminalStripEditor() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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, TerminalStripEditor::Root);
|
||||||
|
|
||||||
|
const auto ts_vector = m_project->terminalStrip();
|
||||||
|
for (const auto ts : ts_vector) {
|
||||||
|
addTerminalStrip(ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
QTreeWidgetItem* TerminalStripEditor::addTerminalStrip(TerminalStrip *terminal_strip)
|
||||||
|
{
|
||||||
|
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, TerminalStripEditor::Inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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, TerminalStripEditor::Loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the terminal strip
|
||||||
|
QStringList name{terminal_strip->name()};
|
||||||
|
return new QTreeWidgetItem(loc_qtwi, name, TerminalStripEditor::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() == TerminalStripEditor::Strip) {
|
||||||
|
item = item->parent();
|
||||||
|
}
|
||||||
|
if (item->type() == TerminalStripEditor::Loc) {
|
||||||
|
dialog->setLocation(item->data(0, Qt::DisplayRole).toString());
|
||||||
|
item = item->parent();
|
||||||
|
}
|
||||||
|
if (item->type() == TerminalStripEditor::Inst) {
|
||||||
|
dialog->setInstallation(item->data(0, Qt::DisplayRole).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dialog->exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
auto item = addTerminalStrip(dialog->generatedTerminalStrip());
|
||||||
|
ui->m_terminal_strip_tw->setCurrentItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,15 +25,36 @@ namespace Ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class QETProject;
|
class QETProject;
|
||||||
|
class TerminalStrip;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripEditor class
|
||||||
|
* Main dialog used to edit terminal strip
|
||||||
|
* of a project
|
||||||
|
*/
|
||||||
class TerminalStripEditor : public QDialog
|
class TerminalStripEditor : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
enum TreeWidgetType{
|
||||||
|
Root,
|
||||||
|
Inst,
|
||||||
|
Loc,
|
||||||
|
Strip
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
||||||
~TerminalStripEditor() override;
|
~TerminalStripEditor() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void buildTree();
|
||||||
|
QTreeWidgetItem* addTerminalStrip(TerminalStrip *terminal_strip);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_m_add_terminal_strip_pb_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TerminalStripEditor *ui;
|
Ui::TerminalStripEditor *ui;
|
||||||
QETProject *m_project = nullptr;
|
QETProject *m_project = nullptr;
|
||||||
|
@ -18,21 +18,24 @@
|
|||||||
<widget class="QTableView" name="tableView"/>
|
<widget class="QTableView" name="tableView"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="m_add_terminal_strip_pb">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ajouter un bornier</string>
|
<string>Ajouter un bornier</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="m_remove_terminal_strip_pb">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Supprimer le bornier</string>
|
<string>Supprimer le bornier</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QTreeWidget" name="treeWidget">
|
<widget class="QTreeWidget" name="m_terminal_strip_tw">
|
||||||
|
<property name="animated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Explorateur de bornier</string>
|
<string>Explorateur de bornier</string>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "titleblocktemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "ui/dialogwaiting.h"
|
#include "ui/dialogwaiting.h"
|
||||||
#include "ui/importelementdialog.h"
|
#include "ui/importelementdialog.h"
|
||||||
|
#include "TerminalStrip/terminalstrip.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@ -1816,6 +1817,34 @@ void QETProject::setProjectProperties(const DiagramContext &context) {
|
|||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETProject::terminalStrip
|
||||||
|
* @return a QVector who contain all terminal strip owned by this project
|
||||||
|
*/
|
||||||
|
QVector<TerminalStrip *> QETProject::terminalStrip() const {
|
||||||
|
return m_terminal_strip_vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETProject::newTerminalStrip
|
||||||
|
* @param installation : installation of the terminal strip
|
||||||
|
* @param location : location of the terminal strip
|
||||||
|
* @param name : name of the terminal strip
|
||||||
|
* @return Create a new terminal strip with this project as parent.
|
||||||
|
* You can retrieve this terminal strip at any time by calling the function
|
||||||
|
* QETProject::terminalStrip()
|
||||||
|
*/
|
||||||
|
TerminalStrip *QETProject::newTerminalStrip(QString installation, QString location, QString name)
|
||||||
|
{
|
||||||
|
auto ts = new TerminalStrip(installation,
|
||||||
|
location,
|
||||||
|
name,
|
||||||
|
this);
|
||||||
|
|
||||||
|
m_terminal_strip_vector.append(ts);
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
||||||
que l'on obtient en faisant Fichier > Nouveau.
|
que l'on obtient en faisant Fichier > Nouveau.
|
||||||
|
@ -42,6 +42,8 @@ class NumerotationContext;
|
|||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
class XmlElementCollection;
|
class XmlElementCollection;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
class TerminalStrip;
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF5
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
#else
|
#else
|
||||||
class KAutoSaveFile;
|
class KAutoSaveFile;
|
||||||
@ -176,6 +178,9 @@ class QETProject : public QObject
|
|||||||
void setProjectProperties(const DiagramContext &);
|
void setProjectProperties(const DiagramContext &);
|
||||||
QUndoStack* undoStack() {return m_undo_stack;}
|
QUndoStack* undoStack() {return m_undo_stack;}
|
||||||
|
|
||||||
|
QVector<TerminalStrip *> terminalStrip() const;
|
||||||
|
TerminalStrip * newTerminalStrip(QString installation = QString(), QString location = QString(), QString name = QString());
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Diagram *addNewDiagram(int pos = -1);
|
Diagram *addNewDiagram(int pos = -1);
|
||||||
void removeDiagram(Diagram *);
|
void removeDiagram(Diagram *);
|
||||||
@ -281,6 +286,7 @@ class QETProject : public QObject
|
|||||||
#endif
|
#endif
|
||||||
QUuid m_uuid = QUuid::createUuid();
|
QUuid m_uuid = QUuid::createUuid();
|
||||||
projectDataBase m_data_base;
|
projectDataBase m_data_base;
|
||||||
|
QVector<TerminalStrip *> m_terminal_strip_vector;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QETProject *)
|
Q_DECLARE_METATYPE(QETProject *)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user