Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose embedded layers inclusion to the creation UI
- Loading branch information
Hugo Mercier
committed
Feb 17, 2016
1 parent
baaeedf
commit bc7036f
Showing
7 changed files
with
430 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsEmbeddedLayerSelectDialog</class> | ||
<widget class="QDialog" name="QgsEmbeddedLayerSelectDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>422</width> | ||
<height>366</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Select layers to embed</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QListWidget" name="mLayers"> | ||
<property name="selectionMode"> | ||
<enum>QAbstractItemView::ExtendedSelection</enum> | ||
</property> | ||
<property name="selectionBehavior"> | ||
<enum>QAbstractItemView::SelectRows</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>QgsEmbeddedLayerSelectDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>QgsEmbeddedLayerSelectDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>mLayers</sender> | ||
<signal>itemDoubleClicked(QListWidgetItem*)</signal> | ||
<receiver>QgsEmbeddedLayerSelectDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>210</x> | ||
<y>166</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>210</x> | ||
<y>182</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*************************************************************************** | ||
Virtual layer embedded layer selection widget | ||
begin : Feb 2016 | ||
copyright : (C) 2016 Hugo Mercier, Oslandia | ||
email : hugo dot mercier at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 "qgsembeddedlayerselectdialog.h" | ||
|
||
#include <QMainWindow> | ||
#include <QSettings> | ||
|
||
#include <qgsvectorlayer.h> | ||
#include <layertree/qgslayertreeview.h> | ||
#include <layertree/qgslayertreemodel.h> | ||
#include <layertree/qgslayertreegroup.h> | ||
#include <layertree/qgslayertreelayer.h> | ||
#include <qgsproviderregistry.h> | ||
#include <qgsvectordataprovider.h> | ||
|
||
QgsEmbeddedLayerSelectDialog::QgsEmbeddedLayerSelectDialog( QWidget* parent, QgsLayerTreeView* tv ) | ||
: QDialog( parent ) | ||
{ | ||
setupUi( this ); | ||
|
||
// populate list | ||
QList<QgsLayerTreeLayer*> layers = tv->layerTreeModel()->rootGroup()->findLayers(); | ||
Q_FOREACH ( const QgsLayerTreeLayer* l, layers ) | ||
{ | ||
if ( l->layer() && l->layer()->type() == QgsMapLayer::VectorLayer ) | ||
{ | ||
// display layer name and store its pointer | ||
QListWidgetItem *item = new QListWidgetItem(); | ||
item->setText( l->layer()->name() ); | ||
item->setData( Qt::UserRole, QVariant::fromValue( static_cast<void*>( l->layer() ) ) ); | ||
mLayers->insertItem( mLayers->count(), item ); | ||
} | ||
} | ||
} | ||
|
||
QStringList QgsEmbeddedLayerSelectDialog::layers() const | ||
{ | ||
QStringList ids; | ||
QModelIndexList selected = mLayers->selectionModel()->selectedRows(); | ||
for ( int i = 0; i < selected.size(); i++ ) | ||
{ | ||
QgsVectorLayer* l = static_cast<QgsVectorLayer*>( mLayers->item( selected[i].row() )->data( Qt::UserRole ).value<void*>() ); | ||
ids << l->id(); | ||
} | ||
return ids; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*************************************************************************** | ||
Virtual layer embedded layer selection widget | ||
begin : Feb 2016 | ||
copyright : (C) 2016 Hugo Mercier, Oslandia | ||
email : hugo dot mercier at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSVIRTUAL_EMBEDDED_LAYER_SELECT_DIALOG_H | ||
#define QGSVIRTUAL_EMBEDDED_LAYER_SELECT_DIALOG_H | ||
|
||
#include "ui_qgsembeddedlayerselect.h" | ||
|
||
#include <QDialog> | ||
|
||
class QgsVectorLayer; | ||
class QMainWindow; | ||
class QgsLayerTreeView; | ||
|
||
class QgsEmbeddedLayerSelectDialog : public QDialog, private Ui::QgsEmbeddedLayerSelectDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsEmbeddedLayerSelectDialog( QWidget * parent, QgsLayerTreeView* tv ); | ||
|
||
/** Returns the list of layer ids selected */ | ||
QStringList layers() const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.