<commit_before>/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include <QPointF>
#include <QNetworkProxy>

#ifdef Q_OS_SYMBIAN
#include <QMessageBox>
#include <qnetworksession.h>
#include <qnetworkconfigmanager.h>
#endif

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "qgeomaptile.h"
#include "qgeorouterequest.h"
#include "qmapmarker.h"
#include "qmapellipse.h"
#include "qmaproute.h"
#include "qmaprect.h"
#include "qmapline.h"
#include "qmappolygon.h"
#include "qmappixmap.h"
#include "qmapmarker.h"

#include "qgeomapservice_nokia_p.h"
#include "qgeoroutingservice_nokia_p.h"

QTM_USE_NAMESPACE

MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow),
        popupMenu(NULL)
{
    ui->setupUi(this);

    QGeoMapServiceNokia *mService = new QGeoMapServiceNokia();
    QGeoRoutingServiceNokia *rService = new QGeoRoutingServiceNokia();

    QNetworkProxy proxy(QNetworkProxy::HttpProxy, "172.16.42.41", 8080);
    mService->setProxy(proxy);
    mService->setHost("maptile.mapplayer.maps.svc.ovi.com");

    mapService = mService;
    routingService = rService;

    qgv = new QGraphicsView(this);
    qgv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    qgv->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    qgv->setVisible(true);
    qgv->setGeometry(QRect(0, 0, width(), height()));

    QGraphicsScene* scene = new QGraphicsScene(0, 0, width(), height());
    qgv->setScene(scene);

    mapView = new QMapView();
    qgv->scene()->addItem(mapView);
    mapView->setGeometry(0, 0, width(), height());

    QObject::connect(routingService, SIGNAL(finished(QGeoRouteReply*)),
                     this, SLOT(routeReplyFinished(QGeoRouteReply*)));
    QObject::connect(mapView, SIGNAL(mapClicked(QGeoCoordinate, QGraphicsSceneMouseEvent*)),
                     this, SLOT(mapClicked(QGeoCoordinate, QGraphicsSceneMouseEvent*)));
    QObject::connect(mapView, SIGNAL(zoomLevelChanged(quint16, quint16)),
                     this, SLOT(zoomLevelChanged(quint16, quint16)));
    QObject::connect(mapView, SIGNAL(mapObjectSelected(QMapObject*)),
                     this, SLOT(mapObjectSelected(QMapObject*)));

    slider = new QSlider(Qt::Vertical, this);
    slider->setMinimum(0);
    slider->setMaximum(18);
    slider->setSliderPosition(4);
    slider->setGeometry(10, 10, 30, 180);
    slider->setVisible(true);
    QObject::connect(slider, SIGNAL(sliderMoved(int)),
                     mapView, SLOT(setZoomLevel(int)));

    //QGraphicsProxyWidget* proxy = qgv->scene()->addWidget(slider);

    setContextMenuPolicy(Qt::CustomContextMenu);
    QObject::connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
                     this, SLOT(customContextMenuRequest(const QPoint&)));

    setWindowTitle(tr("Map Viewer Demo"));

    QTimer::singleShot(0, this, SLOT(delayedInit()));
}

MainWindow::~MainWindow()
{
    delete ui;
    delete mapService;
    delete routingService;
}

void MainWindow::delayedInit()
{
#ifdef Q_OS_SYMBIAN
    // Set Internet Access Point
    QNetworkConfigurationManager manager;
    const bool canStartIAP = (manager.capabilities()
                              & QNetworkConfigurationManager::CanStartAndStopInterfaces);
    // Is there default access point, use it
    QNetworkConfiguration cfg = manager.defaultConfiguration();
    if (!cfg.isValid() || (!canStartIAP && cfg.state() != QNetworkConfiguration::Active)) {
        QMessageBox::information(this, tr("MapViewer Example"), tr(
                                     "Available Access Points not found."));
        return;
    }

    session = new QNetworkSession(cfg, this);
    session->open();
    session->waitForOpened(-1);
#endif

    mapView->init(mapService, QGeoCoordinate(52.35, 13));
}<commit_msg>Map padding and launch speed up to MapViewer example<commit_after>/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include <QPointF>
#include <QNetworkProxy>

#ifdef Q_OS_SYMBIAN
#include <QMessageBox>
#include <qnetworksession.h>
#include <qnetworkconfigmanager.h>
#endif

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "qgeomaptile.h"
#include "qgeorouterequest.h"
#include "qmapmarker.h"
#include "qmapellipse.h"
#include "qmaproute.h"
#include "qmaprect.h"
#include "qmapline.h"
#include "qmappolygon.h"
#include "qmappixmap.h"
#include "qmapmarker.h"

#include "qgeomapservice_nokia_p.h"
#include "qgeoroutingservice_nokia_p.h"

QTM_USE_NAMESPACE

MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow),
        popupMenu(NULL),
        mapService(NULL),
        routingService(NULL)
{
    ui->setupUi(this);

    qgv = new QGraphicsView(this);
    qgv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    qgv->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    qgv->setVisible(true);
    qgv->setGeometry(QRect(0, 0, width(), height()));

    QGraphicsScene* scene = new QGraphicsScene(0, 0, width(), height());
    qgv->setScene(scene);

    mapView = new QMapView();
    qgv->scene()->addItem(mapView);
    mapView->setGeometry(0, 0, width(), height());

    QObject::connect(mapView, SIGNAL(mapClicked(QGeoCoordinate, QGraphicsSceneMouseEvent*)),
                     this, SLOT(mapClicked(QGeoCoordinate, QGraphicsSceneMouseEvent*)));
    QObject::connect(mapView, SIGNAL(zoomLevelChanged(quint16, quint16)),
                     this, SLOT(zoomLevelChanged(quint16, quint16)));
    QObject::connect(mapView, SIGNAL(mapObjectSelected(QMapObject*)),
                     this, SLOT(mapObjectSelected(QMapObject*)));

    slider = new QSlider(Qt::Vertical, this);
    slider->setMinimum(0);
    slider->setMaximum(18);
    slider->setSliderPosition(4);
    slider->setGeometry(10, 10, 30, 180);
    slider->setVisible(true);
    QObject::connect(slider, SIGNAL(sliderMoved(int)),
                     mapView, SLOT(setZoomLevel(int)));

    setContextMenuPolicy(Qt::CustomContextMenu);
    QObject::connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
                     this, SLOT(customContextMenuRequest(const QPoint&)));

    setWindowTitle(tr("Map Viewer Demo"));

    QTimer::singleShot(0, this, SLOT(delayedInit()));
}

MainWindow::~MainWindow()
{
    delete ui;
    delete mapService;
    delete routingService;
}

void MainWindow::delayedInit()
{
#ifdef Q_OS_SYMBIAN
    // Set Internet Access Point
    QNetworkConfigurationManager manager;
    const bool canStartIAP = (manager.capabilities()
                              & QNetworkConfigurationManager::CanStartAndStopInterfaces);
    // Is there default access point, use it
    QNetworkConfiguration cfg = manager.defaultConfiguration();
    if (!cfg.isValid() || (!canStartIAP && cfg.state() != QNetworkConfiguration::Active)) {
        QMessageBox::information(this, tr("MapViewer Example"), tr(
                                     "Available Access Points not found."));
        return;
    }

    session = new QNetworkSession(cfg, this);
    session->open();
    session->waitForOpened(-1);
#endif
    
    QGeoMapServiceNokia *mService = new QGeoMapServiceNokia();
    QGeoRoutingServiceNokia *rService = new QGeoRoutingServiceNokia();

    QNetworkProxy proxy(QNetworkProxy::HttpProxy, "172.16.42.41", 8080);
    mService->setProxy(proxy);
    mService->setHost("maptile.mapplayer.maps.svc.ovi.com");

    mapService = mService;
    routingService = rService;
    
    QObject::connect(routingService, SIGNAL(finished(QGeoRouteReply*)),
                     this, SLOT(routeReplyFinished(QGeoRouteReply*)));

    mapView->setHorizontalPadding(100);
    mapView->setVerticalPadding(100);
    mapView->init(mapService, QGeoCoordinate(52.35, 13));
}
{'fraction_non_alphanumeric': 0.14969662495259764, 'fraction_numerical': 0.011945392491467578, 'mean_word_length': 4.293025589563472, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1764386', 'n_tokens_mistral': 3327, 'n_tokens_neox': 3123, 'n_words': 759}