mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix header data for combined model
This commit is contained in:
parent
d005c6bbc2
commit
6529309f48
@ -40,6 +40,9 @@ A model which contains entities from multiple :py:class:`QgsStyle` databases.
|
||||
Constructor for QgsCombinedStyleModel with the specified ``parent`` object.
|
||||
%End
|
||||
|
||||
virtual QVariant headerData( int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole ) const;
|
||||
|
||||
void addStyle( QgsStyle *style );
|
||||
%Docstring
|
||||
Adds a style to the model.
|
||||
|
@ -28,6 +28,11 @@ QgsCombinedStyleModel::QgsCombinedStyleModel( QObject *parent )
|
||||
|
||||
}
|
||||
|
||||
QVariant QgsCombinedStyleModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
||||
{
|
||||
return QgsStyleModel::headerDataStatic( section, orientation, role );
|
||||
}
|
||||
|
||||
void QgsCombinedStyleModel::addStyle( QgsStyle *style )
|
||||
{
|
||||
connect( style, &QgsStyle::destroyed, this, [this, style]()
|
||||
|
@ -61,6 +61,9 @@ class CORE_EXPORT QgsCombinedStyleModel: public QConcatenateTablesProxyModel
|
||||
*/
|
||||
explicit QgsCombinedStyleModel( QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||
|
||||
QVariant headerData( int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole ) const override;
|
||||
|
||||
/**
|
||||
* Adds a style to the model.
|
||||
*
|
||||
|
@ -511,6 +511,11 @@ Qt::ItemFlags QgsStyleModel::flags( const QModelIndex &index ) const
|
||||
}
|
||||
|
||||
QVariant QgsStyleModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
||||
{
|
||||
return headerDataStatic( section, orientation, role );
|
||||
}
|
||||
|
||||
QVariant QgsStyleModel::headerDataStatic( int section, Qt::Orientation orientation, int role )
|
||||
{
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
|
@ -199,7 +199,10 @@ class CORE_EXPORT QgsStyleModel: public QAbstractItemModel
|
||||
QgsStyle::StyleEntity entityTypeFromRow( int row ) const;
|
||||
|
||||
int offsetForEntity( QgsStyle::StyleEntity entity ) const;
|
||||
static QVariant headerDataStatic( int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole );
|
||||
|
||||
friend class QgsCombinedStyleModel;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ import os
|
||||
|
||||
import qgis # NOQA
|
||||
|
||||
from qgis.PyQt.QtCore import QCoreApplication, QEvent
|
||||
from qgis.PyQt.QtCore import QCoreApplication, QEvent, Qt
|
||||
|
||||
from qgis.core import (
|
||||
QgsStyle,
|
||||
@ -47,6 +47,8 @@ class TestQgsCombinedStyleModel(unittest.TestCase):
|
||||
|
||||
model.addStyle(style1)
|
||||
self.assertEqual(model.styles(), [style1])
|
||||
self.assertEqual(model.headerData(0, Qt.Horizontal), 'Name')
|
||||
self.assertEqual(model.headerData(1, Qt.Horizontal), 'Tags')
|
||||
|
||||
self.assertEqual(model.columnCount(), 2)
|
||||
self.assertEqual(model.rowCount(), 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user