mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-06 06:19:59 +01:00
Revert "Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet into terminal_strip"
This reverts commit364bce618c, reversing changes made toefb4a8dd71.
This commit is contained in:
@@ -1,107 +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 "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"); }
|
||||
|
||||
auto strip = m_project->newTerminalStrip(installation_,
|
||||
location_,
|
||||
name_);
|
||||
strip->setComment(ui->m_comment_le->text());
|
||||
strip->setDescription(ui->m_description_te->toPlainText());
|
||||
|
||||
return strip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
@@ -1,54 +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 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
|
||||
@@ -1,146 +0,0 @@
|
||||
<?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>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Commentaire :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="m_comment_le"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_installation_le</tabstop>
|
||||
<tabstop>m_location_le</tabstop>
|
||||
<tabstop>m_name_le</tabstop>
|
||||
<tabstop>m_comment_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>
|
||||
@@ -1,383 +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 "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 "terminalstriptreewidget.h"
|
||||
#include "../../qeticons.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::TerminalStripEditor
|
||||
* @param project : Project to manage the terminal strip
|
||||
* @param parent : paent widget
|
||||
*/
|
||||
TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TerminalStripEditor),
|
||||
m_project(project)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_remove_terminal_strip_pb->setDisabled(true);
|
||||
buildTree();
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
setUpUndoConnections();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::~TerminalStripEditor
|
||||
*/
|
||||
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 terminal = m_uuid_terminal_H.value(terminal_uuid);
|
||||
auto old_strip = m_uuid_strip_H.value(old_strip_uuid);
|
||||
auto new_strip = m_uuid_strip_H.value(new_strip_uuid);
|
||||
|
||||
if (!terminal || !old_strip || !new_strip) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto undo = new AddTerminalToStripCommand(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 terminal_ = m_uuid_terminal_H.value(terminal_uuid);
|
||||
auto strip_ = m_uuid_strip_H.value(old_strip_uuid);
|
||||
|
||||
if (!terminal_ || !strip_) {
|
||||
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 index = terminal_strip->index(i);
|
||||
auto term_item = new QTreeWidgetItem(strip_item, QStringList(index.label()), TerminalStripTreeWidget::Terminal);
|
||||
term_item->setData(0, TerminalStripTreeWidget::UUID_USER_ROLE, index.uuid().toString());
|
||||
term_item->setIcon(0, QET::Icons::ElementTerminal);
|
||||
|
||||
if (index.isElement()) {
|
||||
m_uuid_terminal_H.insert(index.uuid(), index.element());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripEditor::clearDataTab
|
||||
*/
|
||||
void TerminalStripEditor::clearDataTab()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.keys());
|
||||
|
||||
buildTree();
|
||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
clearDataTab();
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(button)
|
||||
|
||||
if (m_current_strip)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
on_m_reload_pb_clicked();
|
||||
}
|
||||
@@ -1,70 +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 TERMINALSTRIPEDITOR_H
|
||||
#define TERMINALSTRIPEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class TerminalStripEditor;
|
||||
}
|
||||
|
||||
class QETProject;
|
||||
class TerminalStrip;
|
||||
class QTreeWidgetItem;
|
||||
class TerminalElement;
|
||||
class QAbstractButton;
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripEditor class
|
||||
* Main dialog used to edit terminal strip
|
||||
* of a project
|
||||
*/
|
||||
class TerminalStripEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
||||
~TerminalStripEditor() override;
|
||||
|
||||
private:
|
||||
void setUpUndoConnections();
|
||||
void buildTree();
|
||||
QTreeWidgetItem* addTerminalStrip(TerminalStrip *terminal_strip);
|
||||
void addFreeTerminal();
|
||||
void clearDataTab();
|
||||
|
||||
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_apply_data_pb_clicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
Ui::TerminalStripEditor *ui;
|
||||
QETProject *m_project = nullptr;
|
||||
|
||||
QHash<QTreeWidgetItem *, TerminalStrip *> m_item_strip_H;
|
||||
QHash<QUuid, QPointer<TerminalElement>> m_uuid_terminal_H;
|
||||
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
|
||||
TerminalStrip *m_current_strip = nullptr;
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPEDITOR_H
|
||||
@@ -1,271 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TerminalStripEditor</class>
|
||||
<widget class="QDialog" name="TerminalStripEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>951</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Gestionnaire de borniers</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1" columnstretch="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_add_terminal_strip_pb">
|
||||
<property name="text">
|
||||
<string>Ajouter un bornier</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>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/list-remove.png</normaloff>:/ico/16x16/list-remove.png</iconset>
|
||||
</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">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="handleWidth">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</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="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="tableView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</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="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Description</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="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Commentaire</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_name_le"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="m_description_te"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Nom :</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="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Localisation :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_comment_le"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_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>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_apply_data_pb">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TerminalStripTreeWidget</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header location="global">terminalstriptreewidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_tab_widget</tabstop>
|
||||
<tabstop>m_installation_le</tabstop>
|
||||
<tabstop>m_location_le</tabstop>
|
||||
<tabstop>m_name_le</tabstop>
|
||||
<tabstop>m_comment_le</tabstop>
|
||||
<tabstop>m_description_te</tabstop>
|
||||
<tabstop>tableView</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../qelectrotech.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,139 +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 "terminalstriptreewidget.h"
|
||||
#include "../../qeticons.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QDragMoveEvent>
|
||||
|
||||
int TerminalStripTreeWidget::UUID_USER_ROLE = Qt::UserRole + 1;
|
||||
|
||||
TerminalStripTreeWidget::TerminalStripTreeWidget(QWidget *parent) :
|
||||
QTreeWidget(parent)
|
||||
{}
|
||||
|
||||
QStringList TerminalStripTreeWidget::mimeTypes() const
|
||||
{
|
||||
QStringList strl(QStringLiteral("application/x-qet-terminal-strip-tree-terminal-uuid"));
|
||||
|
||||
return strl;
|
||||
}
|
||||
|
||||
void TerminalStripTreeWidget::startDrag(Qt::DropActions supportedActions)
|
||||
{
|
||||
Q_UNUSED(supportedActions)
|
||||
|
||||
auto item = currentItem();
|
||||
|
||||
if (!item ||
|
||||
item->type() != TerminalStripTreeWidget::Terminal) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDrag drag(this);
|
||||
auto mime_data = new QMimeData();
|
||||
mime_data->setData("application/x-qet-terminal-strip-tree-terminal-uuid", item->data(0, UUID_USER_ROLE).toString().toLatin1());
|
||||
|
||||
drag.setMimeData(mime_data);
|
||||
drag.setPixmap(QET::Icons::ElementTerminal.pixmap(16,16));
|
||||
drag.exec(Qt::MoveAction);
|
||||
}
|
||||
|
||||
void TerminalStripTreeWidget::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
auto strl = event->mimeData()->formats();
|
||||
if (strl.size() != 1 ||
|
||||
strl.first() != "application/x-qet-terminal-strip-tree-terminal-uuid") {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
//Accepted move are :
|
||||
//free terminal to terminal strip
|
||||
//terminal strip to another terminal strip
|
||||
//terminal strip to free terminal
|
||||
//All other other move is ignored
|
||||
QTreeWidget::dragMoveEvent(event);
|
||||
|
||||
auto overred_item = itemAt(event->pos());
|
||||
auto dragged_item = currentItem();
|
||||
if (!overred_item ||
|
||||
!dragged_item ||
|
||||
!dragged_item->parent()) {
|
||||
return;
|
||||
}
|
||||
//Ignore the event by default, we confirm it bellow if needed.
|
||||
event->ignore();
|
||||
|
||||
//Move terminal
|
||||
if (dragged_item->parent()->type() == FreeTerminal && //From free to strip
|
||||
overred_item->type() == Strip) {
|
||||
event->accept();
|
||||
}
|
||||
else if (dragged_item->parent()->type() == Strip) //From strip to ...
|
||||
{
|
||||
if (overred_item->type() == FreeTerminal) { //Free terminal
|
||||
event->accept();
|
||||
} else if (overred_item->type() == Strip && //Another strip
|
||||
dragged_item->parent() != overred_item) {
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripTreeWidget::dropEvent(QDropEvent *event)
|
||||
{
|
||||
auto overred_item = itemAt(event->pos());
|
||||
auto dragged_item = currentItem();
|
||||
if (!overred_item ||
|
||||
!dragged_item ||
|
||||
!dragged_item->parent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto old_parent = dragged_item->parent();
|
||||
old_parent->removeChild(dragged_item);
|
||||
overred_item->addChild(dragged_item);
|
||||
|
||||
//Move terminal
|
||||
if (old_parent->type() == FreeTerminal && //From free to strip
|
||||
overred_item->type() == Strip) {
|
||||
emit terminalAddedToStrip(QUuid::fromString(dragged_item->data(0, UUID_USER_ROLE).toString()),
|
||||
QUuid::fromString(overred_item->data(0, UUID_USER_ROLE).toString()));
|
||||
}
|
||||
else if (old_parent->type() == Strip) //From strip to ...
|
||||
{
|
||||
if (overred_item->type() == FreeTerminal) //Free terminal
|
||||
{
|
||||
emit terminalRemovedFromStrip(QUuid::fromString(dragged_item->data(0, UUID_USER_ROLE).toString()),
|
||||
QUuid::fromString(old_parent->data(0, UUID_USER_ROLE).toString()));
|
||||
}
|
||||
else if (overred_item->type() == Strip) //To another strip
|
||||
{
|
||||
emit terminalMovedFromStripToStrip(QUuid::fromString(dragged_item->data(0, UUID_USER_ROLE).toString()),
|
||||
QUuid::fromString(old_parent->data(0, UUID_USER_ROLE).toString()),
|
||||
QUuid::fromString(overred_item->data(0, UUID_USER_ROLE).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Qt::DropActions TerminalStripTreeWidget::supportedDropActions() const {
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
@@ -1,73 +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 TERMINALSTRIPTREEWIDGET_H
|
||||
#define TERMINALSTRIPTREEWIDGET_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QUuid>
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripTreeWidget class
|
||||
* Derived class use to implement custom drag and drop
|
||||
*/
|
||||
class TerminalStripTreeWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public :
|
||||
enum TreeWidgetType{
|
||||
Root,
|
||||
Terminal,
|
||||
FreeTerminal,
|
||||
Installation,
|
||||
Location,
|
||||
Strip
|
||||
};
|
||||
|
||||
//Role used for data in QTreeWidgetItem
|
||||
static int UUID_USER_ROLE;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief terminalAddedToStrip
|
||||
* Signal emited when a terminal is moved from free terminal to a terminals trip
|
||||
*/
|
||||
void terminalAddedToStrip(QUuid terminal_uuid, QUuid strip_uuid);
|
||||
/**
|
||||
* @brief terminalMovedFromStripToStrip
|
||||
* Signam emitted when a terminal is moved from from a terminal stip to another one
|
||||
*/
|
||||
void terminalMovedFromStripToStrip(QUuid terminal_uuid, QUuid old_strip_uuid, QUuid new_strip_uuid);
|
||||
/**
|
||||
* @brief terminalRemovedFromStrip
|
||||
* Signal emitted when a terminal is moved from a terminal strip to free terminal
|
||||
*/
|
||||
void terminalRemovedFromStrip(QUuid terminal_uuid, QUuid old_strip_uuid);
|
||||
|
||||
|
||||
public:
|
||||
TerminalStripTreeWidget(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
QStringList mimeTypes() const override;
|
||||
void startDrag(Qt::DropActions supportedActions) override;
|
||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPTREEWIDGET_H
|
||||
Reference in New Issue
Block a user