mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 12:03:25 -08:00
Compare commits
4 commits
bdb9de0e6e
...
d3b9ac2b43
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3b9ac2b43 | ||
|
|
317b37db01 | ||
|
|
14b3de0826 | ||
|
|
b4a2869579 |
4 changed files with 25 additions and 17 deletions
|
|
@ -42,6 +42,11 @@ DeckSyncManager::DeckSyncManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeckSyncManager::DeckSyncManager(AbstractClient *_client, ColorIdentityProvider provider, QObject *parent)
|
||||||
|
: QObject(parent), client(_client), colorIdentityProvider(std::move(provider))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void DeckSyncManager::setClient(AbstractClient *_client)
|
void DeckSyncManager::setClient(AbstractClient *_client)
|
||||||
{
|
{
|
||||||
client = _client;
|
client = _client;
|
||||||
|
|
@ -145,11 +150,12 @@ void DeckSyncManager::collectServerFiles(const ServerInfo_DeckStorage_Folder &fo
|
||||||
} else if (item.has_file()) {
|
} else if (item.has_file()) {
|
||||||
const QString path = prefix.isEmpty() ? name : prefix + "/" + name;
|
const QString path = prefix.isEmpty() ? name : prefix + "/" + name;
|
||||||
const ServerInfo_DeckStorage_File &file = item.file();
|
const ServerInfo_DeckStorage_File &file = item.file();
|
||||||
ServerFile entry;
|
ServerFile entry{
|
||||||
entry.id = item.id();
|
.id = item.id(),
|
||||||
entry.guid = QString::fromStdString(file.guid());
|
.guid = QString::fromStdString(file.guid()),
|
||||||
entry.hash = QString::fromStdString(file.hash());
|
.hash = QString::fromStdString(file.hash()),
|
||||||
entry.lastModifiedSecs = file.has_last_modified() ? static_cast<qint64>(file.last_modified()) : 0;
|
.lastModifiedSecs = file.has_last_modified() ? static_cast<qint64>(file.last_modified()) : 0,
|
||||||
|
};
|
||||||
files.insert(path, entry);
|
files.insert(path, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,17 @@ public:
|
||||||
/** @brief Computes the color identity string uploaded alongside a deck. May be empty. */
|
/** @brief Computes the color identity string uploaded alongside a deck. May be empty. */
|
||||||
using ColorIdentityProvider = std::function<QString(const DeckList &)>;
|
using ColorIdentityProvider = std::function<QString(const DeckList &)>;
|
||||||
|
|
||||||
|
/** @brief Outcome counts for a finished sync run; mirrors syncFinished() parameters. */
|
||||||
|
struct SyncSummary
|
||||||
|
{
|
||||||
|
int uploaded = 0;
|
||||||
|
int downloaded = 0;
|
||||||
|
int unchanged = 0;
|
||||||
|
int skipped = 0;
|
||||||
|
};
|
||||||
|
|
||||||
explicit DeckSyncManager(QObject *parent = nullptr);
|
explicit DeckSyncManager(QObject *parent = nullptr);
|
||||||
|
DeckSyncManager(AbstractClient *client, ColorIdentityProvider provider, QObject *parent = nullptr);
|
||||||
|
|
||||||
void setClient(AbstractClient *_client);
|
void setClient(AbstractClient *_client);
|
||||||
void setProfile(const DeckSyncProfile &_profile);
|
void setProfile(const DeckSyncProfile &_profile);
|
||||||
|
|
|
||||||
|
|
@ -255,10 +255,8 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
|
||||||
rightToolBar->addAction(aNewFolder);
|
rightToolBar->addAction(aNewFolder);
|
||||||
rightToolBar->addAction(aDeleteRemoteDeck);
|
rightToolBar->addAction(aDeleteRemoteDeck);
|
||||||
|
|
||||||
syncManager = new DeckSyncManager(this);
|
syncManager = new DeckSyncManager(
|
||||||
syncManager->setClient(client);
|
client, [](const DeckList &deck) { return getDeckColorIdentity(deck, CardDatabaseManager::query()); }, this);
|
||||||
syncManager->setColorIdentityProvider(
|
|
||||||
[](const DeckList &deck) { return getDeckColorIdentity(deck, CardDatabaseManager::query()); });
|
|
||||||
connect(syncManager, &DeckSyncManager::statusMessage, this, &TabDeckStorage::onSyncStatusMessage);
|
connect(syncManager, &DeckSyncManager::statusMessage, this, &TabDeckStorage::onSyncStatusMessage);
|
||||||
connect(syncManager, &DeckSyncManager::syncFinished, this, &TabDeckStorage::onSyncFinished);
|
connect(syncManager, &DeckSyncManager::syncFinished, this, &TabDeckStorage::onSyncFinished);
|
||||||
if (currentUserInfo != nullptr) {
|
if (currentUserInfo != nullptr) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#ifndef TAB_DECK_STORAGE_H
|
#ifndef TAB_DECK_STORAGE_H
|
||||||
#define TAB_DECK_STORAGE_H
|
#define TAB_DECK_STORAGE_H
|
||||||
|
|
||||||
|
#include "../deck_sync/deck_sync_manager.h"
|
||||||
#include "../interface/widgets/server/remote/remote_decklist_tree_widget.h"
|
#include "../interface/widgets/server/remote/remote_decklist_tree_widget.h"
|
||||||
#include "tab.h"
|
#include "tab.h"
|
||||||
|
|
||||||
|
|
@ -29,7 +30,6 @@ class QLabel;
|
||||||
class CommandContainer;
|
class CommandContainer;
|
||||||
class Response;
|
class Response;
|
||||||
class ShareBarWidget;
|
class ShareBarWidget;
|
||||||
class DeckSyncManager;
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class TabSupervisor;
|
class TabSupervisor;
|
||||||
|
|
@ -64,13 +64,7 @@ private:
|
||||||
Finished,
|
Finished,
|
||||||
Failed
|
Failed
|
||||||
};
|
};
|
||||||
struct SyncSummary
|
using SyncSummary = DeckSyncManager::SyncSummary;
|
||||||
{
|
|
||||||
int uploaded = 0;
|
|
||||||
int downloaded = 0;
|
|
||||||
int unchanged = 0;
|
|
||||||
int skipped = 0;
|
|
||||||
};
|
|
||||||
SyncStatusType syncStatusType = SyncStatusType::Idle;
|
SyncStatusType syncStatusType = SyncStatusType::Idle;
|
||||||
QString syncStatusDetail;
|
QString syncStatusDetail;
|
||||||
SyncSummary lastSyncSummary;
|
SyncSummary lastSyncSummary;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue