mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-29 05:49:57 +02:00
Revert "Feature: Implement max_slaves limit for Master elements"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -348,34 +348,16 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &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
|
||||
*/
|
||||
void MasterPropertiesWidget::on_link_button_clicked()
|
||||
{
|
||||
// --- NEU: Prüfen, ob das Master-Limit im UI bereits erreicht ist ---
|
||||
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();
|
||||
|
||||
// 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.
|
||||
return;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
//take the current item from free_list and push it to linked_list
|
||||
//take the current item from free_list and push it 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user