@@ -56,21 +56,41 @@ void FolderItem::setProgress(const ProgressInfo &progress)
5656 // this might be premature - if so use one of the completion states from folder sync result
5757 _totalSize = 0 ;
5858 _completedSize = 0 ;
59+ _percentComplete = 0 ;
60+ _estimatedDownBw = 0 ;
61+ _estimatedUpBw = 0 ;
5962 return ;
6063 }
6164
6265 if (progress.totalSize () == 0 ) {
63- // nothing is going to happen so ditch - with vfs this will always be the case?
66+ // nothing is going to happen, visually so ditch - with vfs this will always be the case?
6467 return ;
6568 }
6669
67- // completed size is literal - meaning if there was nothing to actually sync,
68- // total size = 0
70+ // total size is literal - meaning if there was nothing to actually sync, total size = 0
6971 // this can happen if there are no files/folders in a space
70- // or of the space is already 100% up to date, so no diffs, or if there is nothing to "move" between server/client (move or delete)
72+ // or of the space is already 100% up to date, so no diffs,
73+ // or if there is nothing to "move" between server/client (move or delete)
7174 _totalSize = progress.totalSize ();
7275 _completedSize = progress.completedSize ();
73- // _percentComplete = progress.refresh();
76+ // the old impl added extra "bytes" to the calculation to account for "contentless" operations (move, delete, possibly vfs placeholder creation)
77+ // but I'm going with the simple calc because my strong gut feeling is that these tiny updates won't take long enough to substantially change the
78+ // info in the gui. If someone complains we can make it more complicated again.
79+ _percentComplete = qBound (0 , qRound (double (_completedSize) / double (_totalSize) * 100.0 ), 100 );
80+
81+ _estimatedUpBw = 0 ;
82+ _estimatedDownBw = 0 ;
83+
84+ for (const auto &citm : progress._currentItems ) {
85+ // the idea here is the total available bandwidth will be "shared" among multiple items. So summing their individual bw consumption reveals
86+ // the total bw up or down.
87+ if (citm._item ._direction == SyncFileItem::Up) {
88+ _estimatedUpBw += progress.fileProgress (citm._item ).estimatedBandwidth ;
89+ } else {
90+ _estimatedDownBw += progress.fileProgress (citm._item ).estimatedBandwidth ;
91+ }
92+ }
93+
7494 refresh ();
7595}
7696
@@ -134,8 +154,19 @@ QString FolderItem::statusAsString() const
134154 case SyncResult::SyncRunning: {
135155 QString completedFormatted = Utility::octetsToString (_completedSize);
136156 QString totalFormatted = Utility::octetsToString (_totalSize);
137-
138- return tr (" Syncing %1 of %2" ).arg (completedFormatted, totalFormatted);
157+ QString percentFormatted = QString::number (_percentComplete);
158+ QString progress = tr (" Syncing %1 of %2 (%3 %" ).arg (completedFormatted, totalFormatted, percentFormatted);
159+
160+ if (_estimatedDownBw > 0 ) {
161+ QString formattedDownBw = Utility::octetsToString (_estimatedDownBw);
162+ progress.append (tr (" , ⬇️ %1/s" ).arg (formattedDownBw));
163+ }
164+ if (_estimatedUpBw > 0 ) {
165+ QString formattedUpBw = Utility::octetsToString (_estimatedUpBw);
166+ progress.append (tr (" , ⬆️ %1/s" ).arg (formattedUpBw));
167+ }
168+ progress.append (" )" );
169+ return progress;
139170 }
140171 };
141172
@@ -169,23 +200,7 @@ QVariant FolderItem::data(int role) const
169200 if (!_folder)
170201 return QVariant ();
171202
172- /* auto getErrors = [f] {
173- auto errors = f->syncResult().errorStrings();
174- const Result<void, QString> notLegacyError = FolderMan::instance()->unsupportedConfiguration(f->path());
175- if (!notLegacyError) {
176- errors.append(notLegacyError.error());
177- }
178- if (f->syncResult().hasUnresolvedConflicts()) {
179- errors.append(tr("There are unresolved conflicts."));
180- }
181- return errors;
182- };*/
183-
184203 switch (role) {
185- // case Roles::Subtitle:
186- // return getDescription();
187- // case Roles::FolderErrorMsg:
188- // return getErrors();
189204 case Qt::DisplayRole:
190205 return _folder->displayName ();
191206 case Qt::DecorationRole:
@@ -194,27 +209,10 @@ QVariant FolderItem::data(int role) const
194209 return Resources::getCoreIcon (statusIconName ());
195210 case FolderItemRoles::StatusStringRole:
196211 return _statusString;
197- // case ItemRoles::StatusInfoRole:
198- // return _progress._progressString;
199- /* case Roles::SyncProgressOverallPercent:
200- return folderInfo->_progress._overallPercent / 100.0;
201- case Roles::SyncProgressOverallString:
202- return folderInfo->_progress._overallSyncString; */
203212 case FolderItemRoles::SortPriorityRole:
204213 // everything will be sorted in descending order, multiply the priority by 100 and prefer A over Z by applying a negative factor
205214 return QVariant::fromValue (
206215 _folder->sortPriority () * 100 - (_folder->displayName ().isEmpty () ? 0 : static_cast <int64_t >(_folder->displayName ().at (0 ).toLower ().unicode ())));
207- /*
208-
209- case Roles::AccessibleDescriptionRole: {
210- QStringList desc = {f->displayName(), Utility::enumToDisplayName(f->syncResult().status())};
211- desc << getErrors();
212- if (f->syncResult().status() == SyncResult::SyncRunning) {
213- desc << folderInfo->_progress._overallSyncString << QStringLiteral("%1%").arg(QString::number(folderInfo->_progress._overallPercent));
214- }
215- desc << getDescription();
216- return desc.join(QLatin1Char(','));
217- }*/
218216 }
219217 return QStandardItem::data (role);
220218}
0 commit comments