mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
refactor saveDeckToClipboard in AbstractTabDeckEditor (#5671)
* refactor saveDeckToClipboard in AbstractTabDeckEditor * make deckloader functions const * use const * move method into DeckLoader
This commit is contained in:
parent
58a2b7ff39
commit
2a9599eed8
4 changed files with 29 additions and 41 deletions
|
|
@ -5,6 +5,8 @@
|
|||
#include "../main.h"
|
||||
#include "decklist.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
|
@ -372,7 +374,16 @@ DeckLoader::FileFormat DeckLoader::getFormatFromName(const QString &fileName)
|
|||
return PlainTextFormat;
|
||||
}
|
||||
|
||||
bool DeckLoader::saveToStream_Plain(QTextStream &out, bool addComments, bool addSetNameAndNumber)
|
||||
void DeckLoader::saveToClipboard(bool addComments, bool addSetNameAndNumber) const
|
||||
{
|
||||
QString buffer;
|
||||
QTextStream stream(&buffer);
|
||||
saveToStream_Plain(stream, addComments, addSetNameAndNumber);
|
||||
QApplication::clipboard()->setText(buffer, QClipboard::Clipboard);
|
||||
QApplication::clipboard()->setText(buffer, QClipboard::Selection);
|
||||
}
|
||||
|
||||
bool DeckLoader::saveToStream_Plain(QTextStream &out, bool addComments, bool addSetNameAndNumber) const
|
||||
{
|
||||
if (addComments) {
|
||||
saveToStream_DeckHeader(out);
|
||||
|
|
@ -391,7 +402,7 @@ bool DeckLoader::saveToStream_Plain(QTextStream &out, bool addComments, bool add
|
|||
return true;
|
||||
}
|
||||
|
||||
void DeckLoader::saveToStream_DeckHeader(QTextStream &out)
|
||||
void DeckLoader::saveToStream_DeckHeader(QTextStream &out) const
|
||||
{
|
||||
if (!getName().isEmpty()) {
|
||||
out << "// " << getName() << "\n\n";
|
||||
|
|
@ -409,7 +420,7 @@ void DeckLoader::saveToStream_DeckHeader(QTextStream &out)
|
|||
void DeckLoader::saveToStream_DeckZone(QTextStream &out,
|
||||
const InnerDecklistNode *zoneNode,
|
||||
bool addComments,
|
||||
bool addSetNameAndNumber)
|
||||
bool addSetNameAndNumber) const
|
||||
{
|
||||
// group cards by card type and count the subtotals
|
||||
QMultiMap<QString, DecklistCardNode *> cardsByType;
|
||||
|
|
@ -457,7 +468,7 @@ void DeckLoader::saveToStream_DeckZoneCards(QTextStream &out,
|
|||
const InnerDecklistNode *zoneNode,
|
||||
QList<DecklistCardNode *> cards,
|
||||
bool addComments,
|
||||
bool addSetNameAndNumber)
|
||||
bool addSetNameAndNumber) const
|
||||
{
|
||||
// QMultiMap sorts values in reverse order
|
||||
for (int i = cards.size() - 1; i >= 0; --i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue