Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
sub layer dialog: sort by layer id and feature count numerically (fixes
- Loading branch information
|
@@ -70,6 +70,12 @@ class QgsSublayersDialog : QDialog |
|
|
:rtype: bool |
|
|
%End |
|
|
|
|
|
int countColumn() const; |
|
|
%Docstring |
|
|
.. versionadded:: 3.0 |
|
|
:rtype: int |
|
|
%End |
|
|
|
|
|
public slots: |
|
|
void on_buttonBox_helpRequested(); |
|
|
int exec(); |
|
|
|
@@ -20,6 +20,24 @@ |
|
|
#include <QTableWidgetItem> |
|
|
#include <QPushButton> |
|
|
|
|
|
class SubLayerItem : public QTreeWidgetItem |
|
|
{ |
|
|
public: |
|
|
SubLayerItem( const QStringList &strings, int type = QTreeWidgetItem::Type ) |
|
|
: QTreeWidgetItem( strings, type ) |
|
|
{} |
|
|
|
|
|
bool operator <( const QTreeWidgetItem &other ) const |
|
|
{ |
|
|
QgsSublayersDialog *d = qobject_cast<QgsSublayersDialog *>( treeWidget()->parent() ); |
|
|
int col = treeWidget()->sortColumn(); |
|
|
|
|
|
if ( col == 0 || ( col > 0 && d->countColumn() == col ) ) |
|
|
return text( col ).toInt() < other.text( col ).toInt(); |
|
|
else |
|
|
return text( col ) < other.text( col ); |
|
|
} |
|
|
}; |
|
|
|
|
|
QgsSublayersDialog::QgsSublayersDialog( ProviderType providerType, const QString &name, |
|
|
QWidget *parent, Qt::WindowFlags fl ) |
|
@@ -123,7 +141,7 @@ void QgsSublayersDialog::populateLayerTable( const QgsSublayersDialog::LayerDefi |
|
|
elements << QString::number( item.count ); |
|
|
if ( mShowType ) |
|
|
elements << item.type; |
|
|
layersTable->addTopLevelItem( new QTreeWidgetItem( elements ) ); |
|
|
layersTable->addTopLevelItem( new SubLayerItem( elements ) ); |
|
|
} |
|
|
|
|
|
// resize columns |
|
|
|
@@ -80,6 +80,10 @@ class GUI_EXPORT QgsSublayersDialog : public QDialog, private Ui::QgsSublayersDi |
|
|
//! \since QGIS 3.0 |
|
|
bool addToGroupCheckbox() const { return mCheckboxAddToGroup->isChecked(); } |
|
|
|
|
|
//! Return column with count or -1 |
|
|
//! \since QGIS 3.0 |
|
|
int countColumn() const { return mShowCount ? 2 : -1; } |
|
|
|
|
|
public slots: |
|
|
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); } |
|
|
int exec(); |
|
|