Skip to content
Permalink
Browse files

Make additional sort caches accessible

  • Loading branch information
m-kuhn committed May 17, 2018
1 parent 2325fe5 commit 9963892790bc0933b668eccb71bc19ba7593bd1c
@@ -194,14 +194,18 @@ Specify -1 as column to invalidate the cache
void prefetchSortData( const QString &expression, unsigned long cacheIndex = 0 );
%Docstring
Prefetches the entire data for one expression. Based on this cached information
the sorting can later be done in a performant way.
the sorting can later be done in a performant way. A ``cacheIndex`` can be specified
if multiple caches should be filled. In this case, the caches will be available
as ``QgsAttributeTableModel.SortRole + cacheIndex``.

:param expression: The expression to cache
%End

QString sortCacheExpression() const;
QString sortCacheExpression( unsigned long cacheIndex = 0 ) const;
%Docstring
The expression which was used to fill the sorting cache
The expression which was used to fill the sorting cache at index \cacheIndex.

.. seealso:: :py:func:`prefetchSortData`
%End

void setRequest( const QgsFeatureRequest &request );
@@ -908,13 +908,14 @@ void QgsAttributeTableModel::prefetchSortData( const QString &expressionString,
}
}

QString QgsAttributeTableModel::sortCacheExpression() const
QString QgsAttributeTableModel::sortCacheExpression( unsigned long cacheIndex ) const
{
Q_ASSERT( !mSortCaches.empty() );

QString expressionString;

const QgsExpression &expression = mSortCaches.begin()->sortCacheExpression;
if ( cacheIndex >= mSortCaches.size() )
return expressionString;

const QgsExpression &expression = mSortCaches[cacheIndex].sortCacheExpression;

if ( expression.isValid() )
expressionString = expression.expression();
@@ -200,16 +200,20 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel

/**
* Prefetches the entire data for one expression. Based on this cached information
* the sorting can later be done in a performant way.
* the sorting can later be done in a performant way. A \a cacheIndex can be specified
* if multiple caches should be filled. In this case, the caches will be available
* as ``QgsAttributeTableModel::SortRole + cacheIndex``.
*
* \param expression The expression to cache
*/
void prefetchSortData( const QString &expression, unsigned long cacheIndex = 0 );

/**
* The expression which was used to fill the sorting cache
* The expression which was used to fill the sorting cache at index \cacheIndex.
*
* \see prefetchSortData
*/
QString sortCacheExpression() const;
QString sortCacheExpression( unsigned long cacheIndex = 0 ) const;

/**
* Set a request that will be used to fill this attribute table model.

0 comments on commit 9963892

Please sign in to comment.
You can’t perform that action at this time.