Refactor comments and improve code formatting

This commit is contained in:
Kellermorph
2026-03-30 21:14:10 +02:00
committed by GitHub
parent 5296c1b478
commit 9149128f7a

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2026 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/>.
* Copyright 2006-2026 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 "masterpropertieswidget.h"
@@ -25,12 +25,13 @@
#include "ui_masterpropertieswidget.h"
#include <QListWidgetItem>
#include <QMessageBox>
/**
@brief MasterPropertiesWidget::MasterPropertiesWidget
Default constructor
@param elmt
@param parent
* @brief MasterPropertiesWidget::MasterPropertiesWidget
* Default constructor
* @param elmt
* @param parent
*/
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent),
@@ -106,8 +107,8 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
}
/**
@brief MasterPropertiesWidget::~MasterPropertiesWidget
Destructor
* @brief MasterPropertiesWidget::~MasterPropertiesWidget
* Destructor
*/
MasterPropertiesWidget::~MasterPropertiesWidget()
{
@@ -121,9 +122,9 @@ MasterPropertiesWidget::~MasterPropertiesWidget()
}
/**
@brief MasterPropertiesWidget::setElement
Set the element to be edited
@param element
* @brief MasterPropertiesWidget::setElement
* Set the element to be edited
* @param element
*/
void MasterPropertiesWidget::setElement(Element *element)
{
@@ -164,12 +165,12 @@ void MasterPropertiesWidget::setElement(Element *element)
}
/**
@brief MasterPropertiesWidget::apply
If link between edited element and other change,
apply the change with a QUndoCommand (got with method associatedUndo)
pushed to the stack of element project.
Return true if link change, else false
@note is void no Return ???
* @brief MasterPropertiesWidget::apply
* If link between edited element and other change,
* apply the change with a QUndoCommand (got with method associatedUndo)
* pushed to the stack of element project.
* Return true if link change, else false
* @note is void no Return ???
*/
void MasterPropertiesWidget::apply()
{
@@ -178,8 +179,8 @@ void MasterPropertiesWidget::apply()
}
/**
@brief MasterPropertiesWidget::reset
Reset current widget, clear eveything and rebuild widget.
* @brief MasterPropertiesWidget::reset
* Reset current widget, clear eveything and rebuild widget.
*/
void MasterPropertiesWidget::reset()
{
@@ -191,11 +192,11 @@ void MasterPropertiesWidget::reset()
}
/**
@brief MasterPropertiesWidget::associatedUndo
If link between the edited element and other change,
return a QUndoCommand with this change.
If no change return nullptr.
@return
* @brief MasterPropertiesWidget::associatedUndo
* If link between the edited element and other change,
* return a QUndoCommand with this change.
* If no change return nullptr.
* @return
*/
QUndoCommand* MasterPropertiesWidget::associatedUndo() const
{
@@ -229,10 +230,10 @@ QUndoCommand* MasterPropertiesWidget::associatedUndo() const
}
/**
@brief MasterPropertiesWidget::setLiveEdit
@param live_edit = true : live edit is enable
else false : live edit is disable.
@return always true because live edit is handled by this editor widget
* @brief MasterPropertiesWidget::setLiveEdit
* @param live_edit = true : live edit is enable
* else false : live edit is disable.
* @return always true because live edit is handled by this editor widget
*/
bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
{
@@ -241,8 +242,8 @@ bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
}
/**
@brief MasterPropertiesWidget::updateUi
Build the interface of the widget
* @brief MasterPropertiesWidget::updateUi
* Build the interface of the widget
*/
void MasterPropertiesWidget::updateUi()
{
@@ -334,8 +335,8 @@ void MasterPropertiesWidget::updateUi()
}
/**
@brief MasterPropertiesWidget::headerCustomContextMenuRequested
@param pos
* @brief MasterPropertiesWidget::headerCustomContextMenuRequested
* @param pos
*/
void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
{
@@ -344,31 +345,33 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
m_context_menu->popup(ui->m_free_tree_widget->header()->mapToGlobal(pos));
}
/**
@brief MasterPropertiesWidget::on_link_button_clicked
move current item in the free_list to linked_list
*/
/**
* @brief MasterPropertiesWidget::on_link_button_clicked
* move current item in the free_list to linked_list
* Moves the current item from the free_list to the linked_list,
* provided the master's slave limit has not been reached.
*/
void MasterPropertiesWidget::on_link_button_clicked()
{
// --- NEU: Prüfen, ob das Master-Limit im UI bereits erreicht ist ---
// Get the maximum number of allowed slaves from the element's information
QVariant max_slaves_variant = m_element->kindInformations().value("max_slaves");
if (max_slaves_variant.isValid() && !max_slaves_variant.toString().isEmpty()) {
int max_slaves = max_slaves_variant.toInt();
int current_slaves = ui->m_link_tree_widget->topLevelItemCount();
// Wir zählen, wie viele Elemente schon in der "Verbunden"-Liste liegen
if (max_slaves != -1 && ui->m_link_tree_widget->topLevelItemCount() >= max_slaves) {
// Limit erreicht! Wir brechen die Aktion einfach ab.
// If a limit is set and reached
if (max_slaves != -1 && current_slaves >= max_slaves) {
// Show a message box with the actual window as parent to ensure it's on top
QMessageBox::warning(this->window(),
tr("Maximum Slaves Reached"),
tr("This master element cannot accept any new slaves because it is full (Limit: %1).").arg(max_slaves));
return;
}
}
// -------------------------------------------------------------------
//take the current item from free_list and push it to linked_list
// Move current item from free_list to linked_list
QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem();
if (qtwi)
{
@@ -381,9 +384,10 @@ void MasterPropertiesWidget::on_link_button_clicked()
}
}
/**
@brief MasterPropertiesWidget::on_unlink_button_clicked
move current item in linked_list to free_list
* @brief MasterPropertiesWidget::on_unlink_button_clicked
* move current item in linked_list to free_list
*/
void MasterPropertiesWidget::on_unlink_button_clicked()
{
@@ -401,10 +405,10 @@ void MasterPropertiesWidget::on_unlink_button_clicked()
}
/**
@brief MasterPropertiesWidget::showElementFromTWI
Show the element corresponding to the given QTreeWidgetItem
@param qtwi
@param column
* @brief MasterPropertiesWidget::showElementFromTWI
* Show the element corresponding to the given QTreeWidgetItem
* @param qtwi
* @param column
*/
void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int column)
{
@@ -426,8 +430,8 @@ void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int colum
}
/**
@brief MasterPropertiesWidget::showedElementWasDeleted
Set to nullptr the current showed element when he was deleted
* @brief MasterPropertiesWidget::showedElementWasDeleted
* Set to nullptr the current showed element when he was deleted
*/
void MasterPropertiesWidget::showedElementWasDeleted()
{
@@ -435,9 +439,9 @@ void MasterPropertiesWidget::showedElementWasDeleted()
}
/**
@brief MasterPropertiesWidget::diagramWasdeletedFromProject
This slot is called when a diagram is removed from the parent project
of edited element to update the content of this widget
* @brief MasterPropertiesWidget::diagramWasdeletedFromProject
* This slot is called when a diagram is removed from the parent project
* of edited element to update the content of this widget
*/
void MasterPropertiesWidget::diagramWasdeletedFromProject()
{
@@ -449,10 +453,10 @@ void MasterPropertiesWidget::diagramWasdeletedFromProject()
}
/**
@brief MasterPropertiesWidget::customContextMenu
Display a context menu
@param pos
@param i : the tree widget where the context menu was requested.
* @brief MasterPropertiesWidget::customContextMenu
* Display a context menu
* @param pos
* @param i : the tree widget where the context menu was requested.
*/
void MasterPropertiesWidget::customContextMenu(const QPoint &pos, int i)
{