Skip to content

Commit

Permalink
Rebranding for 34c3
Browse files Browse the repository at this point in the history
Added suppot for all of c3, gpn, mrmcd
  • Loading branch information
k0rmarun committed Dec 14, 2017
1 parent 60012eb commit f90340f
Show file tree
Hide file tree
Showing 28 changed files with 502 additions and 298 deletions.
4 changes: 2 additions & 2 deletions companion.desktop → harbour-companion.desktop
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Desktop Entry]
Type=Application
X-Nemo-Application-Type=silica-qt5
Icon=companion
Exec=companion
Icon=harbour-companion
Exec=harbour-companion
Name=companion
# translation example:
# your app name in German locale (de)
Expand Down
27 changes: 13 additions & 14 deletions companion.pro → harbour-companion.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@
# - translation filenames have to be changed

# The name of your application
TARGET = companion
TARGET = harbour-companion

QT += qml

CONFIG += sailfishapp

SOURCES += src/companion.cpp \
src/schedule.cpp \
src/memory.cpp
src/loader.cpp

OTHER_FILES += qml/companion.qml \
qml/cover/CoverPage.qml \
rpm/companion.spec \
rpm/companion.yaml \
translations/*.ts \
companion.desktop
translations/*.ts

SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256

Expand All @@ -37,18 +33,21 @@ CONFIG += sailfishapp_i18n
# planning to localize your app, remember to comment out the
# following TRANSLATIONS line. And also do not forget to
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/companion-de.ts
TRANSLATIONS += translations/harbour-companion-de.ts

HEADERS += \
src/schedule.h \
src/memory.h
src/loader.h

DISTFILES += \
qml/pages/MainView.qml \
qml/pages/DateView.qml \
qml/js/Global.js \
qml/pages/SubDateView.qml \
rpm/companion.changes
qml/pages/DateView.qml \
qml/pages/SelectConferenceView.qml \
qml/pages/ConferenceView.qml \
qml/pages/EventView.qml \
rpm/harbour-companion.changes \
rpm/harbour-companion.spec \
rpm/harbour-companion.yaml \
harbour-companion.desktop

desktop.files = $${TARGET}.desktop
desktop.path = /usr/share/applications
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 1 addition & 5 deletions qml/companion.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@ import "js/Global.js" as Global

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

id: root
property int date

Schedule {
id: schedule
}
}

87 changes: 87 additions & 0 deletions qml/js/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,90 @@
function padLeft(nr, n, str){
return Array(n-String(nr).length+1).join(str||'0')+nr;
}

// Objects are grouped by place => regroup by time
function groupByTime(objects){
var newData = []
var groupedByTime = {}
for(var room in objects){
for(var elem in objects[room]){
var tmp = objects[room][elem]
if(!groupedByTime[tmp.start]){
groupedByTime[tmp.start] = []
}

groupedByTime[tmp.start].push(tmp);
}
}
for(var time in groupedByTime){
for(var elem1 in groupedByTime[time]){
var tmp1 = groupedByTime[time][elem1]
var start = tmp1.start

var startHours = parseInt(start[0]+start[1])
var durationHours = parseInt(tmp1.duration[0]+tmp1.duration[1])
var startMinute = parseInt(start[3]+start[4])
var durationMinute = parseInt(tmp1.duration[3]+tmp1.duration[4])

var endTime = (startHours*60)+startMinute+(durationHours*60)+durationMinute
var end = padLeft(Math.floor(endTime/60),2)+":"+padLeft(endTime%60,2)
tmp1["end"] = end;

newData.push(tmp1);
}
}
return newData
}

function compareTime(aTime, aPlace, bTime, bPlace){
//Sort by time
if(aTime > bTime)
return 1;
if(aTime < bTime)
return -1;

//Same time => Sort by room name
if(aPlace > bPlace)
return 1;
if(aPlace < bPlace)
return -1;

//Whatever
return 0;
}

function comparePlace(aTime, aPlace, bTime, bPlace){
//Sort by room name
if(aPlace > bPlace)
return 1;
if(aPlace < bPlace)
return -1;

//Sort by time
if(aTime > bTime)
return 1;
if(aTime < bTime)
return -1;

//Whatever
return 0;
}

function orderBy(objects, byPlace){
objects = objects.sort(function(a,b){
//Late night events are on the wrong date in the fahrplan sheet
var aStart = parseInt(a.start[0]+a.start[1]);
var bStart = parseInt(b.start[0]+b.start[1]);
if(aStart < 7){
aStart += 30;
}
if(bStart < 7){
bStart += 30;
}

if(byPlace)
return comparePlace(aStart, a.room, bStart, b.room);
return compareTime(aStart, a.room, bStart, b.room);
});
return objects;
}
61 changes: 22 additions & 39 deletions qml/pages/MainView.qml → qml/pages/ConferenceView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,39 @@ import "../js/Global.js" as Global
Page {
id: page

Loader{
id: loader
}

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

// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
leftMargin: Theme.paddingMedium
rightMargin: Theme.paddingMedium
anchors.fill: parent

// Tell SilicaFlickable the height of its content.
contentHeight: column.height

PullDownMenu {

MenuItem {
text: qsTr("Select conference")
onClicked: {
pageStack.push(Qt.resolvedUrl("SelectConferenceView.qml"), {loader:loader});
}

}

MenuItem {
text: "Update schedule"
onClicked: {
update.execute("Updating schedule",function(){
schedule.loadFromNetwork();
loader.loadFromNetwork();
})
}
}
}
}

Expand All @@ -71,16 +86,16 @@ Page {
width: page.width
spacing: Theme.paddingSmall
PageHeader {
title: qsTr("GPN Companion")
title: qsTr("Chaos Companion")
}

Label {
text: "Updating..."
visible: schedule.updating
visible: loader.loading
}

ColumnView{
model:JSON.parse(schedule.schedule).schedule.conference.days
model:JSON.parse(loader.schedule).schedule.conference.days
width: parent.width
itemHeight: Theme.itemSizeSmall
delegate: BackgroundItem {
Expand All @@ -91,41 +106,9 @@ Page {
}

onClicked: {
var base = JSON.parse(schedule.schedule).schedule.conference.days[model.index];
var base = JSON.parse(loader.schedule).schedule.conference.days[model.index];
var data = base.rooms;
var newData = []
var timed = {}
for(var keys in data){
for(var elem in data[keys]){
var tmp = data[keys][elem]
if(!timed[tmp.start]){
timed[tmp.start] = []
}

timed[tmp.start].push(tmp);
}
}
for(var time in timed){
for(var elem1 in timed[time]){
var tmp1 = timed[time][elem1]
var start = tmp1.start

var hours = parseInt(start[0]+start[1])
var dhours = parseInt(tmp1.duration[0]+tmp1.duration[1])
var minute = parseInt(start[3]+start[4])
var dminute = parseInt(tmp1.duration[3]+tmp1.duration[4])

var endTime = (hours*60)+minute+(dhours*60)+dminute
var end = Global.padLeft(Math.floor(endTime/60),2)+":"+Global.padLeft(endTime%60,2)
tmp1["end"] = end;

newData.push(tmp1)
}
}

Memory.set("model", newData)
Memory.set("title", base.date)
pageStack.push(Qt.resolvedUrl("DateView.qml"));
pageStack.push(Qt.resolvedUrl("DateView.qml"), {model:base.rooms, title:base.date});
}
}
}
Expand Down
29 changes: 24 additions & 5 deletions qml/pages/DateView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,43 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import harbour.companion 1.0
import "../js/Global.js" as Global

Page {
id: page
property var model
property string title
property bool order: false

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

SilicaListView {

PullDownMenu {

MenuItem {
text: page.order ? qsTr("Sort by time") : qsTr("Sort by place")
onClicked: {
page.order = !page.order
page.model = Global.orderBy(page.model, page.order);
}
}
}

id: listView

x: Theme.paddingMedium
width: parent.width - 2*Theme.paddingMedium

model: Memory.get("model")
model: page.model
anchors.fill: parent
header: PageHeader {
title: Memory.get("title")
title: page.title
}
delegate: ListItem {
id: delegate
height: title.height + times.height
height: title.contentHeight + times.height

Label {
id: title
Expand Down Expand Up @@ -82,12 +98,15 @@ Page {
}

onClicked: {
Memory.set("subdata",modelData);
pageStack.push(Qt.resolvedUrl("SubDateView.qml"));
pageStack.push(Qt.resolvedUrl("EventView.qml"), {event:modelData});
}

}

VerticalScrollDecorator {}

Component.onCompleted: {
page.model = Global.orderBy(Global.groupByTime(page.model), page.order);
}
}
}
Loading

0 comments on commit f90340f

Please sign in to comment.