Skip to content

Commit

Permalink
Conver page support
Browse files Browse the repository at this point in the history
  • Loading branch information
k0rmarun committed Dec 30, 2018
1 parent ddf7245 commit 0776c04
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 62 deletions.
6 changes: 4 additions & 2 deletions harbour-companion.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ SOURCES += src/companion.cpp \
src/conference.cpp \
src/conferenceday.cpp \
src/conferenceevent.cpp \
src/conferenceeventcompare.cpp
src/conferenceeventcompare.cpp \
src/staticloader.cpp

OTHER_FILES += qml/companion.qml \
qml/cover/CoverPage.qml \
Expand All @@ -51,7 +52,8 @@ HEADERS += \
src/conferenceday.h \
src/conferenceevent.h \
src/conferenceeventsortingorder.h \
src/conferenceeventcompare.h
src/conferenceeventcompare.h \
src/staticloader.h

DISTFILES += \
rpm/harbour-companion.changes \
Expand Down
2 changes: 1 addition & 1 deletion qml/companion.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import "js/Global.js" as Global

ApplicationWindow
{
initialPage: Component { ConferenceView { } }
initialPage: Qt.resolvedUrl("pages/ConferenceView.qml")
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: defaultAllowedOrientations

Expand Down
35 changes: 31 additions & 4 deletions qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,39 @@

import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.companion 1.0

import "../js/Global.js" as Global

CoverBackground {
Label {
id: label
anchors.centerIn: parent
text: qsTr("Nothing to\nsee yet")
id: page
property var loader

SilicaListView {
model: loader.conference.getNextEvents();
anchors.fill: parent
delegate: ListItem {
width: parent.width
Label {
id: itemTime
text: Global.formatTime(modelData.start)
font.pixelSize: Theme.fontSizeExtraSmall
width: 80
}
Label {
anchors.left: itemTime.right
text: modelData.title
font.pixelSize: Theme.fontSizeExtraSmall
lineHeight: 0.8
wrapMode: "WordWrap"
maximumLineCount: 3
width: parent.width - 80
}
}
}

Component.onCompleted: {
loader = StaticLoader.getLoader()
}
}

4 changes: 4 additions & 0 deletions qml/pages/ConferenceDayView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ Page {
text: modelData.room
anchors.top: title.bottom
anchors.right: title.right
anchors.left: times.right
truncationMode: TruncationMode.Elide
horizontalAlignment: "AlignRight"
maximumLineCount: 1
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
}
Expand Down
15 changes: 7 additions & 8 deletions qml/pages/ConferenceView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ import "../js/Global.js" as Global

Page {
id: page

Loader{
id: loader
}

property var loader
// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations: Orientation.All

Expand All @@ -59,8 +55,7 @@ Page {
MenuItem {
text: qsTr("Select conference")
onClicked: {

pageStack.push(Qt.resolvedUrl("SelectConferenceView.qml"), {loader:loader});
pageStack.push(Qt.resolvedUrl("SelectConferenceView.qml"), {loader:Loader});
}

}
Expand Down Expand Up @@ -96,7 +91,7 @@ Page {
}

ColumnView{
model:loader.conference.days
model: loader.conference.days
width: parent.width
itemHeight: Theme.itemSizeSmall
delegate: BackgroundItem {
Expand All @@ -115,5 +110,9 @@ Page {
}
}
}

Component.onCompleted: {
loader = StaticLoader.getLoader()
}
}

22 changes: 0 additions & 22 deletions qml/pages/SelectConferenceView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,6 @@ Page {
// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations: Orientation.All

// ListModel {
// id: eventModel
// ListElement {
// name: qsTr("34. Chaos Communication Congress")
// cachename: "%0c3"
// iteration: 2017
// url: "https://fahrplan.events.ccc.de/congress/%0/Fahrplan/schedule.json"
// }
// ListElement {
// name: qsTr("17. Gulasch Programmier Nacht")
// cachename: "gpn%0"
// iteration:17
// url: "https://entropia.de/GPN%0:Fahrplan:JSON?action=raw"
// }
// ListElement {
// name: qsTr("MRMCD 17")
// cachename: "mrmcd%0"
// iteration: 2017
// url: "https://%0.mrmcd.net/fahrplan/schedule.json"
// }
// }

SilicaListView {
id: listView

Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-companion.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Name: harbour-companion
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Chaos Companion
Version: 0.5
Version: 0.6
Release: 1
Group: Qt/Qt
License: LICENSE
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-companion.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: harbour-companion
Summary: Chaos Companion
Version: 0.5
Version: 0.6
Release: 1
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
Expand Down
4 changes: 4 additions & 0 deletions src/companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "loader.h"
#include "event.h"
#include "conferenceeventsortingorder.h"
#include "staticloader.h"
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
Expand Down Expand Up @@ -65,6 +66,9 @@ int main(int argc, char *argv[])
//
// For details see:
// https://harbour.jolla.com/faq#1.5.0
qmlRegisterSingletonType<StaticLoader>("harbour.companion", 1, 0, "StaticLoader", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
return new StaticLoader();
});
qmlRegisterType<Loader>("harbour.companion", 1, 0, "Loader");
qmlRegisterType<Conference>("harbour.companion", 1, 0, "Conference");
qmlRegisterType<ConferenceDay>("harbour.companion", 1, 0, "ConferenceDay");
Expand Down
30 changes: 30 additions & 0 deletions src/conference.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "conference.h"
#include "conferenceeventcompare.h"

Conference::Conference(QObject *parent) : QObject(parent)
{
Expand Down Expand Up @@ -37,3 +38,32 @@ Conference* Conference::fromJson(const QJsonObject &json)
}
return conference;
}

QList<QObject*> Conference::getNextEvents()
{
QList<ConferenceEvent*> events;
QDateTime now = QDateTime::currentDateTime();
for(QObject* dayObj: days ){
ConferenceDay* day = dynamic_cast<ConferenceDay*>(dayObj);
if(day){
for(QObject* eventObj: day->events){
ConferenceEvent* event = dynamic_cast<ConferenceEvent*>(eventObj);
if(event){
if(event->start > now || event->end > now){
events.append(event);
}
}
}
}
}

ConferenceEventPointerCompare comparator;
comparator.sortingOrder = ConferenceEventSortingOrder::SortingOrder::BY_TIME;
std::sort(events.begin(), events.end(), comparator);

QList<QObject*> result;
for(int i = 0; i < std::min(5, events.size()); i++){
result.append(events.at(i));
}
return result;
}
2 changes: 2 additions & 0 deletions src/conference.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Conference : public QObject

static Conference* fromJson(const QJsonObject& json);

Q_INVOKABLE QList<QObject *> getNextEvents();

signals:
void titleChanged(const QString& title);
void startChanged(const QDate& date);
Expand Down
5 changes: 2 additions & 3 deletions src/conferenceday.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ class ConferenceDay : public QObject
Q_PROPERTY(QList<QObject*> events MEMBER events NOTIFY eventsChanged)
Q_PROPERTY(QStringList rooms MEMBER rooms NOTIFY roomsChanged)
Q_PROPERTY(ConferenceEventSortingOrder::SortingOrder sortingOrder READ getSortingOrder WRITE setSortingOrder NOTIFY sortingOrderChanged)

public:
ConferenceEventSortingOrder::SortingOrder sortingOrder;

QDate date;
QList<QObject*> events;
QStringList rooms;
public:

explicit ConferenceDay(QObject *parent = nullptr);
void setDate(const QDate& date);
void addEvent(ConferenceEvent* event);
Expand Down
9 changes: 5 additions & 4 deletions src/conferenceevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ class ConferenceEvent : public QObject
Q_PROPERTY(QStringList persons MEMBER persons NOTIFY personsChanged)
Q_PROPERTY(QStringList links MEMBER links NOTIFY linksChanged)

QDateTime start, end;
QString room, title, subtitle, track, type, language, abstract, description;
bool record;
QStringList persons, links;
bool _compareByTime(const ConferenceEvent& b) const;
bool _compareByTitle(const ConferenceEvent& b) const;
bool _compareByTrack(const ConferenceEvent& b) const;
bool _compareByRoom(const ConferenceEvent& b) const;

public:
QDateTime start, end;
QString room, title, subtitle, track, type, language, abstract, description;
bool record;
QStringList persons, links;

explicit ConferenceEvent(QObject *parent = nullptr);
void setStartEnd(const QString& date, const QString& start, const QString& duration);
void setRoom(const QString& room);
Expand Down
7 changes: 7 additions & 0 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ QList<QObject*> generateEventList()
"https://fahrplan.events.ccc.de/congress/%0/Fahrplan/schedule.json"
)
);
eventList.append(
new Event(
"(Merged) Chaos Communication Congress",
2018-35,
"https://streaming.media.ccc.de/configs/conferences/%0c3/everything.schedule.json"
)
);
eventList.append(
new Event(
"Gulasch Programmier Nacht",
Expand Down
16 changes: 16 additions & 0 deletions src/staticloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "staticloader.h"

Loader* StaticLoader::loader = nullptr;

StaticLoader::StaticLoader(QObject *parent) : QObject(parent)
{

}

Loader *StaticLoader::getLoader() const
{
if(loader == nullptr){
loader = new Loader();
}
return loader;
}
21 changes: 21 additions & 0 deletions src/staticloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef STATICLOADER_H
#define STATICLOADER_H

#include <QObject>
#include "loader.h"

class StaticLoader : public QObject
{
Q_OBJECT
static Loader* loader;
public:
explicit StaticLoader(QObject *parent = nullptr);

Q_INVOKABLE Loader* getLoader() const;

signals:

public slots:
};

#endif // STATICLOADER_H
8 changes: 0 additions & 8 deletions translations/harbour-companion-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
<source>Nothing to
see yet</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SelectConferenceView</name>
<message>
Expand Down
8 changes: 0 additions & 8 deletions translations/harbour-companion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
<source>Nothing to
see yet</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SelectConferenceView</name>
<message>
Expand Down

0 comments on commit 0776c04

Please sign in to comment.