Skip to content

Commit b952069

Browse files
Marco Bernasocchipka
Marco Bernasocchi
authored andcommitted
implemented settings dialog with placeholders methods
1 parent e62a086 commit b952069

8 files changed

+415
-19
lines changed

src/plugins/globe/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ SET (globe_plugin_SRCS
1515
qgsosgviewer.cpp
1616
qgsosgearthtilesource.cpp
1717
Controls.cpp
18+
globe_plugin_dialog.cpp
1819
)
1920

20-
SET (globe_plugin_UIS globe_plugin_guibase.ui)
21+
SET (globe_plugin_UIS
22+
globe_plugin_guibase.ui
23+
globe_plugin_dialog_guibase.ui
24+
)
2125

2226
SET (globe_plugin_MOC_HDRS
2327
globe_plugin.h
2428
globe_plugin_gui.h
29+
globe_plugin_dialog.h
2530
)
2631

2732
SET (globe_plugin_RCCS globe_plugin.qrc)

src/plugins/globe/globe.earth

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<loading_policy mode="sequential"/>
44

55
<cache type="tilecache">
6-
<path>/home/pi/devel/gis/qgis/.qgis/cache/globe</path>
6+
<path>/home/marco/.qgis/cache/globe</path>
77
</cache>
88

99
<image name="world" driver="gdal">
@@ -25,18 +25,16 @@
2525
<url>http://demo.pelicanmapping.com/rmweb/data/srtm30_plus_tms/tms.xml</url>
2626
</heightfield>
2727
-->
28-
28+
2929
<heightfield name="WorldWind bil" driver="worldwind">
30-
<worldwind_cache>/home/pi/devel/gis/qgis/.qgis/cache/globe/worldwind_srtm</worldwind_cache>
30+
<worldwind_cache>/home/marco/.qgis/cache/globe/worldwind_srtm</worldwind_cache>
3131
<cache_enabled>false</cache_enabled>
3232
</heightfield>
33-
34-
<!--
33+
3534
<heightfield name="aster_dem" driver="gdal">
36-
<url>/home/pi/data/geodata/Lech/ASTGTM_N47E010/ASTGTM_N47E010_dem.tif</url>
35+
<url>/home/marco/data/geodata/Lech/ASTGTM_N47E010/ASTGTM_N47E010_dem.tif</url>
3736
<cache_enabled>false</cache_enabled>
3837
</heightfield>
39-
-->
4038

4139
<!--
4240
<vertical_scale>2</vertical_scale>

src/plugins/globe/globe_plugin.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "globe_plugin.h"
2020
#include "globe_plugin_gui.h"
21-
//#include "globe_plugin_settings_gui.h"
21+
#include "globe_plugin_dialog.h"
2222
#include "qgsosgearthtilesource.h"
2323

2424
#include <qgisinterface.h>
@@ -81,8 +81,8 @@ GlobePlugin::~GlobePlugin()
8181
void GlobePlugin::initGui()
8282
{
8383
// Create the action for tool
84-
mQActionPointer = new QAction( QIcon( ":/globe/globe_plugin.png" ), tr( "Globe" ), this );
85-
mQActionSettingsPointer = new QAction( QIcon( ":/globe/globe_plugin.png" ), tr( "Globe Settings" ), this );
84+
mQActionPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Launch Globe" ), this );
85+
mQActionSettingsPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Globe Settings" ), this );
8686
// Set the what's this text
8787
mQActionPointer->setWhatsThis( tr( "Overlay data on a 3D globe" ) );
8888
mQActionSettingsPointer->setWhatsThis( tr( "Settings for 3D globe" ) );
@@ -161,13 +161,9 @@ void GlobePlugin::run()
161161

162162
void GlobePlugin::settings()
163163
{
164-
//Ui_GlobePluginSettings* settingsDialog = new Ui_globeSettingsGuiBase( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
165-
//ogrDialog->setAttribute( Qt::WA_DeleteOnClose );
166-
//settingsDialog->show();
167-
// TODO: implement settings dialog
168-
QMessageBox msgBox;
169-
msgBox.setText("settings dialog not implemented yet");
170-
msgBox.exec();
164+
QgsGlobePluginDialog* settingsDialog = new QgsGlobePluginDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
165+
settingsDialog->setAttribute( Qt::WA_DeleteOnClose );
166+
settingsDialog->show();
171167
}
172168

173169
void GlobePlugin::setupMap()

src/plugins/globe/globe_plugin.qrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<RCC>
22
<qresource prefix="/globe/" >
3-
<file>globe_plugin.png</file>
3+
<file alias="globe_plugin.png">images/globe.png</file>
44
</qresource>
55
</RCC>
66

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
* $Id$
3+
*/
4+
/***************************************************************************
5+
globe_plugin_dialog.cpp - settings dialog for the globe plugin
6+
--------------------------------------
7+
Date : 11-Nov-2010
8+
Copyright : (C) 2010 by Marco Bernasocchi
9+
Email : marco at bernawebdesign.ch
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
19+
#include "globe_plugin_dialog.h"
20+
21+
#include <qgsapplication.h>
22+
#include <qgslogger.h>
23+
#include <qgscontexthelp.h>
24+
25+
#include <QtAlgorithms>
26+
#include <QtDebug>
27+
#include <QFileDialog>
28+
#include <QMessageBox>
29+
#include <QSettings>
30+
#include <QString>
31+
#include <QStringList>
32+
#include <QVariant>
33+
34+
//constructor
35+
QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
36+
: QDialog( parent, fl )
37+
{
38+
setupUi( this );
39+
}
40+
41+
//destructor
42+
QgsGlobePluginDialog::~QgsGlobePluginDialog()
43+
{
44+
}
45+
46+
QString QgsGlobePluginDialog::openFile()
47+
{
48+
QSettings sets;
49+
QString path = QFileDialog::getOpenFileName( this,
50+
tr( "Open Earthfile" ),
51+
"/home",
52+
tr( "Earthfiles (*.earth)" ) );
53+
54+
return path;
55+
}
56+
57+
void QgsGlobePluginDialog::on_buttonBox_accepted()
58+
{
59+
/*
60+
// Validate input settings
61+
QString srcUrl( inputSrcDataset->text() );
62+
QString srcLayer( comboSrcLayer->currentText() );
63+
64+
if ( srcUrl.isEmpty() )
65+
{
66+
QMessageBox::warning( this,
67+
tr( "OGR Layer Converter" ),
68+
tr( "Input OGR dataset is missing!" ) );
69+
return;
70+
}
71+
72+
if ( srcLayer.isEmpty() )
73+
{
74+
QMessageBox::warning( this,
75+
tr( "OGR Layer Converter" ),
76+
tr( "Input OGR layer name is missing!" ) );
77+
return;
78+
}
79+
80+
// Validate output settings
81+
QString dstFormat( comboDstFormats->currentText() );
82+
QString dstUrl( inputDstDataset->text() );
83+
QString dstLayer( inputDstLayer->text() );
84+
if ( dstLayer.isEmpty() )
85+
dstLayer = srcLayer;
86+
87+
if ( dstFormat.isEmpty() )
88+
{
89+
QMessageBox::warning( this,
90+
tr( "OGR Layer Converter" ),
91+
tr( "Target OGR format not selected!" ) );
92+
return;
93+
}
94+
95+
if ( dstUrl.isEmpty() )
96+
{
97+
QMessageBox::warning( this,
98+
tr( "OGR Layer Converter" ),
99+
tr( "Output OGR dataset is missing!" ) );
100+
return;
101+
}
102+
103+
if ( dstLayer.isEmpty() )
104+
{
105+
QMessageBox::warning( this,
106+
tr( "OGR Layer Converter" ),
107+
tr( "Output OGR layer name is missing!" ) );
108+
return;
109+
}
110+
111+
// TODO: SRS transformation support
112+
//QString srcSrs("EPSG:");
113+
//QString dstSrs("EPSG:");
114+
//srcSrs += inputSrcSrs->text();
115+
//dstSrs += inputDstSrs->text();
116+
117+
// Execute layer translation
118+
bool success = false;
119+
120+
// TODO: Use try-catch to display more meaningful error messages from Translator
121+
Translator worker( srcUrl, dstUrl, dstFormat );
122+
worker.setSourceLayer( srcLayer );
123+
worker.setTargetLayer( dstLayer );
124+
success = worker.translate();
125+
126+
if ( success )
127+
{
128+
QMessageBox::information( this,
129+
tr( "OGR Layer Converter" ),
130+
tr( "Successfully translated layer '%1'" ).arg( srcLayer ) );
131+
}
132+
else
133+
{
134+
QMessageBox::information( this,
135+
tr( "OGR Layer Converter" ),
136+
tr( "Failed to translate layer '%1'" ).arg( srcLayer ) );
137+
}
138+
139+
// Close dialog box
140+
*/
141+
accept();
142+
}
143+
144+
void QgsGlobePluginDialog::on_buttonBox_rejected()
145+
{
146+
reject();
147+
}
148+
149+
void QgsGlobePluginDialog::on_comboStereo_currentIndexChanged( int stereoMode )
150+
{
151+
QMessageBox msgBox;
152+
msgBox.setText("stereo mode changed");
153+
msgBox.exec();
154+
//showText("stereo mode changed");
155+
/*
156+
// Select destination data format
157+
QString frmtCode = comboDstFormats->currentText();
158+
mDstFormat = mFrmts.find( frmtCode );
159+
160+
resetDstUi();
161+
*/
162+
}
163+
164+
void QgsGlobePluginDialog::on_buttonSelectEarthfile_clicked()
165+
{
166+
QMessageBox msgBox;
167+
msgBox.setText("select file");
168+
msgBox.exec();
169+
/*
170+
QSettings settings;
171+
QString src;
172+
173+
src = openFile();
174+
175+
inputSrcDataset->setText( src );
176+
177+
if ( !src.isEmpty() )
178+
{
179+
QMessageBox msgBox;
180+
msgBox.setText(src);
181+
msgBox.exec();
182+
//showText( src.toString() );
183+
}
184+
*/
185+
}
186+
187+
/*void QgsGlobePluginDialog::showText(QString text)
188+
{
189+
QMessageBox msgBox;
190+
msgBox.setText(text);
191+
msgBox.exec();
192+
}
193+
*/
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* $Id$
3+
*/
4+
/***************************************************************************
5+
globe_plugin_dialog.h - settings dialog for the globe plugin
6+
--------------------------------------
7+
Date : 11-Nov-2010
8+
Copyright : (C) 2010 by Marco Bernasocchi
9+
Email : marco at bernawebdesign.ch
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
#ifndef QGIS_GLOBE_PLUGIN_DIALOG_H
19+
#define QGIS_GLOBE_PLUGIN_DIALOG_H
20+
21+
#include <ui_globe_plugin_dialog_guibase.h>
22+
#include <QDialog>
23+
#include "qgscontexthelp.h"
24+
25+
class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBase
26+
{
27+
Q_OBJECT
28+
29+
public:
30+
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
31+
~QgsGlobePluginDialog();
32+
33+
private:
34+
QString openFile();
35+
void showText( int text);
36+
37+
private slots:
38+
void on_buttonBox_accepted();
39+
void on_buttonBox_rejected();
40+
void on_buttonSelectEarthfile_clicked();
41+
void on_comboStereo_currentIndexChanged( int stereoMode );
42+
};
43+
44+
#endif // QGIS_GLOBE_PLUGIN_DIALOG_H

0 commit comments

Comments
 (0)