Hi, I am implementing Lazy population tree view.
have implemented hasChilderen(), fetchMore and canFetchMore() functions as below.
I am getting the Error: QSortFilterProxyModel: invalid inserted rows reported by source model;
Please let me know the problem.
bool TreeModel
::canFetchMore(const QModelIndex &parent
) const {
if(!parent.isValid())
return true;
if(m_totalRowCount > m_lastreadRowIndex) //I am storing lst read row value
{
return true;
}
return false;
}
void DebugTreeModel::fetchMore(const QModelIndex& parent)
{
//to fect readRows od records (rows) from sql
int readRows = 1000;
if( m_totalRowCount < ( readRows + m_lastreadRowIndex ) )
{
readRows = m_totalRowCount - m_lastreadRowIndex;
}
//will get me last row number
qint64 lastRow = m_lastreadRowIndex ;
emit fetchMoreData(readRows); //will fecth readRows number of records form the sql and form tree
qint64 parentsInFetchedData = getZerosInFetchedData();
//i have writtem logic so that, next inserted row should be 0 (so parent should be m_rootItem always (it is my top most parent))
//so I am passing m_rootItem as root and last inserted row number, num of row to insert.
beginInsertRows
(QModelIndex(), lastRow , lastRow
+parentsInFetchedData
-1 );
//same result for beginInsertRows(parent, lastRow , lastRow+parentsInFetchedData -1 ); endInsertRows();
}
bool TreeModel::canFetchMore(const QModelIndex &parent ) const
{
if(!parent.isValid())
return true;
if(m_totalRowCount > m_lastreadRowIndex) //I am storing lst read row value
{
return true;
}
return false;
}
void DebugTreeModel::fetchMore(const QModelIndex& parent)
{
//to fect readRows od records (rows) from sql
int readRows = 1000;
if( m_totalRowCount < ( readRows + m_lastreadRowIndex ) )
{
readRows = m_totalRowCount - m_lastreadRowIndex;
}
//will get me last row number
qint64 lastRow = m_lastreadRowIndex ;
emit fetchMoreData(readRows); //will fecth readRows number of records form the sql and form tree
qint64 parentsInFetchedData = getZerosInFetchedData();
//i have writtem logic so that, next inserted row should be 0 (so parent should be m_rootItem always (it is my top most parent))
//so I am passing m_rootItem as root and last inserted row number, num of row to insert.
beginInsertRows(QModelIndex(), lastRow , lastRow+parentsInFetchedData -1 ); //same result for beginInsertRows(parent, lastRow , lastRow+parentsInFetchedData -1 );
endInsertRows();
}
To copy to clipboard, switch view to plain text mode
Bookmarks