--- 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user