|
20 | 20 | #include "globe_plugin.h"
|
21 | 21 |
|
22 | 22 | #include <qgsapplication.h>
|
| 23 | +#include <qgsproject.h> |
23 | 24 | #include <qgslogger.h>
|
24 | 25 | #include <qgscontexthelp.h>
|
25 | 26 | #include <QtAlgorithms>
|
@@ -47,7 +48,6 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
|
47 | 48 | updateStereoDialog(); //update the dialog gui
|
48 | 49 |
|
49 | 50 | elevationPath->setText( QDir::homePath() );
|
50 |
| - readElevationDatasourcesFromSettings(); |
51 | 51 | }
|
52 | 52 |
|
53 | 53 | //destructor
|
@@ -149,29 +149,29 @@ void QgsGlobePluginDialog::on_buttonBox_rejected()
|
149 | 149 | {
|
150 | 150 | loadStereoConfig();
|
151 | 151 | setStereoConfig();
|
152 |
| - readElevationDatasourcesFromSettings(); |
| 152 | + readElevationDatasources(); |
153 | 153 | reject();
|
154 | 154 | }
|
155 | 155 |
|
156 | 156 | //ELEVATION
|
157 | 157 | void QgsGlobePluginDialog::on_elevationCombo_currentIndexChanged(QString type)
|
158 | 158 | {
|
| 159 | + elevationPath->setEnabled(true); |
159 | 160 | if("Raster" == type)
|
160 | 161 | {
|
161 | 162 | elevationActions->setCurrentIndex(0);
|
162 | 163 | elevationPath->setText( QDir::homePath() );
|
163 | 164 | }
|
164 |
| - else |
| 165 | + else if ( "Worldwind" == type ) |
165 | 166 | {
|
166 | 167 | elevationActions->setCurrentIndex(1);
|
167 |
| - if ( "Worldwind" == type ) |
168 |
| - { |
169 |
| - elevationPath->setText("http://tileservice.worldwindcentral.com/getTile?"); |
170 |
| - } |
171 |
| - if ( "TMS" == type ) |
172 |
| - { |
173 |
| - elevationPath->setText("http://"); |
174 |
| - } |
| 168 | + elevationPath->setText("http://tileservice.worldwindcentral.com/getTile?bmng.topo.bathy.200401"); |
| 169 | + elevationPath->setEnabled(false); |
| 170 | + } |
| 171 | + else if ( "TMS" == type ) |
| 172 | + { |
| 173 | + elevationActions->setCurrentIndex(1); |
| 174 | + elevationPath->setText("http://tilecache.osgeo.org/wms-c/Basic.py/1.0.0/linktothepast/"); |
175 | 175 | }
|
176 | 176 | }
|
177 | 177 |
|
@@ -264,41 +264,40 @@ void QgsGlobePluginDialog::setRow(QTableWidget* widget, int row, const QList<QTa
|
264 | 264 | }
|
265 | 265 | }
|
266 | 266 |
|
267 |
| -void QgsGlobePluginDialog::readElevationDatasourcesFromSettings() |
| 267 | +void QgsGlobePluginDialog::readElevationDatasources() |
268 | 268 | {
|
| 269 | + // clear the widget |
269 | 270 | elevationDatasourcesWidget->clearContents();
|
270 |
| - settings.beginGroup("Plugin-Globe"); |
271 |
| - int size = settings.beginReadArray("ElevationsDatasources"); |
272 |
| - for (int i = 0; i < size; ++i) { |
273 |
| - settings.setArrayIndex(i); |
274 |
| - QTableWidgetItem *type = new QTableWidgetItem(settings.value("type").toString()); |
275 |
| - QTableWidgetItem *uri = new QTableWidgetItem(settings.value("uri").toString()); |
| 271 | + int keysCount = QgsProject::instance()->subkeyList("Globe-Plugin", "/elevationDatasources/").count(); |
| 272 | + for (int i = 0; i < keysCount; ++i) { |
| 273 | + QString iNum; |
| 274 | + iNum.setNum(i); |
| 275 | + QTableWidgetItem *type = new QTableWidgetItem( |
| 276 | + QgsProject::instance()->readEntry("Globe-Plugin", "/elevationDatasources/L"+iNum+"/type")); |
| 277 | + QTableWidgetItem *uri = new QTableWidgetItem( |
| 278 | + QgsProject::instance()->readEntry("Globe-Plugin", "/elevationDatasources/L"+iNum+"/uri")); |
| 279 | + |
276 | 280 | elevationDatasourcesWidget->setRowCount(1+i);
|
277 | 281 | elevationDatasourcesWidget->setItem(i, 0, type);
|
278 | 282 | elevationDatasourcesWidget->setItem(i, 1, uri);
|
279 | 283 | }
|
280 |
| - settings.endArray(); |
281 |
| - settings.endGroup(); |
282 | 284 | }
|
283 | 285 |
|
284 | 286 | void QgsGlobePluginDialog::saveElevationDatasources()
|
285 | 287 | {
|
286 |
| - settings.beginGroup("Plugin-Globe"); |
287 |
| - settings.remove("ElevationsDatasources"); |
288 |
| - settings.beginWriteArray("ElevationsDatasources"); |
289 |
| - |
| 288 | + QgsProject::instance()->removeEntry("Globe-Plugin", "/elevationDatasources/"); |
290 | 289 | for(int i = 0; i < elevationDatasourcesWidget->rowCount(); ++i)
|
291 | 290 | {
|
292 | 291 | QString type = elevationDatasourcesWidget->item(i, 0)->text();
|
293 | 292 | QString uri = elevationDatasourcesWidget->item(i, 1)->text();
|
| 293 | + bool cache = true; //elevationDatasourcesWidget->item(i, 1)->isChecked(); |
| 294 | + QString iNum; |
| 295 | + iNum.setNum(i); |
294 | 296 |
|
295 |
| - settings.setArrayIndex(i); |
296 |
| - settings.setValue("type", type); |
297 |
| - settings.setValue("uri", uri); |
| 297 | + QgsProject::instance()->writeEntry("Globe-Plugin", "/elevationDatasources/L"+iNum+"/type", type); |
| 298 | + QgsProject::instance()->writeEntry("Globe-Plugin", "/elevationDatasources/L"+iNum+"/uri", uri); |
| 299 | + QgsProject::instance()->writeEntry("Globe-Plugin", "/elevationDatasources/L"+iNum+"/cache", cache); |
298 | 300 | }
|
299 |
| - |
300 |
| - settings.endArray(); |
301 |
| - settings.endGroup(); |
302 | 301 | }
|
303 | 302 | //END ELEVATION
|
304 | 303 |
|
|
0 commit comments