10
10
QgsEmbedLayerDialog::QgsEmbedLayerDialog ( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
11
11
{
12
12
setupUi ( this );
13
- QObject::connect ( mButtonBox , SIGNAL (rejected () ), this , SLOT (reject () ) );
13
+ QObject::connect ( mButtonBox , SIGNAL ( rejected () ), this , SLOT ( reject () ) );
14
14
}
15
15
16
16
QgsEmbedLayerDialog::~QgsEmbedLayerDialog ()
@@ -23,11 +23,11 @@ QList< QPair < QString, QString > > QgsEmbedLayerDialog::embeddedGroups() const
23
23
24
24
QList<QTreeWidgetItem*> items = mTreeWidget ->selectedItems ();
25
25
QList<QTreeWidgetItem*>::iterator itemIt = items.begin ();
26
- for ( ; itemIt != items.end (); ++itemIt )
26
+ for ( ; itemIt != items.end (); ++itemIt )
27
27
{
28
- if ( ( *itemIt)->data (0 , Qt::UserRole).toString () == " group" )
28
+ if (( *itemIt )->data ( 0 , Qt::UserRole ).toString () == " group" )
29
29
{
30
- result.push_back ( qMakePair ( ( *itemIt)->text ( 0 ), mProjectPath ) );
30
+ result.push_back ( qMakePair (( *itemIt )->text ( 0 ), mProjectPath ) );
31
31
}
32
32
}
33
33
@@ -40,11 +40,11 @@ QList< QPair < QString, QString > > QgsEmbedLayerDialog::embeddedLayers() const
40
40
41
41
QList<QTreeWidgetItem*> items = mTreeWidget ->selectedItems ();
42
42
QList<QTreeWidgetItem*>::iterator itemIt = items.begin ();
43
- for ( ; itemIt != items.end (); ++itemIt )
43
+ for ( ; itemIt != items.end (); ++itemIt )
44
44
{
45
- if ( ( *itemIt)->data (0 , Qt::UserRole).toString () == " layer" )
45
+ if (( *itemIt )->data ( 0 , Qt::UserRole ).toString () == " layer" )
46
46
{
47
- result.push_back ( qMakePair ( ( *itemIt)->data (0 , Qt::UserRole + 1 ).toString (), mProjectPath ) );
47
+ result.push_back ( qMakePair (( *itemIt )->data ( 0 , Qt::UserRole + 1 ).toString (), mProjectPath ) );
48
48
}
49
49
}
50
50
return result;
@@ -56,8 +56,8 @@ void QgsEmbedLayerDialog::on_mBrowseFileToolButton_clicked()
56
56
mProjectFileLineEdit ->blockSignals ( true );
57
57
58
58
QSettings s;
59
- QString projectFile = QFileDialog::getOpenFileName ( 0 , tr (" Select project file" ), s.value (" /qgis/last_embedded_project_path" ).toString () ,tr (" QGIS project files (*.qgs)" ) );
60
- if ( !projectFile.isEmpty () )
59
+ QString projectFile = QFileDialog::getOpenFileName ( 0 , tr ( " Select project file" ), s.value ( " /qgis/last_embedded_project_path" ).toString () , tr ( " QGIS project files (*.qgs)" ) );
60
+ if ( !projectFile.isEmpty () )
61
61
{
62
62
mProjectFileLineEdit ->setText ( projectFile );
63
63
}
@@ -73,55 +73,55 @@ void QgsEmbedLayerDialog::on_mProjectFileLineEdit_editingFinished()
73
73
void QgsEmbedLayerDialog::changeProjectFile ()
74
74
{
75
75
QFile projectFile ( mProjectFileLineEdit ->text () );
76
- if ( !projectFile.exists () )
76
+ if ( !projectFile.exists () )
77
77
{
78
78
return ;
79
79
}
80
80
81
- if ( mProjectPath == mProjectFileLineEdit ->text () )
81
+ if ( mProjectPath == mProjectFileLineEdit ->text () )
82
82
{
83
83
// already up to date
84
84
return ;
85
85
}
86
86
87
87
// check we are not embedding from/to the same project
88
- if ( mProjectFileLineEdit ->text () == QgsProject::instance ()->fileName () )
88
+ if ( mProjectFileLineEdit ->text () == QgsProject::instance ()->fileName () )
89
89
{
90
- QMessageBox::critical ( 0 , tr (" Recursive embeding not possible" ), tr (" It is not possible to embed layers / groups from the current project" ) );
90
+ QMessageBox::critical ( 0 , tr ( " Recursive embeding not possible" ), tr ( " It is not possible to embed layers / groups from the current project" ) );
91
91
return ;
92
92
}
93
93
94
94
mTreeWidget ->clear ();
95
95
96
96
// parse project file and fill tree
97
- if ( !projectFile.open ( QIODevice::ReadOnly ) )
97
+ if ( !projectFile.open ( QIODevice::ReadOnly ) )
98
98
{
99
99
return ;
100
100
}
101
101
102
102
QDomDocument projectDom;
103
- if ( !projectDom.setContent ( &projectFile ) )
103
+ if ( !projectDom.setContent ( &projectFile ) )
104
104
{
105
105
return ;
106
106
}
107
107
108
- QDomElement legendElem = projectDom.documentElement ().firstChildElement (" legend" );
109
- if ( legendElem.isNull () )
108
+ QDomElement legendElem = projectDom.documentElement ().firstChildElement ( " legend" );
109
+ if ( legendElem.isNull () )
110
110
{
111
111
return ;
112
112
}
113
113
114
114
QDomNodeList legendChildren = legendElem.childNodes ();
115
115
QDomElement currentChildElem;
116
116
117
- for ( int i = 0 ; i < legendChildren.size (); ++i )
117
+ for ( int i = 0 ; i < legendChildren.size (); ++i )
118
118
{
119
119
currentChildElem = legendChildren.at ( i ).toElement ();
120
- if ( currentChildElem.tagName () == " legendlayer" )
120
+ if ( currentChildElem.tagName () == " legendlayer" )
121
121
{
122
122
addLegendLayerToTreeWidget ( currentChildElem );
123
123
}
124
- else if ( currentChildElem.tagName () == " legendgroup" )
124
+ else if ( currentChildElem.tagName () == " legendgroup" )
125
125
{
126
126
addLegendGroupToTreeWidget ( currentChildElem );
127
127
}
@@ -135,32 +135,32 @@ void QgsEmbedLayerDialog::addLegendGroupToTreeWidget( const QDomElement& groupEl
135
135
QDomNodeList groupChildren = groupElem.childNodes ();
136
136
QDomElement currentChildElem;
137
137
138
- if ( groupElem.attribute (" embedded" ) == " 1" )
138
+ if ( groupElem.attribute ( " embedded" ) == " 1" )
139
139
{
140
140
return ;
141
141
}
142
142
143
143
QTreeWidgetItem* groupItem = 0 ;
144
- if ( !parent )
144
+ if ( !parent )
145
145
{
146
146
groupItem = new QTreeWidgetItem ( mTreeWidget );
147
147
}
148
148
else
149
149
{
150
150
groupItem = new QTreeWidgetItem ( parent );
151
151
}
152
- groupItem->setIcon ( 0 , QgisApp::getThemeIcon (" mActionFolder.png" ) );
153
- groupItem->setText ( 0 , groupElem.attribute (" name" ) );
152
+ groupItem->setIcon ( 0 , QgisApp::getThemeIcon ( " mActionFolder.png" ) );
153
+ groupItem->setText ( 0 , groupElem.attribute ( " name" ) );
154
154
groupItem->setData ( 0 , Qt::UserRole, " group" );
155
155
156
- for ( int i = 0 ; i < groupChildren.size (); ++i )
156
+ for ( int i = 0 ; i < groupChildren.size (); ++i )
157
157
{
158
158
currentChildElem = groupChildren.at ( i ).toElement ();
159
- if ( currentChildElem.tagName () == " legendlayer" )
159
+ if ( currentChildElem.tagName () == " legendlayer" )
160
160
{
161
161
addLegendLayerToTreeWidget ( currentChildElem, groupItem );
162
162
}
163
- else if ( currentChildElem.tagName () == " legendgroup" )
163
+ else if ( currentChildElem.tagName () == " legendgroup" )
164
164
{
165
165
addLegendGroupToTreeWidget ( currentChildElem, groupItem );
166
166
}
@@ -169,31 +169,31 @@ void QgsEmbedLayerDialog::addLegendGroupToTreeWidget( const QDomElement& groupEl
169
169
170
170
void QgsEmbedLayerDialog::addLegendLayerToTreeWidget ( const QDomElement& layerElem, QTreeWidgetItem* parent )
171
171
{
172
- if ( layerElem.attribute (" embedded" ) == " 1" )
172
+ if ( layerElem.attribute ( " embedded" ) == " 1" )
173
173
{
174
174
return ;
175
175
}
176
176
177
177
QTreeWidgetItem* item = 0 ;
178
- if ( parent )
178
+ if ( parent )
179
179
{
180
180
item = new QTreeWidgetItem ( parent );
181
181
}
182
182
else
183
183
{
184
184
item = new QTreeWidgetItem ( mTreeWidget );
185
185
}
186
- item->setText ( 0 , layerElem.attribute (" name" ) );
186
+ item->setText ( 0 , layerElem.attribute ( " name" ) );
187
187
item->setData ( 0 , Qt::UserRole, " layer" );
188
- item->setData ( 0 , Qt::UserRole + 1 , layerElem.firstChildElement (" filegroup" ).firstChildElement (" legendlayerfile" ).attribute (" layerid" ) );
188
+ item->setData ( 0 , Qt::UserRole + 1 , layerElem.firstChildElement ( " filegroup" ).firstChildElement ( " legendlayerfile" ).attribute ( " layerid" ) );
189
189
}
190
190
191
191
void QgsEmbedLayerDialog::on_mTreeWidget_itemSelectionChanged ()
192
192
{
193
193
mTreeWidget ->blockSignals ( true );
194
194
QList<QTreeWidgetItem*> items = mTreeWidget ->selectedItems ();
195
195
QList<QTreeWidgetItem*>::iterator itemIt = items.begin ();
196
- for ( ; itemIt != items.end (); ++itemIt )
196
+ for ( ; itemIt != items.end (); ++itemIt )
197
197
{
198
198
// deselect children recursively
199
199
unselectChildren ( *itemIt );
@@ -203,13 +203,13 @@ void QgsEmbedLayerDialog::on_mTreeWidget_itemSelectionChanged()
203
203
204
204
void QgsEmbedLayerDialog::unselectChildren ( QTreeWidgetItem* item )
205
205
{
206
- if ( !item )
206
+ if ( !item )
207
207
{
208
208
return ;
209
209
}
210
210
211
211
QTreeWidgetItem* currentChild = 0 ;
212
- for ( int i = 0 ; i < item->childCount (); ++i )
212
+ for ( int i = 0 ; i < item->childCount (); ++i )
213
213
{
214
214
currentChild = item->child ( i );
215
215
currentChild->setSelected ( false );
@@ -221,9 +221,9 @@ void QgsEmbedLayerDialog::on_mButtonBox_accepted()
221
221
{
222
222
QSettings s;
223
223
QFileInfo fi ( mProjectPath );
224
- if ( fi.exists () )
224
+ if ( fi.exists () )
225
225
{
226
- s.setValue (" /qgis/last_embedded_project_path" , fi.absolutePath () );
226
+ s.setValue ( " /qgis/last_embedded_project_path" , fi.absolutePath () );
227
227
}
228
228
accept ();
229
229
}
0 commit comments