--- fy
This commit is contained in:
@@ -128,17 +128,13 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
|
||||
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
||||
{
|
||||
|
||||
if( _sections.size() > 0)
|
||||
{
|
||||
// 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 )
|
||||
return _sections.at(i);
|
||||
}
|
||||
for (const auto& section : _sections)
|
||||
{
|
||||
qDebug() << " ---- SEC: " << itemRow << " -> " << section.firstRow() << " : " << lastRow( section );
|
||||
XQSectionRange range = sectionRange(section);
|
||||
if( itemRow >= range.firstRow && itemRow <= range.lastRow)
|
||||
return section;
|
||||
}
|
||||
|
||||
throw XQException( "No section for item row: ", QString::number(itemRow));
|
||||
@@ -169,9 +165,9 @@ int XQSectionManager::lastRow(const XQModelSection& section ) const
|
||||
{
|
||||
// last section? return last row of model
|
||||
if (index == _sections.size() - 1)
|
||||
return section.startIndex().model()->rowCount();// - 1;
|
||||
return section.startIndex().model()->rowCount() - 1;
|
||||
// return row above the row of the next section -> last row of given section
|
||||
return _sections.at(index+1).firstRow();// - 1;
|
||||
return _sections.at(index+1).firstRow() - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ XQViewModel::XQViewModel( QObject* parent )
|
||||
XQItem* xqItem = static_cast<XQItem*>(item);
|
||||
emit xqItemChanged( *xqItem );
|
||||
});
|
||||
|
||||
|
||||
// not needed
|
||||
//qRegisterMetaType<XQItem>("XQItem");
|
||||
}
|
||||
|
||||
@@ -192,8 +191,10 @@ void XQViewModel::onToggleSection(const QString& sectionKey )
|
||||
void XQViewModel::toggleSection( const XQModelSection& section )
|
||||
{
|
||||
if( section.isValid() && _treeTable )
|
||||
{
|
||||
{
|
||||
XQSectionRange pos = _sections.sectionRange(section);
|
||||
qDebug() << " --- Section RANGE: " << pos.firstRow << " -> " << pos.lastRow;
|
||||
|
||||
_treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow );
|
||||
}
|
||||
}
|
||||
@@ -521,8 +522,15 @@ void XQViewModel::cmdToggleSection( const XQCommand& command )
|
||||
const QModelIndex& index = command.originIndex();
|
||||
Q_ASSERT(index.isValid());
|
||||
const XQModelSection& section = _sections.sectionByRow(index.row());
|
||||
|
||||
// Obacht! Das ist hier etwas unsauber, 'toogleSection'' ändert den check-State
|
||||
// im document-tree, was wiederum die 'toggleSection' auslöst, das gibt also
|
||||
// einen doppelten Aufruf und wir sind dann wieder im Anfangszustand.
|
||||
|
||||
//toggleSection( section );
|
||||
|
||||
emit sectionToggled(section);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user