From ce7145a3884ad1633fb73c64c201eb96357e526e Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 20 Apr 2017 14:40:24 -0700 Subject: [PATCH] Announcement cards, debug data. --- interface/resources/qml/hifi/Card.qml | 5 +- interface/resources/qml/hifi/Feed.qml | 55 +++++++++++-------- .../qml/hifi/tablet/TabletAddressDialog.qml | 6 +- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/interface/resources/qml/hifi/Card.qml b/interface/resources/qml/hifi/Card.qml index c6e833826a..1a3ae43692 100644 --- a/interface/resources/qml/hifi/Card.qml +++ b/interface/resources/qml/hifi/Card.qml @@ -35,6 +35,7 @@ Rectangle { property string timePhrase: pastTime(timestamp); property int onlineUsers: 0; property bool isConcurrency: action === 'concurrency'; + property bool isAnnouncement: action === 'announcement'; property bool isStacked: !isConcurrency && drillDownToPlace; property int textPadding: 10; @@ -156,7 +157,7 @@ Rectangle { Row { FiraSansRegular { id: users; - visible: isConcurrency; + visible: isConcurrency || isAnnouncement; text: onlineUsers; size: textSize; color: messageColor; @@ -171,7 +172,7 @@ Rectangle { } RalewayRegular { id: message; - text: isConcurrency ? ((onlineUsers === 1) ? "person" : "people") : (drillDownToPlace ? "snapshots" : ("by " + userName)); + text: isConcurrency ? ((onlineUsers === 1) ? "person" : "people") : (isAnnouncement ? "connections" : (drillDownToPlace ? "snapshots" : ("by " + userName))); size: textSizeSmall; color: messageColor; elide: Text.ElideRight; // requires a width to be specified` diff --git a/interface/resources/qml/hifi/Feed.qml b/interface/resources/qml/hifi/Feed.qml index 9f2dfcd553..4f73d5bd16 100644 --- a/interface/resources/qml/hifi/Feed.qml +++ b/interface/resources/qml/hifi/Feed.qml @@ -19,6 +19,7 @@ import "../styles-uit" Column { id: root; + visible: false; property int cardWidth: 212; property int cardHeight: 152; @@ -44,6 +45,11 @@ Column { tags = data.tags || [data.action, data.username], description = data.description || "", thumbnail_url = data.thumbnail_url || ""; + if (actions === 'concurrency,snapshot') { + // A temporary hack for simulating announcements. We won't use this in production, but if requested, we'll use this data like announcements. + data.details.connections = 4; + data.action = 'announcement'; + } return { place_name: name, username: data.username || "", @@ -57,14 +63,14 @@ Column { tags: tags, description: description, - online_users: data.details.concurrency || 0, + online_users: data.details.connections || data.details.concurrency || 0, drillDownToPlace: false, searchText: [name].concat(tags, description || []).join(' ').toUpperCase() } } property var allStories: []; - property var placeMap: ({}); // Used for making stacks. FIXME: generalize to not just by place. + property var placeMap: ({}); // Used for making stacks. property int requestId: 0; function getUserStoryPage(pageNumber, cb) { // cb(error) after all pages of domain data have been added to model var options = [ @@ -95,32 +101,17 @@ Column { getUserStoryPage(1, function (error) { allStories.forEach(makeFilteredStoryProcessor()); console.log('user stories query', actions, error || 'ok', allStories.length, 'filtered to', suggestions.count); + root.visible = !!suggestions.count; // fixme reset on filtering, too! }); } - function addToSuggestions(place) { // fixme: move to makeFilteredStoryProcessor - var collapse = (actions === 'snapshot,concurrency') && (place.action !== 'concurrency'); // fixme generalize? - if (collapse) { - var existing = placeMap[place.place_name]; - if (existing) { - existing.drillDownToPlace = true; - return; - } - } - suggestions.append(place); - if (collapse) { - placeMap[place.place_name] = suggestions.get(suggestions.count - 1); - } else if (place.action === 'concurrency') { - suggestions.get(suggestions.count - 1).drillDownToPlace = true; // Don't change raw place object (in allStories). - } - } - function suggestable(story) { // fixme add to makeFilteredStoryProcessor - if (story.action === 'snapshot') { - return true; - } - return (story.place_name !== AddressManager.placename); // Not our entry, but do show other entry points to current domain. - } function makeFilteredStoryProcessor() { // answer a function(storyData) that adds it to suggestions if it matches var words = filter.toUpperCase().split(/\s+/).filter(identity); + function suggestable(story) { // fixme add to makeFilteredStoryProcessor + if (story.action === 'snapshot') { + return true; + } + return (story.place_name !== AddressManager.placename); // Not our entry, but do show other entry points to current domain. + } function matches(story) { if (!words.length) { return suggestable(story); @@ -129,6 +120,22 @@ Column { return story.searchText.indexOf(word) >= 0; }); } + function addToSuggestions(place) { + var collapse = ((actions === 'concurrency,snapshot') && (place.action !== 'concurrency')) || (place.action === 'announcement'); + if (collapse) { + var existing = placeMap[place.place_name]; + if (existing) { + existing.drillDownToPlace = true; + return; + } + } + suggestions.append(place); + if (collapse) { + placeMap[place.place_name] = suggestions.get(suggestions.count - 1); + } else if (place.action === 'concurrency') { + suggestions.get(suggestions.count - 1).drillDownToPlace = true; // Don't change raw place object (in allStories). + } + } return function (story) { if (matches(story)) { addToSuggestions(story); diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index 1d07625e34..5be8e158f4 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -186,7 +186,6 @@ StackView { } font.pixelSize: hifi.fonts.pixelSize * 0.75 onTextChanged: { - console.log('fixme onTextChanged "' + addressLine.text + "'."); updateLocationText(text.length > 0); } onAccepted: { @@ -234,7 +233,7 @@ StackView { ScrollView { anchors.fill: bgMain; horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff; - verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn; //Qt.ScrollBarAsNeeded; + verticalScrollBarPolicy: Qt.ScrollBarAsNeeded; Rectangle { // Column margins require QtQuick 2.7, which we don't use yet. id: column; property real pad: 10; @@ -258,7 +257,8 @@ StackView { cardHeight: places.cardHeight * happeningNow.cardScale; metaverseServerUrl: addressBarDialog.metaverseServerUrl; labelText: 'Happening Now'; - actions: 'concurrency,snapshot'; //selectedTab.includeActions; + actions: 'concurrency,snapshot'; // uncomment this line instead of next to produce fake announcement data for testing. + //actions: 'announcement'; filter: addressLine.text; } Feed {