Skip to content

Commit

Permalink
Little changes. Project is usable
Browse files Browse the repository at this point in the history
  • Loading branch information
cuzbog committed Nov 20, 2014
1 parent 9d3dceb commit ee3783e
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 113 deletions.
22 changes: 10 additions & 12 deletions CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.1, 2014-11-18T14:19:31. -->
<!-- Written by QtCreator 3.1.1, 2014-11-20T19:31:31. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down Expand Up @@ -236,8 +236,8 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">UbuntuProjectManager.UploadStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles">
<value type="QString">/home/boghison/Projects/build-MixCloud-Ubuntu_Device_GCC_armhf_ubuntu_sdk_14_10_utopic-Default/com.ubuntu.developer.boghison.mixcloud_0.1_armhf.click</value>
<value type="QString">/usr/share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py</value>
<value type="QString">/home/boghison/Projects/build-MixCloud-Ubuntu_Device_GCC_armhf_ubuntu_sdk_14_10_utopic-Default/com.ubuntu.developer.boghison.mixcloud_0.1_armhf.click</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts">
<value type="QString">127.0.0.1</value>
Expand All @@ -252,8 +252,8 @@
<value type="QString">/var/lib/schroot/chroots/click-ubuntu-sdk-14.10-armhf</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes">
<value type="QDateTime">2014-11-17T16:46:12</value>
<value type="QDateTime">2014-11-17T16:46:12</value>
<value type="QDateTime">2014-11-19T18:08:12</value>
<value type="QDateTime">2014-11-19T18:08:12</value>
</valuelist>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
Expand Down Expand Up @@ -303,21 +303,19 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
<value type="int" key="PE.EnvironmentAspect.Base">1</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">mixcloudscope</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">UbuntuProjectManager.RemoteRunConfiguration.Scopemixcloudscope</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="UbuntuRemoteRunConfiguration.ForceInstall">false</value>
<value type="bool" key="UbuntuRemoteRunConfiguration.Uninstall">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
1 change: 1 addition & 0 deletions include/api/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Client {
int repost_count;
User user;
std::string slug;
std::string created;
};

/**
Expand Down
1 change: 1 addition & 0 deletions include/scope/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Query: public unity::scopes::SearchQueryBase {
void cancelled() override;

void run(const unity::scopes::SearchReplyProxy &reply) override;
void parseCasts(unity::scopes::CategorisedResult &hotRes, const api::Client::CloudCast &hotCast);

private:
std::string installdir;
Expand Down
9 changes: 7 additions & 2 deletions src/api/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <unity/scopes/QueryMetadata.h>
#include <QVariantMap>
#include <math.h>
#include <QDebug>
#include <boost/algorithm/string/replace.hpp>


namespace http = core::net::http;
Expand Down Expand Up @@ -52,7 +54,9 @@ void Client::get(const net::Uri::Path &path,

// Build the URI from its components
net::Uri uri = net::make_uri(config_->apiroot, path, parameters);
configuration.uri = client->uri_to_string(uri);
std::string temporaryUri = client->uri_to_string(uri);
configuration.uri = boost::replace_all_copy(temporaryUri, "%20", "+");
qDebug(configuration.uri.c_str());
// Give out a user agent string
configuration.header.add("User-Agent", config_->user_agent);

Expand Down Expand Up @@ -118,7 +122,8 @@ Client::CloudCasts Client::parseJson(QJsonDocument root){
listener_count,
repost_count,
myUser,
item["slug"].toString().toStdString()
item["slug"].toString().toStdString(),
item["created_time"].toString().toStdString()
});
}
return result;
Expand Down
83 changes: 43 additions & 40 deletions src/scope/preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,111 +28,114 @@ void Preview::run(sc::PreviewReplyProxy const& reply) {
if (result["getExtra"].get_bool()){
layoutcol1.add_column({"image", "header", "description", "expandable", "button"});
layoutcol2.add_column({"image", "header", "button"});
layoutcol2.add_column({"description", "audio_length", "favoritecount", "listencount", "repostcount"});
layoutcol2.add_column({"description", "audio_length", "favoritecount", "listencount", "repostcount", "created"});
}
else{
layoutcol1.add_column({"image", "header", "expandable", "button"});
layoutcol2.add_column({"image", "header", "button"});
layoutcol2.add_column({"audio_length", "favoritecount", "listencount", "repostcount"});
layoutcol2.add_column({"audio_length", "favoritecount", "listencount", "repostcount", "created"});
}
reply->register_layout({layoutcol1, layoutcol2});
sc::PreviewWidget header("header", "header");
sc::PreviewWidget created("created", "text"), header("header", "header"), button("button", "actions"), image("image", "image"), expandable("expandable", "expandable"), listencount("listencount", "text"), favoritecount("favoritecount", "text"), repostcount("repostcount", "text"), audio_length("audio_length", "text");
QString dateString = QString::fromUtf8(result["created"].get_string().data(), result["created"].get_string().size());
QDate date = QDate::fromString(dateString, Qt::ISODate);
QString fullDate = date.toString(Qt::SystemLocaleShortDate);
created.add_attribute_value("text", sc::Variant("Uploaded on " + fullDate.toStdString()));
header.add_attribute_mapping("title", "title");
header.add_attribute_mapping("subtitle", "subtitle");
sc::PreviewWidget button("button", "actions");
sc::VariantBuilder builder;
builder.add_tuple({
{"id", sc::Variant("open")},
{"label",sc::Variant("Open")},
{"uri", result["uri"]}
});
sc::PreviewWidget image("image", "image");
image.add_attribute_mapping("source", "art");
button.add_attribute_value("actions", builder.end());
sc::PreviewWidget expandable("expandable", "expandable");
expandable.add_attribute_value("title", sc::Variant("Additional info"));
sc::PreviewWidget audio_length("audio_length", "text");
audio_length.add_attribute_value("title", sc::Variant("Length"));
audio_length.add_attribute_value("text", result["audio_length"]);
sc::PreviewWidget listencount("listencount", "text");
sc::PreviewWidget favoritecount("favoritecount", "text");
sc::PreviewWidget repostcount("repostcount", "text");
listencount.add_attribute_value("title", sc::Variant("Play Count"));
favoritecount.add_attribute_value("title", sc::Variant("Favorite Count"));
repostcount.add_attribute_value("title", sc::Variant("Repost Count"));
listencount.add_attribute_value("text", (result["listen"].get_int() == 0) ? sc::Variant("None") : result["listen"]);
favoritecount.add_attribute_value("text", (result["favorite"].get_int() == 0) ? sc::Variant("None") : result["favorite"]);
repostcount.add_attribute_value("text", (result["repost"].get_int() == 0) ? sc::Variant("None") : result["repost"]);
audio_length.add_attribute_value("text", sc::Variant("" + result["audio_length"].get_string()));
listencount.add_attribute_value("text", sc::Variant(std::to_string(result["listen"].get_int()) + " ♪♫"));
favoritecount.add_attribute_value("text", sc::Variant(std::to_string(result["favorite"].get_int()) + ""));
repostcount.add_attribute_value("text", sc::Variant(std::to_string(result["repost"].get_int()) + ""));
expandable.add_widget(audio_length);
expandable.add_widget(listencount);
expandable.add_widget(favoritecount);
expandable.add_widget(listencount);
expandable.add_widget(repostcount);
expandable.add_widget(created);
if (result["getExtra"].get_bool()){
sc::PreviewWidget description("description", "text");
description.add_attribute_value("title", sc::Variant("Description"));
std::vector<std::string> full = client_.getExtra(1, result["username"].get_string() + "/" + result["slug"].get_string());
description.add_attribute_value("text", sc::Variant(full[0]));
reply->push({image, header, description, button, expandable, audio_length, listencount, favoritecount, repostcount});
if (full[0] != ""){
description.add_attribute_value("text", sc::Variant(full[0]));
reply->push({image, header, description, button, expandable, audio_length, favoritecount, listencount, repostcount, created});
}
else {
reply->push({image, header, button, expandable, audio_length, favoritecount, listencount, repostcount, created});
}
}
else{
reply->push({image, header, button, expandable, audio_length, listencount, favoritecount, repostcount});
reply->push({image, header, button, expandable, audio_length, favoritecount, listencount, repostcount, created});
}
}
else {
if (result["getExtra"].get_bool()) {
sc::ColumnLayout layoutcol1(1), layoutcol2(2);
layoutcol1.add_column({"image", "header", "bio", "expandable", "button"});
layoutcol2.add_column({"image", "header", "button"});
layoutcol2.add_column({"bio", "location", "created_time", "cloudcast_count", "favorite_count", "follower_count", "following_count"});
layoutcol2.add_column({"bio", "location", "favorite_count", "cloudcast_count", "follower_count", "following_count", "created_time"});
reply->register_layout({layoutcol1, layoutcol2});
}
else {
sc::ColumnLayout layout(1);
layout.add_column({"image", "header", "button"});
reply->register_layout({layout});
}
sc::PreviewWidget header("header", "header");
sc::PreviewWidget header("header", "header"), button("button", "actions"), image("image", "image");
header.add_attribute_mapping("title", "title");
header.add_attribute_mapping("subtitle", "subtitle");
sc::PreviewWidget button("button", "actions");
sc::VariantBuilder builder;
builder.add_tuple({
{"id", sc::Variant("open")},
{"label",sc::Variant("Open")},
{"uri", result["uri"]}
});
sc::PreviewWidget image("image", "image");
image.add_attribute_mapping("source", "art");
button.add_attribute_value("actions", builder.end());
if (result["getExtra"].get_bool()) {
std::vector<std::string> full = client_.getExtra(2, result["subtitle"].get_string());
sc::PreviewWidget bio("bio", "text"), expandable("expandable", "expandable"), location("location", "text"), created_time("created_time", "text"), cloudcast_count("cloudcast_count", "text"), favorite_count("favorite_count", "text"), follower_count("follower_count", "text"), following_count("following_count", "text");
bio.add_attribute_value("title", sc::Variant("Bio"));
bio.add_attribute_value("text", sc::Variant(full[7]));
std::string fullLocation = full[0] + ", " + full[2];
//location.add_attribute_value("title", sc::Variant("Location"));
string fullLocation;
if (full[0] == "" && full[2] == ""){
fullLocation = "N/A";
}
else if (full[0] == "" && full[2] != ""){
fullLocation = full[2];
}
else if (full[0] != "" && full [2] != ""){
fullLocation = full[0] + ", " + full[2];
}
else {
fullLocation = full[0];
}
location.add_attribute_value("text", sc::Variant("Lives in " + fullLocation));
QString dateString = QString::fromUtf8(full[3].data(), full[3].size());
QDate date = QDate::fromString(dateString, Qt::ISODate);
QString fullDate = date.toString("d MMMM yyyy");
//created_time.add_attribute_value("title", sc::Variant("Created on"));
created_time.add_attribute_value("text", sc::Variant("Created on " + fullDate.toStdString()));
//cloudcast_count.add_attribute_value("title", sc::Variant("Cloucast Count"));
cloudcast_count.add_attribute_value("text", sc::Variant(full[4] + " Cloudcasts"));
//favorite_count.add_attribute_value("title", sc::Variant("Favorite Count"));
favorite_count.add_attribute_value("text", sc::Variant(full[5] + " Favorites"));
//follower_count.add_attribute_value("title", sc::Variant("Follower Count"));
QString fullDate = date.toString(Qt::SystemLocaleShortDate);
created_time.add_attribute_value("text", sc::Variant("Account created on " + fullDate.toStdString()));
cloudcast_count.add_attribute_value("text", sc::Variant(full[4] + ""));
favorite_count.add_attribute_value("text", sc::Variant(full[5] + ""));
follower_count.add_attribute_value("text", sc::Variant(full[6] + " Followers"));
//following_count.add_attribute_value("title", sc::Variant("Following Count"));
following_count.add_attribute_value("text", sc::Variant("Following " + full[1]));
expandable.add_attribute_value("title", sc::Variant("Additional Info"));
expandable.add_widget(created_time);
expandable.add_widget(location);
expandable.add_widget(cloudcast_count);
expandable.add_widget(favorite_count);
expandable.add_widget(cloudcast_count);
expandable.add_widget(follower_count);
expandable.add_widget(following_count);
reply->push({image, header, button, expandable, bio, location, created_time, cloudcast_count, favorite_count, follower_count, following_count});
expandable.add_widget(created_time);
reply->push({image, header, expandable, button, bio, location, favorite_count, cloudcast_count, follower_count, following_count, created_time});
}
else{
reply->push({image, header, button});
Expand Down
Loading

0 comments on commit ee3783e

Please sign in to comment.