diff options
author | Jing Bai <jing.bai@digia.com> | 2012-12-07 17:35:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-07 19:20:16 +0100 |
commit | 993702d515ac222ba47ec255f4f82a5b3e58437a (patch) | |
tree | 15597e32ad9140c9588f600f5b1b601f0493f3f9 /examples | |
parent | 875aaa9796ee36bd7683abdcce60a1a865e9d875 (diff) | |
download | qtxmlpatterns-993702d515ac222ba47ec255f4f82a5b3e58437a.tar.gz |
remove trafficinfo example and related doc
Due to trafikanten API change, this example doesn't work anymore.
The new API uses JSON based content, we can probably use it for qjson
example.
Task-number: QTBUG-28423
Change-Id: I36b499b4b2f36d46314937c24d9a2df3bba7b391
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/xmlpatterns/trafficinfo/doc/src/trafficinfo.qdoc | 149 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/main.cpp | 53 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/mainwindow.cpp | 180 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/mainwindow.h | 76 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/station_example.wml | 31 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/stationdialog.cpp | 161 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/stationdialog.h | 69 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/stationdialog.ui | 104 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/stationquery.cpp | 93 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/stationquery.h | 73 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/time_example.wml | 56 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/timequery.cpp | 115 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/timequery.h | 73 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/trafficinfo.desktop | 11 | ||||
-rw-r--r-- | examples/xmlpatterns/trafficinfo/trafficinfo.pro | 12 | ||||
-rw-r--r-- | examples/xmlpatterns/xmlpatterns.pro | 2 |
16 files changed, 1 insertions, 1257 deletions
diff --git a/examples/xmlpatterns/trafficinfo/doc/src/trafficinfo.qdoc b/examples/xmlpatterns/trafficinfo/doc/src/trafficinfo.qdoc deleted file mode 100644 index 8b32563..0000000 --- a/examples/xmlpatterns/trafficinfo/doc/src/trafficinfo.qdoc +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example xmlpatterns/trafficinfo - \title TrafficInfo Example - \ingroup xmlpattern_examples - Shows how XQuery can be used extract information from WML documents provided by a WAP service. - - \section1 Overview - - The WAP service used in this example is \l{Trafikanten}{wap.trafikanten.no} - that is run by the Norwegian governmental agency for public transport in - Oslo. The service provides real time information about the departure of - busses, trams and undergrounds for every station in the city area. - - This example application displays the departure information for a specific - station and provides the feature to filter for a special bus or tram line. - - \image trafficinfo-example.png - - \section1 Retrieving the Data - - Without the knowledge of XQuery, one would use QNetworkAccessManager to - query the WML document from the WAP service and then using the QDom - classes or QXmlStreamReader classes to iterate over the document and - extract the needed information. - However this approach results in a lot of glue code and consumes valuable - developer time, so we are looking for something that can access XML - documents locally or over the network and extract data according to given - filter rules. That's the point where XQuery enters the stage! - - If we want to know when the underground number 6 in direction - \Aring\c{}sjordet is passing the underground station in Nydalen on November - 14th 2008 after 1pm, we use the following URL: - - \c{http://wap.trafikanten.no/F.asp?f=03012130&t=13&m=00&d=14.11.2008&start=1} - - The parameters have the following meanings: - \list - \li \e{f} The unique station ID of Nydalen. - \li \e{t} The hour in 0-23 format. - \li \e{m} The minute in 0-59 format. - \li \e{d} The date in dd.mm.yyyy format. - \li \e{start} Not interesting for our use but should be passed. - \endlist - - As a result we get the following document: - - \quotefile xmlpatterns/trafficinfo/time_example.wml - - So for every departure we have a \c <a> tag that contains the time as a - text element, and the following text element contains the line number - and direction. - - To encapsulate the XQuery code in the example application, we create a - custom \c TimeQuery class. This provides the \c queryInternal() function - that takes a station ID and date/time as input and returns the list of - times and directions: - - \snippet xmlpatterns/trafficinfo/timequery.cpp 1 - - The first lines of this function synthesize the XQuery strings that fetch - the document and extract the data. - For better readability, two separated queries are used here: the first one - fetches the times and the second fetches the line numbers and directions. - - The \c doc() XQuery method opens a local or remote XML document and returns - it, so the \c{/wml/card/p/small/} statement behind it selects all XML nodes - that can be reached by the path, \c wml \rarrow \c card \rarrow \c p \rarrow - \c small. - Now we are on the node that contains all the XML nodes we are interested in. - - In the first query we select all \c a nodes that have a \c href attribute - starting with the string "Rute" and return the text of these nodes. - - In the second query we select all text nodes that are children of the - \c small node which start with a number. - These two queries are passed to the QXmlQuery instance and are evaluated - to string lists. After some sanity checking, we have collected all the - information we need. - - In the section above we have seen that an unique station ID must be passed - as an argument to the URL for retrieving the time, so how to find out which - is the right station ID to use? The WAP service provides a page for that - as well, so the URL - - \c{http://wap.trafikanten.no/FromLink1.asp?fra=Nydalen} - - will return the following document: - - \snippet xmlpatterns/trafficinfo/station_example.wml 0 - - The names of the available stations are listed as separate text elements - and the station ID is part of the \c href attribute of the parent \c a - (anchor) element. In our example, the \c StationQuery class encapsulates - the action of querying the stations that match the given name pattern with - the following code: - - \snippet xmlpatterns/trafficinfo/stationquery.cpp 0 - - Just as in the \c TimeQuery implementation, the first step is to - synthesize the XQuery strings for selecting the station names and the - station IDs. As the station name that we pass in the URL will be input - from the user, we should protect the XQuery from code injection by using - the QXmlQuery::bindVariable() method to do proper quoting of the variable - content for us instead of concatenating the two strings manually. - - So, we define a XQuery \c $station variable that is bound to the user - input. This variable is concatenated inside the XQuery code with the - \c concat method. To extract the station IDs, we select all \c a elements - that have an \c title attribute with the content "Velg", and from these - elements we take the substring of the \c href attribute that starts at the - 18th character. - - The station name can be extracted a bit more easily by just taking the - text elements of the selected \a elements. - - After some sanity checks we have all the station IDs and the corresponding - names available. - - The rest of the code in this example is just for representing the time and - station information to the user, and uses techniques described in the - \l{Widget Examples}. -*/ diff --git a/examples/xmlpatterns/trafficinfo/main.cpp b/examples/xmlpatterns/trafficinfo/main.cpp deleted file mode 100644 index f2a20b3..0000000 --- a/examples/xmlpatterns/trafficinfo/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -#include <QtWidgets/QApplication> - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - MainWindow window; - window.show(); - - return app.exec(); -} diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp deleted file mode 100644 index 3e43925..0000000 --- a/examples/xmlpatterns/trafficinfo/mainwindow.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" -#include "stationdialog.h" - -#include <QtCore/QSettings> -#include <QtCore/QTimer> -#include <QtWidgets/QAction> -#include <QtWidgets/QApplication> -#include <QtGui/QBitmap> -#include <QtGui/QLinearGradient> -#include <QtGui/QMouseEvent> -#include <QtGui/QPainter> - -MainWindow::MainWindow() - : QWidget(0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) -{ - QAction *quitAction = new QAction(tr("E&xit"), this); - quitAction->setShortcuts(QKeySequence::Quit); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - QAction *configAction = new QAction(tr("&Select station..."), this); - configAction->setShortcut(tr("Ctrl+C")); - connect(configAction, SIGNAL(triggered()), this, SLOT(configure())); - - addAction(configAction); - addAction(quitAction); - - setContextMenuPolicy(Qt::ActionsContextMenu); - - setWindowTitle(tr("Traffic Info Oslo")); - - const QSettings settings("Qt Traffic Info", "trafficinfo"); - m_station = StationInformation(settings.value("stationId", "03012130").toString(), - settings.value("stationName", "Nydalen [T-bane] (OSL)").toString()); - m_lines = settings.value("lines", QStringList()).toStringList(); - - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeInformation())); - timer->start(1000*60*5); - QMetaObject::invokeMethod(this, SLOT(updateTimeInformation()), Qt::QueuedConnection); -} - -MainWindow::~MainWindow() -{ - QSettings settings("Qt Traffic Info", "trafficinfo"); - settings.setValue("stationId", m_station.id()); - settings.setValue("stationName", m_station.name()); - settings.setValue("lines", m_lines); -} - -QSize MainWindow::sizeHint() const -{ - return QSize(300, 200); -} - -void MainWindow::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() & Qt::LeftButton) { - move(event->globalPos() - m_dragPosition); - event->accept(); - } -} - -void MainWindow::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - m_dragPosition = event->globalPos() - frameGeometry().topLeft(); - event->accept(); - } -} - -void MainWindow::paintEvent(QPaintEvent*) -{ - const QPoint start(width()/2, 0); - const QPoint finalStop(width()/2, height()); - QLinearGradient gradient(start, finalStop); - const QColor qtGreen(102, 176, 54); - gradient.setColorAt(0, qtGreen.dark()); - gradient.setColorAt(0.5, qtGreen); - gradient.setColorAt(1, qtGreen.dark()); - - QPainter p(this); - p.fillRect(0, 0, width(), height(), gradient); - - QFont headerFont("Sans Serif", 12, QFont::Bold); - QFont normalFont("Sans Serif", 9, QFont::Normal); - - // draw it twice for shadow effect - p.setFont(headerFont); - QRect headerRect(1, 1, width(), 25); - p.setPen(Qt::black); - p.drawText(headerRect, Qt::AlignCenter, m_station.name()); - - headerRect.moveTopLeft(QPoint(0, 0)); - p.setPen(Qt::white); - p.drawText(headerRect, Qt::AlignCenter, m_station.name()); - - p.setFont(normalFont); - int pos = 40; - for (int i = 0; i < m_times.count() && i < 9; ++i) { - p.setPen(Qt::black); - p.drawText(51, pos + 1, m_times.at(i).time()); - p.drawText(101, pos + 1, m_times.at(i).direction()); - - p.setPen(Qt::white); - p.drawText(50, pos, m_times.at(i).time()); - p.drawText(100, pos, m_times.at(i).direction()); - - pos += 18; - } -} - -void MainWindow::resizeEvent(QResizeEvent*) -{ - QBitmap maskBitmap(width(), height()); - maskBitmap.clear(); - - QPainter p(&maskBitmap); - p.setBrush(Qt::black); - p.drawRoundRect(0, 0, width(), height(), 20, 30); - p.end(); - - setMask(maskBitmap); -} - -void MainWindow::updateTimeInformation() -{ - m_times = TimeQuery::query(m_station.id(), m_lines, QDateTime::currentDateTime()); - - update(); -} - -void MainWindow::configure() -{ - StationDialog dlg(m_station.name(), m_lines, this); - if (dlg.exec()) { - m_station = dlg.selectedStation(); - m_lines = dlg.lineNumbers(); - updateTimeInformation(); - } -} diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.h b/examples/xmlpatterns/trafficinfo/mainwindow.h deleted file mode 100644 index 4573e5a..0000000 --- a/examples/xmlpatterns/trafficinfo/mainwindow.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include "stationquery.h" -#include "timequery.h" - -#include <QtWidgets/QWidget> - -class MainWindow : public QWidget -{ - Q_OBJECT - - public: - MainWindow(); - ~MainWindow(); - - QSize sizeHint() const; - - protected: - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - - private Q_SLOTS: - void updateTimeInformation(); - void configure(); - - private: - QPoint m_dragPosition; - TimeInformation::List m_times; - StationInformation m_station; - QStringList m_lines; -}; - -#endif diff --git a/examples/xmlpatterns/trafficinfo/station_example.wml b/examples/xmlpatterns/trafficinfo/station_example.wml deleted file mode 100644 index da7f82f..0000000 --- a/examples/xmlpatterns/trafficinfo/station_example.wml +++ /dev/null @@ -1,31 +0,0 @@ -//! [0] -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> -<wml> -<template> - <do type="prev" name="b" label="Tilbake"><prev/></do> - <do type="options" label="Nytt søk"><go href="velkommen.wml"/></do> -</template> -<card id="Liste" title="Trafikanten"> -<p> -<small> -Velg stoppsted: <br /> - - <a title="Velg" href="DateLink.asp?fra=05280320">Nydalen (Østre Toten) (Ø-T)</a><br /> - - <a title="Velg" href="DateLink.asp?fra=03012126">Nydalen st. (i Store ringvei) (OSL)</a><br /> - - <a title="Velg" href="DateLink.asp?fra=03012131">Nydalen T [buss] (OSL)</a><br /> - - <a title="Velg" href="DateLink.asp?fra=03012130">Nydalen [T-bane] (OSL)</a><br /> - - <a title="Velg" href="DateLink.asp?fra=03012125">Nydalen [tog] (OSL)</a><br /> - -<br/> -<a title="Nytt søk" href="Velkommen.wml">"Nytt søk"</a> -<br/> -</small> -</p> -</card> -</wml> -//! [0] diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.cpp b/examples/xmlpatterns/trafficinfo/stationdialog.cpp deleted file mode 100644 index 6cd267f..0000000 --- a/examples/xmlpatterns/trafficinfo/stationdialog.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stationdialog.h" -#include "ui_stationdialog.h" - -#include <QtCore/QAbstractListModel> - -class StationModel : public QAbstractListModel -{ - public: - enum Role - { - StationIdRole = Qt::UserRole + 1, - StationNameRole - }; - - StationModel(QObject *parent = 0) - : QAbstractListModel(parent) - { - } - - void setStations(const StationInformation::List &list) - { - m_stations = list; - layoutChanged(); - } - - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const - { - if (!parent.isValid()) - return m_stations.count(); - else - return 0; - } - - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const - { - if (!parent.isValid()) - return 1; - else - return 0; - } - - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const - { - if (!index.isValid()) - return QVariant(); - - if (index.column() > 1 || index.row() >= m_stations.count()) - return QVariant(); - - const StationInformation info = m_stations.at(index.row()); - if (role == Qt::DisplayRole || role == StationNameRole) - return info.name(); - else if (role == StationIdRole) - return info.id(); - - return QVariant(); - } - - private: - StationInformation::List m_stations; -}; - -StationDialog::StationDialog(const QString &name, const QStringList &lineNumbers, QWidget *parent) - : QDialog(parent) -{ - m_ui.setupUi(this); - - connect(m_ui.m_searchButton, SIGNAL(clicked()), this, SLOT(searchStations())); - - m_ui.m_searchButton->setDefault(true); - m_ui.m_input->setText(name); - - m_model = new StationModel(this); - m_ui.m_view->setModel(m_model); - - for (int i = 0; i < lineNumbers.count(); ++i) { - if (i == 0) - m_ui.m_line1->setText(lineNumbers.at(i)); - else if (i == 1) - m_ui.m_line2->setText(lineNumbers.at(i)); - else if (i == 2) - m_ui.m_line3->setText(lineNumbers.at(i)); - else if (i == 3) - m_ui.m_line4->setText(lineNumbers.at(i)); - } - - QMetaObject::invokeMethod(this, SLOT(searchStations()), Qt::QueuedConnection); -} - -StationInformation StationDialog::selectedStation() const -{ - const QModelIndex index = m_ui.m_view->currentIndex(); - - if (!index.isValid()) - return StationInformation(); - - return StationInformation(index.data(StationModel::StationIdRole).toString(), - index.data(StationModel::StationNameRole).toString()); -} - -QStringList StationDialog::lineNumbers() const -{ - QStringList lines; - - if (!m_ui.m_line1->text().simplified().isEmpty()) - lines.append(m_ui.m_line1->text().simplified()); - if (!m_ui.m_line2->text().simplified().isEmpty()) - lines.append(m_ui.m_line2->text().simplified()); - if (!m_ui.m_line3->text().simplified().isEmpty()) - lines.append(m_ui.m_line3->text().simplified()); - if (!m_ui.m_line4->text().simplified().isEmpty()) - lines.append(m_ui.m_line4->text().simplified()); - - return lines; -} - -void StationDialog::searchStations() -{ - m_model->setStations(StationQuery::query(m_ui.m_input->text())); - m_ui.m_view->keyboardSearch(m_ui.m_input->text()); -} diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.h b/examples/xmlpatterns/trafficinfo/stationdialog.h deleted file mode 100644 index c720292..0000000 --- a/examples/xmlpatterns/trafficinfo/stationdialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATIONDIALOG_H -#define STATIONDIALOG_H - -#include <QtWidgets/QDialog> - -#include "stationquery.h" -#include "ui_stationdialog.h" - -class StationModel; - -class StationDialog : public QDialog -{ - Q_OBJECT - - public: - StationDialog(const QString &id, const QStringList &lineNumbers, QWidget *parent); - - StationInformation selectedStation() const; - QStringList lineNumbers() const; - - private Q_SLOTS: - void searchStations(); - - private: - Ui_StationDialog m_ui; - StationModel *m_model; -}; - -#endif diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.ui b/examples/xmlpatterns/trafficinfo/stationdialog.ui deleted file mode 100644 index 254dedb..0000000 --- a/examples/xmlpatterns/trafficinfo/stationdialog.ui +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>StationDialog</class> - <widget class="QDialog" name="StationDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>462</width> - <height>391</height> - </rect> - </property> - <property name="windowTitle"> - <string>Select Station</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLineEdit" name="m_input"/> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="m_searchButton"> - <property name="text"> - <string>Search</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QListView" name="m_view"/> - </item> - <item row="2" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Lines:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="m_line1"/> - </item> - <item> - <widget class="QLineEdit" name="m_line2"/> - </item> - <item> - <widget class="QLineEdit" name="m_line3"/> - </item> - <item> - <widget class="QLineEdit" name="m_line4"/> - </item> - </layout> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>StationDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>228</x> - <y>373</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>StationDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>296</x> - <y>372</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/xmlpatterns/trafficinfo/stationquery.cpp b/examples/xmlpatterns/trafficinfo/stationquery.cpp deleted file mode 100644 index e445f15..0000000 --- a/examples/xmlpatterns/trafficinfo/stationquery.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stationquery.h" - -#include <QtCore/QStringList> -#include <QtXmlPatterns/QXmlQuery> - -StationInformation::StationInformation() -{ -} - -StationInformation::StationInformation(const QString &id, const QString &name) - : m_id(id), m_name(name) -{ -} - -QString StationInformation::id() const -{ - return m_id; -} - -QString StationInformation::name() const -{ - return m_name; -} - -//! [0] -StationInformation::List StationQuery::query(const QString &name) -{ - const QString stationIdQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/substring(@href,18)"); - const QString stationNameQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/string()"); - - QStringList stationIds; - QStringList stationNames; - - QXmlQuery query; - - query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name)))); - query.setQuery(stationIdQueryUrl); - query.evaluateTo(&stationIds); - - query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name)))); - query.setQuery(stationNameQueryUrl); - query.evaluateTo(&stationNames); - - if (stationIds.count() != stationNames.count()) // something went wrong... - return StationInformation::List(); - - StationInformation::List information; - for (int i = 0; i < stationIds.count(); ++i) - information.append(StationInformation(stationIds.at(i), stationNames.at(i))); - - return information; -} -//! [0] diff --git a/examples/xmlpatterns/trafficinfo/stationquery.h b/examples/xmlpatterns/trafficinfo/stationquery.h deleted file mode 100644 index bda7f11..0000000 --- a/examples/xmlpatterns/trafficinfo/stationquery.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef STATIONQUERY_H -#define STATIONQUERY_H - -#include <QtCore/QList> -#include <QtCore/QString> - -//! [0] -class StationInformation -{ - public: - typedef QList<StationInformation> List; - - StationInformation(); - StationInformation(const QString &id, const QString &name); - - QString id() const; - QString name() const; - - private: - QString m_id; - QString m_name; -}; -//! [0] - -//! [1] -class StationQuery -{ - public: - static StationInformation::List query(const QString &name); -}; -//! [1] - -#endif diff --git a/examples/xmlpatterns/trafficinfo/time_example.wml b/examples/xmlpatterns/trafficinfo/time_example.wml deleted file mode 100644 index 75e3408..0000000 --- a/examples/xmlpatterns/trafficinfo/time_example.wml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> -<wml> -<template> - <do type="prev" name="b" label="Tilbake"><prev/></do> - <do type="options" name="n" label="Nytt søk"><go href="velkommen.wml"/></do> -</template> -<card id="Liste" title="Trafikanten"> -<p> -<small> -Fra Nydalen [T-bane]:<br /> - - <a href="Rute.asp?d=3011030&t=21832&l=4&Start=1">13.00</a> - 4 Bergkrystallen [T-bane]<br /> - - <a href="Rute.asp?d=3012585&t=22543&l=6&Start=1">13.05</a> - 6 Åsjordet<br /> - - <a href="Rute.asp?d=3011730&t=22264&l=5&Start=1">13.09</a> - 5 Vestli [T-bane]<br /> - - <a href="Rute.asp?d=3012120&t=22080&l=5&Start=1">13.13</a> - 5 Storo [T-bane]<br /> - - <a href="Rute.asp?d=3011030&t=21831&l=4&Start=1">13.15</a> - 4 Bergkrystallen [T-bane]<br /> - - <a href="Rute.asp?d=3012585&t=22542&l=6&Start=1">13.20</a> - 6 Åsjordet<br /> - - <a href="Rute.asp?d=3011730&t=22263&l=5&Start=1">13.24</a> - 5 Vestli [T-bane]<br /> - - <a href="Rute.asp?d=3012120&t=22079&l=5&Start=1">13.28</a> - 5 Storo [T-bane]<br /> - - <a href="Rute.asp?d=3011030&t=21830&l=4&Start=1">13.30</a> - 4 Bergkrystallen [T-bane]<br /> - - <a href="Rute.asp?d=3012585&t=22541&l=6&Start=1">13.35</a> - 6 Åsjordet<br /> - - <br /> - <a title="Neste 10" href="F.asp?f=03012130&t=13&m=35&d=14.11.2008&Start=11">Neste 10 avganger</a> - -<br/> -<a href="F.asp?f=03012130&t=14&d=14.11.2008&Start=1">Neste timeintervall</a> -<br/> -<a href="F.asp?f=03012130&t=12&d=14.11.2008&Start=1">Forrige timeintervall</a> -<br/> -<a href="Velkommen.wml">"Nytt søk"</a> -<br/> -</small> -</p> -</card> -</wml> diff --git a/examples/xmlpatterns/trafficinfo/timequery.cpp b/examples/xmlpatterns/trafficinfo/timequery.cpp deleted file mode 100644 index 547c3b6..0000000 --- a/examples/xmlpatterns/trafficinfo/timequery.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "timequery.h" - -#include <QtCore/QStringList> -#include <QtXmlPatterns/QXmlQuery> - -TimeInformation::TimeInformation(const QString &time, const QString &direction) - : m_time(time), m_direction(direction) -{ -} - -QString TimeInformation::time() const -{ - return m_time; -} - -QString TimeInformation::direction() const -{ - return m_direction; -} - -TimeInformation::List TimeQuery::query(const QString &stationId, const QStringList &lineNumbers, const QDateTime &dateTime) -{ - const TimeInformation::List information = queryInternal(stationId, dateTime); - - TimeInformation::List filteredInformation; - - if (!lineNumbers.isEmpty()) { - for (int i = 0; i < information.count(); ++i) { - const TimeInformation info = information.at(i); - for (int j = 0; j < lineNumbers.count(); ++j) { - if (info.direction().startsWith(QString("%1 ").arg(lineNumbers.at(j)))) - filteredInformation.append(info); - } - } - } else { - filteredInformation = information; - } - - return filteredInformation; -} - -//! [1] -TimeInformation::List TimeQuery::queryInternal(const QString &stationId, const QDateTime &dateTime) -{ - const QString timesQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&t=%2&m=%3&d=%4&start=1')/wml/card/p/small/a[fn:starts-with(@href, 'Rute')]/string()") - .arg(stationId) - .arg(dateTime.time().hour()) - .arg(dateTime.time().minute()) - .arg(dateTime.toString("dd.MM.yyyy")); - const QString directionsQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&t=%2&m=%3&d=%4&start=1')/wml/card/p/small/text()[matches(., '[0-9].*')]/string()") - .arg(stationId) - .arg(dateTime.time().hour()) - .arg(dateTime.time().minute()) - .arg(dateTime.toString("dd.MM.yyyy")); - - QStringList times; - QStringList directions; - - QXmlQuery query; - query.setQuery(timesQueryUrl); - query.evaluateTo(×); - - query.setQuery(directionsQueryUrl); - query.evaluateTo(&directions); - - if (times.count() != directions.count()) // something went wrong... - return TimeInformation::List(); - - TimeInformation::List information; - for (int i = 0; i < times.count(); ++i) - information.append(TimeInformation(times.at(i).simplified(), directions.at(i).simplified())); - - return information; -} -//! [1] diff --git a/examples/xmlpatterns/trafficinfo/timequery.h b/examples/xmlpatterns/trafficinfo/timequery.h deleted file mode 100644 index a792dd8..0000000 --- a/examples/xmlpatterns/trafficinfo/timequery.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TIMEQUERY_H -#define TIMEQUERY_H - -#include <QtCore/QDateTime> -#include <QtCore/QList> -#include <QtCore/QStringList> - -class TimeInformation -{ - public: - typedef QList<TimeInformation> List; - - TimeInformation(const QString &time, const QString &direction); - - QString time() const; - QString direction() const; - - private: - QString m_time; - QString m_direction; -}; - - -class TimeQuery -{ - public: - static TimeInformation::List query(const QString &stationId, const QStringList &lineNumbers, const QDateTime &dateTime); - - private: - static TimeInformation::List queryInternal(const QString &stationId, const QDateTime &dateTime); -}; - -#endif diff --git a/examples/xmlpatterns/trafficinfo/trafficinfo.desktop b/examples/xmlpatterns/trafficinfo/trafficinfo.desktop deleted file mode 100644 index 246d34b..0000000 --- a/examples/xmlpatterns/trafficinfo/trafficinfo.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=TrafficInfo -Exec=/opt/usr/bin/trafficinfo -Icon=trafficinfo -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/xmlpatterns/trafficinfo/trafficinfo.pro b/examples/xmlpatterns/trafficinfo/trafficinfo.pro deleted file mode 100644 index fd71fac..0000000 --- a/examples/xmlpatterns/trafficinfo/trafficinfo.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets xmlpatterns -HEADERS = mainwindow.h stationdialog.h stationquery.h timequery.h -SOURCES = main.cpp mainwindow.cpp stationdialog.cpp stationquery.cpp timequery.cpp -FORMS = stationdialog.ui - -target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/trafficinfo -INSTALLS += target - -maemo5: CONFIG += qt_example - -maemo5: warning(This example might not fully work on Maemo platform) -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/xmlpatterns/xmlpatterns.pro b/examples/xmlpatterns/xmlpatterns.pro index ede6b3a..cce970f 100644 --- a/examples/xmlpatterns/xmlpatterns.pro +++ b/examples/xmlpatterns/xmlpatterns.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs SUBDIRS += xquery -!contains(QT_CONFIG, no-widgets): SUBDIRS += filetree trafficinfo schema recipes +!contains(QT_CONFIG, no-widgets): SUBDIRS += filetree schema recipes EXAMPLE_FILES = \ shared |