finally, fixed hiding of headers.

This commit is contained in:
2025-09-06 14:07:25 +02:00
parent a9dacca684
commit 89c671295f
6 changed files with 79 additions and 49 deletions

View File

@@ -19,7 +19,7 @@
//! der datenknoten.
XQModelSection::XQModelSection(const QModelIndex& modelIndex, XQNodePtr sheetNode)
: _modelIndex{ modelIndex }, _sectionRootNode{ sheetNode }
: _modelIndex{ modelIndex }, _sectionSheetRootNode{ sheetNode }
{
}
@@ -29,7 +29,7 @@ XQModelSection::XQModelSection(const QModelIndex& modelIndex, XQNodePtr sheetNod
bool XQModelSection::operator==(const XQModelSection& other) const
{
return _modelIndex == other._modelIndex && _sectionRootNode == other._sectionRootNode;
return _modelIndex == other._modelIndex && _sectionSheetRootNode == other._sectionSheetRootNode;
}
@@ -37,7 +37,7 @@ bool XQModelSection::operator==(const XQModelSection& other) const
bool XQModelSection::isValid() const
{
return _modelIndex.isValid() && _sectionRootNode;
return _modelIndex.isValid() && _sectionSheetRootNode;
}
QModelIndex XQModelSection::startIndex() const
@@ -47,7 +47,7 @@ QModelIndex XQModelSection::startIndex() const
XQNodePtr XQModelSection::sectionRootNode() const
{
return _sectionRootNode;
return _sectionSheetRootNode;
}
//! Gibt den sheet-node zurück, das ist die model-beschreibung,
@@ -60,7 +60,7 @@ XQNodePtr XQModelSection::sectionRootNode() const
XQNodePtr XQModelSection::sheetRootNode() const
{
return _sectionRootNode->find_child_by_tag_name( c_ModelSheet );
return _sectionSheetRootNode->find_child_by_tag_name( c_ModelSheet );
}
@@ -90,7 +90,8 @@ int XQModelSection::XQModelSection::firstRow() const
const QString& XQModelSection::contentType() const
{
return _sectionRootNode->attribute( c_ContentType );
//qDebug() << " ---AUA & AUS!";
return _sectionSheetRootNode->attribute( c_ContentType );
}
@@ -116,8 +117,7 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
if( hasValidSection( sectionKey ) )
return _sections.at(sectionKey);
static const XQModelSection s_DummySection;
return s_DummySection;
throw XQException( "No section for key: ", sectionKey);
}
@@ -127,21 +127,31 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
{
/*
for( const XQModelSection& section : _sections )
{
qDebug() << " --- sectionByRow: " <<section.startIndex().data().toString() << ": " << lastRow(section);
}
*/
// wir gehen rückwärts, weil wir da nur einen vergleich brauchen
// und uns den test mit lastRow() sparen können.
int i = _sections.size() - 1;
for (; i >= 0; --i)
{
if ( _sections.at(i).startIndex().row() < itemRow )
if ( _sections.at(i).startIndex().row() <= itemRow )
return _sections.at(i);
}
static XQModelSection s_DummySection;
return s_DummySection;
throw XQException( "No section for item row: ", QString::number(itemRow));
}
const XQModelSection& XQSectionManager::createSection(const QString& sectionKey, const QModelIndex& modelIndex, XQNodePtr sheetNode)
const XQModelSection& XQSectionManager::createSection(const QModelIndex& modelIndex, XQNodePtr sheetNode)
{
// 6. jetzt können wir auch die sction erzeugen
const QString& sectionKey = sheetNode->attribute(c_ContentType);
qDebug() << " --- create Section: " << sectionKey << ": " << modelIndex.data().toString();
XQModelSection section(modelIndex, sheetNode );
_sections.addAtKey( sectionKey, section);
return sectionByKey(sectionKey);
@@ -151,20 +161,9 @@ const XQModelSection& XQSectionManager::createSection(const QString& sectionKey,
//! ermittelt die zeile unterhalb des gegebenen modelindex,
//! zum einfügen neuer items ebendort.
/*
int XQSectionManager::lastRow(const QModelIndex& idx) const
{
return lastRow(sectionByRow(idx.row()));
}
//! ermittelt die zeile unterhalb der gegebenen section,
//! zum einfügen neuer items ebendort.
*/
int XQSectionManager::lastRow(const XQModelSection& section ) const
{
qDebug() << " -- last row in section: " << section.startIndex().data().toString() << " --> " << section.startIndex().row();
//qDebug() << " -- last row in section: " << section.startIndex().data().toString() << " --> " << section.startIndex().row();
// row() der section unterhalb dieser
// __fix? index mit speichern?
int index = _sections.indexOf(section);