Merge branch 'master' into master

This commit is contained in:
Kellermorph
2026-03-31 14:14:02 +02:00
committed by GitHub
9 changed files with 56 additions and 104 deletions

View File

@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linksingleelementwidget.h"
#include "../qetgraphicsitem/masterelement.h"
#include "../qetgraphicsitem/conductor.h"
#include "../diagram.h"
#include "../diagramposition.h"
@@ -386,22 +386,7 @@ QVector <QPointer<Element>> LinkSingleElementWidget::availableElements()
//If element is linked, remove is parent from the list
if(!m_element->isFree()) elmt_vector.removeAll(m_element->linkedElements().first());
// NEU: Filtere volle Master-Elemente aus der Liste heraus
for (int i = elmt_vector.size() - 1; i >= 0; --i) {
Element *elmt = elmt_vector.at(i);
// Wenn das Element in der Liste ein Master ist
if (elmt->linkType() == Element::Master) {
// Wir wandeln den generischen Element-Pointer in einen MasterElement-Pointer um
MasterElement *master = static_cast<MasterElement*>(elmt);
// Wenn der Master voll ist, werfen wir ihn aus der Liste!
if (master->isFull()) {
elmt_vector.removeAt(i);
}
}
}
return elmt_vector;
}

View File

@@ -342,7 +342,7 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
{
m_context_menu->clear();
m_context_menu->addAction(m_save_header_state);
m_context_menu->popup(ui->m_free_tree_widget->header()->mapToGlobal(pos));
m_context_menu->popup(ui->m_free_tree_widget->header()->mapToGlobal(pos));
}
/**
@@ -352,33 +352,33 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
*/
void MasterPropertiesWidget::on_link_button_clicked()
{
// Get the maximum number of allowed slaves from the element's information
QVariant max_slaves_variant = m_element->kindInformations().value("max_slaves");
// 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();
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();
// If a limit is set and reached
if (max_slaves != -1 && current_slaves >= max_slaves) {
// 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;
}
}
// 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;
}
}
// Move current item from free_list to linked_list
QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem();
// Move current item from free_list to linked_list
QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem();
if (qtwi)
{
ui->m_free_tree_widget->takeTopLevelItem(
ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_link_tree_widget->insertTopLevelItem(0, qtwi);
if(m_live_edit)
apply();
}