32
32
#include < QVarLengthArray>
33
33
34
34
#include < set>
35
+ #include < winrt/base.h>
35
36
36
37
using namespace std ::chrono_literals;
37
38
@@ -181,7 +182,7 @@ namespace {
181
182
182
183
183
184
FolderStatusModel::FolderStatusModel (QObject *parent)
184
- : QAbstractTableModel (parent)
185
+ : QAbstractListModel (parent)
185
186
, _accountState(nullptr )
186
187
{
187
188
}
@@ -243,23 +244,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
243
244
if (!f)
244
245
return QVariant ();
245
246
246
- const auto getSpace = [&]() -> GraphApi::Space * {
247
- if (_accountState->supportsSpaces ()) {
248
- return _accountState->account ()->spacesManager ()->space (f->spaceId ());
249
- }
250
- return nullptr ;
251
- };
252
-
253
- switch (static_cast <Roles>(role)) {
254
- case Roles::Subtitle: {
255
- if (auto *space = getSpace ()) {
256
- if (!space->drive ().getDescription ().isEmpty ()) {
257
- return space->drive ().getDescription ();
258
- }
259
- }
260
- return tr (" Local folder: %1" ).arg (f->shortGuiLocalPath ());
261
- }
262
- case Roles::FolderErrorMsg: {
247
+ auto getErrors = [f] {
263
248
auto errors = f->syncResult ().errorStrings ();
264
249
const auto legacyError = FolderMan::instance ()->unsupportedConfiguration (f->path ());
265
250
if (!legacyError) {
@@ -276,13 +261,24 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
276
261
});
277
262
}
278
263
return errors;
279
- }
280
- case Roles::DisplayName: {
281
- if (auto *space = getSpace ()) {
282
- return space->displayName ();
264
+ };
265
+
266
+ auto getDescription = [f] {
267
+ if (auto *space = f->space ()) {
268
+ if (!space->drive ().getDescription ().isEmpty ()) {
269
+ return space->drive ().getDescription ();
270
+ }
283
271
}
272
+ return tr (" Local folder: %1" ).arg (f->shortGuiLocalPath ());
273
+ };
274
+
275
+ switch (static_cast <Roles>(role)) {
276
+ case Roles::Subtitle:
277
+ return getDescription ();
278
+ case Roles::FolderErrorMsg:
279
+ return getErrors ();
280
+ case Roles::DisplayName:
284
281
return f->displayName ();
285
- }
286
282
case Roles::FolderImageUrl:
287
283
if (f->accountState ()->supportsSpaces ()) {
288
284
// TODO: the url hast random parts to enforce a reload
@@ -323,15 +319,17 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
323
319
}
324
320
return tr (" %1 of %2 used" ).arg (Utility::octetsToString (used), Utility::octetsToString (total));
325
321
}
326
- case Roles::ToolTip: {
327
- if (_accountState->isConnected ()) {
328
- return tr (" The status of %1 is %2" ).arg (f->displayName (), Utility::enumToDisplayName (f->syncResult ().status ()));
329
- } else {
330
- return tr (" The account %1 is currently not connected." ).arg (f->accountState ()->account ()->displayName ());
331
- }
332
- }
333
322
case Roles::Folder:
334
323
return QVariant::fromValue (f);
324
+ case Roles::AccessibleDescriptionRole: {
325
+ QStringList desc = {f->displayName (), Utility::enumToDisplayName (f->syncResult ().status ())};
326
+ desc << getErrors ();
327
+ if (f->syncResult ().status () == SyncResult::SyncRunning) {
328
+ desc << folderInfo->_progress ._overallSyncString << QStringLiteral (" %1%" ).arg (QString::number (folderInfo->_progress ._overallPercent ));
329
+ }
330
+ desc << getDescription ();
331
+ return desc.join (QLatin1Char (' ,' ));
332
+ }
335
333
}
336
334
return {};
337
335
}
@@ -365,8 +363,8 @@ QHash<int, QByteArray> FolderStatusModel::roleNames() const
365
363
{static_cast <int >(Roles::SyncProgressItemString), " itemText" },
366
364
{static_cast <int >(Roles::FolderErrorMsg), " errorMsg" },
367
365
{static_cast <int >(Roles::Quota), " quota" },
368
- {static_cast <int >(Roles::ToolTip), " toolTip" },
369
366
{static_cast <int >(Roles::Folder), " folder" },
367
+ {static_cast <int >(Roles::AccessibleDescriptionRole), " accessibleDescription" },
370
368
};
371
369
}
372
370
0 commit comments