Mywebwidget3/mytoolbar.cpp
changeset 5 3d8bce9e1a9f
parent 2 fa1a8300ce01
equal deleted inserted replaced
4:ebd5cf1fc7e9 5:3d8bce9e1a9f
       
     1 /*
       
     2 * Copyright (c) 2010 Symbian Foundation.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Symbian Foundation - Initial contribution
       
    11 *
       
    12 * Description:
       
    13 * Implementation of the MyToolBar class.
       
    14 */
       
    15 
       
    16 #include <QtGui/QPushButton>
       
    17 #include <QtGui/QLabel>
       
    18 #include <QtGui/QHBoxLayout>
       
    19 #include <QtGui/QAction>
       
    20 #include <QtGui/QApplication>
       
    21 #include <QGeoPositionInfo>
       
    22 #include <QGeoPositionInfoSource>
       
    23 
       
    24 #include "mytoolbar.h"
       
    25 
       
    26 const QString locString("My Location: ");
       
    27 
       
    28 MyToolBar::MyToolBar(QWidget* parent)
       
    29     :QWidget(parent)
       
    30 {
       
    31     m_backButton = new QPushButton("Back",this);
       
    32     m_locationLabel = new QLabel(this);
       
    33 
       
    34     m_location = QGeoPositionInfoSource::createDefaultSource(this);
       
    35     m_location->setUpdateInterval(10000);
       
    36     m_location->startUpdates();
       
    37 
       
    38     m_layout = new QHBoxLayout;
       
    39     m_layout->addWidget(m_backButton);
       
    40     m_layout->addWidget(m_locationLabel);
       
    41     m_layout->insertSpacing(1,10);
       
    42     setLayout(m_layout);
       
    43     m_layout->addStretch();
       
    44 
       
    45     connect(m_backButton,SIGNAL(clicked()),SLOT(onBackPressed()));
       
    46     connect(m_location,SIGNAL(positionUpdated(QGeoPositionInfo)),SLOT(onPositionUpdated(QGeoPositionInfo)));
       
    47 }
       
    48 
       
    49 MyToolBar::~MyToolBar()
       
    50 {
       
    51 
       
    52 }
       
    53 
       
    54 void MyToolBar::onPositionUpdated(const QGeoPositionInfo& posInfo)
       
    55 {
       
    56     QGeoCoordinate coordinate = posInfo.coordinate();
       
    57     QString label_coordinate = coordinate.toString();
       
    58     m_locationLabel->setText(locString+" "+label_coordinate);
       
    59 }
       
    60 
       
    61 void MyToolBar::onBackPressed()
       
    62 {
       
    63     emit goBack();
       
    64 }