Merge pull request #7366 from markej/ShowDownloadURLs

Show which URLs are being actively downloaded
This commit is contained in:
Brad Hefta-Gaub 2016-03-18 10:42:01 -07:00
commit 481a75faca
3 changed files with 52 additions and 5 deletions

View file

@ -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(0, 5) + "..." + modelData.substring(modelData.length - 22)
: modelData
}
}
}
}
Rectangle {

View file

@ -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<Resource*> 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 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 (shouldUpdateUrls) {
_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<float, QString> 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

View file

@ -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