Skip to content
Permalink
Browse files

implemented settings dialog with placeholders methods

  • Loading branch information
Marco Bernasocchi authored and pka committed Nov 16, 2010
1 parent e62a086 commit b95206965bc51f0d866fb9d12ac363324f4f6ab6
@@ -15,13 +15,18 @@ SET (globe_plugin_SRCS
qgsosgviewer.cpp
qgsosgearthtilesource.cpp
Controls.cpp
globe_plugin_dialog.cpp
)

SET (globe_plugin_UIS globe_plugin_guibase.ui)
SET (globe_plugin_UIS
globe_plugin_guibase.ui
globe_plugin_dialog_guibase.ui
)

SET (globe_plugin_MOC_HDRS
globe_plugin.h
globe_plugin_gui.h
globe_plugin_dialog.h
)

SET (globe_plugin_RCCS globe_plugin.qrc)
@@ -3,7 +3,7 @@
<loading_policy mode="sequential"/>

<cache type="tilecache">
<path>/home/pi/devel/gis/qgis/.qgis/cache/globe</path>
<path>/home/marco/.qgis/cache/globe</path>
</cache>

<image name="world" driver="gdal">
@@ -25,18 +25,16 @@
<url>http://demo.pelicanmapping.com/rmweb/data/srtm30_plus_tms/tms.xml</url>
</heightfield>
-->

<heightfield name="WorldWind bil" driver="worldwind">
<worldwind_cache>/home/pi/devel/gis/qgis/.qgis/cache/globe/worldwind_srtm</worldwind_cache>
<worldwind_cache>/home/marco/.qgis/cache/globe/worldwind_srtm</worldwind_cache>
<cache_enabled>false</cache_enabled>
</heightfield>

<!--

<heightfield name="aster_dem" driver="gdal">
<url>/home/pi/data/geodata/Lech/ASTGTM_N47E010/ASTGTM_N47E010_dem.tif</url>
<url>/home/marco/data/geodata/Lech/ASTGTM_N47E010/ASTGTM_N47E010_dem.tif</url>
<cache_enabled>false</cache_enabled>
</heightfield>
-->

<!--
<vertical_scale>2</vertical_scale>
@@ -18,7 +18,7 @@

#include "globe_plugin.h"
#include "globe_plugin_gui.h"
//#include "globe_plugin_settings_gui.h"
#include "globe_plugin_dialog.h"
#include "qgsosgearthtilesource.h"

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

void GlobePlugin::settings()
{
//Ui_GlobePluginSettings* settingsDialog = new Ui_globeSettingsGuiBase( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
//ogrDialog->setAttribute( Qt::WA_DeleteOnClose );
//settingsDialog->show();
// TODO: implement settings dialog
QMessageBox msgBox;
msgBox.setText("settings dialog not implemented yet");
msgBox.exec();
QgsGlobePluginDialog* settingsDialog = new QgsGlobePluginDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
settingsDialog->setAttribute( Qt::WA_DeleteOnClose );
settingsDialog->show();
}

void GlobePlugin::setupMap()
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/globe/" >
<file>globe_plugin.png</file>
<file alias="globe_plugin.png">images/globe.png</file>
</qresource>
</RCC>

@@ -0,0 +1,193 @@
/*
* $Id$
*/
/***************************************************************************
globe_plugin_dialog.cpp - settings dialog for the globe plugin
--------------------------------------
Date : 11-Nov-2010
Copyright : (C) 2010 by Marco Bernasocchi
Email : marco at bernawebdesign.ch
/***************************************************************************
* *
* 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 "globe_plugin_dialog.h"

#include <qgsapplication.h>
#include <qgslogger.h>
#include <qgscontexthelp.h>

#include <QtAlgorithms>
#include <QtDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QString>
#include <QStringList>
#include <QVariant>

//constructor
QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
}

//destructor
QgsGlobePluginDialog::~QgsGlobePluginDialog()
{
}

QString QgsGlobePluginDialog::openFile()
{
QSettings sets;
QString path = QFileDialog::getOpenFileName( this,
tr( "Open Earthfile" ),
"/home",
tr( "Earthfiles (*.earth)" ) );

return path;
}

void QgsGlobePluginDialog::on_buttonBox_accepted()
{
/*
// Validate input settings
QString srcUrl( inputSrcDataset->text() );
QString srcLayer( comboSrcLayer->currentText() );
if ( srcUrl.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Input OGR dataset is missing!" ) );
return;
}
if ( srcLayer.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Input OGR layer name is missing!" ) );
return;
}
// Validate output settings
QString dstFormat( comboDstFormats->currentText() );
QString dstUrl( inputDstDataset->text() );
QString dstLayer( inputDstLayer->text() );
if ( dstLayer.isEmpty() )
dstLayer = srcLayer;
if ( dstFormat.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Target OGR format not selected!" ) );
return;
}
if ( dstUrl.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Output OGR dataset is missing!" ) );
return;
}
if ( dstLayer.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Output OGR layer name is missing!" ) );
return;
}
// TODO: SRS transformation support
//QString srcSrs("EPSG:");
//QString dstSrs("EPSG:");
//srcSrs += inputSrcSrs->text();
//dstSrs += inputDstSrs->text();
// Execute layer translation
bool success = false;
// TODO: Use try-catch to display more meaningful error messages from Translator
Translator worker( srcUrl, dstUrl, dstFormat );
worker.setSourceLayer( srcLayer );
worker.setTargetLayer( dstLayer );
success = worker.translate();
if ( success )
{
QMessageBox::information( this,
tr( "OGR Layer Converter" ),
tr( "Successfully translated layer '%1'" ).arg( srcLayer ) );
}
else
{
QMessageBox::information( this,
tr( "OGR Layer Converter" ),
tr( "Failed to translate layer '%1'" ).arg( srcLayer ) );
}
// Close dialog box
*/
accept();
}

void QgsGlobePluginDialog::on_buttonBox_rejected()
{
reject();
}

void QgsGlobePluginDialog::on_comboStereo_currentIndexChanged( int stereoMode )
{
QMessageBox msgBox;
msgBox.setText("stereo mode changed");
msgBox.exec();
//showText("stereo mode changed");
/*
// Select destination data format
QString frmtCode = comboDstFormats->currentText();
mDstFormat = mFrmts.find( frmtCode );
resetDstUi();
*/
}

void QgsGlobePluginDialog::on_buttonSelectEarthfile_clicked()
{
QMessageBox msgBox;
msgBox.setText("select file");
msgBox.exec();
/*
QSettings settings;
QString src;
src = openFile();
inputSrcDataset->setText( src );
if ( !src.isEmpty() )
{
QMessageBox msgBox;
msgBox.setText(src);
msgBox.exec();
//showText( src.toString() );
}
*/
}

/*void QgsGlobePluginDialog::showText(QString text)
{
QMessageBox msgBox;
msgBox.setText(text);
msgBox.exec();
}
*/
@@ -0,0 +1,44 @@
/*
* $Id$
*/
/***************************************************************************
globe_plugin_dialog.h - settings dialog for the globe plugin
--------------------------------------
Date : 11-Nov-2010
Copyright : (C) 2010 by Marco Bernasocchi
Email : marco at bernawebdesign.ch
/***************************************************************************
* *
* 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 QGIS_GLOBE_PLUGIN_DIALOG_H
#define QGIS_GLOBE_PLUGIN_DIALOG_H

#include <ui_globe_plugin_dialog_guibase.h>
#include <QDialog>
#include "qgscontexthelp.h"

class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBase
{
Q_OBJECT

public:
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
~QgsGlobePluginDialog();

private:
QString openFile();
void showText( int text);

private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonSelectEarthfile_clicked();
void on_comboStereo_currentIndexChanged( int stereoMode );
};

#endif // QGIS_GLOBE_PLUGIN_DIALOG_H

0 comments on commit b952069

Please sign in to comment.
You can’t perform that action at this time.