remorked sections.
This commit is contained in:
@@ -40,7 +40,7 @@ bool XQModelSection::isValid() const
|
||||
return _modelIndex.isValid() && _sectionRootNode;
|
||||
}
|
||||
|
||||
QModelIndex XQModelSection::persistentModelIndex() const
|
||||
QModelIndex XQModelSection::startIndex() const
|
||||
{
|
||||
return _modelIndex.operator QModelIndex();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ void XQModelSection::setContentRootNode( const XQNodePtr contentRootNode ) const
|
||||
|
||||
//! gibt die zeile des start-index zurück.
|
||||
|
||||
int XQModelSection::XQModelSection::row() const
|
||||
int XQModelSection::XQModelSection::firstRow() const
|
||||
{
|
||||
return _modelIndex.row();
|
||||
}
|
||||
@@ -111,7 +111,7 @@ bool XQSectionManager::hasValidSection(const QString& sectionKey) const
|
||||
return _sections.at(sectionKey).isValid();
|
||||
}
|
||||
|
||||
const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey )
|
||||
const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey ) const
|
||||
{
|
||||
if( hasValidSection( sectionKey ) )
|
||||
return _sections.at(sectionKey);
|
||||
@@ -121,29 +121,20 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
|
||||
|
||||
}
|
||||
|
||||
//! gibt für einen model index die 'zuständige' section zurück.
|
||||
|
||||
const XQModelSection& XQSectionManager::sectionByIndex( const QModelIndex& index ) const
|
||||
{
|
||||
return sectionByRow( index.row() );
|
||||
}
|
||||
|
||||
|
||||
//! gibt für eine zeile die 'zuständige' section zurück: der bestand an section wird
|
||||
//! nach der passenden section durchsucht.
|
||||
|
||||
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
||||
{
|
||||
|
||||
int i = _sections.size() - 1;
|
||||
for (; i >= 0; --i)
|
||||
{
|
||||
if ( _sections.at(i).persistentModelIndex().row() < itemRow )
|
||||
if ( _sections.at(i).startIndex().row() < itemRow )
|
||||
return _sections.at(i);
|
||||
}
|
||||
|
||||
static XQModelSection s_DummySection;
|
||||
|
||||
return s_DummySection;
|
||||
|
||||
}
|
||||
@@ -156,14 +147,6 @@ const XQModelSection& XQSectionManager::createSection(const QString& sectionKey,
|
||||
return sectionByKey(sectionKey);
|
||||
}
|
||||
|
||||
//! ermittelt die erste zeile einer section.
|
||||
|
||||
/*
|
||||
int XQSectionManager::firstRow(const QModelIndex& idx) const
|
||||
{
|
||||
return sectionByRow(idx.row() ).row();
|
||||
}
|
||||
*/
|
||||
|
||||
//! ermittelt die zeile unterhalb des gegebenen modelindex,
|
||||
//! zum einfügen neuer items ebendort.
|
||||
@@ -177,10 +160,11 @@ int XQSectionManager::lastRow(const QModelIndex& idx) const
|
||||
|
||||
//! 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.modelIndex.data().toString() << " --> " << section.modelIndex.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);
|
||||
@@ -188,23 +172,18 @@ int XQSectionManager::lastRow(const XQModelSection& section ) const
|
||||
{
|
||||
// last section? return last row of model
|
||||
if (index == _sections.size() - 1)
|
||||
return section.persistentModelIndex().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).row();
|
||||
return _sections.at(index+1).firstRow() - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
int firstRow(const QModelIndex& idx) const;
|
||||
int lastRow(const QModelIndex& idx) const;
|
||||
int lastRow(const XQModelSection& section) const;
|
||||
*/
|
||||
|
||||
XQSectionPos XQSectionManager::sectionPos()
|
||||
XQSectionRange XQSectionManager::sectionRange(const XQModelSection& section ) const
|
||||
{
|
||||
return XQSectionPos();
|
||||
qDebug() << " ---- Section RANGE: " << section.startIndex().row() << " -> " << lastRow(section);
|
||||
return XQSectionRange{ section.startIndex().row(), lastRow(section) };
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +194,7 @@ void XQSectionManager::dump() const
|
||||
qDebug() << " --- sections dump(): " <<_sections.size() << " entries.";
|
||||
for( int i = 0; i<_sections.size(); ++i )
|
||||
{
|
||||
QModelIndex idx = _sections.at(i).persistentModelIndex();
|
||||
QModelIndex idx = _sections.at(i).startIndex();
|
||||
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << _sections.keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user