Skip to content

Commit

Permalink
Intial commit of open source version of Fly.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbu committed Oct 22, 2012
0 parents commit 91592d8
Show file tree
Hide file tree
Showing 75 changed files with 4,810 additions and 0 deletions.
Binary file added Fly.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Fly_package.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions OpenFly.desktop
@@ -0,0 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.10
Type=Application
Terminal=false
Name=OpenFly
Exec=/usr/bin/single-instance /opt/openfly/bin/openfly
Icon=Fly
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable
86 changes: 86 additions & 0 deletions OpenFly.pro
@@ -0,0 +1,86 @@
######################################################################
# Automatically generated by qmake (2.01a) Thu Sep 9 16:27:53 2010
######################################################################

TEMPLATE = app
TARGET = openfly
DEPENDPATH += .
INCLUDEPATH += .
VERSION = 1.0.0

DEFINES += TARGET="\"$$TARGET\"" VERSION="\"$$VERSION\""

# Input
HEADERS += \
node.h \
receiver.h \
util.h \
xmldatasource.h \
airportnames.h \
flightstatuses.h \
flighttimes.h \
flightsmodel.h \
settings.h \
constants.h

SOURCES += \
receiver.cpp \
xmldatasource.cpp \
airportnames.cpp \
flightstatuses.cpp \
flighttimes.cpp \
flightsmodel.cpp \
settings.cpp \
main.cpp

RESOURCES += \
fly.qrc

TRANSLATIONS += \

QT += network declarative

symbian {
TARGET.UID3 = 0xe36f34d8
ICON = images/fly_symbiansurround2.svg
TARGET.CAPABILITY += NetworkServices
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x3D09000
vendorinfo = \
"%{\"GPLv3\"}" \
":\"GPLv3\""
vendor.pkg_prerules = vendorinfo
DEPLOYMENT += vendor
}

linux-g++-maemo*:{
DEFINES += Q_OS_MAEMO
}

unix:!symbian:!maemo5 {
target.path = /opt/openfly/bin
INSTALLS += target
icon.files = OpenFly.svg
icon.path = /usr/share/icons/hicolor/scalable/apps
INSTALLS += icon
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications
INSTALLS += desktopfile
}

OTHER_FILES += \
qtc_packaging/debian_harmattan/rules \
qtc_packaging/debian_harmattan/README \
qtc_packaging/debian_harmattan/copyright \
qtc_packaging/debian_harmattan/control \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog \
qtc_packaging/debian_harmattan/rules \
qtc_packaging/debian_harmattan/README \
qtc_packaging/debian_harmattan/manifest.aegis \
qtc_packaging/debian_harmattan/copyright \
qtc_packaging/debian_harmattan/control \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog


51 changes: 51 additions & 0 deletions OpenFly.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions airlinenames.cpp
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2010 Cutehacks AS. All rights reserved.
* info@cutehacks.com
* http://cutehacks.com
*
*/

#include "airlinenames.h"
#include "node.h"
#include <QStack>

AirlineNames::AirlineNames(QObject *parent)
: XmlDataSource(parent)
{
setUrl(QUrl("http://flydata.avinor.no/airlineNames.asp"));
setRefreshRate(86400000); //msecs == 24h
QObject::connect(this, SIGNAL(dataUpdated(Node*)), this, SLOT(createMapping(Node*)));
}

AirlineNames::~AirlineNames()
{
}

QString AirlineNames::airlineName(const QString &code) const
{
return m_mapping.value(code, code);
}

void AirlineNames::createMapping(Node *root)
{
m_mapping.clear();
QStack<Node*> pending;
pending.push(root);
while (!pending.isEmpty()) {
Node *node = pending.pop();
if (node->type() == "airlineName")
m_mapping.insert(node->attribute("code"), node->attribute("name"));
for (int i = 0; i < node->childCount(); ++i)
pending.push(node->child(i));
}
}
30 changes: 30 additions & 0 deletions airlinenames.h
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2010 Cutehacks AS. All rights reserved.
* info@cutehacks.com
* http://cutehacks.com
*
*/

#ifndef AIRLINENAMES_H
#define AIRLINENAMES_H

#include "xmldatasource.h"
#include <QHash>

class AirlineNames : public XmlDataSource
{
Q_OBJECT
public:
AirlineNames(QObject *parent = 0);
~AirlineNames();

QString airlineName(const QString &code) const;

protected Q_SLOTS:
void createMapping(Node *root);

private:
QHash<QString, QString> m_mapping;
};

#endif
127 changes: 127 additions & 0 deletions airportitem.cpp
@@ -0,0 +1,127 @@
/*
* Copyright (C) 2010 Cutehacks AS. All rights reserved.
* info@cutehacks.com
* http://cutehacks.com
*
*/

#include "airportitem.h"
#include "constants.h"

#include <QPainter>
#include <QMouseEvent>

AirportItem::AirportItem(int index, const QString airport, QWidget *parent)
: QWidget(parent),
m_index(index),
m_airport(airport),
m_active(false),
m_pressed(false),
m_counter(0)
{
setFixedHeight(48);
QFont fnt(font());
fnt.setPixelSize(pixelSizes[0][1]);
setFont(fnt);
}

AirportItem::~AirportItem()
{
}

QString AirportItem::airport() const
{
return m_airport;
}

bool AirportItem::active() const
{
return m_pressed;
}

void AirportItem::setActive(bool set)
{
m_active = set;
update();
}

void AirportItem::startAnimation()
{
m_counter = 0;
m_timer.start(200, this);
}

void AirportItem::stopAnimation()
{
m_timer.stop();
m_counter = 0;
}

void AirportItem::mousePressEvent(QMouseEvent *event)
{
m_pressPosition = event->pos();
m_pressed = true;
update();
event->ignore();
}

void AirportItem::mouseMoveEvent(QMouseEvent *event)
{
const QPoint movement = event->pos() - m_pressPosition;
if (movement.manhattanLength() > 16) {
m_pressed = false;
update();
}
event->ignore();
}

void AirportItem::mouseReleaseEvent(QMouseEvent *event)
{
if (m_pressed) {
emit activated(m_index);
m_pressed = false;
update();
}
event->ignore();
}

void AirportItem::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);

QColor color;
if (m_active) {
QFont fnt(font());
fnt.setBold(true);
painter.setFont(fnt);
color = Qt::white;
} else {
color = palette().color(QPalette::Text);
}

const QRect bounds = rect().adjusted(12, 8, -12, -8);
if (m_pressed) {
painter.fillRect(bounds, color);
painter.setPen(palette().color(QPalette::Base));
} else {
painter.setPen(color);
}
painter.drawText(rect().adjusted(16, 0, -16, 0), m_airport, QTextOption(Qt::AlignVCenter));

if (m_timer.isActive()) {
const int x = width() - 96;
const int h = height() - 32;
unsigned int i = (m_counter % 5);
for (unsigned int j = 0; j < 5; ++j)
painter.fillRect(x + (j * 16) + 1, 16, 14, h, i == j ? color : Qt::darkGray);
}
}

void AirportItem::timerEvent(QTimerEvent *event)
{
if (m_timer.timerId() == event->timerId()) {
++m_counter;
update();
}
}

0 comments on commit 91592d8

Please sign in to comment.