Terminal strip can now be edited and managed by undo command

This commit is contained in:
joshua
2021-05-05 22:34:11 +02:00
parent e0579b3040
commit 580ebe8b97
9 changed files with 215 additions and 27 deletions

View File

@@ -24,6 +24,7 @@
#include "../qetgraphicsitem/terminalelement.h"
#include "../UndoCommand/addterminalstripcommand.h"
#include "../UndoCommand/addterminaltostripcommand.h"
#include "../UndoCommand/changeterminalstripdata.h"
#include "terminalstriptreewidget.h"
#include "../../qeticons.h"
@@ -242,6 +243,7 @@ void TerminalStripEditor::clearDataTab()
ui->m_name_le ->clear();
ui->m_comment_le ->clear();
ui->m_description_te ->clear();
m_current_strip = nullptr;
}
/**
@@ -336,6 +338,7 @@ void TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetI
}
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());
@@ -345,3 +348,22 @@ void TerminalStripEditor::on_m_terminal_strip_tw_currentItemChanged(QTreeWidgetI
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();
}

View File

@@ -28,6 +28,7 @@ class QETProject;
class TerminalStrip;
class QTreeWidgetItem;
class TerminalElement;
class QAbstractButton;
/**
* @brief The TerminalStripEditor class
@@ -54,6 +55,7 @@ class TerminalStripEditor : public QDialog
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;
@@ -62,6 +64,7 @@ class TerminalStripEditor : public QDialog
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

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>706</width>
<height>396</height>
<width>951</width>
<height>491</height>
</rect>
</property>
<property name="windowTitle">
@@ -146,6 +146,13 @@
<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">
@@ -160,12 +167,8 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Nom :</string>
</property>
</widget>
<item row="2" column="1">
<widget class="QLineEdit" name="m_name_le"/>
</item>
<item row="4" column="1">
<widget class="Line" name="line">
@@ -174,6 +177,22 @@
</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">
@@ -181,28 +200,47 @@
</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="1" column="1">
<widget class="QLineEdit" name="m_location_le"/>
</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="2" column="1">
<widget class="QLineEdit" name="m_name_le"/>
</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>