mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 11:03:25 -08:00
[Client+Server] Deck version history with restore
This commit is contained in:
parent
6d67b76fa3
commit
3cec286168
17 changed files with 436 additions and 0 deletions
73
cockatrice/src/interface/widgets/dialogs/dlg_deck_history.h
Normal file
73
cockatrice/src/interface/widgets/dialogs/dlg_deck_history.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* @file dlg_deck_history.h
|
||||
* @brief Browser for the stored versions of one server deck.
|
||||
*/
|
||||
|
||||
#ifndef DLG_DECK_HISTORY_H
|
||||
#define DLG_DECK_HISTORY_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
class AbstractClient;
|
||||
class CommandContainer;
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
class Response;
|
||||
|
||||
/** @brief One stored deck version for display. */
|
||||
struct DeckHistoryVersion
|
||||
{
|
||||
unsigned int versionNo = 0;
|
||||
qint64 createdAtSecs = 0;
|
||||
QString createdByClientId;
|
||||
QString hash;
|
||||
QString content;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class DlgDeckHistory
|
||||
* @brief Lists stored versions with a diff preview against the current deck.
|
||||
*
|
||||
* Restoring uploads the selected version as the new current content through
|
||||
* the regular deck-upload path, so it becomes a version itself instead of
|
||||
* rewriting history. Rejected dialogs restore nothing.
|
||||
*/
|
||||
class DlgDeckHistory : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgDeckHistory(int deckId, const QString &deckName, int limit, AbstractClient *client, QWidget *parent = nullptr);
|
||||
void retranslateUi();
|
||||
|
||||
signals:
|
||||
void restoreRequested(int deckId, const QString &content);
|
||||
|
||||
private slots:
|
||||
void onHistoryFinished(const Response &response, const CommandContainer &commandContainer);
|
||||
void onCurrentFinished(const Response &response, const CommandContainer &commandContainer);
|
||||
void onSelectionChanged();
|
||||
void onRestoreClicked();
|
||||
|
||||
private:
|
||||
void renderVersions();
|
||||
void renderPreview();
|
||||
|
||||
int deckId = -1;
|
||||
QString deckName;
|
||||
int limit = 20;
|
||||
AbstractClient *client = nullptr;
|
||||
QList<DeckHistoryVersion> versions;
|
||||
QString currentContent;
|
||||
bool historyArrived = false;
|
||||
bool currentArrived = false;
|
||||
|
||||
QLabel *detailLabel;
|
||||
QListWidget *versionsList;
|
||||
QListWidget *previewList;
|
||||
QPushButton *restoreButton;
|
||||
};
|
||||
|
||||
#endif // DLG_DECK_HISTORY_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue