[Marble-commits] KDE/kdeedu/marble/src
Jens-Michael Hoffmann
jensmh at gmx.de
Thu May 13 06:56:00 CEST 2010
SVN commit 1126060 by jmhoffmann:
When showing the download region dialog always set selection method to
"visible region" to not confuse users.
M +58 -15 lib/DownloadRegionDialog.cpp
M +4 -0 lib/DownloadRegionDialog.h
M +2 -0 marble_part.cpp
--- trunk/KDE/kdeedu/marble/src/lib/DownloadRegionDialog.cpp #1126059:1126060
@@ -54,6 +54,8 @@
AbstractScanlineTextureMapper const * textureMapper() const;
QDialog * m_dialog;
+ QRadioButton * m_visibleRegionMethodButton;
+ QRadioButton * m_specifiedRegionMethodButton;
LatLonBoxWidget * m_latLonBoxWidget;
TileLevelRangeWidget * m_tileLevelRangeWidget;
QLabel * m_tilesCountLabel;
@@ -65,12 +67,15 @@
int m_maximumAllowedTileLevel;
MarbleModel const * const m_model;
GeoSceneTexture const * m_textureLayer;
+ SelectionMethod m_selectionMethod;
GeoDataLatLonBox m_visibleRegion;
};
DownloadRegionDialog::Private::Private( MarbleModel const * const model,
QDialog * const dialog )
: m_dialog( dialog ),
+ m_visibleRegionMethodButton( 0 ),
+ m_specifiedRegionMethodButton( 0 ),
m_latLonBoxWidget( new LatLonBoxWidget ),
m_tileLevelRangeWidget( new TileLevelRangeWidget ),
m_tilesCountLabel( 0 ),
@@ -82,6 +87,7 @@
m_maximumAllowedTileLevel( -1 ),
m_model( model ),
m_textureLayer( model->textureMapper()->textureLayer() ),
+ m_selectionMethod( VisibleRegionMethod ),
m_visibleRegion()
{
m_latLonBoxWidget->setEnabled( false );
@@ -91,15 +97,14 @@
QWidget * DownloadRegionDialog::Private::createSelectionMethodBox()
{
- QRadioButton * const visibleRegionMethodButton = new QRadioButton( tr( "Visible region" ));
- visibleRegionMethodButton->setChecked( true );
- QRadioButton * const latLonBoxMethodButton = new QRadioButton( tr( "Specify region" ));
- connect( latLonBoxMethodButton, SIGNAL( toggled( bool )),
+ m_visibleRegionMethodButton = new QRadioButton( tr( "Visible region" ));
+ m_specifiedRegionMethodButton = new QRadioButton( tr( "Specify region" ));
+ connect( m_specifiedRegionMethodButton, SIGNAL( toggled( bool )),
m_dialog, SLOT( toggleSelectionMethod() ));
QVBoxLayout * const layout = new QVBoxLayout;
- layout->addWidget( visibleRegionMethodButton );
- layout->addWidget( latLonBoxMethodButton );
+ layout->addWidget( m_visibleRegionMethodButton );
+ layout->addWidget( m_specifiedRegionMethodButton );
layout->addWidget( m_latLonBoxWidget );
QGroupBox * const selectionMethodBox = new QGroupBox( tr( "Selection method" ));
@@ -210,12 +215,43 @@
d->m_tileLevelRangeWidget->setDefaultLevel( tileLevel );
}
+void DownloadRegionDialog::setSelectionMethod( SelectionMethod const selectionMethod )
+{
+ // block signals to prevent infinite recursion:
+ // radioButton->setChecked() -> toggleSelectionMethod() -> setSelectionMethod()
+ // -> radioButton->setChecked() -> ...
+ d->m_visibleRegionMethodButton->blockSignals( true );
+ d->m_specifiedRegionMethodButton->blockSignals( true );
+
+ d->m_selectionMethod = selectionMethod;
+ switch ( selectionMethod ) {
+ case VisibleRegionMethod:
+ d->m_visibleRegionMethodButton->setChecked( true );
+ d->m_latLonBoxWidget->setEnabled( false );
+ setSpecifiedLatLonAltBox( d->m_visibleRegion );
+ break;
+ case SpecifiedRegionMethod:
+ d->m_specifiedRegionMethodButton->setChecked( true );
+ d->m_latLonBoxWidget->setEnabled( true );
+ break;
+ }
+
+ d->m_visibleRegionMethodButton->blockSignals( false );
+ d->m_specifiedRegionMethodButton->blockSignals( false );
+}
+
TileCoordsPyramid DownloadRegionDialog::region() const
{
// check whether "visible region" or "lat/lon region" is selection method
- GeoDataLatLonBox downloadRegion = d->m_visibleRegion;
- if ( d->m_latLonBoxWidget->isEnabled() )
+ GeoDataLatLonBox downloadRegion;
+ switch ( d->m_selectionMethod ) {
+ case VisibleRegionMethod:
+ downloadRegion = d->m_visibleRegion;
+ break;
+ case SpecifiedRegionMethod:
downloadRegion = d->m_latLonBoxWidget->latLonBox();
+ break;
+ }
int const westX = d->rad2PixelX( downloadRegion.west() );
int const northY = d->rad2PixelY( downloadRegion.north() );
@@ -284,13 +320,18 @@
return coordsPyramid;
}
+void DownloadRegionDialog::setSpecifiedLatLonAltBox( GeoDataLatLonAltBox const & region )
+{
+ d->m_latLonBoxWidget->setLatLonBox( region );
+}
+
void DownloadRegionDialog::setVisibleLatLonAltBox( GeoDataLatLonAltBox const & region )
{
d->m_visibleRegion = region;
// update lat/lon widget only if not active to prevent that users unintentionally loose
// entered values
- if ( !d->m_latLonBoxWidget->isEnabled() ) {
- d->m_latLonBoxWidget->setLatLonBox( region );
+ if ( d->m_selectionMethod == VisibleRegionMethod ) {
+ setSpecifiedLatLonAltBox( region );
}
updateTilesCount();
}
@@ -323,11 +364,13 @@
void DownloadRegionDialog::toggleSelectionMethod()
{
- d->m_latLonBoxWidget->setEnabled( !d->m_latLonBoxWidget->isEnabled() );
- // when selection method changes from "specify region" to "visible region",
- // update the (now read only) lat/lon values
- if ( !d->m_latLonBoxWidget->isEnabled() ) {
- d->m_latLonBoxWidget->setLatLonBox( d->m_visibleRegion );
+ switch ( d->m_selectionMethod ) {
+ case VisibleRegionMethod:
+ setSelectionMethod( SpecifiedRegionMethod );
+ break;
+ case SpecifiedRegionMethod:
+ setSelectionMethod( VisibleRegionMethod );
+ break;
}
}
--- trunk/KDE/kdeedu/marble/src/lib/DownloadRegionDialog.h #1126059:1126060
@@ -33,16 +33,20 @@
Q_OBJECT
public:
+ enum SelectionMethod { VisibleRegionMethod, SpecifiedRegionMethod };
+
explicit DownloadRegionDialog( MarbleModel const * const model, QWidget * const parent = 0,
Qt::WindowFlags const f = 0 );
void setAllowedTileLevelRange( int const minimumTileLevel,
int const maximumTileLevel );
void setOriginatingTileLevel( int const tileLevel );
+ void setSelectionMethod( SelectionMethod const );
TileCoordsPyramid region() const;
public Q_SLOTS:
+ void setSpecifiedLatLonAltBox( GeoDataLatLonAltBox const & );
void setVisibleLatLonAltBox( GeoDataLatLonAltBox const & );
void updateTextureLayer();
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1126059:1126060
@@ -1005,8 +1005,10 @@
}
// FIXME: get allowed range from current map theme
m_downloadRegionDialog->setAllowedTileLevelRange( 0, 18 );
+ m_downloadRegionDialog->setSelectionMethod( DownloadRegionDialog::VisibleRegionMethod );
ViewportParams const * const viewport =
m_controlView->marbleWidget()->map()->viewParams()->viewport();
+ m_downloadRegionDialog->setSpecifiedLatLonAltBox( viewport->viewLatLonAltBox() );
m_downloadRegionDialog->setVisibleLatLonAltBox( viewport->viewLatLonAltBox() );
m_downloadRegionDialog->show();
More information about the Marble-commits
mailing list