mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
parent
febcabb0da
commit
b83aab7d74
@ -154,4 +154,16 @@ class QgsAttributeTableConfig
|
|||||||
* @see columnHidden()
|
* @see columnHidden()
|
||||||
*/
|
*/
|
||||||
void setColumnHidden( int column, bool hidden );
|
void setColumnHidden( int column, bool hidden );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sort order
|
||||||
|
* @note Added in 2.16
|
||||||
|
*/
|
||||||
|
Qt::SortOrder sortOrder() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sort order
|
||||||
|
* @note Added in 2.16
|
||||||
|
*/
|
||||||
|
void setSortOrder( const Qt::SortOrder& sortOrder );
|
||||||
};
|
};
|
||||||
|
@ -135,6 +135,7 @@ class QgsDualView : QStackedWidget
|
|||||||
* @return The table view
|
* @return The table view
|
||||||
*/
|
*/
|
||||||
QgsAttributeTableView* tableView();
|
QgsAttributeTableView* tableView();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the attribute table config which should be used to control
|
* Set the attribute table config which should be used to control
|
||||||
* the appearance of the attribute table.
|
* the appearance of the attribute table.
|
||||||
@ -144,7 +145,7 @@ class QgsDualView : QStackedWidget
|
|||||||
/**
|
/**
|
||||||
* Set the expression used for sorting the table and feature list.
|
* Set the expression used for sorting the table and feature list.
|
||||||
*/
|
*/
|
||||||
void setSortExpression( const QString& sortExpression );
|
void setSortExpression( const QString& sortExpression , Qt::SortOrder sortOrder = Qt::AscendingOrder );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the expression used for sorting the table and feature list.
|
* Get the expression used for sorting the table and feature list.
|
||||||
|
@ -196,6 +196,7 @@ void QgsAttributeTableConfig::readXml( const QDomNode& node )
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSortExpression = configNode.toElement().attribute( "sortExpression" );
|
mSortExpression = configNode.toElement().attribute( "sortExpression" );
|
||||||
|
mSortOrder = static_cast<Qt::SortOrder>( configNode.toElement().attribute( "sortOrder" ).toInt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsAttributeTableConfig::sortExpression() const
|
QString QgsAttributeTableConfig::sortExpression() const
|
||||||
@ -230,7 +231,17 @@ void QgsAttributeTableConfig::setColumnHidden( int column, bool hidden )
|
|||||||
|
|
||||||
bool QgsAttributeTableConfig::operator!=( const QgsAttributeTableConfig& other ) const
|
bool QgsAttributeTableConfig::operator!=( const QgsAttributeTableConfig& other ) const
|
||||||
{
|
{
|
||||||
return mSortExpression != other.mSortExpression || mColumns != other.mColumns || mActionWidgetStyle != other.mActionWidgetStyle;
|
return mSortExpression != other.mSortExpression || mColumns != other.mColumns || mActionWidgetStyle != other.mActionWidgetStyle || mSortOrder != other.mSortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::SortOrder QgsAttributeTableConfig::sortOrder() const
|
||||||
|
{
|
||||||
|
return mSortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsAttributeTableConfig::setSortOrder( const Qt::SortOrder& sortOrder )
|
||||||
|
{
|
||||||
|
mSortOrder = sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTableConfig::writeXml( QDomNode& node ) const
|
void QgsAttributeTableConfig::writeXml( QDomNode& node ) const
|
||||||
@ -242,6 +253,8 @@ void QgsAttributeTableConfig::writeXml( QDomNode& node ) const
|
|||||||
|
|
||||||
configElement.setAttribute( "sortExpression", mSortExpression );
|
configElement.setAttribute( "sortExpression", mSortExpression );
|
||||||
|
|
||||||
|
configElement.setAttribute( "sortOrder", mSortOrder );
|
||||||
|
|
||||||
QDomElement columnsElement = doc.createElement( "columns" );
|
QDomElement columnsElement = doc.createElement( "columns" );
|
||||||
|
|
||||||
Q_FOREACH ( const ColumnConfig& column, mColumns )
|
Q_FOREACH ( const ColumnConfig& column, mColumns )
|
||||||
|
@ -167,6 +167,18 @@ class CORE_EXPORT QgsAttributeTableConfig
|
|||||||
*/
|
*/
|
||||||
void setColumnHidden( int column, bool hidden );
|
void setColumnHidden( int column, bool hidden );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sort order
|
||||||
|
* @note Added in 2.16
|
||||||
|
*/
|
||||||
|
Qt::SortOrder sortOrder() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sort order
|
||||||
|
* @note Added in 2.16
|
||||||
|
*/
|
||||||
|
void setSortOrder( const Qt::SortOrder& sortOrder );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare this configuration to other.
|
* Compare this configuration to other.
|
||||||
*/
|
*/
|
||||||
@ -176,6 +188,7 @@ class CORE_EXPORT QgsAttributeTableConfig
|
|||||||
QVector<ColumnConfig> mColumns;
|
QVector<ColumnConfig> mColumns;
|
||||||
ActionWidgetStyle mActionWidgetStyle;
|
ActionWidgetStyle mActionWidgetStyle;
|
||||||
QString mSortExpression;
|
QString mSortExpression;
|
||||||
|
Qt::SortOrder mSortOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QgsAttributeTableConfig::ColumnConfig )
|
Q_DECLARE_METATYPE( QgsAttributeTableConfig::ColumnConfig )
|
||||||
|
@ -205,7 +205,7 @@ void QgsAttributeTableFilterModel::setAttributeTableConfig( const QgsAttributeTa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort( config.sortExpression() );
|
sort( config.sortExpression(), config.sortOrder() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTableFilterModel::sort( QString expression, Qt::SortOrder order )
|
void QgsAttributeTableFilterModel::sort( QString expression, Qt::SortOrder order )
|
||||||
|
@ -591,7 +591,7 @@ void QgsDualView::modifySort()
|
|||||||
orderByDlg.setLayout( layout );
|
orderByDlg.setLayout( layout );
|
||||||
|
|
||||||
QGroupBox* sortingGroupBox = new QGroupBox();
|
QGroupBox* sortingGroupBox = new QGroupBox();
|
||||||
sortingGroupBox->setTitle( tr( "Enable sorting order in attribute table" ) );
|
sortingGroupBox->setTitle( tr( "Defined sort order in attribute table" ) );
|
||||||
sortingGroupBox->setCheckable( true );
|
sortingGroupBox->setCheckable( true );
|
||||||
sortingGroupBox->setChecked( !sortExpression().isEmpty() );
|
sortingGroupBox->setChecked( !sortExpression().isEmpty() );
|
||||||
layout->addWidget( sortingGroupBox );
|
layout->addWidget( sortingGroupBox );
|
||||||
@ -610,22 +610,27 @@ void QgsDualView::modifySort()
|
|||||||
|
|
||||||
sortingGroupBox->layout()->addWidget( expressionBuilder );
|
sortingGroupBox->layout()->addWidget( expressionBuilder );
|
||||||
|
|
||||||
|
QCheckBox* cbxSortAscending = new QCheckBox( tr( "Sort ascending" ) );
|
||||||
|
cbxSortAscending->setChecked( config.sortOrder() == Qt::AscendingOrder );
|
||||||
|
sortingGroupBox->layout()->addWidget( cbxSortAscending );
|
||||||
|
|
||||||
layout->addWidget( dialogButtonBox );
|
layout->addWidget( dialogButtonBox );
|
||||||
if ( orderByDlg.exec() )
|
if ( orderByDlg.exec() )
|
||||||
{
|
{
|
||||||
|
Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||||
if ( sortingGroupBox->isChecked() )
|
if ( sortingGroupBox->isChecked() )
|
||||||
{
|
{
|
||||||
setSortExpression( expressionBuilder->expressionText() );
|
setSortExpression( expressionBuilder->expressionText(), sortOrder );
|
||||||
config.setSortExpression( expressionBuilder->expressionText() );
|
config.setSortExpression( expressionBuilder->expressionText() );
|
||||||
|
config.setSortOrder( sortOrder );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setSortExpression( QString() );
|
setSortExpression( QString(), sortOrder );
|
||||||
config.setSortExpression( QString() );
|
config.setSortExpression( QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
layer->setAttributeTableConfig( config );
|
setAttributeTableConfig( config );
|
||||||
mConfig = config;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,12 +660,18 @@ void QgsDualView::onSortColumnChanged()
|
|||||||
{
|
{
|
||||||
QgsAttributeTableConfig cfg = mLayerCache->layer()->attributeTableConfig();
|
QgsAttributeTableConfig cfg = mLayerCache->layer()->attributeTableConfig();
|
||||||
cfg.setSortExpression( mFilterModel->sortExpression() );
|
cfg.setSortExpression( mFilterModel->sortExpression() );
|
||||||
|
cfg.setSortOrder( mFilterModel->sortOrder() );
|
||||||
mLayerCache->layer()->setAttributeTableConfig( cfg );
|
mLayerCache->layer()->setAttributeTableConfig( cfg );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsDualView::sortByPreviewExpression()
|
void QgsDualView::sortByPreviewExpression()
|
||||||
{
|
{
|
||||||
setSortExpression( mFeatureList->displayExpression() );
|
Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
||||||
|
if ( mFeatureList->displayExpression() == sortExpression() )
|
||||||
|
{
|
||||||
|
sortOrder = mConfig.sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder;
|
||||||
|
}
|
||||||
|
setSortExpression( mFeatureList->displayExpression(), sortOrder );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsDualView::featureFormAttributeChanged()
|
void QgsDualView::featureFormAttributeChanged()
|
||||||
@ -697,16 +708,16 @@ void QgsDualView::setAttributeTableConfig( const QgsAttributeTableConfig& config
|
|||||||
mConfig = config;
|
mConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsDualView::setSortExpression( const QString& sortExpression )
|
void QgsDualView::setSortExpression( const QString& sortExpression, Qt::SortOrder sortOrder )
|
||||||
{
|
{
|
||||||
if ( sortExpression.isNull() )
|
if ( sortExpression.isNull() )
|
||||||
mFilterModel->sort( -1 );
|
mFilterModel->sort( -1 );
|
||||||
else
|
else
|
||||||
mFilterModel->sort( sortExpression );
|
mFilterModel->sort( sortExpression, sortOrder );
|
||||||
|
|
||||||
QgsAttributeTableConfig cfg = mLayerCache->layer()->attributeTableConfig();
|
mConfig.setSortExpression( sortExpression );
|
||||||
cfg.setSortExpression( sortExpression );
|
mConfig.setSortOrder( sortOrder );
|
||||||
mLayerCache->layer()->setAttributeTableConfig( cfg );
|
mLayerCache->layer()->setAttributeTableConfig( mConfig );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsDualView::sortExpression() const
|
QString QgsDualView::sortExpression() const
|
||||||
|
@ -185,7 +185,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
|
|||||||
/**
|
/**
|
||||||
* Set the expression used for sorting the table and feature list.
|
* Set the expression used for sorting the table and feature list.
|
||||||
*/
|
*/
|
||||||
void setSortExpression( const QString& sortExpression );
|
void setSortExpression( const QString& sortExpression , Qt::SortOrder sortOrder = Qt::AscendingOrder );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the expression used for sorting the table and feature list.
|
* Get the expression used for sorting the table and feature list.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user