From 809ef10c0dce053400f5653dd5d8f45f74a562e6 Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Mon, 8 Sep 2025 22:58:52 +0200 Subject: [PATCH] fixed toggle section --- src/application/xqmainwindow.cpp | 11 +---------- src/items/xqitemdelegate.cpp | 6 ++---- src/items/xqitemtype.cpp | 1 + src/model/xqviewmodel.cpp | 10 +++++----- xml/modelsheets.xml | 2 +- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index b2ae636..e61a127 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -267,7 +267,7 @@ void XQMainWindow::onTreeViewItemClicked( const XQItem& item ) void XQMainWindow::onTreeViewItemChanged(const XQItem& item ) { - //qDebug() << " --- TREE VIEW itemChanged:" << item.text() << " : " << item.parent()->text(); + qDebug() << " --- TREE VIEW itemChanged:" << item.text() << " : " << item.parent()->text() << " : " << (void*)&_mainModel << " : " << (void*) sender(); // hier müssen wir erst das projekt aktivieren XQItem* xqItem = static_cast(item.parent()); onTreeViewItemClicked( *xqItem ); @@ -312,23 +312,14 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section ) void XQMainWindow::onSectionToggled( const XQModelSection& section ) { qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string(); - if( _currentProjectItem ) { - - qDebug() << " --- XXX section toggled 2: " << _currentProjectItem->text(); for (int row = 0; row < _currentProjectItem->rowCount(); ++row) { QStandardItem* child = _currentProjectItem->child(row); - qDebug() << " --- XXX section toggled 3: " << child->text(); if (child->text() == section.contentType() ) { - // rekursion vermeiden - _currentProjectItem->model()->blockSignals( true ); bool checked = (child->checkState() == Qt::Checked); - qDebug() << " --- XXX section toggled 4: " << child->text() << " ->" << checked; child->setCheckState( checked ? Qt::Unchecked :Qt::Checked ); - _currentProjectItem->model()->blockSignals( false ); - _mainTreeView->repaint(); break; } } diff --git a/src/items/xqitemdelegate.cpp b/src/items/xqitemdelegate.cpp index fbc15d4..276cc29 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -92,18 +92,16 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option case XQItem::ComboBoxStyle : return drawComboBoxStyle( painter, option, index ); - +/* case XQItem::SpinBoxStyle : return drawSpinBoxStyle( painter, option, index ); case XQItem::ProgressBarStyle : return drawProgressBarStyle( painter, option, index ); - +*/ case XQItem::HiddenStyle : return; - - default: break; } // switch diff --git a/src/items/xqitemtype.cpp b/src/items/xqitemtype.cpp index 136c7d0..e8c4b1d 100644 --- a/src/items/xqitemtype.cpp +++ b/src/items/xqitemtype.cpp @@ -113,6 +113,7 @@ XQItemType* XQItemType::replaceAttribute( const QVariant& newValue, int role ) // Gibt es den geänderten ItemType schon? QString newKey = myClone->makeItemTypeKey(); // jawoll + if( s_ItemTypeMap.contains( newKey ) ) { // abräumen ... diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 1281d43..6e0cfcb 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -154,7 +154,7 @@ void XQViewModel::initModel(const QString& modelName) //! die section kann erst gültig sein, wenn die items im model gelandet sind, //! deswegen ist das hier zusammengefasst. -//! Wrzeugt dann eine section aus einer frisch erzeugten itemlist. Der erste modelindex +//! Erzeugt dann eine section aus einer frisch erzeugten itemlist. Der erste modelindex //! der liste und der root knoten der model-beschreibung werden gespeichert. void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode ) @@ -182,7 +182,7 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode //! SLOT, toggled die section mit dem 'sectionKey' (hier: contentType) void XQViewModel::onToggleSection(const QString& sectionKey ) -{ +{ toggleSection( _sections.sectionByKey(sectionKey) ); } @@ -194,8 +194,7 @@ void XQViewModel::toggleSection( const XQModelSection& section ) if( section.isValid() && _treeTable ) { XQSectionRange pos = _sections.sectionRange(section); - _treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow ); - emit sectionToggled(section); + _treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow ); } } @@ -522,7 +521,8 @@ void XQViewModel::cmdToggleSection( const XQCommand& command ) const QModelIndex& index = command.originIndex(); Q_ASSERT(index.isValid()); const XQModelSection& section = _sections.sectionByRow(index.row()); - toggleSection( section ); + //toggleSection( section ); + emit sectionToggled(section); } diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index 7c1c79b..9ffa8d3 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -19,7 +19,7 @@ - +