• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

marble/src

MarbleControlBox.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  *
00003  * Copyright 2004-2007 Torsten Rahn  <tackat@kde.org>"
00004  * Copyright 2007      Inge Wallin   <ingwa@kde.org>"
00005  * Copyright 2007      Thomas Zander <zander@kde.org>"
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #include "MarbleControlBox.h"
00024 
00025 #include <QtCore/QtAlgorithms>
00026 #include <QtCore/QDebug>
00027 #include <QtCore/QTimer>
00028 #include <QtGui/QSortFilterProxyModel>
00029 #include <QtGui/QStringListModel>
00030 #include <QtGui/QTextFrame>
00031 
00032 #include "ui_MarbleControlBox.h"
00033 
00034 #include <global.h>
00035 
00036 #include <MarbleWidget.h>
00037 #include <MarbleDirs.h>
00038 #include <MapTheme.h>
00039 #include <FileViewModel.h>
00040 #include "gps/GpxFileModel.h"
00041 
00042 class MarbleControlBoxPrivate
00043 {
00044  public:
00045 
00046     MarbleWidget  *m_widget;
00047     QString        m_searchTerm;
00048     bool           m_searchTriggered;
00049 
00050     Ui::MarbleControlBox  uiWidget;
00051     QWidget              *m_navigationWidget;
00052     QWidget              *m_legendWidget;
00053     QWidget              *m_mapViewWidget;
00054     QWidget              *m_currentLocationWidget;
00055     QWidget              *m_fileViewWidget;
00056 
00057     QStandardItemModel     *m_mapthememodel;
00058     QSortFilterProxyModel  *m_sortproxy;
00059 };
00060 
00061 
00062 // ================================================================
00063 
00064 
00065 MarbleControlBox::MarbleControlBox(QWidget *parent)
00066     : QWidget( parent ),
00067       d( new MarbleControlBoxPrivate )
00068 {
00069     d->m_widget = 0;
00070     d->m_searchTerm = QString();
00071     d->m_searchTriggered = false;
00072 
00073     d->uiWidget.setupUi( this );
00074 
00075     setFocusPolicy( Qt::NoFocus );
00076 //    setFocusProxy( d->uiWidget.searchLineEdit );
00077 
00078     //  Iterate through all of the Side Widget values  //
00079     d->uiWidget.toolBox->setCurrentIndex( 0 );
00080     d->m_navigationWidget = d->uiWidget.toolBox->currentWidget();
00081 
00082     d->uiWidget.toolBox->setCurrentIndex( 1 );
00083     d->m_legendWidget = d->uiWidget.toolBox->currentWidget();
00084 
00085     d->uiWidget.toolBox->setCurrentIndex( 2 );
00086     d->m_mapViewWidget = d->uiWidget.toolBox->currentWidget();
00087 
00088     d->uiWidget.toolBox->setCurrentIndex( 3 );
00089     d->m_currentLocationWidget = d->uiWidget.toolBox->currentWidget();
00090 
00091     d->uiWidget.toolBox->setCurrentIndex( 4 );
00092     d->m_fileViewWidget = d->uiWidget.toolBox->currentWidget();
00093 
00094     d->m_sortproxy = new QSortFilterProxyModel( d->uiWidget.locationListView );
00095     d->uiWidget.locationListView->setModel( d->m_sortproxy );
00096 
00097 //  d->m_currentLocationWidget->hide(); // Current location tab is hidden
00098                                     //by default
00099  //   toolBox->removeItem( 3 );
00100     d->uiWidget.toolBox->setCurrentIndex(0);
00101 
00102     //default
00103     setCurrentLocationTabShown( false );
00104     setFileViewTabShown( false );
00105 
00106     setupGpsOption();
00107 
00108     connect( d->uiWidget.goHomeButton,  SIGNAL( clicked() ),
00109              this,                      SIGNAL( goHome() ) );
00110     connect( d->uiWidget.zoomSlider,    SIGNAL( valueChanged( int ) ),
00111              this,                      SIGNAL( zoomChanged( int ) ) );
00112     connect( d->uiWidget.zoomInButton,  SIGNAL( clicked() ),
00113              this,                      SIGNAL( zoomIn() ) );
00114     connect( d->uiWidget.zoomOutButton, SIGNAL( clicked() ),
00115              this,                      SIGNAL( zoomOut() ) );
00116 
00117     connect( d->uiWidget.zoomSlider,  SIGNAL( valueChanged( int ) ),
00118              this,                      SLOT( updateButtons( int ) ) );
00119 
00120     connect( d->uiWidget.moveLeftButton,  SIGNAL( clicked() ),
00121              this,                        SIGNAL( moveLeft() ) );
00122     connect( d->uiWidget.moveRightButton, SIGNAL( clicked() ),
00123              this,                        SIGNAL( moveRight() ) );
00124     connect( d->uiWidget.moveUpButton,    SIGNAL( clicked() ),
00125              this,                        SIGNAL( moveUp() ) );
00126     connect( d->uiWidget.moveDownButton,  SIGNAL( clicked() ),
00127              this,                        SIGNAL (moveDown() ) );
00128 
00129     connect(d->uiWidget.searchLineEdit,   SIGNAL( textChanged( const QString& ) ),
00130             this,                         SLOT( searchLineChanged( const QString& ) ) );
00131 
00132     connect( d->uiWidget.locationListView, SIGNAL( centerOn( const QModelIndex& ) ),
00133              this,                         SLOT( mapCenterOnSignal( const QModelIndex& ) ) );
00134 
00135     d->m_mapthememodel = 0;
00136     updateMapThemes();
00137 
00138     connect( d->uiWidget.marbleThemeSelectView, SIGNAL( selectMapTheme( const QString& ) ),
00139              this,                              SIGNAL( selectMapTheme( const QString& ) ) );
00140     connect( d->uiWidget.projectionComboBox,    SIGNAL( currentIndexChanged( int ) ),
00141              this,                              SIGNAL( projectionSelected( int ) ) );
00142 
00143     d->uiWidget.projectionComboBox->setEnabled( true );
00144 }
00145 
00146 MarbleControlBox::~MarbleControlBox()
00147 {
00148     delete d->m_mapthememodel;
00149     delete d;
00150 }
00151 
00152 
00153 void MarbleControlBox::updateMapThemes()
00154 {
00155     QStringList  mapthemedirs = MapTheme::findMapThemes( "maps/earth" );
00156     d->m_mapthememodel = MapTheme::mapThemeModel( mapthemedirs );
00157     d->uiWidget.marbleThemeSelectView->setModel( d->m_mapthememodel );
00158 }
00159 
00160 void MarbleControlBox::updateButtons( int value )
00161 {
00162     if ( value <= d->uiWidget.zoomSlider->minimum() ) {
00163         d->uiWidget.zoomInButton->setEnabled( true );
00164         d->uiWidget.zoomOutButton->setEnabled( false );
00165     } else if ( value >= d->uiWidget.zoomSlider->maximum() ) {
00166         d->uiWidget.zoomInButton->setEnabled( false );
00167         d->uiWidget.zoomOutButton->setEnabled( true );
00168     } else {
00169         d->uiWidget.zoomInButton->setEnabled( true );
00170         d->uiWidget.zoomOutButton->setEnabled( true );
00171     }
00172 }
00173 
00174 
00175 void MarbleControlBox::setupGpsOption()
00176 {
00177     d->uiWidget.m_gpsDrawBox -> setEnabled( true );
00178     d->uiWidget.m_gpsGoButton -> setEnabled( false );
00179 
00180     d->uiWidget.m_latComboBox->setCurrentIndex( 0 );
00181     d->uiWidget.m_lonComboBox->setCurrentIndex( 0 );
00182 
00183     connect( d->uiWidget.m_gpsDrawBox, SIGNAL( clicked( bool ) ),
00184              this,                     SLOT( disableGpsInput( bool ) ) );
00185 }
00186 
00187 
00188 void MarbleControlBox::addMarbleWidget(MarbleWidget *widget)
00189 {
00190     d->m_widget = widget;
00191 
00192     // Make us aware of all the PlaceMarks in the MarbleModel so that
00193     // we can search them.
00194     setLocations( d->m_widget->placeMarkModel() );
00195     d->uiWidget.locationListView->setSelectionModel( d->m_widget->placeMarkSelectionModel() );
00196 
00197 #ifndef KML_GSOC
00198     //set up everything for the FileModel
00199     d->uiWidget.m_fileView->setModel( widget->gpxFileModel() );
00200 
00201     connect( d->uiWidget.m_fileView->selectionModel(),
00202          SIGNAL( selectionChanged( QItemSelection, QItemSelection )),
00203          this,
00204          SLOT( enableFileViewActions() ) );
00205     connect( d->uiWidget.m_saveButton,  SIGNAL( clicked() ) ,
00206              widget->gpxFileModel(),    SLOT( saveFile() ) );
00207     connect( d->uiWidget.m_closeButton, SIGNAL( clicked() ) ,
00208              widget->gpxFileModel(),    SLOT( closeFile() ) );
00209 #else
00210     FileViewModel* model = widget->fileViewModel();
00211     d->uiWidget.m_fileView->setModel( model );
00212 
00213     connect( d->uiWidget.m_fileView->selectionModel(),
00214              SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& )),
00215              this,
00216              SLOT( enableFileViewActions() ) );
00217 
00218     connect( d->uiWidget.m_saveButton,  SIGNAL( clicked() ),
00219              model,                     SLOT( saveFile() ) );
00220 
00221     connect( d->uiWidget.m_closeButton, SIGNAL( clicked () ),
00222              model,                     SLOT( closeFile() ) );
00223 #endif
00224 
00225     // Initialize the MarbleLegendBrowser
00226     d->uiWidget.marbleLegendBrowser->setMarbleWidget( d->m_widget );
00227 
00228     d->uiWidget.marbleLegendBrowser->setCheckedLocations( d->m_widget->showPlaces() );
00229     d->uiWidget.marbleLegendBrowser->setCheckedCities( d->m_widget->showCities() );
00230     d->uiWidget.marbleLegendBrowser->setCheckedTerrain( d->m_widget->showTerrain() );
00231     d->uiWidget.marbleLegendBrowser->setCheckedBorders( d->m_widget->showBorders() );
00232     d->uiWidget.marbleLegendBrowser->setCheckedWaterBodies( d->m_widget->showLakes()
00233                                                       && d->m_widget->showRivers() );
00234     d->uiWidget.marbleLegendBrowser->setCheckedOtherPlaces( d->m_widget->showOtherPlaces() );
00235     d->uiWidget.marbleLegendBrowser->setCheckedGrid( d->m_widget->showGrid() );
00236     d->uiWidget.marbleLegendBrowser->setCheckedIceLayer( d->m_widget->showIceLayer() );
00237     d->uiWidget.marbleLegendBrowser->setCheckedRelief( d->m_widget->showRelief() );
00238     d->uiWidget.marbleLegendBrowser->setCheckedCompass( d->m_widget->showCompass() );
00239     d->uiWidget.marbleLegendBrowser->setCheckedScaleBar( d->m_widget->showScaleBar() );
00240 
00241     // Connect necessary signals.
00242     connect( this, SIGNAL(goHome()),         d->m_widget, SLOT(goHome()) );
00243     connect( this, SIGNAL(zoomChanged(int)), d->m_widget, SLOT(zoomView(int)) );
00244     connect( this, SIGNAL(zoomIn()),         d->m_widget, SLOT(zoomIn()) );
00245     connect( this, SIGNAL(zoomOut()),        d->m_widget, SLOT(zoomOut()) );
00246 
00247     connect( this, SIGNAL(moveLeft()),  d->m_widget, SLOT(moveLeft()) );
00248     connect( this, SIGNAL(moveRight()), d->m_widget, SLOT(moveRight()) );
00249     connect( this, SIGNAL(moveUp()),    d->m_widget, SLOT(moveUp()) );
00250     connect( this, SIGNAL(moveDown()),  d->m_widget, SLOT(moveDown()) );
00251 
00252     connect( this, SIGNAL( projectionSelected( int ) ),  d->m_widget, SLOT( setProjection( int ) ) );
00253 
00254     connect( d->m_widget, SIGNAL( themeChanged( QString ) ),
00255              this,        SLOT( selectTheme( QString ) ) );
00256     selectTheme( d->m_widget->mapTheme() );
00257 
00258     connect( d->m_widget, SIGNAL( projectionChanged( int ) ),
00259              this,        SLOT( selectProjection( int ) ) );
00260     selectProjection( d->m_widget->projection() );
00261 
00262     connect(d->m_widget, SIGNAL(zoomChanged(int)),
00263         this,        SLOT(changeZoom(int)));
00264     connect(this,        SIGNAL(centerOn(const QModelIndex&)),
00265         d->m_widget, SLOT(centerOn(const QModelIndex&)));
00266     connect(this,        SIGNAL(selectMapTheme(const QString&)),
00267         d->m_widget, SLOT(setMapTheme(const QString&)));
00268 
00269     // connect signals for the Legend
00270     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledLocations( bool ) ),
00271              d->m_widget,                     SLOT( setShowPlaces( bool ) ) );
00272     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledCities( bool ) ),
00273              d->m_widget,                     SLOT( setShowCities( bool ) ) );
00274     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledTerrain( bool ) ),
00275              d->m_widget,                     SLOT( setShowTerrain( bool ) ) );
00276     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledBorders( bool ) ),
00277              d->m_widget,                     SLOT( setShowBorders( bool ) ) );
00278     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledWaterBodies( bool ) ),
00279              d->m_widget,                     SLOT( setShowRivers( bool ) ) );
00280     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledWaterBodies( bool ) ),
00281              d->m_widget,                     SLOT( setShowLakes( bool ) ) );
00282     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledOtherPlaces( bool ) ),
00283              d->m_widget,                     SLOT( setShowOtherPlaces( bool ) ) );
00284     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledGrid( bool ) ),
00285              d->m_widget,                     SLOT( setShowGrid( bool ) ) );
00286     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledIceLayer( bool ) ),
00287              d->m_widget,                     SLOT( setShowIceLayer( bool ) ) );
00288     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledRelief( bool ) ),
00289              d->m_widget,                     SLOT( setShowRelief( bool ) ) );
00290     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledCompass( bool ) ),
00291              d->m_widget,                     SLOT( setShowCompass( bool ) ) );
00292     connect( d->uiWidget.marbleLegendBrowser, SIGNAL( toggledScaleBar( bool ) ),
00293              d->m_widget,                     SLOT( setShowScaleBar( bool ) ) );
00294 
00295     //connect CurrentLoctaion signals
00296     connect( this, SIGNAL( gpsInputDisabled( bool ) ),
00297              d->m_widget, SLOT( setShowGps( bool ) ) );
00298     connect( this, SIGNAL( gpsPositionChanged( double, double ) ),
00299              d->m_widget, SLOT( changeCurrentPosition( double, double ) ) );
00300     connect( d->m_widget, SIGNAL( mouseClickGeoPosition( double, double,
00301                                             GeoDataPoint::Unit ) ),
00302              this, SLOT( receiveGpsCoordinates ( double, double,
00303                                                  GeoDataPoint::Unit) ) );
00304 
00305     connect( d->m_widget, SIGNAL( timeout() ),
00306              this,        SIGNAL( updateGps() ) );
00307 }
00308 
00309 void MarbleControlBox::setWidgetTabShown( QWidget * widget,
00310                                           int insertIndex, bool show,
00311                                           QString &text )
00312 {
00313     int index = d->uiWidget.toolBox->indexOf( widget );
00314 
00315     if( show ) {
00316         if ( !(index >= 0) ){
00317             if ( insertIndex < d->uiWidget.toolBox->count() ) {
00318                 d->uiWidget.toolBox->insertItem( insertIndex,
00319                                                  widget,
00320                                                  text );
00321             } else {
00322                 d->uiWidget.toolBox->insertItem( 3 ,widget, text );
00323             }
00324             widget->show();
00325         }
00326     } else {
00327         if ( index >= 0 ) {
00328             widget->hide();
00329             d->uiWidget.toolBox->removeItem( index );
00330         }
00331     }
00332 }
00333 
00334 
00335 void MarbleControlBox::setLocations(QAbstractItemModel* locations)
00336 {
00337     d->m_sortproxy->setSourceModel( locations );
00338     d->m_sortproxy->sort( 0 );
00339 }
00340 
00341 int MarbleControlBox::minimumZoom() const
00342 {
00343     return d->m_widget->minimumZoom();
00344 }
00345 
00346 
00347 void MarbleControlBox::changeZoom(int zoom)
00348 {
00349     // No infinite loops here
00350     // if (zoomSlider->value() != zoom)
00351     d->uiWidget.zoomSlider->setValue( zoom );
00352     d->uiWidget.zoomSlider->setMinimum( minimumZoom() );
00353 }
00354 
00355 void MarbleControlBox::disableGpsInput( bool in )
00356 {
00357     d->uiWidget.m_latSpinBox->setEnabled( !in );
00358     d->uiWidget.m_lonSpinBox->setEnabled( !in );
00359 
00360     d->uiWidget.m_latComboBox->setEnabled( !in );
00361     d->uiWidget.m_lonComboBox->setEnabled( !in );
00362 
00363     double t_lat = d->uiWidget.m_latSpinBox->value();
00364     double t_lon = d->uiWidget.m_lonSpinBox->value();
00365 
00366     if( d->uiWidget.m_lonComboBox->currentIndex() == 1 ){
00367         t_lon *= -1;
00368     }
00369 
00370     if( d->uiWidget.m_latComboBox->currentIndex() == 1 ){
00371         t_lat *= -1;
00372     }
00373 
00374     emit gpsPositionChanged( t_lon, t_lat );
00375     emit gpsInputDisabled( in );
00376 }
00377 
00378 void MarbleControlBox::receiveGpsCoordinates( double x, double y,
00379                                               GeoDataPoint::Unit unit){
00380     if( d->uiWidget.m_catchGps->isChecked() ){
00381         switch(unit){
00382         case GeoDataPoint::Degree:
00383             d->uiWidget.m_lonSpinBox->setValue( y );
00384             d->uiWidget.m_latSpinBox->setValue( x );
00385             emit gpsPositionChanged( y, x );
00386             break;
00387         case GeoDataPoint::Radian:
00388             double t_lat=0,t_lon=0;
00389             t_lat = y * -RAD2DEG;
00390             t_lon = x * +RAD2DEG;
00391 
00392             if( t_lat < 0 ){
00393                 d->uiWidget.m_latSpinBox->setValue( -t_lat );
00394                 d->uiWidget.m_latComboBox->setCurrentIndex( 1 );
00395             } else {
00396                 d->uiWidget.m_latSpinBox->setValue( t_lat );
00397                 d->uiWidget.m_latComboBox->setCurrentIndex( 0 );
00398             }
00399 
00400             if( t_lon < 0 ){
00401                 d->uiWidget.m_lonSpinBox->setValue( -t_lon );
00402                 d->uiWidget.m_lonComboBox->setCurrentIndex( 1 );
00403             } else {
00404                 d->uiWidget.m_lonSpinBox->setValue( t_lon );
00405                 d->uiWidget.m_lonComboBox->setCurrentIndex( 0 );
00406             }
00407 
00408             emit gpsPositionChanged( t_lon, t_lat );
00409         }
00410     }
00411 }
00412 
00413 void MarbleControlBox::enableFileViewActions()
00414 {
00415     bool tmp = d->uiWidget.m_fileView->selectionModel()
00416             ->selectedIndexes().count() ==1;
00417     d->uiWidget.m_saveButton->setEnabled( tmp );
00418     d->uiWidget.m_closeButton->setEnabled( tmp );
00419 
00420 #ifndef KML_GSOC
00421     if ( tmp ) {
00422         QModelIndex tmpIndex = d->uiWidget.m_fileView ->
00423                 selectionModel() -> currentIndex();
00424         d->m_widget->gpxFileModel()->setSelectedIndex( tmpIndex );
00425     }
00426 #else
00427     if ( tmp ) {
00428         FileViewModel& model = ( FileViewModel& ) *d->uiWidget.m_fileView->model();
00429         model.setSelectedIndex( d->uiWidget.m_fileView->selectionModel()->currentIndex() );
00430     }
00431 #endif
00432 }
00433 
00434 void MarbleControlBox::setNavigationTabShown( bool show )
00435 {
00436     QString  title = tr( "Navigation" );
00437     setWidgetTabShown( d->m_navigationWidget, 0, show, title);
00438 }
00439 
00440 void MarbleControlBox::setLegendTabShown( bool show )
00441 {
00442     QString  title = tr( "Legend" );
00443     setWidgetTabShown( d->m_legendWidget, 1, show, title );
00444 }
00445 
00446 void MarbleControlBox::setMapViewTabShown( bool show )
00447 {
00448     QString  title = tr( "Map View" );
00449     setWidgetTabShown( d->m_mapViewWidget, 2, show, title );
00450 }
00451 
00452 void MarbleControlBox::setCurrentLocationTabShown( bool show )
00453 {
00454     QString  title = tr( "Current Location" );
00455     setWidgetTabShown( d->m_currentLocationWidget, 3, show, title );
00456 }
00457 
00458 void MarbleControlBox::setFileViewTabShown( bool show )
00459 {
00460     QString  title = tr( "File View" );
00461     setWidgetTabShown( d->m_fileViewWidget, 4, show, title );
00462 }
00463 
00464 
00465 
00466 
00467 void MarbleControlBox::resizeEvent ( QResizeEvent * )
00468 {
00469     if ( height() < 500 ) {
00470         if ( !d->uiWidget.zoomSlider->isHidden() ) {
00471             setUpdatesEnabled(false);
00472             d->uiWidget.zoomSlider->hide();
00473             d->uiWidget.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred,
00474                                                        QSizePolicy::Expanding );
00475             setUpdatesEnabled(true);
00476         }
00477     } else {
00478         if ( d->uiWidget.zoomSlider->isHidden() == true ) {
00479             setUpdatesEnabled(false);
00480             d->uiWidget.zoomSlider->show();
00481             d->uiWidget.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred,
00482                                                        QSizePolicy::Fixed );
00483             setUpdatesEnabled(true);
00484         }
00485     }
00486 }
00487 
00488 void MarbleControlBox::searchLineChanged(const QString &search)
00489 {
00490     d->m_searchTerm = search;
00491     if ( d->m_searchTriggered )
00492         return;
00493     d->m_searchTriggered = true;
00494     QTimer::singleShot( 0, this, SLOT( search() ) );
00495 }
00496 
00497 
00498 void MarbleControlBox::search()
00499 {
00500     d->m_searchTriggered = false;
00501     int  currentSelected = d->uiWidget.locationListView->currentIndex().row();
00502     d->uiWidget.locationListView->selectItem( d->m_searchTerm );
00503     if ( currentSelected != d->uiWidget.locationListView->currentIndex().row() )
00504         d->uiWidget.locationListView->activate();
00505 }
00506 
00507 void MarbleControlBox::selectTheme( const QString &theme )
00508 {
00509     for ( int row = 0; row < d->m_mapthememodel->rowCount(); ++row ) {
00510         QModelIndex itIndexName = d->m_mapthememodel->index( row, 1, QModelIndex() );
00511         QModelIndex itIndex     = d->m_mapthememodel->index( row, 0, QModelIndex() );
00512         // qDebug() << "Select Theme: " << theme << " Stored: " << d->m_mapthememodel->data( itIndexName ).toString();
00513 
00514         // If  we have found the theme in the theme model,
00515         //     and it is not the one that we already have,
00516         // then
00517         //     set the new one in the ui.
00518         if ( theme == d->m_mapthememodel->data( itIndexName ).toString()
00519              && itIndexName != d->uiWidget.marbleThemeSelectView->currentIndex() ) {
00520             // Mark the correct picture for the selected map theme and
00521             // also make sure it's shown.
00522             d->uiWidget.marbleThemeSelectView->setCurrentIndex( itIndex );
00523             d->uiWidget.marbleThemeSelectView->scrollTo( itIndex );
00524 
00525             // Dig out the min and max zoom and set the slider.
00526             //
00527             // Since this slot is called when a change of map theme is
00528             // already finished, we can use the widget to get the
00529             // values.
00530             d->uiWidget.zoomSlider->setMinimum( d->m_widget->model()->minimumZoom() );
00531             d->uiWidget.zoomSlider->setMaximum( d->m_widget->model()->maximumZoom() );
00532 
00533             // Break out of the loop
00534             break;
00535         }
00536     }
00537 }
00538 
00539 void MarbleControlBox::selectProjection( int projectionIndex )
00540 {
00541     if ( projectionIndex != d->uiWidget.projectionComboBox->currentIndex() )
00542         d->uiWidget.projectionComboBox->setCurrentIndex( projectionIndex );
00543 }
00544 
00545 void MarbleControlBox::mapCenterOnSignal( const QModelIndex &index )
00546 {
00547     emit centerOn( d->m_sortproxy->mapToSource( index ) );
00548 }
00549 
00550 #include "MarbleControlBox.moc"

marble/src

Skip menu "marble/src"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal