diff --git a/harbour-sailfinder.pro b/harbour-sailfinder.pro index f3cd60e..de147f9 100644 --- a/harbour-sailfinder.pro +++ b/harbour-sailfinder.pro @@ -90,6 +90,7 @@ DISTFILES += qml/harbour-sailfinder.qml \ qml/components/MatchesCover.qml \ qml/components/ProfileCover.qml \ qml/components/DefaultCover.qml + qml/components/SchoolJobDelegate.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256 diff --git a/qml/components/PhotoGridLayout.qml b/qml/components/PhotoGridLayout.qml index 71f9f13..b043cc1 100644 --- a/qml/components/PhotoGridLayout.qml +++ b/qml/components/PhotoGridLayout.qml @@ -18,6 +18,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import Sailfish.Silica 1.0 +import Harbour.Sailfinder.Models 1.0 Item { property var photoListModel @@ -67,7 +68,16 @@ Item { height: parent.height sourceSize.width: width sourceSize.height: height - source: model.urlMedium + source: { + switch(api.getBearerType()) + { + case Sailfinder.Ethernet: + case Sailfinder.WLAN: + return model.urlLarge + default: // mobile networks or unknown + return model.urlMedium + } + } asynchronous: true opacity: progress visible: index < 6 // Max 6 photos @@ -144,6 +154,7 @@ Item { height: parent.width anchors.centerIn: parent visible: false + asynchronous: true z: 1 MouseArea { diff --git a/qml/components/SchoolJobDelegate.qml b/qml/components/SchoolJobDelegate.qml new file mode 100644 index 0000000..e975ec6 --- /dev/null +++ b/qml/components/SchoolJobDelegate.qml @@ -0,0 +1,67 @@ +/* +* This file is part of Sailfinder. +* +* Sailfinder is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Sailfinder is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Sailfinder. If not, see . +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +ListItem { + property string icon + property string name + property string title + property bool editable + + contentHeight: column.height + Theme.paddingLarge + width: parent.width + enabled: editable + + Column { + id: column + anchors { + left: image.right + leftMargin: Theme.paddingMedium + right: parent.right + rightMargin: Theme.horizontalPageMargin + verticalCenter: parent.verticalCenter + } + + TextLabel { + text: name + visible: text.length > 0 + } + + TextLabel { + text: title + // No name provided? Use the normal textsize + font.pixelSize: name.length > 0? Theme.fontSizeTiny: Theme.fontSizeMedium + font.italic: name.length > 0 // Italic when fontSizeTiny is in use + visible: text.length > 0 + } + } + + Image { + id: image + width: Theme.itemSizeSmall + height: width + anchors { + left: parent.left + leftMargin: Theme.horizontalPageMargin + verticalCenter: parent.verticalCenter + } + asynchronous: true + source: icon + } +} diff --git a/qml/pages/MatchProfilePage.qml b/qml/pages/MatchProfilePage.qml index 1f246af..024589d 100644 --- a/qml/pages/MatchProfilePage.qml +++ b/qml/pages/MatchProfilePage.qml @@ -32,10 +32,15 @@ Page { Connections { target: api onFullMatchProfileFetched: { + // Enhance profile match.distance = distance match.schools = schools match.jobs = jobs + + // Update view heading.title = Util.createHeaderMatchProfile(match.name, match.birthDate, match.gender, match.distance) + schoolsListView.model = match.schools + jobsListView.model = match.jobs console.debug("Match profile enhanced!") } } @@ -64,6 +69,27 @@ Page { readOnly: true visible: text.length > 0 } + + SilicaListView { + id: schoolsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-school.png" + name: model.name + } + } + + SilicaListView { + id: jobsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-job.png" + name: model.name + title: model.title + } + } } } } diff --git a/qml/pages/ProfileView.qml b/qml/pages/ProfileView.qml index 95fef45..3badd49 100644 --- a/qml/pages/ProfileView.qml +++ b/qml/pages/ProfileView.qml @@ -88,6 +88,8 @@ SilicaFlickable { ageMin.value = api.profile.ageMin // Order is important otherwise the value will not be updated due our limits implemented in the sliders photoList.photoListModel = api.profile.photos bio.text = api.profile.bio + schoolsListView.model = api.profile.schools + jobsListView.model = api.profile.jobs headerChanged(Util.createHeaderProfile(api.profile.name, api.profile.birthDate, api.profile.gender)) updatesTimer.start() } @@ -139,6 +141,29 @@ SilicaFlickable { placeholderText: qsTrId("sailfinder-bio-hint") } + SilicaListView { + id: schoolsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-school.png" + name: model.name + editable: false // Updating schools and jobs not supported yet + } + } + + SilicaListView { + id: jobsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-job.png" + name: model.name + title: model.title + editable: false // Updating schools and jobs not supported yet + } + } + //% "Discovery" SectionHeader { text: qsTrId("sailfinder-discovery") } diff --git a/qml/pages/RecommendationsView.qml b/qml/pages/RecommendationsView.qml index f06955a..675d5ca 100644 --- a/qml/pages/RecommendationsView.qml +++ b/qml/pages/RecommendationsView.qml @@ -40,6 +40,8 @@ SilicaFlickable { console.debug("Recommendation data received") photoList.photoListModel = api.recommendation.photos bio.text = api.recommendation.bio + schoolsListView.model = api.recommendation.schools + jobsListView.model = api.recommendation.jobs retryTimer.stop() recsBar.canSuperlike = api.canSuperlike recsBar.loaded = true @@ -107,6 +109,27 @@ SilicaFlickable { readOnly: true visible: text.length > 0 } + + SilicaListView { + id: schoolsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-school.png" + name: model.name + } + } + + SilicaListView { + id: jobsListView + width: parent.width + height: contentHeight + delegate: SchoolJobDelegate { + icon: "qrc:///images/icon-job.png" + name: model.name + title: model.title + } + } } ViewPlaceholder { diff --git a/qml/resources/images/icon-addimage.png b/qml/resources/images/icon-addimage.png deleted file mode 100644 index dfa83cf..0000000 Binary files a/qml/resources/images/icon-addimage.png and /dev/null differ diff --git a/qml/resources/images/icon-bio.png b/qml/resources/images/icon-bio.png deleted file mode 100644 index 9832901..0000000 Binary files a/qml/resources/images/icon-bio.png and /dev/null differ diff --git a/qml/resources/images/icon-edit.png b/qml/resources/images/icon-edit.png deleted file mode 100644 index 1333ca1..0000000 Binary files a/qml/resources/images/icon-edit.png and /dev/null differ diff --git a/qml/resources/images/icon-job.png b/qml/resources/images/icon-job.png index e273a38..a1e1089 100644 Binary files a/qml/resources/images/icon-job.png and b/qml/resources/images/icon-job.png differ diff --git a/qml/resources/images/icon-liked.png b/qml/resources/images/icon-liked.png deleted file mode 100644 index be6cc79..0000000 Binary files a/qml/resources/images/icon-liked.png and /dev/null differ diff --git a/qml/resources/images/icon-location.png b/qml/resources/images/icon-location.png deleted file mode 100644 index 215e3c3..0000000 Binary files a/qml/resources/images/icon-location.png and /dev/null differ diff --git a/qml/resources/images/icon-more.png b/qml/resources/images/icon-more.png deleted file mode 100644 index b789d75..0000000 Binary files a/qml/resources/images/icon-more.png and /dev/null differ diff --git a/qml/resources/images/icon-noimage.png b/qml/resources/images/icon-noimage.png deleted file mode 100644 index 11c0097..0000000 Binary files a/qml/resources/images/icon-noimage.png and /dev/null differ diff --git a/qml/resources/images/icon-notliked.png b/qml/resources/images/icon-notliked.png deleted file mode 100644 index 42be015..0000000 Binary files a/qml/resources/images/icon-notliked.png and /dev/null differ diff --git a/qml/resources/images/icon-share.png b/qml/resources/images/icon-share.png deleted file mode 100644 index 7fe42ad..0000000 Binary files a/qml/resources/images/icon-share.png and /dev/null differ diff --git a/qml/resources/images/icon-social.png b/qml/resources/images/icon-social.png deleted file mode 100644 index ef460bf..0000000 Binary files a/qml/resources/images/icon-social.png and /dev/null differ diff --git a/qml/resources/images/image-placeholder.png b/qml/resources/images/image-placeholder.png deleted file mode 100644 index 014c680..0000000 Binary files a/qml/resources/images/image-placeholder.png and /dev/null differ diff --git a/qml/resources/resources.qrc b/qml/resources/resources.qrc index 89dcd0e..7f1c674 100644 --- a/qml/resources/resources.qrc +++ b/qml/resources/resources.qrc @@ -4,10 +4,7 @@ images/cover-background.png images/cover-logo.png images/dislike.png - images/icon-addimage.png - images/icon-bio.png images/icon-code.png - images/icon-edit.png images/icon-fontawesome.png images/icon-friends.png images/icon-giphy.png @@ -15,14 +12,9 @@ images/icon-gitlab.png images/icon-instagram.png images/icon-job.png - images/icon-liked.png images/icon-linkedin.png - images/icon-location.png images/icon-matches.png - images/icon-more.png - images/icon-noimage.png images/icon-notifications.png - images/icon-notliked.png images/icon-paypal.png images/icon-profile.png images/icon-recs.png @@ -30,11 +22,8 @@ images/icon-school.png images/icon-search.png images/icon-send.png - images/icon-share.png - images/icon-social.png images/icon-spotify.png images/icon-translate.png - images/image-placeholder.png images/launcher-logo.png images/like.png images/sources.txt diff --git a/rpm/harbour-sailfinder.changes b/rpm/harbour-sailfinder.changes index 1d6c7c5..99d8434 100644 --- a/rpm/harbour-sailfinder.changes +++ b/rpm/harbour-sailfinder.changes @@ -1,16 +1,18 @@ * Tue May 10 2018 Dylan Van Assche 4.4-4 - [MINOR BUGFIX] Sailfinder can now run in the emulator again - [MINOR BUGFIX] Messages are scrolling automatically when the keyboard shows/hides +- [MAJOR BUGFIX] Jobs are now parsed correctly by Sailfinder - [IMPROVEMENT] Remorse action used when needed - [IMPROVEMENT] Stability improvements for the login screen - [IMPROVEMENT] Location updates are still working OK +- [IMPROVEMENT] Automatically throttle the quality of the pictures to reduce data usage on mobile networks - [IMPROVEMENT] Use Silica booster for faster startup - [NEW] SFOS cover when Sailfinder is minimized - [NEW] Delete pictures from Tinder (hold a profile picture to show remove screen) - [NEW] Opt-in for Smart Photo's - [NEW] Moved to OBS for building RPM's - [NEW] See the distance of your matches -- [NEW] Show schools and jobs for recommendations and matches +- [NEW] Show schools and jobs for recommendations, matches and your profile - [UPGRADE] /updates endpoint data upgrade - [WIP] Phone login support preparations - [LIBS] Moved to new Nemo import syntax diff --git a/rpm/harbour-sailfinder.spec b/rpm/harbour-sailfinder.spec index c96c565..ce672e0 100644 --- a/rpm/harbour-sailfinder.spec +++ b/rpm/harbour-sailfinder.spec @@ -14,7 +14,7 @@ Name: harbour-sailfinder %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Sailfinder Version: 4.4 -Release: 4 +Release: 5 Group: Qt/Qt License: GPLv3 URL: https://github.com/DylanVanAssche/harbour-sailfinder diff --git a/rpm/harbour-sailfinder.yaml b/rpm/harbour-sailfinder.yaml index 6f1b36a..c890ad5 100644 --- a/rpm/harbour-sailfinder.yaml +++ b/rpm/harbour-sailfinder.yaml @@ -1,7 +1,7 @@ Name: harbour-sailfinder Summary: Sailfinder Version: 4.4 -Release: 4 +Release: 5 # 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 Group: Qt/Qt diff --git a/src/api.cpp b/src/api.cpp index 22219e5..a20aba1 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -25,7 +25,6 @@ API::API(QObject *parent) : QObject(parent) // Initiate a new QNetworkAccessManager with cache QNAM = new QNetworkAccessManager(this); QNetworkConfigurationManager QNAMConfig; - QNAM->setConfiguration(QNAMConfig.defaultConfiguration()); QNAMCache = new QNetworkDiskCache(this); QNAMCache->setCacheDirectory(SFOS.cacheLocation()+ "/network"); QNAM->setCache(QNAMCache); @@ -753,6 +752,11 @@ void API::getFullMatchProfile(QString userId) } } +int API::getBearerType() +{ + return QNAM->configuration().bearerType(); +} + /** * @class API * @brief Parse the positioning @@ -1311,14 +1315,30 @@ void API::parseProfile(QJsonObject json) foreach(QJsonValue item, user["jobs"].toArray()) { QJsonObject job = item.toObject(); - // Name is needed but ID might be missing sometimes! - if(job.value("id") != QJsonValue::Undefined) { - jobList.append(new Job(job["id"].toString(), job["name"].toString())); + + QString companyName; + QString titleName; + QString id; + if(job.value("company") != QJsonValue::Undefined) + { + QJsonObject company = job["company"].toObject(); + companyName = company["name"].toString(); + if(company.value("id") != QJsonValue::Undefined) + { + id = company["id"].toString(); + } } - else { - qWarning() << "Job id is missing"; - jobList.append(new Job(job["name"].toString())); + + if(job.value("title") != QJsonValue::Undefined) + { + QJsonObject title = job["title"].toObject(); + titleName = title["name"].toString(); + if(id.length() == 0 && title.value("id") != QJsonValue::Undefined) + { + id = title["id"].toString(); + } } + jobList.append(new Job(id, companyName, titleName)); } qDebug() << "Profile data:"; @@ -1383,14 +1403,30 @@ void API::parseRecommendations(QJsonObject json) foreach(QJsonValue item, recommendation["jobs"].toArray()) { QJsonObject job = item.toObject(); - // Name is needed but ID might be missing sometimes! - if(job.value("id") != QJsonValue::Undefined) { - jobList.append(new Job(job["id"].toString(), job["name"].toString())); + + QString companyName; + QString titleName; + QString id; + if(job.value("company") != QJsonValue::Undefined) + { + QJsonObject company = job["company"].toObject(); + companyName = company["name"].toString(); + if(company.value("id") != QJsonValue::Undefined) + { + id = company["id"].toString(); + } } - else { - qWarning() << "Job id is missing"; - jobList.append(new Job(job["name"].toString())); + + if(job.value("title") != QJsonValue::Undefined) + { + QJsonObject title = job["title"].toObject(); + titleName = title["name"].toString(); + if(id.length() == 0 && title.value("id") != QJsonValue::Undefined) + { + id = title["id"].toString(); + } } + jobList.append(new Job(id, companyName, titleName)); } recsList.append(new Recommendation(id, name, birthDate, gender, bio, schoolList, jobList, photoList, contentHash, sNumber, distance)); @@ -1670,7 +1706,6 @@ void API::parseFullMatchProfile(QJsonObject json) { QList schoolList; QList jobList; - qDebug() << json; foreach(Match* match, this->matchesList()->matchesList()) { QJsonObject result = json["results"].toObject(); @@ -1693,14 +1728,30 @@ void API::parseFullMatchProfile(QJsonObject json) // Add jobs if available foreach(QJsonValue item, result["jobs"].toArray()) { QJsonObject job = item.toObject(); - // Name is needed but ID might be missing sometimes! - if(job.value("id") != QJsonValue::Undefined) { - jobList.append(new Job(job["id"].toString(), job["name"].toString())); + + QString companyName; + QString titleName; + QString id; + if(job.value("company") != QJsonValue::Undefined) + { + QJsonObject company = job["company"].toObject(); + companyName = company["name"].toString(); + if(company.value("id") != QJsonValue::Undefined) + { + id = company["id"].toString(); + } } - else { - qWarning() << "Job id is missing"; - jobList.append(new Job(job["name"].toString())); + + if(job.value("title") != QJsonValue::Undefined) + { + QJsonObject title = job["title"].toObject(); + titleName = title["name"].toString(); + if(id.length() == 0 && title.value("id") != QJsonValue::Undefined) + { + id = title["id"].toString(); + } } + jobList.append(new Job(id, companyName, titleName)); } // Update match profile diff --git a/src/api.h b/src/api.h index 000014a..85dea35 100644 --- a/src/api.h +++ b/src/api.h @@ -115,6 +115,7 @@ class API : public QObject Q_INVOKABLE void uploadPhoto(QString path); Q_INVOKABLE void removePhoto(QString photoId); Q_INVOKABLE void getFullMatchProfile(QString userId); + Q_INVOKABLE int getBearerType(); QString token() const; void setToken(const QString &token); bool networkEnabled() const; diff --git a/src/models/enum.h b/src/models/enum.h index be16417..f36f5c7 100644 --- a/src/models/enum.h +++ b/src/models/enum.h @@ -3,6 +3,7 @@ #include #include +#include class Sailfinder { @@ -26,8 +27,15 @@ class Sailfinder Full = 5 // 1080x1080 }; + // Stripped down from QNetworkConfiguration + enum class ConnectionType { + Ethernet = QNetworkConfiguration::BearerEthernet, + WLAN = QNetworkConfiguration::BearerWLAN + }; + Q_ENUMS(Gender) Q_ENUMS(Size) + Q_ENUMS(ConnectionType) }; Q_DECLARE_METATYPE(Sailfinder::Gender) diff --git a/src/models/job.cpp b/src/models/job.cpp index 5569419..2ef057b 100644 --- a/src/models/job.cpp +++ b/src/models/job.cpp @@ -11,6 +11,13 @@ Job::Job(QString id, QString name) this->setName(name); } +Job::Job(QString id, QString name, QString title) +{ + this->setId(id); + this->setName(name); + this->setTitle(title); +} + Job::Job(QString name) { this->setId(""); @@ -38,3 +45,14 @@ void Job::setName(const QString &name) m_name = name; emit this->nameChanged(); } + +QString Job::title() const +{ + return m_title; +} + +void Job::setTitle(const QString &title) +{ + m_title = title; + emit this->titleChanged(); +} diff --git a/src/models/job.h b/src/models/job.h index 3fcaf70..716811d 100644 --- a/src/models/job.h +++ b/src/models/job.h @@ -9,23 +9,29 @@ class Job : public QObject Q_OBJECT Q_PROPERTY(QString id READ id NOTIFY idChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) public: explicit Job(QObject *parent = 0); explicit Job(QString id, QString name); + explicit Job(QString id, QString name, QString title); explicit Job(QString name); QString id() const; void setId(const QString &id); QString name() const; void setName(const QString &name); + QString title() const; + void setTitle(const QString &title); signals: void idChanged(); void nameChanged(); + void titleChanged(); private: QString m_id = QString(); QString m_name = QString(); + QString m_title = QString(); }; #endif // JOB_H diff --git a/src/models/joblistmodel.cpp b/src/models/joblistmodel.cpp index db85446..994e29f 100644 --- a/src/models/joblistmodel.cpp +++ b/src/models/joblistmodel.cpp @@ -46,6 +46,7 @@ QHash JobListModel::roleNames() const QHash roles; roles[IdRole] = "id"; roles[NameRole] = "name"; + roles[TitleRole] = "title"; return roles; } @@ -60,6 +61,8 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const return QVariant(this->jobList().at(index.row())->id()); case NameRole: return QVariant(this->jobList().at(index.row())->name()); + case TitleRole: + return QVariant(this->jobList().at(index.row())->title()); default: return QVariant(); } diff --git a/src/models/joblistmodel.h b/src/models/joblistmodel.h index 1abb58c..2f8451b 100644 --- a/src/models/joblistmodel.h +++ b/src/models/joblistmodel.h @@ -30,7 +30,8 @@ class JobListModel : public QAbstractListModel public: enum Roles { IdRole = Qt::UserRole + 1, - NameRole = Qt::UserRole + 2 + NameRole = Qt::UserRole + 2, + TitleRole = Qt::UserRole + 3 }; explicit JobListModel(QList jobList); diff --git a/src/models/matcheslistmodel.cpp b/src/models/matcheslistmodel.cpp index 1e81fac..10ecbb9 100644 --- a/src/models/matcheslistmodel.cpp +++ b/src/models/matcheslistmodel.cpp @@ -95,7 +95,7 @@ QVariant MatchesListModel::data(const QModelIndex &index, int role) const } else { // Return a placeholder when match doesn't has any pictures - return QVariant(":/images/icon-liked.png"); + return QVariant(":/images/icon-matches.png"); } case MessagesPreviewRole: if(this->matchesList().at(index.row())->message() != NULL) {