[Marble-commits] KDE/kdeedu/marble/src/lib
Gaurav Gupta
1989.gaurav at googlemail.com
Tue Aug 10 18:09:53 CEST 2010
SVN commit 1161691 by ggupta:
Bookmark Name suggestion added on the basis of distance and reverseGeocoding the coordinates
M +83 -4 BookmarkInfoDialog.cpp
M +7 -0 BookmarkInfoDialog.h
M +7 -3 BookmarkInfoDialog.ui
M +4 -0 NewFolderInfoDialog.cpp
M +1 -2 NewFolderInfoDialog.h
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkInfoDialog.cpp #1161690:1161691
@@ -14,26 +14,105 @@
#include "BookmarkManager.h"
#include "GeoDataPlacemark.h"
#include "GeoDataFolder.h"
+#include "GeoDataCoordinates.h"
#include "NewFolderInfoDialog.h"
-
+#include "GeoDataExtendedData.h"
#include <QtGui/QLineEdit>
#include <QtCore/QString>
#include <QtCore/QPointer>
-
+#include <QtCore/QDebug>
+#include "MarbleModel.h"
using namespace Marble;
BookmarkInfoDialog::BookmarkInfoDialog(MarbleWidget *parent)
- : QDialog(parent), m_widget(parent)
+ : QDialog( parent ),
+ m_widget( parent ),
+ m_manager( 0 )
{
setupUi(this);
setWindowTitle( tr("Add Bookmark") );
connect( m_saveButton, SIGNAL( clicked() ), this, SLOT( addBookmark() ) );
connect( m_newFolderButton, SIGNAL( clicked() ), this, SLOT( openNewFolderDialog() ) );
- //Initializing ComboBox
+ m_manager = new MarbleRunnerManager( m_widget->model()->pluginManager(), this );
+
+ //reverse geocode the bookmark point for better user experience
+ connect( m_manager, SIGNAL( reverseGeocodingFinished( GeoDataCoordinates, GeoDataPlacemark ) ),
+ this, SLOT( retrieveGeocodeResult( GeoDataCoordinates, GeoDataPlacemark ) ) );
+
+ GeoDataCoordinates coordinates( m_widget->centerLongitude(), m_widget->centerLatitude(), 0, GeoDataCoordinates::Degree, 0 ) ;
+ m_manager->reverseGeocoding( coordinates );
+
+
+ name->setText(coordinates.toString() );
+ name->selectAll();
+ //Initialzing ComboBox
initComboBox();
}
+BookmarkInfoDialog::~BookmarkInfoDialog()
+{
+ delete m_manager;
+}
+
+void BookmarkInfoDialog::retrieveGeocodeResult( const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark)
+{
+
+ GeoDataExtendedData extended = placemark.extendedData();
+ QString bookmarkName = "";
+ qreal distance = m_widget->distance() * KM2METER;
+ //FIXME : Optimal logic for suggestion with distance consideration is required
+
+ if( distance >= 3500 ){
+ bookmarkName = extended.value("country").value().toString() ;
+ }
+ else if( distance >= 200 ){
+ bookmarkName = append( extended.value("town").value().toString()
+ , extended.value("state").value().toString() );
+ bookmarkName = append( bookmarkName, extended.value("country").value().toString() ) ;
+ }
+ else{
+ bookmarkName = append( extended.value("road").value().toString()
+ , extended.value("town").value().toString());
+ bookmarkName = append( bookmarkName, extended.value("country").value().toString() ) ;
+ }
+
+ if( bookmarkName.isEmpty() ){
+ bookmarkName = placemark.address();
+ }
+
+ /* if( !extended.value("country").value().toString().isEmpty() )
+ bookmarkName = extended.value("country").value().toString() ;
+ else if( !extended.value("state").value().toString().isEmpty() )
+ bookmarkName = extended.value("state").value().toString() ;
+ else if( !extended.value("county").value().toString().isEmpty() )
+ bookmarkName = extended.value("county").value().toString() ;
+ else if( !extended.value("village").value().toString().isEmpty() )
+ bookmarkName = extended.value("village").value().toString() ;
+ else if( !extended.value("suburb").value().toString().isEmpty() )
+ bookmarkName = extended.value("suburb").value().toString() ;
+ else if( !extended.value("road").value().toString().isEmpty() )
+ bookmarkName = extended.value("road").value().toString() ;
+ */
+ name->setText( bookmarkName );
+
+ name->selectAll();
+}
+
+QString BookmarkInfoDialog::append( const QString &bookmark, const QString &text)
+{
+ if( bookmark.isEmpty() && text.isEmpty() ){
+ return "";
+ }
+ else if( bookmark.isEmpty() ){
+ return text;
+ }
+ else if( text.isEmpty() ){
+ return bookmark;
+ }
+ return bookmark + "," + text;
+}
+
void BookmarkInfoDialog::initComboBox()
{
m_folders->clear();
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkInfoDialog.h #1161690:1161691
@@ -14,6 +14,7 @@
#include "ui_BookmarkInfoDialog.h"
#include "MarbleWidget.h"
#include "marble_export.h"
+#include "MarbleRunnerManager.h"
namespace Marble
{
@@ -27,6 +28,8 @@
explicit BookmarkInfoDialog( MarbleWidget *parent = 0);
+ ~BookmarkInfoDialog();
+
void initComboBox();
@@ -36,10 +39,14 @@
void openNewFolderDialog();
+ void retrieveGeocodeResult( const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark);
+ QString append( const QString &bookmark, const QString &text);
+
private:
Q_DISABLE_COPY( BookmarkInfoDialog )
MarbleWidget *m_widget;
+ MarbleRunnerManager* m_manager;
};
}
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkInfoDialog.ui #1161690:1161691
@@ -32,7 +32,7 @@
<item row="0" column="1">
<widget class="QLineEdit" name="name">
<property name="text">
- <string>Bookmark</string>
+ <string/>
</property>
<property name="cursorPosition">
<number>0</number>
@@ -61,12 +61,16 @@
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
+</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;">
<tr>
<td style="border: none;">
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></td></tr></table></body></html></string>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:9pt;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:9pt;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:9pt;"></p></td></tr></table></body></html></string>
</property>
</widget>
</item>
--- trunk/KDE/kdeedu/marble/src/lib/NewFolderInfoDialog.cpp #1161690:1161691
@@ -24,6 +24,10 @@
connect( m_save, SIGNAL( clicked() ), this, SLOT( addNewBookmarkFolder() ) );
}
+NewFolderInfoDialog::~NewFolderInfoDialog()
+{
+}
+
void NewFolderInfoDialog::addNewBookmarkFolder()
{
mDebug() << " Adding New Bookmark Folder "<< m_name->text() ;
--- trunk/KDE/kdeedu/marble/src/lib/NewFolderInfoDialog.h #1161690:1161691
@@ -1,8 +1,6 @@
//
// This file is part of the Marble Desktop Globe.
//
-// This program is free software licensed under the GNU LGPL. You can
-// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2010 Gaurav Gupta <1989.gaurav at googlemail.com>
@@ -26,6 +24,7 @@
explicit NewFolderInfoDialog( MarbleWidget *parent = 0);
+ ~NewFolderInfoDialog();
public Q_SLOTS:
void addNewBookmarkFolder();
More information about the Marble-commits
mailing list