mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
parent
8be36cfb91
commit
48071fa228
@ -548,7 +548,12 @@ Replaces the columns in the table with a specified list of :py:class:`QgsLayoutT
|
||||
|
||||
QgsLayoutTableSortColumns &sortColumns();
|
||||
%Docstring
|
||||
Returns a reference to the list of :py:class:`QgsLayoutTableSortColumns` shown in the table
|
||||
Returns a reference to the list of :py:class:`QgsLayoutTableSortColumns` shown in the table.
|
||||
|
||||
.. warning::
|
||||
|
||||
It is expected that the :py:func:`QgsLayoutTableColumn.attribute()` values in the columns
|
||||
are valid QGIS expression values, and that column references are correctly escaped accordingly.
|
||||
|
||||
.. seealso:: :py:func:`setSortColumns`
|
||||
|
||||
@ -561,6 +566,11 @@ Replaces the sorting columns in the table with a specified list of :py:class:`Qg
|
||||
|
||||
:param sortColumns: list of :py:class:`QgsLayoutTableColumns` used to sort the table.
|
||||
|
||||
.. warning::
|
||||
|
||||
It is expected that the :py:func:`QgsLayoutTableColumn.attribute()` values in ``sortColumns``
|
||||
are valid QGIS expression values, and that column references are correctly escaped accordingly.
|
||||
|
||||
.. seealso:: :py:func:`sortColumns`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
|
@ -489,7 +489,12 @@ class CORE_EXPORT QgsLayoutTable: public QgsLayoutMultiFrame
|
||||
void setColumns( const QgsLayoutTableColumns &columns );
|
||||
|
||||
/**
|
||||
* Returns a reference to the list of QgsLayoutTableSortColumns shown in the table
|
||||
* Returns a reference to the list of QgsLayoutTableSortColumns shown in the table.
|
||||
*
|
||||
*
|
||||
* \warning It is expected that the QgsLayoutTableColumn::attribute() values in the columns
|
||||
* are valid QGIS expression values, and that column references are correctly escaped accordingly.
|
||||
*
|
||||
* \see setSortColumns()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
@ -498,6 +503,10 @@ class CORE_EXPORT QgsLayoutTable: public QgsLayoutMultiFrame
|
||||
/**
|
||||
* Replaces the sorting columns in the table with a specified list of QgsLayoutTableSortColumns.
|
||||
* \param sortColumns list of QgsLayoutTableColumns used to sort the table.
|
||||
*
|
||||
* \warning It is expected that the QgsLayoutTableColumn::attribute() values in \a sortColumns
|
||||
* are valid QGIS expression values, and that column references are correctly escaped accordingly.
|
||||
*
|
||||
* \see sortColumns()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
|
@ -415,10 +415,11 @@ void QgsLayoutColumnAlignmentDelegate::updateEditorGeometry( QWidget *editor, co
|
||||
|
||||
// QgsLayoutColumnSourceDelegate
|
||||
|
||||
QgsLayoutColumnSourceDelegate::QgsLayoutColumnSourceDelegate( QgsVectorLayer *vlayer, QObject *parent, const QgsLayoutObject *layoutObject )
|
||||
QgsLayoutColumnSourceDelegate::QgsLayoutColumnSourceDelegate( QgsVectorLayer *vlayer, QObject *parent, const QgsLayoutObject *layoutObject, bool forceExpressions )
|
||||
: QItemDelegate( parent )
|
||||
, mVectorLayer( vlayer )
|
||||
, mLayoutObject( layoutObject )
|
||||
, mForceExpressions( forceExpressions )
|
||||
{
|
||||
|
||||
}
|
||||
@ -462,7 +463,7 @@ void QgsLayoutColumnSourceDelegate::setEditorData( QWidget *editor, const QModel
|
||||
void QgsLayoutColumnSourceDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
|
||||
{
|
||||
QgsFieldExpressionWidget *fieldExpression = static_cast<QgsFieldExpressionWidget *>( editor );
|
||||
const QString field = fieldExpression->currentField();
|
||||
const QString field = mForceExpressions ? fieldExpression->asExpression() : fieldExpression->currentField();
|
||||
|
||||
model->setData( index, field, Qt::EditRole );
|
||||
}
|
||||
@ -631,7 +632,7 @@ QgsLayoutAttributeSelectionDialog::QgsLayoutAttributeSelectionDialog( QgsLayoutI
|
||||
mSortColumnModel = new QgsLayoutTableSortModel( mTable, mSortColumnTableView );
|
||||
mSortColumnTableView->setModel( mSortColumnModel );
|
||||
mSortColumnTableView->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
|
||||
mSortColumnSourceDelegate = new QgsLayoutColumnSourceDelegate( vLayer, mSortColumnTableView, mTable );
|
||||
mSortColumnSourceDelegate = new QgsLayoutColumnSourceDelegate( vLayer, mSortColumnTableView, mTable, true );
|
||||
mSortColumnTableView->setItemDelegateForColumn( 0, mSortColumnSourceDelegate );
|
||||
mSortColumnOrderDelegate = new QgsLayoutColumnSortOrderDelegate( mSortColumnTableView );
|
||||
mSortColumnTableView->setItemDelegateForColumn( 1, mSortColumnOrderDelegate );
|
||||
|
@ -213,8 +213,15 @@ class GUI_EXPORT QgsLayoutColumnSourceDelegate : public QItemDelegate, private Q
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
QgsLayoutColumnSourceDelegate( QgsVectorLayer *vlayer, QObject *parent = nullptr, const QgsLayoutObject *layoutObject = nullptr );
|
||||
|
||||
/**
|
||||
* Constructor for QgsLayoutColumnSourceDelegate.
|
||||
*
|
||||
* If \a forceExpressionValues is TRUE then the values generated by the delegate will always be complete
|
||||
* QGIS expressions, i.e. field references will be quoted accordingly.
|
||||
*/
|
||||
QgsLayoutColumnSourceDelegate( QgsVectorLayer *vlayer, QObject *parent = nullptr, const QgsLayoutObject *layoutObject = nullptr, bool forceExpressions = false );
|
||||
|
||||
QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
|
||||
void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
|
||||
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
|
||||
@ -224,6 +231,7 @@ class GUI_EXPORT QgsLayoutColumnSourceDelegate : public QItemDelegate, private Q
|
||||
private:
|
||||
QgsVectorLayer *mVectorLayer = nullptr;
|
||||
const QgsLayoutObject *mLayoutObject = nullptr;
|
||||
bool mForceExpressions = false;
|
||||
QgsExpressionContext createExpressionContext() const override;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user