diff --git a/python/gui/qgsmaplayercombobox.sip b/python/gui/qgsmaplayercombobox.sip index c14b53e927b..dce2b3bab61 100644 --- a/python/gui/qgsmaplayercombobox.sip +++ b/python/gui/qgsmaplayercombobox.sip @@ -21,6 +21,12 @@ class QgsMapLayerComboBox : QComboBox //! currently used filter on list layers QgsMapLayerProxyModel::Filters filters() const; + + //! except a list of layers not to be listed + void setExceptedLayerList( QList layerList ); + + //! returns the list of excepted layers + QList exceptedLayerList() const; //! currentLayer returns the current layer selected in the combo box QgsMapLayer* currentLayer() const; diff --git a/python/gui/qgsmaplayerproxymodel.sip b/python/gui/qgsmaplayerproxymodel.sip index 2f423dae0c5..46de3776630 100644 --- a/python/gui/qgsmaplayerproxymodel.sip +++ b/python/gui/qgsmaplayerproxymodel.sip @@ -42,6 +42,10 @@ class QgsMapLayerProxyModel : QSortFilterProxyModel */ QgsMapLayerProxyModel* setFilters( Filters filters ); const Filters& filters() const; + + //! offer the possibility to except some layers to be listed + void setExceptedLayerList( QList exceptList ); + QList exceptedLayerList(); // QSortFilterProxyModel interface public: diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index c026516303c..6b6bbcf9ed9 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -7,7 +7,7 @@ SET(QGIS_APP_SRCS qgssponsors.cpp qgsaddattrdialog.cpp qgsaddtaborgroup.cpp - qgsaddjoindialog.cpp + qgsjoindialog.cpp qgsannotationwidget.cpp qgsattributeactiondialog.cpp qgsattributetypedialog.cpp @@ -163,7 +163,7 @@ SET (QGIS_APP_MOC_HDRS qgisappstylesheet.h qgsabout.h qgsaddattrdialog.h - qgsaddjoindialog.h + qgsjoindialog.h qgsaddtaborgroup.h qgsannotationwidget.h qgsattributeactiondialog.h diff --git a/src/app/qgsaddjoindialog.cpp b/src/app/qgsaddjoindialog.cpp deleted file mode 100644 index d9bc6a8e221..00000000000 --- a/src/app/qgsaddjoindialog.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************** - qgsaddjoindialog.cpp - -------------------- - begin : July 10, 2010 - copyright : (C) 2010 by Marco Hugentobler - email : marco dot hugentobler at sourcepole dot ch - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "qgsaddjoindialog.h" -#include "qgsmaplayer.h" -#include "qgsmaplayerregistry.h" -#include "qgsvectordataprovider.h" -#include "qgsvectorlayer.h" - -#include - -QgsAddJoinDialog::QgsAddJoinDialog( QgsVectorLayer* layer, QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mLayer( layer ) -{ - setupUi( this ); - - if ( !mLayer ) - { - return; - } - - //insert possible vector layers into mJoinLayerComboBox - - mJoinLayerComboBox->blockSignals( true ); - const QMap& layerList = QgsMapLayerRegistry::instance()->mapLayers(); - QMap::const_iterator layerIt = layerList.constBegin(); - for ( ; layerIt != layerList.constEnd(); ++layerIt ) - { - QgsMapLayer* currentLayer = layerIt.value(); - if ( currentLayer->type() == QgsMapLayer::VectorLayer ) - { - QgsVectorLayer* currentVectorLayer = dynamic_cast( currentLayer ); - if ( currentVectorLayer && currentVectorLayer != mLayer ) - { - if ( currentVectorLayer->dataProvider() && currentVectorLayer->dataProvider()->supportsSubsetString() ) - mJoinLayerComboBox->addItem( currentLayer->name(), QVariant( currentLayer->id() ) ); - } - } - } - mJoinLayerComboBox->blockSignals( false ); - on_mJoinLayerComboBox_currentIndexChanged( mJoinLayerComboBox->currentIndex() ); - - //insert possible target fields - QgsVectorDataProvider* provider = mLayer->dataProvider(); - if ( provider ) - { - const QgsFields& layerFields = provider->fields(); - for ( int idx = 0; idx < layerFields.count(); ++idx ) - { - mTargetFieldComboBox->addItem( layerFields[idx].name(), idx ); - } - } - - mCacheInMemoryCheckBox->setChecked( true ); -} - -QgsAddJoinDialog::~QgsAddJoinDialog() -{ -} - -QString QgsAddJoinDialog::joinedLayerId() const -{ - return mJoinLayerComboBox->itemData( mJoinLayerComboBox->currentIndex() ).toString(); -} - -QString QgsAddJoinDialog::joinFieldName() const -{ - return mJoinFieldComboBox->itemText( mJoinFieldComboBox->currentIndex() ); -} - -QString QgsAddJoinDialog::targetFieldName() const -{ - return mTargetFieldComboBox->itemText( mTargetFieldComboBox->currentIndex() ); -} - -bool QgsAddJoinDialog::cacheInMemory() const -{ - return mCacheInMemoryCheckBox->isChecked(); -} - -bool QgsAddJoinDialog::createAttributeIndex() const -{ - return mCreateIndexCheckBox->isChecked(); -} - -bool QgsAddJoinDialog::hasJoinFieldsSubset() const -{ - return mUseJoinFieldsSubset->isChecked(); -} - -QStringList QgsAddJoinDialog::joinFieldsSubset() const -{ - QStringList lst; - QAbstractItemModel* model = mJoinFieldsSubsetView->model(); - if ( !model ) - return lst; - - for ( int i = 0; i < model->rowCount(); ++i ) - { - QModelIndex index = model->index( i, 0 ); - if ( model->data( index, Qt::CheckStateRole ).toInt() == Qt::Checked ) - lst << model->data( index ).toString(); - } - return lst; -} - -bool QgsAddJoinDialog::hasCustomPrefix() const -{ - return mUseCustomPrefix; -} - -const QString QgsAddJoinDialog::customPrefix() const -{ - return mCustomPrefix->text(); -} - -void QgsAddJoinDialog::on_mJoinLayerComboBox_currentIndexChanged( int index ) -{ - mJoinFieldComboBox->clear(); - QString layerId = mJoinLayerComboBox->itemData( index ).toString(); - QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerId ); - QgsVectorLayer* vLayer = dynamic_cast( layer ); - if ( !vLayer ) - { - return; - } - - QStandardItemModel* subsetModel = new QStandardItemModel( this ); - - const QgsFields& layerFields = vLayer->pendingFields(); - for ( int idx = 0; idx < layerFields.count(); ++idx ) - { - mJoinFieldComboBox->addItem( layerFields[idx].name(), idx ); - QStandardItem* subsetItem = new QStandardItem( layerFields[idx].name() ); - subsetItem->setCheckable( true ); - //subsetItem->setFlags( subsetItem->flags() | Qt::ItemIsUserCheckable ); - subsetModel->appendRow( subsetItem ); - } - - //does provider support creation of attribute indices? - QgsVectorDataProvider* dp = vLayer->dataProvider(); - if ( dp && ( dp->capabilities() & QgsVectorDataProvider::CreateAttributeIndex ) ) - { - mCreateIndexCheckBox->setEnabled( true ); - } - else - { - mCreateIndexCheckBox->setEnabled( false ); - mCreateIndexCheckBox->setChecked( false ); - } - - mJoinFieldsSubsetView->setModel( subsetModel ); - - if ( !mUseCustomPrefix->isChecked() ) - { - mCustomPrefix->setText( layer->name() + "_" ); - } -} diff --git a/src/app/qgsjoindialog.cpp b/src/app/qgsjoindialog.cpp new file mode 100644 index 00000000000..c8b01539378 --- /dev/null +++ b/src/app/qgsjoindialog.cpp @@ -0,0 +1,164 @@ +/*************************************************************************** + qgsjoindialog.cpp + -------------------- + begin : July 10, 2010 + copyright : (C) 2010 by Marco Hugentobler + email : marco dot hugentobler at sourcepole dot ch + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsjoindialog.h" +#include "qgsmaplayer.h" +#include "qgsmaplayerregistry.h" +#include "qgsvectordataprovider.h" +#include "qgsvectorlayer.h" +#include "qgsmaplayercombobox.h" +#include "qgsfieldcombobox.h" + +#include + +QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QWidget * parent, Qt::WindowFlags f ) + : QDialog( parent, f ) + , mLayer( layer ) +{ + setupUi( this ); + + if ( !mLayer ) + { + return; + } + + mTargetFieldComboBox->setLayer( mLayer ); + mJoinLayerComboBox->setExceptedLayerList( QList() << mLayer ); + connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), mJoinFieldComboBox, SLOT( setLayer( QgsMapLayer* ) ) ); + connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( joinedLayerChanged( QgsMapLayer* ) ) ); + connect( mJoinFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( allowAttrIndexCreation() ) ); + + mCacheInMemoryCheckBox->setChecked( true ); +} + +QgsJoinDialog::~QgsJoinDialog() +{ +} + +void QgsJoinDialog::setJoinInfo( const QgsVectorJoinInfo& joinInfo ) +{ + mJoinLayerComboBox->setLayer( QgsMapLayerRegistry::instance()->mapLayer( joinInfo.joinLayerId ) ); + mJoinFieldComboBox->setField( joinInfo.joinFieldName ); + mTargetFieldComboBox->setField( joinInfo.targetFieldName ); + mCacheInMemoryCheckBox->setChecked( joinInfo.memoryCache ); + if ( joinInfo.prefix.isNull() ) + { + mUseCustomPrefix->setChecked( false ); + } + else + { + mUseCustomPrefix->setChecked( true ); + mCustomPrefix->setText( joinInfo.prefix ); + } + + QStringList* lst = joinInfo.joinFieldNamesSubset(); + mUseJoinFieldsSubset->setChecked( lst->count() > 0 ); + QAbstractItemModel* model = mJoinFieldsSubsetView->model(); + if ( model ) + { + for ( int i = 0; i < model->rowCount(); ++i ) + { + QModelIndex index = model->index( i, 0 ); + if ( lst->contains( model->data( index, Qt::DisplayRole ).toString() ) ) + { + model->setData( index, Qt::Checked, Qt::CheckStateRole ); + } + else + { + model->setData( index, Qt::Unchecked, Qt::CheckStateRole ); + } + } + } +} + +QgsVectorJoinInfo QgsJoinDialog::joinInfo() const +{ + QgsVectorJoinInfo info; + info.joinLayerId = mJoinLayerComboBox->currentLayer()->id(); + info.joinFieldName = mJoinFieldComboBox->currentField(); + info.targetFieldName = mTargetFieldComboBox->currentField(); + info.memoryCache = mCacheInMemoryCheckBox->isChecked(); + + if ( mUseCustomPrefix->isChecked() ) + info.prefix = mCustomPrefix->text(); + else + info.prefix = QString::null; + + if ( mUseJoinFieldsSubset->isChecked() ) + { + QStringList lst; + QAbstractItemModel* model = mJoinFieldsSubsetView->model(); + if ( model ) + { + for ( int i = 0; i < model->rowCount(); ++i ) + { + QModelIndex index = model->index( i, 0 ); + if ( model->data( index, Qt::CheckStateRole ).toInt() == Qt::Checked ) + lst << model->data( index ).toString(); + } + } + info.setJoinFieldNamesSubset( new QStringList( lst ) ); + } + + return info; +} + +bool QgsJoinDialog::createAttributeIndex() const +{ + return mCreateIndexCheckBox->isChecked(); +} + +void QgsJoinDialog::joinedLayerChanged( QgsMapLayer* layer ) +{ + + mJoinFieldComboBox->clear(); + + QgsVectorLayer* vLayer = dynamic_cast( layer ); + if ( !vLayer ) + { + return; + } + + mUseJoinFieldsSubset->setChecked( false ); + QStandardItemModel* subsetModel = new QStandardItemModel( this ); + const QgsFields& layerFields = vLayer->pendingFields(); + for ( int idx = 0; idx < layerFields.count(); ++idx ) + { + QStandardItem* subsetItem = new QStandardItem( layerFields[idx].name() ); + subsetItem->setCheckable( true ); + //subsetItem->setFlags( subsetItem->flags() | Qt::ItemIsUserCheckable ); + subsetModel->appendRow( subsetItem ); + } + mJoinFieldsSubsetView->setModel( subsetModel ); + + QgsVectorDataProvider* dp = vLayer->dataProvider(); + bool canCreateAttrIndex = dp && ( dp->capabilities() & QgsVectorDataProvider::CreateAttributeIndex ); + if ( canCreateAttrIndex ) + { + mCreateIndexCheckBox->setEnabled( true ); + } + else + { + mCreateIndexCheckBox->setEnabled( false ); + mCreateIndexCheckBox->setChecked( false ); + } + + if ( !mUseCustomPrefix->isChecked() ) + { + mCustomPrefix->setText( layer->name() + "_" ); + } +} diff --git a/src/app/qgsaddjoindialog.h b/src/app/qgsjoindialog.h similarity index 50% rename from src/app/qgsaddjoindialog.h rename to src/app/qgsjoindialog.h index 9805b56571c..8b6d3984e53 100644 --- a/src/app/qgsaddjoindialog.h +++ b/src/app/qgsjoindialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgsaddjoindialog.h + qgsjoindialog.h ------------------ begin : July 10, 2010 copyright : (C) 2010 by Marco Hugentobler @@ -15,42 +15,32 @@ * * ***************************************************************************/ -#ifndef QGSADDJOINDIALOG_H -#define QGSADDJOINDIALOG_H +#ifndef QgsJoinDIALOG_H +#define QgsJoinDIALOG_H + +#include "ui_qgsjoindialogbase.h" -#include "ui_qgsaddjoindialogbase.h" class QgsVectorLayer; +class QgsVectorJoinInfo; -class APP_EXPORT QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogBase +class APP_EXPORT QgsJoinDialog: public QDialog, private Ui::QgsJoinDialogBase { Q_OBJECT public: - QgsAddJoinDialog( QgsVectorLayer* layer, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - ~QgsAddJoinDialog(); + QgsJoinDialog( QgsVectorLayer* layer, QWidget * parent = 0, Qt::WindowFlags f = 0 ); + ~QgsJoinDialog(); - //retrieve results + /** Configure the dialog for an existing join */ + void setJoinInfo( const QgsVectorJoinInfo& joinInfo ); + + /** Returns the join info */ + QgsVectorJoinInfo joinInfo() const; - /** Get the id of the layer to join*/ - QString joinedLayerId() const; - /** Returns the name of the join field*/ - QString joinFieldName() const; - /** Returns the name of the target field (join-to field)*/ - QString targetFieldName() const; - /** True if joined layer should be cached in virtual memory*/ - bool cacheInMemory() const; /** Returns true if user wants to create an attribute index on the join field*/ bool createAttributeIndex() const; - /** True if onle a subset of fields of joined layer should be used*/ - bool hasJoinFieldsSubset() const; - /** Return list of checked fields from joined layer to be used in join*/ - QStringList joinFieldsSubset() const; - /** Return if the user selected a custom prefix*/ - bool hasCustomPrefix() const; - /** The custom prefix the user defined*/ - const QString customPrefix() const; private slots: - void on_mJoinLayerComboBox_currentIndexChanged( int index ); + void joinedLayerChanged( QgsMapLayer* layer ); private: /**Target layer*/ @@ -58,4 +48,4 @@ class APP_EXPORT QgsAddJoinDialog: public QDialog, private Ui::QgsAddJoinDialogB }; -#endif // QGSADDJOINDIALOG_H +#endif // QgsJoinDIALOG_H diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 3cff78155d2..bc105b2133e 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -20,7 +20,7 @@ #include #include "qgisapp.h" -#include "qgsaddjoindialog.h" +#include "qgsjoindialog.h" #include "qgsapplication.h" #include "qgsattributeactiondialog.h" #include "qgsapplydialog.h" @@ -1031,17 +1031,10 @@ void QgsVectorLayerProperties::showListOfStylesFromDatabase() void QgsVectorLayerProperties::on_mButtonAddJoin_clicked() { - QgsAddJoinDialog d( layer ); + QgsJoinDialog d( layer ); if ( d.exec() == QDialog::Accepted ) { - QgsVectorJoinInfo info; - info.targetFieldName = d.targetFieldName(); - info.joinLayerId = d.joinedLayerId(); - info.joinFieldName = d.joinFieldName(); - info.memoryCache = d.cacheInMemory(); - - if ( d.hasJoinFieldsSubset() ) - info.setJoinFieldNamesSubset( new QStringList( d.joinFieldsSubset() ) ); + QgsVectorJoinInfo info = d.joinInfo(); if ( layer ) { //create attribute index if possible @@ -1053,11 +1046,6 @@ void QgsVectorLayerProperties::on_mButtonAddJoin_clicked() joinLayer->dataProvider()->createAttributeIndex( joinLayer->pendingFields().indexFromName( info.joinFieldName ) ); } } - if ( d.hasCustomPrefix() ) - info.prefix = d.customPrefix(); - else - info.prefix = QString::null; - layer->addJoin( info ); addJoinToTreeWidget( info ); pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() && @@ -1067,6 +1055,62 @@ void QgsVectorLayerProperties::on_mButtonAddJoin_clicked() } } +void QgsVectorLayerProperties::on_mButtonEditJoin_clicked() +{ + QTreeWidgetItem* currentJoinItem = mJoinTreeWidget->currentItem(); + if ( !layer || !currentJoinItem ) + { + return; + } + + QString joinLayerId = currentJoinItem->data( 0, Qt::UserRole ).toString(); + const QList< QgsVectorJoinInfo >& joins = layer->vectorJoins(); + int j = -1; + for ( int i = 0; i < joins.size(); ++i ) + { + if ( joins[i].joinLayerId == joinLayerId ) + { + j = i; + break; + } + } + if ( j == -1 ) + { + return; + } + + QgsJoinDialog d( layer ); + d.setJoinInfo( joins[j] ); + + if ( d.exec() == QDialog::Accepted ) + { + // remove old join + layer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() ); + mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) ); + + // add the new edited + QgsVectorJoinInfo info = d.joinInfo(); + if ( layer ) + { + //create attribute index if possible + if ( d.createAttributeIndex() ) + { + QgsVectorLayer* joinLayer = qobject_cast( QgsMapLayerRegistry::instance()->mapLayer( info.joinLayerId ) ); + if ( joinLayer ) + { + joinLayer->dataProvider()->createAttributeIndex( joinLayer->pendingFields().indexFromName( info.joinFieldName ) ); + } + } + layer->addJoin( info ); + addJoinToTreeWidget( info ); + + pbnQueryBuilder->setEnabled( layer && layer->dataProvider() && layer->dataProvider()->supportsSubsetString() && + !layer->isEditable() && layer->vectorJoins().size() < 1 ); + mFieldsPropertiesDialog->init(); + } + } +} + void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join ) { QTreeWidgetItem* joinItem = new QTreeWidgetItem(); diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index d70a2126305..5bef0e90ffd 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -115,6 +115,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private void enableLabelOptions( bool theFlag ); void on_mButtonAddJoin_clicked(); + void on_mButtonEditJoin_clicked(); void on_mButtonRemoveJoin_clicked(); void on_mSimplifyDrawingGroupBox_toggled( bool checked ); diff --git a/src/gui/qgsmaplayercombobox.cpp b/src/gui/qgsmaplayercombobox.cpp index f4856ce9d08..0efc00f35e4 100644 --- a/src/gui/qgsmaplayercombobox.cpp +++ b/src/gui/qgsmaplayercombobox.cpp @@ -26,11 +26,6 @@ QgsMapLayerComboBox::QgsMapLayerComboBox( QWidget *parent ) : connect( this, SIGNAL( activated( int ) ), this, SLOT( indexChanged( int ) ) ); } -void QgsMapLayerComboBox::setFilters( QgsMapLayerProxyModel::Filters filters ) -{ - mProxyModel->setFilters( filters ); -} - void QgsMapLayerComboBox::setLayer( QgsMapLayer *layer ) { QModelIndex idx = mProxyModel->sourceLayerModel()->indexFromLayer( layer ); @@ -78,3 +73,4 @@ void QgsMapLayerComboBox::indexChanged( int i ) QgsMapLayer* layer = currentLayer(); emit layerChanged( layer ); } + diff --git a/src/gui/qgsmaplayercombobox.h b/src/gui/qgsmaplayercombobox.h index c221cec23cd..930bd24b39a 100644 --- a/src/gui/qgsmaplayercombobox.h +++ b/src/gui/qgsmaplayercombobox.h @@ -41,11 +41,17 @@ class GUI_EXPORT QgsMapLayerComboBox : public QComboBox explicit QgsMapLayerComboBox( QWidget *parent = 0 ); //! setFilters allows fitering according to layer type and/or geometry type. - void setFilters( QgsMapLayerProxyModel::Filters filters ); + void setFilters( QgsMapLayerProxyModel::Filters filters ) { mProxyModel->setFilters( filters ); } //! currently used filter on list layers QgsMapLayerProxyModel::Filters filters() const { return mProxyModel->filters(); } + //! except a list of layers not to be listed + void setExceptedLayerList( QList layerList ) { mProxyModel->setExceptedLayerList( layerList ); } + + //! returns the list of excepted layers + QList exceptedLayerList() const {return mProxyModel->exceptedLayerList();} + //! currentLayer returns the current layer selected in the combo box QgsMapLayer* currentLayer() const; diff --git a/src/gui/qgsmaplayerproxymodel.cpp b/src/gui/qgsmaplayerproxymodel.cpp index c1c20295404..70fe574d639 100644 --- a/src/gui/qgsmaplayerproxymodel.cpp +++ b/src/gui/qgsmaplayerproxymodel.cpp @@ -21,6 +21,7 @@ QgsMapLayerProxyModel::QgsMapLayerProxyModel( QObject *parent ) : QSortFilterProxyModel( parent ) , mFilters( All ) + , mExceptList( QList() ) , mModel( new QgsMapLayerModel( parent ) ) { setSourceModel( mModel ); @@ -37,6 +38,12 @@ QgsMapLayerProxyModel *QgsMapLayerProxyModel::setFilters( Filters filters ) return this; } +void QgsMapLayerProxyModel::setExceptedLayerList(QList exceptList) +{ + mExceptList = exceptList; + invalidateFilter(); +} + bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const { if ( mFilters.testFlag( All ) ) @@ -47,6 +54,9 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex if ( !layer ) return false; + if ( mExceptList.contains( layer ) ) + return false; + // layer type if (( mFilters.testFlag( RasterLayer ) && layer->type() == QgsMapLayer::RasterLayer ) || ( mFilters.testFlag( VectorLayer ) && layer->type() == QgsMapLayer::VectorLayer ) || diff --git a/src/gui/qgsmaplayerproxymodel.h b/src/gui/qgsmaplayerproxymodel.h index d0046bfe766..7b9026819bd 100644 --- a/src/gui/qgsmaplayerproxymodel.h +++ b/src/gui/qgsmaplayerproxymodel.h @@ -19,6 +19,7 @@ #include class QgsMapLayerModel; +class QgsMapLayer; /** * @brief The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets. @@ -62,8 +63,13 @@ class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel QgsMapLayerProxyModel* setFilters( Filters filters ); const Filters& filters() const { return mFilters; } + //! offer the possibility to except some layers to be listed + void setExceptedLayerList( QList exceptList ); + QList exceptedLayerList() {return mExceptList;} + private: Filters mFilters; + QList mExceptList; QgsMapLayerModel* mModel; // QSortFilterProxyModel interface diff --git a/src/ui/qgsaddjoindialogbase.ui b/src/ui/qgsjoindialogbase.ui similarity index 81% rename from src/ui/qgsaddjoindialogbase.ui rename to src/ui/qgsjoindialogbase.ui index da899ea1ca4..feccfe1a054 100644 --- a/src/ui/qgsaddjoindialogbase.ui +++ b/src/ui/qgsjoindialogbase.ui @@ -1,7 +1,7 @@ - QgsAddJoinDialogBase - + QgsJoinDialogBase + 0 @@ -14,51 +14,42 @@ Add vector join - + Join layer - - - - + Join field - - - - + Target field - - - - + Cache join layer in virtual memory - + Create attribute index on join field - + Choose which fields are joined @@ -69,7 +60,7 @@ false - + true @@ -79,7 +70,7 @@ - + Custom field name prefix @@ -90,7 +81,7 @@ false - + true @@ -100,7 +91,7 @@ - + Qt::Horizontal @@ -110,7 +101,7 @@ - + Qt::Vertical @@ -123,6 +114,19 @@ + + + + QgsMapLayerProxyModel::VectorLayer + + + + + + + + + @@ -132,11 +136,18 @@
qgscollapsiblegroupbox.h
1 + + QgsFieldComboBox + QComboBox +
qgsfieldcombobox.h
+
+ + QgsMapLayerComboBox + QComboBox +
qgsmaplayercombobox.h
+
- mJoinLayerComboBox - mJoinFieldComboBox - mTargetFieldComboBox mCacheInMemoryCheckBox mCreateIndexCheckBox mUseJoinFieldsSubset @@ -150,7 +161,7 @@ buttonBox accepted() - QgsAddJoinDialogBase + QgsJoinDialogBase accept() @@ -166,7 +177,7 @@ buttonBox rejected() - QgsAddJoinDialogBase + QgsJoinDialogBase reject() diff --git a/src/ui/qgsvectorlayerpropertiesbase.ui b/src/ui/qgsvectorlayerpropertiesbase.ui index f989afd0113..cc0c4a6f902 100644 --- a/src/ui/qgsvectorlayerpropertiesbase.ui +++ b/src/ui/qgsvectorlayerpropertiesbase.ui @@ -293,8 +293,8 @@ 0 0 - 730 - 537 + 331 + 431 @@ -1316,6 +1316,17 @@
+ + + + + + + + :/images/themes/default/mActionToggleEditing.png:/images/themes/default/mActionToggleEditing.png + + + @@ -1364,8 +1375,8 @@ 0 0 - 730 - 537 + 100 + 30 @@ -1424,7 +1435,7 @@ 0 0 - 714 + 392 608