Skip to content

Commit 4f29c07

Browse files
author
Marco Hugentobler
committed
Optionally show embedded layers/groups in selection dialog
1 parent 166d5c8 commit 4f29c07

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

src/app/qgsprojectlayergroupdialog.cpp

+33-31
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#include <QMessageBox>
2424
#include <QSettings>
2525

26-
QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget * parent, const QString& projectFile, Qt::WindowFlags f ): QDialog( parent, f )
26+
QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget * parent, const QString& projectFile, Qt::WindowFlags f ): QDialog( parent, f ),
27+
mShowEmbeddedContent( false )
2728
{
2829
setupUi( this );
2930

@@ -36,6 +37,7 @@ QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget * parent, const
3637
mProjectFileLabel->hide();
3738
mProjectFileLineEdit->hide();
3839
mBrowseFileToolButton->hide();
40+
mShowEmbeddedContent = true;
3941
changeProjectFile();
4042
}
4143

@@ -50,52 +52,52 @@ QgsProjectLayerGroupDialog::~QgsProjectLayerGroupDialog()
5052

5153
QStringList QgsProjectLayerGroupDialog::selectedGroups() const
5254
{
53-
QStringList groups;
54-
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
55-
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
56-
for ( ; itemIt != items.end(); ++itemIt )
55+
QStringList groups;
56+
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
57+
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
58+
for ( ; itemIt != items.end(); ++itemIt )
59+
{
60+
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "group" )
5761
{
58-
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "group" )
59-
{
60-
groups.push_back( ( *itemIt )->text( 0 ) );
61-
}
62+
groups.push_back(( *itemIt )->text( 0 ) );
6263
}
63-
return groups;
64+
}
65+
return groups;
6466
}
6567

6668
QStringList QgsProjectLayerGroupDialog::selectedLayerIds() const
6769
{
68-
QStringList layerIds;
69-
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
70-
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
71-
for ( ; itemIt != items.end(); ++itemIt )
70+
QStringList layerIds;
71+
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
72+
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
73+
for ( ; itemIt != items.end(); ++itemIt )
74+
{
75+
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "layer" )
7276
{
73-
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "layer" )
74-
{
75-
layerIds.push_back( ( *itemIt )->data( 0, Qt::UserRole + 1 ).toString() );
76-
}
77+
layerIds.push_back(( *itemIt )->data( 0, Qt::UserRole + 1 ).toString() );
7778
}
78-
return layerIds;
79+
}
80+
return layerIds;
7981
}
8082

8183
QStringList QgsProjectLayerGroupDialog::selectedLayerNames() const
8284
{
83-
QStringList layerNames;
84-
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
85-
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
86-
for ( ; itemIt != items.end(); ++itemIt )
85+
QStringList layerNames;
86+
QList<QTreeWidgetItem*> items = mTreeWidget->selectedItems();
87+
QList<QTreeWidgetItem*>::iterator itemIt = items.begin();
88+
for ( ; itemIt != items.end(); ++itemIt )
89+
{
90+
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "layer" )
8791
{
88-
if (( *itemIt )->data( 0, Qt::UserRole ).toString() == "layer" )
89-
{
90-
layerNames.push_back( ( *itemIt )->text( 0 ) );
91-
}
92+
layerNames.push_back(( *itemIt )->text( 0 ) );
9293
}
93-
return layerNames;
94+
}
95+
return layerNames;
9496
}
9597

9698
QString QgsProjectLayerGroupDialog::selectedProjectFile() const
9799
{
98-
return mProjectFileLineEdit->text();
100+
return mProjectFileLineEdit->text();
99101
}
100102

101103
void QgsProjectLayerGroupDialog::on_mBrowseFileToolButton_clicked()
@@ -186,7 +188,7 @@ void QgsProjectLayerGroupDialog::addLegendGroupToTreeWidget( const QDomElement&
186188
QDomNodeList groupChildren = groupElem.childNodes();
187189
QDomElement currentChildElem;
188190

189-
if ( groupElem.attribute( "embedded" ) == "1" )
191+
if ( !mShowEmbeddedContent && groupElem.attribute( "embedded" ) == "1" )
190192
{
191193
return;
192194
}
@@ -220,7 +222,7 @@ void QgsProjectLayerGroupDialog::addLegendGroupToTreeWidget( const QDomElement&
220222

221223
void QgsProjectLayerGroupDialog::addLegendLayerToTreeWidget( const QDomElement& layerElem, QTreeWidgetItem* parent )
222224
{
223-
if ( layerElem.attribute( "embedded" ) == "1" )
225+
if ( !mShowEmbeddedContent && layerElem.attribute( "embedded" ) == "1" )
224226
{
225227
return;
226228
}

src/app/qgsprojectlayergroupdialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class QgsProjectLayerGroupDialog: public QDialog, private Ui::QgsProjectLayerGro
4646
void addLegendLayerToTreeWidget( const QDomElement& layerElem, QTreeWidgetItem* parent = 0 );
4747
void unselectChildren( QTreeWidgetItem* item );
4848
QString mProjectPath;
49+
bool mShowEmbeddedContent;
4950
};
5051

5152
#endif //QGSPROJECTLAYERGROUPDIALOG_H

0 commit comments

Comments
 (0)