From d749290e5095a5993d078ad87dd4cab6f3bb2e86 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Tue, 4 Jul 2023 18:10:21 +0300 Subject: [PATCH] file upload stats (gui) --- .../gui/FileTransfer/SharedFilesDialog.cpp | 7 +++- retroshare-gui/src/gui/RemoteDirModel.cpp | 40 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 74a7d5744..d858384cd 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -61,7 +61,8 @@ #define SHARED_FILES_DIALOG_COLUMN_AGE 3 #define SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS 4 #define SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR 5 -#define SHARED_FILES_DIALOG_COLUMN_COUNT 6 +#define SHARED_FILES_DIALOG_COLUMN_UPLOADED 6 +#define SHARED_FILES_DIALOG_COLUMN_COUNT 7 #define SHARED_FILES_DIALOG_FILTER_STRING "filtered" @@ -235,6 +236,7 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_AGE , charWidth*6 ); header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, charWidth*10 ); header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR , charWidth*20 ); + header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_UPLOADED , charWidth*20 ); header->setStretchLastSection(true); @@ -293,6 +295,7 @@ RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent) { ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ; ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ; + ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_UPLOADED, true) ; ui.checkButton->hide() ; connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected())); @@ -490,6 +493,7 @@ void RemoteSharedFilesDialog::showProperColumns() ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, false) ; ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, true) ; ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ; + ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_UPLOADED, true) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW ui.filterLabel->hide(); ui.filterPatternLineEdit->hide(); @@ -502,6 +506,7 @@ void RemoteSharedFilesDialog::showProperColumns() ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, true) ; ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ; ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ; + ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_UPLOADED, true) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW ui.filterLabel->show(); ui.filterPatternLineEdit->show(); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 05e19857f..332ad97d3 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -54,7 +54,8 @@ #define REMOTEDIRMODEL_COLUMN_AGE 3 #define REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS 4 #define REMOTEDIRMODEL_COLUMN_WN_VISU_DIR 5 -#define REMOTEDIRMODEL_COLUMN_COUNT 6 +#define REMOTEDIRMODEL_COLUMN_UPLOADED 6 +#define REMOTEDIRMODEL_COLUMN_COUNT 7 #define RETROSHARE_DIR_MODEL_FILTER_STRING "filtered" static const uint32_t FLAT_VIEW_MAX_REFS_PER_SECOND = 2000 ; @@ -547,7 +548,17 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const return QString(); else return misc::timeRelativeToNow(details.max_mtime); - + case REMOTEDIRMODEL_COLUMN_UPLOADED: + { + if(!RemoteMode && details.id == rsPeers->getOwnId()) // Totals in "My files" row + { + uint64_t n = rsFiles->getCumulativeUploadNum(); + if(n) + return QString(misc::friendlyUnit(rsFiles->getCumulativeUploadAll()) + QString(" - %1 files").arg(n)); + else + return QString("-"); + } + } default: return QString() ; } @@ -580,6 +591,14 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const return QVariant(); case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return getGroupsString(details.flags,details.parent_groups) ; + case REMOTEDIRMODEL_COLUMN_UPLOADED: + { + uint64_t x = rsFiles->getCumulativeUpload(details.hash); + if(x) + return misc::friendlyUnit(x); + else + return QString(); + } default: return tr("FILE"); @@ -606,6 +625,8 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const return QVariant(); case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return getGroupsString(details.flags,details.parent_groups) ; + case REMOTEDIRMODEL_COLUMN_UPLOADED: + return ""; default: return tr("DIR"); @@ -665,6 +686,14 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const case REMOTEDIRMODEL_COLUMN_AGE: return misc::timeRelativeToNow(details.max_mtime); case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str()); case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return computeDirectoryPath(details); + case REMOTEDIRMODEL_COLUMN_UPLOADED: + { + uint64_t x = rsFiles->getCumulativeUpload(details.hash); + if(x) + return misc::friendlyUnit(x); + else + return QString(); + } default: return QVariant() ; } @@ -733,6 +762,8 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& ind = getAgeIndicatorString(details); return ind; } + case REMOTEDIRMODEL_COLUMN_UPLOADED: + return (qulonglong) rsFiles->getCumulativeUpload(details.hash); default: return tr("FILE"); } @@ -779,6 +810,7 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& return computeDirectoryPath(details); } + case REMOTEDIRMODEL_COLUMN_UPLOADED: return (qulonglong) rsFiles->getCumulativeUpload(details.hash); } } return QVariant(); @@ -945,6 +977,8 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int return tr("What's new"); else return tr("Visibility"); + case REMOTEDIRMODEL_COLUMN_UPLOADED: + return tr("Uploaded"); } return tr("Column %1").arg(section); } @@ -991,6 +1025,8 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int return tr("Share Flags"); case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return tr("Directory"); + case REMOTEDIRMODEL_COLUMN_UPLOADED: + return tr("Uploaded"); } return tr("Column %1").arg(section); }