[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Sat May 1 09:52:28 CEST 2010
SVN commit 1121412 by nienhueser:
Make the download region feature available in the Qt application as well.
M +41 -7 QtMainWindow.cpp
M +2 -0 QtMainWindow.h
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1121411:1121412
@@ -39,11 +39,13 @@
#include <QtNetwork/QNetworkProxy>
-#include <MarbleDirs.h>
-#include "lib/MarbleAboutDialog.h"
-#include "lib/QtMarbleConfigDialog.h"
-#include "lib/SunControlWidget.h"
-#include "lib/MarbleLocale.h"
+#include "MarbleDirs.h"
+#include "MarbleAboutDialog.h"
+#include "QtMarbleConfigDialog.h"
+#include "SunControlWidget.h"
+#include "MarbleLocale.h"
+#include "DownloadRegionDialog.h"
+#include "ViewParams.h"
#include "AbstractDataPlugin.h"
#include "AbstractFloatItem.h"
#include "MarbleMap.h"
@@ -58,7 +60,8 @@
using namespace Marble;
-MainWindow::MainWindow(const QString& marbleDataPath, QWidget *parent) : QMainWindow(parent), m_sunControlDialog(0)
+MainWindow::MainWindow(const QString& marbleDataPath, QWidget *parent) :
+ QMainWindow(parent), m_sunControlDialog(0), m_downloadRegionAction( 0 )
{
MarbleGlobal::getInstance()->setProfiles( MarbleGlobal::detectProfiles() );
@@ -118,6 +121,11 @@
m_exportMapAct->setStatusTip(tr("Save a screenshot of the map"));
connect(m_exportMapAct, SIGNAL(triggered()), this, SLOT(exportMapScreenShot()));
+ // Action: Download Region
+ m_downloadRegionAction = new QAction( tr( "Download Region..." ), this );
+ m_downloadRegionAction->setStatusTip( tr( "Download a map region in different zoom levels for offline usage" ) );
+ connect( m_downloadRegionAction, SIGNAL( triggered() ), SLOT( showDownloadRegionDialog() ) );
+
m_printAct = new QAction( QIcon(":/icons/document-print.png"), tr("&Print..."), this);
m_printAct->setShortcut(tr("Ctrl+P"));
m_printAct->setStatusTip(tr("Print a screenshot of the map"));
@@ -218,7 +226,9 @@
if( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
menuBar()->addAction(m_workOfflineAct);
menuBar()->addAction(m_sideBarAct);
- menuBar()->addAction(m_fullScreenAct);
+ /** @todo: Full screen cannot be left on Maemo currently (shortcuts not working) */
+ //menuBar()->addAction( m_fullScreenAct );
+ menuBar()->addAction( m_downloadRegionAction );
menuBar()->addAction(m_aboutMarbleAct);
return;
}
@@ -226,6 +236,7 @@
m_fileMenu = menuBar()->addMenu(tr("&File"));
m_fileMenu->addAction(m_openAct);
m_fileMenu->addAction(m_downloadAct);
+ m_fileMenu->addAction( m_downloadRegionAction );
m_fileMenu->addAction(m_exportMapAct);
m_fileMenu->addSeparator();
m_fileMenu->addAction(m_printAct);
@@ -860,4 +871,27 @@
m_controlView->marbleWidget()->updateChangedMap();
}
+void MainWindow::showDownloadRegionDialog()
+{
+ ViewportParams *const viewport = m_controlView->marbleWidget()->map()->viewParams()->viewport();
+ MarbleModel *const model = m_controlView->marbleWidget()->map()->model();
+ QPointer<DownloadRegionDialog> dialog = new DownloadRegionDialog( viewport,
+ model->textureMapper() );
+ // FIXME: get allowed range from current map theme
+ dialog->setAllowedTileLevelRange( 0, 18 );
+ QString const mapThemeId = m_controlView->marbleWidget()->mapThemeId();
+ QString const sourceDir = mapThemeId.left( mapThemeId.lastIndexOf( '/' ));
+ mDebug() << "showDownloadRegionDialog mapThemeId:" << mapThemeId << sourceDir;
+
+ if ( dialog->exec() == QDialog::Accepted ) {
+ // FIXME: use lazy evaluation to not generate up to 100k tiles in one go
+ // this can take considerable time even on very fast systems
+ // in contrast generating the TileIds on the fly when they are needed
+ // does not seem to affect download speed.
+ TileCoordsPyramid const pyramid = dialog->region();
+ model->downloadRegion( sourceDir, pyramid );
+ }
+ delete dialog;
+}
+
#include "QtMainWindow.moc"
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.h #1121411:1121412
@@ -66,6 +66,7 @@
void openFile();
void openMapSite();
void exportMapScreenShot();
+ void showDownloadRegionDialog();
void printMapScreenShot();
void printPixmap( QPrinter * printer, const QPixmap& pixmap );
void printPreview();
@@ -117,6 +118,7 @@
// File Menu
QAction *m_exportMapAct;
QAction *m_downloadAct;
+ QAction *m_downloadRegionAction;
QAction *m_printPreviewAct;
QAction *m_printAct;
QAction *m_workOfflineAct;
More information about the Marble-commits
mailing list