From bc2aea87748d685a9ac1936e62b5fb85db50c63c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 14 Mar 2016 18:18:33 -0700 Subject: [PATCH 1/3] Show the (generally truncated) urls being downloaded --- interface/resources/qml/Stats.qml | 22 ++++++++++++++++++++++ interface/src/ui/Stats.cpp | 28 ++++++++++++++++++++++++---- interface/src/ui/Stats.h | 7 ++++++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 696695de68..002e0fa404 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -169,6 +169,28 @@ Item { text: "Downloads: " + root.downloads + "/" + root.downloadLimit + ", Pending: " + root.downloadsPending; } + Text { + color: root.fontColor; + font.pixelSize: root.fontSize + visible: root.expanded && root.downloadUrls.length > 0; + text: "Download URLs:" + } + ListView { + width: geoCol.width + height: root.downloadUrls.length * 15 + + visible: root.expanded && root.downloadUrls.length > 0; + + model: root.downloadUrls + delegate: Text { + color: root.fontColor; + font.pixelSize: root.fontSize + visible: root.expanded; + text: modelData.length > 30 + ? "..." + modelData.substring(modelData.length - 27) + : modelData + } + } } } Rectangle { diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 23d2b87194..1dbd22c927 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -156,7 +156,7 @@ void Stats::updateStats(bool force) { } } }); - + // update the entities ping with the average for all connected entity servers STAT_UPDATE(entitiesPing, octreeServerCount ? totalPingOctree / octreeServerCount : -1); @@ -192,9 +192,29 @@ void Stats::updateStats(bool force) { STAT_UPDATE(audioMixerPps, -1); } - STAT_UPDATE(downloads, ResourceCache::getLoadingRequests().size()); + QList loadingRequests = ResourceCache::getLoadingRequests(); + STAT_UPDATE(downloads, loadingRequests.size()); STAT_UPDATE(downloadLimit, ResourceCache::getRequestLimit()) STAT_UPDATE(downloadsPending, ResourceCache::getPendingRequestCount()); + + // See if the active download urls have changed + bool updateUrls = _downloads != _downloadUrls.size(); + if (!updateUrls) { + for (int ii = 0; ii < _downloads; ii++) { + if (loadingRequests[ii]->getURL().toString() != _downloadUrls[ii]) { + updateUrls = true; + break; + } + } + } + // If the urls have changed, update the list + if (updateUrls) { + _downloadUrls.clear(); + foreach (Resource* resource, loadingRequests) { + _downloadUrls << resource->getURL().toString(); + } + emit downloadUrlsChanged(); + } // TODO fix to match original behavior //stringstream downloads; //downloads << "Downloads: "; @@ -306,7 +326,7 @@ void Stats::updateStats(bool force) { // we will also include room for 1 line per timing record and a header of 4 lines // Timing details... - // First iterate all the records, and for the ones that should be included, insert them into + // First iterate all the records, and for the ones that should be included, insert them into // a new Map sorted by average time... bool onlyDisplayTopTen = Menu::getInstance()->isOptionChecked(MenuOption::OnlyDisplayTopTen); QMap sortedRecords; @@ -366,7 +386,7 @@ void Stats::setRenderDetails(const RenderDetails& details) { /* // display expanded or contracted stats void Stats::display( - int voxelPacketsToProcess) + int voxelPacketsToProcess) { // iterate all the current voxel stats, and list their sending modes, and total voxel counts diff --git a/interface/src/ui/Stats.h b/interface/src/ui/Stats.h index c6bc13b52c..61069f2ab1 100644 --- a/interface/src/ui/Stats.h +++ b/interface/src/ui/Stats.h @@ -19,7 +19,7 @@ public: \ type name() { return _##name; }; \ private: \ - type _##name{ initialValue }; + type _##name{ initialValue }; class Stats : public QQuickItem { @@ -58,6 +58,7 @@ class Stats : public QQuickItem { STATS_PROPERTY(int, downloads, 0) STATS_PROPERTY(int, downloadLimit, 0) STATS_PROPERTY(int, downloadsPending, 0) + Q_PROPERTY(QStringList downloadUrls READ downloadUrls NOTIFY downloadUrlsChanged) STATS_PROPERTY(int, triangles, 0) STATS_PROPERTY(int, quads, 0) STATS_PROPERTY(int, materialSwitches, 0) @@ -105,6 +106,8 @@ public: } } + QStringList downloadUrls () { return _downloadUrls; } + public slots: void forceUpdateStats() { updateStats(true); } @@ -138,6 +141,7 @@ signals: void downloadsChanged(); void downloadLimitChanged(); void downloadsPendingChanged(); + void downloadUrlsChanged(); void trianglesChanged(); void quadsChanged(); void materialSwitchesChanged(); @@ -167,6 +171,7 @@ private: bool _timingExpanded{ false }; QString _monospaceFont; const AudioIOStats* _audioStats; + QStringList _downloadUrls = QStringList(); }; #endif // hifi_Stats_h From 6094613d069abe5866ff7d9a0a862fd81c2fc3e6 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 15 Mar 2016 13:43:42 -0700 Subject: [PATCH 2/3] When truncating the URL, show the first 5 characters (for the protocol) --- interface/resources/qml/Stats.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 002e0fa404..7412e0168e 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -187,7 +187,7 @@ Item { font.pixelSize: root.fontSize visible: root.expanded; text: modelData.length > 30 - ? "..." + modelData.substring(modelData.length - 27) + ? modelData.substring(0, 5) + "..." + modelData.substring(modelData.length - 22) : modelData } } From 66f9effd124eb1daeb8715b0f6bfd2ea5a9f520c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 16 Mar 2016 15:15:42 -0700 Subject: [PATCH 3/3] Update to match coding standards - Single letter for loop variable names - Preface bool variables with is/has/should/can/want --- interface/src/ui/Stats.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 1dbd22c927..c951c9fb43 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -198,17 +198,17 @@ void Stats::updateStats(bool force) { STAT_UPDATE(downloadsPending, ResourceCache::getPendingRequestCount()); // See if the active download urls have changed - bool updateUrls = _downloads != _downloadUrls.size(); - if (!updateUrls) { - for (int ii = 0; ii < _downloads; ii++) { - if (loadingRequests[ii]->getURL().toString() != _downloadUrls[ii]) { - updateUrls = true; + bool shouldUpdateUrls = _downloads != _downloadUrls.size(); + if (!shouldUpdateUrls) { + for (int i = 0; i < _downloads; i++) { + if (loadingRequests[i]->getURL().toString() != _downloadUrls[i]) { + shouldUpdateUrls = true; break; } } } // If the urls have changed, update the list - if (updateUrls) { + if (shouldUpdateUrls) { _downloadUrls.clear(); foreach (Resource* resource, loadingRequests) { _downloadUrls << resource->getURL().toString();