Skip to content

Commit

Permalink
Add method to get qtified file provider item metadata for account in …
Browse files Browse the repository at this point in the history
…FileProviderSettingsController

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Sep 28, 2023
1 parent 2c56056 commit 3a40c09
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/gui/macOS/fileprovidersettingscontroller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "gui/systray.h"
#include "gui/userinfo.h"
#include "gui/macOS/fileprovideritemmetadata.h"

// Objective-C imports
#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -154,6 +155,24 @@ float gbFromBytesWithOneDecimal(const unsigned long long bytes)
return storageUsage.unsignedLongLongValue;
}

[[nodiscard]] QVector<FileProviderItemMetadata> materialisedItemsForAccount(const QString &userIdAtHost) const
{
const auto materialisedItems = [_materialisedFiles objectForKey:userIdAtHost.toNSString()];
if (materialisedItems == nil) {
return {};
}

QVector<FileProviderItemMetadata> qMaterialisedItems;
qMaterialisedItems.reserve(materialisedItems.count);

for (const id<NSFileProviderItem> item in materialisedItems) {
const auto itemMetadata = FileProviderItemMetadata::fromNSFileProviderItem(item);
qMaterialisedItems.append(itemMetadata);
}

return qMaterialisedItems;
}

private:
[[nodiscard]] NSArray<NSString *> *nsEnabledAccounts() const
{
Expand Down

0 comments on commit 3a40c09

Please sign in to comment.