Compare commits

..

5 Commits

Author SHA1 Message Date
RickyRister
e80f13b78e [DeckDockWidget] Refactor to move down some methods in AbstractTabDeckEditor (#6444)
* move actSwapCard down

* rename method

* move actAddCard down
2025-12-22 05:48:55 -08:00
RickyRister
c12f4e9d2a [DeckListModel] remove more access to underlying decklist for iteration (#6436)
* [DeckListModel] remove more access to underlying decklist for iteration

* remove one last direct iteration of decklist
2025-12-21 16:19:57 -08:00
RickyRister
a0f977e80c [DeckList] refactor: pass DeckList by const ref (#6437)
* [DeckList] refactor: pass DeckList by const ref

* Change getDeckList to return a const ref
2025-12-21 16:19:33 -08:00
tooomm
73a90bdf38 Doxygen: Add bullet points to subpages lists & link webpage on welcome page (#6377)
* add bullet points to subpages

* Link to webpage from welcome page

* Add bullet points to subpages

* grouping

* Add TODO note to card database documentation

Added a TODO note for future updates.

* Fix GH alerts commands to be doxygen compatible
2025-12-20 17:46:13 +01:00
BruebachL
7f1d891e26 [Deprecation] Remove DBConverter from sources. (#6431)
Took 10 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2025-12-20 15:25:13 +01:00
38 changed files with 191 additions and 967 deletions

View File

@@ -122,7 +122,7 @@ if [[ $MAKE_SERVER ]]; then
flags+=("-DWITH_SERVER=1") flags+=("-DWITH_SERVER=1")
fi fi
if [[ $MAKE_NO_CLIENT ]]; then if [[ $MAKE_NO_CLIENT ]]; then
flags+=("-DWITH_CLIENT=0" "-DWITH_ORACLE=0" "-DWITH_DBCONVERTER=0") flags+=("-DWITH_CLIENT=0" "-DWITH_ORACLE=0")
fi fi
if [[ $MAKE_TEST ]]; then if [[ $MAKE_TEST ]]; then
flags+=("-DTEST=1") flags+=("-DTEST=1")
@@ -246,7 +246,7 @@ fi
if [[ $RUNNER_OS == macOS ]]; then if [[ $RUNNER_OS == macOS ]]; then
echo "::group::Inspect Mach-O binaries" echo "::group::Inspect Mach-O binaries"
for app in cockatrice oracle servatrice dbconverter; do for app in cockatrice oracle servatrice; do
binary="$GITHUB_WORKSPACE/build/$app/$app.app/Contents/MacOS/$app" binary="$GITHUB_WORKSPACE/build/$app/$app.app/Contents/MacOS/$app"
echo "Inspecting $app..." echo "Inspecting $app..."
vtool -show-build "$binary" vtool -show-build "$binary"

4
.gitmodules vendored
View File

@@ -1,7 +1,3 @@
[submodule "vcpkg"] [submodule "vcpkg"]
path = vcpkg path = vcpkg
url = https://github.com/microsoft/vcpkg.git url = https://github.com/microsoft/vcpkg.git
[submodule "doxygen-awesome-css"]
path = doc/doxygen/theme
url = https://github.com/jothepro/doxygen-awesome-css.git

View File

@@ -20,8 +20,6 @@ option(WITH_SERVER "build servatrice" OFF)
option(WITH_CLIENT "build cockatrice" ON) option(WITH_CLIENT "build cockatrice" ON)
# Compile oracle # Compile oracle
option(WITH_ORACLE "build oracle" ON) option(WITH_ORACLE "build oracle" ON)
# Compile dbconverter
option(WITH_DBCONVERTER "build dbconverter" ON)
# Compile tests # Compile tests
option(TEST "build tests" OFF) option(TEST "build tests" OFF)
# Use vcpkg regardless of OS # Use vcpkg regardless of OS
@@ -356,11 +354,6 @@ if(WITH_ORACLE)
set(CPACK_INSTALL_CMAKE_PROJECTS "Oracle;Oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) set(CPACK_INSTALL_CMAKE_PROJECTS "Oracle;Oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif() endif()
if(WITH_DBCONVERTER)
add_subdirectory(dbconverter)
set(CPACK_INSTALL_CMAKE_PROJECTS "Dbconverter;Dbconverter;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif()
if(TEST) if(TEST)
include(CTest) include(CTest)
add_subdirectory(tests) add_subdirectory(tests)

View File

@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /src WORKDIR /src
COPY . . COPY . .
RUN mkdir build && cd build && \ RUN mkdir build && cd build && \
cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 -DWITH_DBCONVERTER=0 && \ cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 && \
make -j$(nproc) && \ make -j$(nproc) && \
make install make install

View File

@@ -1068,8 +1068,6 @@ RECURSIVE = YES
EXCLUDE = build/ \ EXCLUDE = build/ \
cmake/ \ cmake/ \
doc/doxygen/theme/docs/ \
doc/doxygen/theme/include/ \
vcpkg/ \ vcpkg/ \
webclient/ webclient/
@@ -1432,8 +1430,7 @@ HTML_STYLESHEET =
# documentation. # documentation.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = doc/doxygen/css/doxygen_style.css \ HTML_EXTRA_STYLESHEET = doc/doxygen/css/doxygen_style.css
doc/doxygen/theme/doxygen-awesome.css
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note # other source files which should be copied to the HTML output directory. Note
@@ -1456,7 +1453,7 @@ HTML_EXTRA_FILES = doc/doxygen/js/graph_toggle.js
# The default value is: AUTO_LIGHT. # The default value is: AUTO_LIGHT.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE = LIGHT # required with doxygen-awesome-css theme, Auto Dark Mode will still work HTML_COLORSTYLE = AUTO_DARK
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to # will adjust the colors in the style sheet and background images according to
@@ -1767,7 +1764,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
DISABLE_INDEX = NO # YES is bugged in the theme, see jothepro/doxygen-awesome-css/issues/201 DISABLE_INDEX = YES
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. If the tag # structure should be generated to display hierarchical information. If the tag

View File

@@ -59,8 +59,8 @@ Join our [Discord community](https://discord.gg/3Z9yzmA) to connect with other p
- [Official Discord](https://discord.gg/3Z9yzmA) - [Official Discord](https://discord.gg/3Z9yzmA)
- [reddit r/Cockatrice](https://reddit.com/r/cockatrice) - [reddit r/Cockatrice](https://reddit.com/r/cockatrice)
>[!IMPORTANT] > [!IMPORTANT]
>For support regarding specific servers, please contact that server's admin/mods and use their dedicated communication channels rather than contacting the team building the software. > For support regarding specific servers, please contact that server's admin/mods and use their dedicated communication channels rather than contacting the team building the software.
# Contribute # Contribute
@@ -131,8 +131,8 @@ You can then
make package make package
``` ```
>[!NOTE] > [!NOTE]
>Detailed compiling instructions can be found in the Cockatrice wiki at [Compiling Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Compiling-Cockatrice) > Detailed compiling instructions can be found in the Cockatrice wiki at [Compiling Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Compiling-Cockatrice)
<br> <br>

View File

@@ -42,7 +42,6 @@ tell disk image_name
set position of item "Cockatrice.app" to { 139, 214 } set position of item "Cockatrice.app" to { 139, 214 }
set position of item "Oracle.app" to { 139, 414 } set position of item "Oracle.app" to { 139, 414 }
set position of item "Servatrice.app" to { 139, 614 } set position of item "Servatrice.app" to { 139, 614 }
set position of item "dbconverter.app" to { 1400, 1400 }
set position of item "Applications" to { 861, 414 } set position of item "Applications" to { 861, 414 }
end tell end tell
update without registering applications update without registering applications

View File

@@ -1,12 +1,11 @@
# Find a compatible Qt version # Find a compatible Qt version
# Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE, WITH_DBCONVERTER, FORCE_USE_QT5 # Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE, FORCE_USE_QT5
# Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system # Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system
# Optional Input: QT5_DIR -- Hint as to where Qt5 lives on the system # Optional Input: QT5_DIR -- Hint as to where Qt5 lives on the system
# Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt5, Qt6 # Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt5, Qt6
# Output: SERVATRICE_QT_MODULES # Output: SERVATRICE_QT_MODULES
# Output: COCKATRICE_QT_MODULES # Output: COCKATRICE_QT_MODULES
# Output: ORACLE_QT_MODULES # Output: ORACLE_QT_MODULES
# Output: DBCONVERTER_QT_MODULES
# Output: TEST_QT_MODULES # Output: TEST_QT_MODULES
set(REQUIRED_QT_COMPONENTS Core) set(REQUIRED_QT_COMPONENTS Core)
@@ -29,15 +28,12 @@ endif()
if(WITH_ORACLE) if(WITH_ORACLE)
set(_ORACLE_NEEDED Concurrent Network Svg Widgets) set(_ORACLE_NEEDED Concurrent Network Svg Widgets)
endif() endif()
if(WITH_DBCONVERTER)
set(_DBCONVERTER_NEEDED Network Widgets)
endif()
if(TEST) if(TEST)
set(_TEST_NEEDED Widgets) set(_TEST_NEEDED Widgets)
endif() endif()
set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_COCKATRICE_NEEDED} ${_ORACLE_NEEDED} set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_COCKATRICE_NEEDED} ${_ORACLE_NEEDED}
${_DBCONVERTER_NEEDED} ${_TEST_NEEDED} ${_TEST_NEEDED}
) )
list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS) list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS)
@@ -112,7 +108,6 @@ message(DEBUG "QT_LIBRARY_DIR = ${QT_LIBRARY_DIR}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" SERVATRICE_QT_MODULES "${_SERVATRICE_NEEDED}") string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" SERVATRICE_QT_MODULES "${_SERVATRICE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" COCKATRICE_QT_MODULES "${_COCKATRICE_NEEDED}") string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" COCKATRICE_QT_MODULES "${_COCKATRICE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" ORACLE_QT_MODULES "${_ORACLE_NEEDED}") string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" ORACLE_QT_MODULES "${_ORACLE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" DB_CONVERTER_QT_MODULES "${_DBCONVERTER_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" TEST_QT_MODULES "${_TEST_NEEDED}") string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" TEST_QT_MODULES "${_TEST_NEEDED}")
# Core-only export (useful for headless libs) # Core-only export (useful for headless libs)

View File

@@ -213,7 +213,6 @@ ${AndIf} ${FileExists} "$INSTDIR\portable.dat"
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\cockatrice.exe" Delete "$INSTDIR\cockatrice.exe"
Delete "$INSTDIR\oracle.exe" Delete "$INSTDIR\oracle.exe"
Delete "$INSTDIR\dbconverter.exe"
Delete "$INSTDIR\servatrice.exe" Delete "$INSTDIR\servatrice.exe"
Delete "$INSTDIR\Qt*.dll" Delete "$INSTDIR\Qt*.dll"
Delete "$INSTDIR\libmysql.dll" Delete "$INSTDIR\libmysql.dll"

View File

@@ -3,7 +3,7 @@
string(LENGTH "$ENV{MACOS_CERTIFICATE_NAME}" MACOS_CERTIFICATE_NAME_LEN) string(LENGTH "$ENV{MACOS_CERTIFICATE_NAME}" MACOS_CERTIFICATE_NAME_LEN)
if(APPLE AND MACOS_CERTIFICATE_NAME_LEN GREATER 0) if(APPLE AND MACOS_CERTIFICATE_NAME_LEN GREATER 0)
set(APPLICATIONS "cockatrice" "servatrice" "oracle" "dbconverter") set(APPLICATIONS "cockatrice" "servatrice" "oracle")
foreach(app_name IN LISTS APPLICATIONS) foreach(app_name IN LISTS APPLICATIONS)
set(FULL_APP_PATH "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/${app_name}.app") set(FULL_APP_PATH "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/${app_name}.app")

View File

@@ -43,23 +43,23 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply)
deleteLater(); deleteLater();
} }
void DeckStatsInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data) void DeckStatsInterface::getAnalyzeRequestData(const DeckList &deck, QByteArray &data)
{ {
DeckList deckWithoutTokens; DeckList deckWithoutTokens;
copyDeckWithoutTokens(*deck, deckWithoutTokens); copyDeckWithoutTokens(deck, deckWithoutTokens);
QUrl params; QUrl params;
QUrlQuery urlQuery; QUrlQuery urlQuery;
urlQuery.addQueryItem("deck", deckWithoutTokens.writeToString_Plain()); urlQuery.addQueryItem("deck", deckWithoutTokens.writeToString_Plain());
urlQuery.addQueryItem("decktitle", deck->getName()); urlQuery.addQueryItem("decktitle", deck.getName());
params.setQuery(urlQuery); params.setQuery(urlQuery);
data->append(params.query(QUrl::EncodeReserved).toUtf8()); data.append(params.query(QUrl::EncodeReserved).toUtf8());
} }
void DeckStatsInterface::analyzeDeck(DeckList *deck) void DeckStatsInterface::analyzeDeck(const DeckList &deck)
{ {
QByteArray data; QByteArray data;
getAnalyzeRequestData(deck, &data); getAnalyzeRequestData(deck, data);
QNetworkRequest request(QUrl("https://deckstats.net/index.php")); QNetworkRequest request(QUrl("https://deckstats.net/index.php"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@@ -68,7 +68,7 @@ void DeckStatsInterface::analyzeDeck(DeckList *deck)
manager->post(request, data); manager->post(request, data);
} }
void DeckStatsInterface::copyDeckWithoutTokens(DeckList &source, DeckList &destination) void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
{ {
auto copyIfNotAToken = [this, &destination](const auto node, const auto card) { auto copyIfNotAToken = [this, &destination](const auto node, const auto card) {
CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName()); CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName());

View File

@@ -28,15 +28,15 @@ private:
* closest non-token card instead. So we construct a new deck which has no * closest non-token card instead. So we construct a new deck which has no
* tokens. * tokens.
*/ */
void copyDeckWithoutTokens(DeckList &source, DeckList &destination); void copyDeckWithoutTokens(const DeckList &source, DeckList &destination);
private slots: private slots:
void queryFinished(QNetworkReply *reply); void queryFinished(QNetworkReply *reply);
void getAnalyzeRequestData(DeckList *deck, QByteArray *data); void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
public: public:
explicit DeckStatsInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr); explicit DeckStatsInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr);
void analyzeDeck(DeckList *deck); void analyzeDeck(const DeckList &deck);
}; };
#endif #endif

View File

@@ -67,24 +67,24 @@ void TappedOutInterface::queryFinished(QNetworkReply *reply)
deleteLater(); deleteLater();
} }
void TappedOutInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data) void TappedOutInterface::getAnalyzeRequestData(const DeckList &deck, QByteArray &data)
{ {
DeckList mainboard, sideboard; DeckList mainboard, sideboard;
copyDeckSplitMainAndSide(*deck, mainboard, sideboard); copyDeckSplitMainAndSide(deck, mainboard, sideboard);
QUrl params; QUrl params;
QUrlQuery urlQuery; QUrlQuery urlQuery;
urlQuery.addQueryItem("name", deck->getName()); urlQuery.addQueryItem("name", deck.getName());
urlQuery.addQueryItem("mainboard", mainboard.writeToString_Plain(false, true)); urlQuery.addQueryItem("mainboard", mainboard.writeToString_Plain(false, true));
urlQuery.addQueryItem("sideboard", sideboard.writeToString_Plain(false, true)); urlQuery.addQueryItem("sideboard", sideboard.writeToString_Plain(false, true));
params.setQuery(urlQuery); params.setQuery(urlQuery);
data->append(params.query(QUrl::EncodeReserved).toUtf8()); data.append(params.query(QUrl::EncodeReserved).toUtf8());
} }
void TappedOutInterface::analyzeDeck(DeckList *deck) void TappedOutInterface::analyzeDeck(const DeckList &deck)
{ {
QByteArray data; QByteArray data;
getAnalyzeRequestData(deck, &data); getAnalyzeRequestData(deck, data);
QNetworkRequest request(QUrl("https://tappedout.net/mtg-decks/paste/")); QNetworkRequest request(QUrl("https://tappedout.net/mtg-decks/paste/"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@@ -93,7 +93,7 @@ void TappedOutInterface::analyzeDeck(DeckList *deck)
manager->post(request, data); manager->post(request, data);
} }
void TappedOutInterface::copyDeckSplitMainAndSide(DeckList &source, DeckList &mainboard, DeckList &sideboard) void TappedOutInterface::copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard)
{ {
auto copyMainOrSide = [this, &mainboard, &sideboard](const auto node, const auto card) { auto copyMainOrSide = [this, &mainboard, &sideboard](const auto node, const auto card) {
CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName()); CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName());

View File

@@ -30,14 +30,14 @@ private:
QNetworkAccessManager *manager; QNetworkAccessManager *manager;
CardDatabase &cardDatabase; CardDatabase &cardDatabase;
void copyDeckSplitMainAndSide(DeckList &source, DeckList &mainboard, DeckList &sideboard); void copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard);
private slots: private slots:
void queryFinished(QNetworkReply *reply); void queryFinished(QNetworkReply *reply);
void getAnalyzeRequestData(DeckList *deck, QByteArray *data); void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
public: public:
explicit TappedOutInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr); explicit TappedOutInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr);
void analyzeDeck(DeckList *deck); void analyzeDeck(const DeckList &deck);
}; };
#endif #endif

View File

@@ -287,14 +287,14 @@ static QString toDecklistExportString(const QList<const DecklistCardNode *> &car
* @param deckList The decklist to export * @param deckList The decklist to export
* @param website The website we're sending the deck to * @param website The website we're sending the deck to
*/ */
QString DeckLoader::exportDeckToDecklist(const DeckList *deckList, DecklistWebsite website) QString DeckLoader::exportDeckToDecklist(const DeckList &deckList, DecklistWebsite website)
{ {
// Add the base url // Add the base url
QString deckString = "https://" + getDomainForWebsite(website) + "/?"; QString deckString = "https://" + getDomainForWebsite(website) + "/?";
// export all cards in zone // export all cards in zone
QString mainBoardCards = toDecklistExportString(deckList->getCardNodes({DECK_ZONE_MAIN})); QString mainBoardCards = toDecklistExportString(deckList.getCardNodes({DECK_ZONE_MAIN}));
QString sideBoardCards = toDecklistExportString(deckList->getCardNodes({DECK_ZONE_SIDE})); QString sideBoardCards = toDecklistExportString(deckList.getCardNodes({DECK_ZONE_SIDE}));
// Remove the extra return at the end of the last cards // Remove the extra return at the end of the last cards
mainBoardCards.chop(3); mainBoardCards.chop(3);
@@ -310,7 +310,7 @@ QString DeckLoader::exportDeckToDecklist(const DeckList *deckList, DecklistWebsi
return deckString; return deckString;
} }
void DeckLoader::saveToClipboard(const DeckList *deckList, bool addComments, bool addSetNameAndNumber) void DeckLoader::saveToClipboard(const DeckList &deckList, bool addComments, bool addSetNameAndNumber)
{ {
QString buffer; QString buffer;
QTextStream stream(&buffer); QTextStream stream(&buffer);
@@ -320,7 +320,7 @@ void DeckLoader::saveToClipboard(const DeckList *deckList, bool addComments, boo
} }
bool DeckLoader::saveToStream_Plain(QTextStream &out, bool DeckLoader::saveToStream_Plain(QTextStream &out,
const DeckList *deckList, const DeckList &deckList,
bool addComments, bool addComments,
bool addSetNameAndNumber) bool addSetNameAndNumber)
{ {
@@ -329,7 +329,7 @@ bool DeckLoader::saveToStream_Plain(QTextStream &out,
} }
// loop zones // loop zones
for (auto zoneNode : deckList->getZoneNodes()) { for (auto zoneNode : deckList.getZoneNodes()) {
saveToStream_DeckZone(out, zoneNode, addComments, addSetNameAndNumber); saveToStream_DeckZone(out, zoneNode, addComments, addSetNameAndNumber);
// end of zone // end of zone
@@ -339,14 +339,14 @@ bool DeckLoader::saveToStream_Plain(QTextStream &out,
return true; return true;
} }
void DeckLoader::saveToStream_DeckHeader(QTextStream &out, const DeckList *deckList) void DeckLoader::saveToStream_DeckHeader(QTextStream &out, const DeckList &deckList)
{ {
if (!deckList->getName().isEmpty()) { if (!deckList.getName().isEmpty()) {
out << "// " << deckList->getName() << "\n\n"; out << "// " << deckList.getName() << "\n\n";
} }
if (!deckList->getComments().isEmpty()) { if (!deckList.getComments().isEmpty()) {
QStringList commentRows = deckList->getComments().split(QRegularExpression("\n|\r\n|\r")); QStringList commentRows = deckList.getComments().split(QRegularExpression("\n|\r\n|\r"));
for (const QString &row : commentRows) { for (const QString &row : commentRows) {
out << "// " << row << "\n"; out << "// " << row << "\n";
} }
@@ -434,7 +434,7 @@ void DeckLoader::saveToStream_DeckZoneCards(QTextStream &out,
} }
} }
bool DeckLoader::convertToCockatriceFormat(QString fileName) bool DeckLoader::convertToCockatriceFormat(const QString &fileName)
{ {
// Change the file extension to .cod // Change the file extension to .cod
QFileInfo fileInfo(fileName); QFileInfo fileInfo(fileName);
@@ -543,7 +543,7 @@ void DeckLoader::printDeckListNode(QTextCursor *cursor, const InnerDecklistNode
cursor->movePosition(QTextCursor::End); cursor->movePosition(QTextCursor::End);
} }
void DeckLoader::printDeckList(QPrinter *printer, const DeckList *deckList) void DeckLoader::printDeckList(QPrinter *printer, const DeckList &deckList)
{ {
QTextDocument doc; QTextDocument doc;
@@ -559,14 +559,14 @@ void DeckLoader::printDeckList(QPrinter *printer, const DeckList *deckList)
headerCharFormat.setFontWeight(QFont::Bold); headerCharFormat.setFontWeight(QFont::Bold);
cursor.insertBlock(headerBlockFormat, headerCharFormat); cursor.insertBlock(headerBlockFormat, headerCharFormat);
cursor.insertText(deckList->getName()); cursor.insertText(deckList.getName());
headerCharFormat.setFontPointSize(12); headerCharFormat.setFontPointSize(12);
cursor.insertBlock(headerBlockFormat, headerCharFormat); cursor.insertBlock(headerBlockFormat, headerCharFormat);
cursor.insertText(deckList->getComments()); cursor.insertText(deckList.getComments());
cursor.insertBlock(headerBlockFormat, headerCharFormat); cursor.insertBlock(headerBlockFormat, headerCharFormat);
for (auto zoneNode : deckList->getZoneNodes()) { for (auto zoneNode : deckList.getZoneNodes()) {
cursor.insertHtml("<br><img src=theme:hr.jpg>"); cursor.insertHtml("<br><img src=theme:hr.jpg>");
cursor.insertBlock(headerBlockFormat, headerCharFormat); cursor.insertBlock(headerBlockFormat, headerCharFormat);

View File

@@ -59,11 +59,11 @@ public:
bool saveToFile(const QString &fileName, DeckFileFormat::Format fmt); bool saveToFile(const QString &fileName, DeckFileFormat::Format fmt);
bool updateLastLoadedTimestamp(const QString &fileName, DeckFileFormat::Format fmt); bool updateLastLoadedTimestamp(const QString &fileName, DeckFileFormat::Format fmt);
static QString exportDeckToDecklist(const DeckList *deckList, DecklistWebsite website); static QString exportDeckToDecklist(const DeckList &deckList, DecklistWebsite website);
static void saveToClipboard(const DeckList *deckList, bool addComments = true, bool addSetNameAndNumber = true); static void saveToClipboard(const DeckList &deckList, bool addComments = true, bool addSetNameAndNumber = true);
static bool saveToStream_Plain(QTextStream &out, static bool saveToStream_Plain(QTextStream &out,
const DeckList *deckList, const DeckList &deckList,
bool addComments = true, bool addComments = true,
bool addSetNameAndNumber = true); bool addSetNameAndNumber = true);
@@ -72,9 +72,9 @@ public:
* @param printer The printer to render the decklist to. * @param printer The printer to render the decklist to.
* @param deckList * @param deckList
*/ */
static void printDeckList(QPrinter *printer, const DeckList *deckList); static void printDeckList(QPrinter *printer, const DeckList &deckList);
bool convertToCockatriceFormat(QString fileName); bool convertToCockatriceFormat(const QString &fileName);
LoadedDeck &getDeck() LoadedDeck &getDeck()
{ {
@@ -91,7 +91,7 @@ public:
private: private:
static void printDeckListNode(QTextCursor *cursor, const InnerDecklistNode *node); static void printDeckListNode(QTextCursor *cursor, const InnerDecklistNode *node);
static void saveToStream_DeckHeader(QTextStream &out, const DeckList *deckList); static void saveToStream_DeckHeader(QTextStream &out, const DeckList &deckList);
static void saveToStream_DeckZone(QTextStream &out, static void saveToStream_DeckZone(QTextStream &out,
const InnerDecklistNode *zoneNode, const InnerDecklistNode *zoneNode,

View File

@@ -76,14 +76,14 @@ void DeckEditorDeckDockWidget::createDeckDock()
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection); deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(deckView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, connect(deckView->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
&DeckEditorDeckDockWidget::updateCard); &DeckEditorDeckDockWidget::updateCard);
connect(deckView, &QTreeView::doubleClicked, this, &DeckEditorDeckDockWidget::actSwapCard); connect(deckView, &QTreeView::doubleClicked, this, &DeckEditorDeckDockWidget::actSwapSelection);
deckView->setContextMenuPolicy(Qt::CustomContextMenu); deckView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(deckView, &QTreeView::customContextMenuRequested, this, &DeckEditorDeckDockWidget::decklistCustomMenu); connect(deckView, &QTreeView::customContextMenuRequested, this, &DeckEditorDeckDockWidget::decklistCustomMenu);
connect(&deckViewKeySignals, &KeySignals::onShiftS, this, &DeckEditorDeckDockWidget::actSwapCard); connect(&deckViewKeySignals, &KeySignals::onShiftS, this, &DeckEditorDeckDockWidget::actSwapSelection);
connect(&deckViewKeySignals, &KeySignals::onEnter, this, &DeckEditorDeckDockWidget::actIncrement); connect(&deckViewKeySignals, &KeySignals::onEnter, this, &DeckEditorDeckDockWidget::actIncrementSelection);
connect(&deckViewKeySignals, &KeySignals::onCtrlAltEqual, this, &DeckEditorDeckDockWidget::actIncrement); connect(&deckViewKeySignals, &KeySignals::onCtrlAltEqual, this, &DeckEditorDeckDockWidget::actIncrementSelection);
connect(&deckViewKeySignals, &KeySignals::onCtrlAltMinus, this, &DeckEditorDeckDockWidget::actDecrementSelection); connect(&deckViewKeySignals, &KeySignals::onCtrlAltMinus, this, &DeckEditorDeckDockWidget::actDecrementSelection);
connect(&deckViewKeySignals, &KeySignals::onShiftRight, this, &DeckEditorDeckDockWidget::actIncrement); connect(&deckViewKeySignals, &KeySignals::onShiftRight, this, &DeckEditorDeckDockWidget::actIncrementSelection);
connect(&deckViewKeySignals, &KeySignals::onShiftLeft, this, &DeckEditorDeckDockWidget::actDecrementSelection); connect(&deckViewKeySignals, &KeySignals::onShiftLeft, this, &DeckEditorDeckDockWidget::actDecrementSelection);
connect(&deckViewKeySignals, &KeySignals::onDelete, this, &DeckEditorDeckDockWidget::actRemoveCard); connect(&deckViewKeySignals, &KeySignals::onDelete, this, &DeckEditorDeckDockWidget::actRemoveCard);
@@ -181,7 +181,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
aIncrement = new QAction(QString(), this); aIncrement = new QAction(QString(), this);
aIncrement->setIcon(QPixmap("theme:icons/increment")); aIncrement->setIcon(QPixmap("theme:icons/increment"));
connect(aIncrement, &QAction::triggered, this, &DeckEditorDeckDockWidget::actIncrement); connect(aIncrement, &QAction::triggered, this, &DeckEditorDeckDockWidget::actIncrementSelection);
auto *tbIncrement = new QToolButton(this); auto *tbIncrement = new QToolButton(this);
tbIncrement->setDefaultAction(aIncrement); tbIncrement->setDefaultAction(aIncrement);
@@ -199,7 +199,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
aSwapCard = new QAction(QString(), this); aSwapCard = new QAction(QString(), this);
aSwapCard->setIcon(QPixmap("theme:icons/swap")); aSwapCard->setIcon(QPixmap("theme:icons/swap"));
connect(aSwapCard, &QAction::triggered, this, &DeckEditorDeckDockWidget::actSwapCard); connect(aSwapCard, &QAction::triggered, this, &DeckEditorDeckDockWidget::actSwapSelection);
auto *tbSwapCard = new QToolButton(this); auto *tbSwapCard = new QToolButton(this);
tbSwapCard->setDefaultAction(aSwapCard); tbSwapCard->setDefaultAction(aSwapCard);
@@ -386,15 +386,15 @@ void DeckEditorDeckDockWidget::updateBannerCardComboBox()
// Collect unique (name, providerId) pairs // Collect unique (name, providerId) pairs
QSet<QPair<QString, QString>> bannerCardSet; QSet<QPair<QString, QString>> bannerCardSet;
QList<const DecklistCardNode *> cardsInDeck = deckModel->getDeckList()->getCardNodes(); QList<CardRef> cardsInDeck = deckModel->getCardRefs();
for (auto currentCard : cardsInDeck) { for (auto cardRef : cardsInDeck) {
if (!CardDatabaseManager::query()->getCard(currentCard->toCardRef())) { if (!CardDatabaseManager::query()->getCard(cardRef)) {
continue; continue;
} }
// Insert one entry per distinct card, ignore copies // Insert one entry per distinct card, ignore copies
bannerCardSet.insert({currentCard->getName(), currentCard->getCardProviderId()}); bannerCardSet.insert({cardRef.name, cardRef.providerId});
} }
// Convert to sorted list // Convert to sorted list
@@ -527,9 +527,9 @@ DeckLoader *DeckEditorDeckDockWidget::getDeckLoader()
return deckLoader; return deckLoader;
} }
DeckList *DeckEditorDeckDockWidget::getDeckList() const DeckList &DeckEditorDeckDockWidget::getDeckList() const
{ {
return deckModel->getDeckList(); return *deckModel->getDeckList();
} }
/** /**
@@ -582,7 +582,32 @@ QModelIndexList DeckEditorDeckDockWidget::getSelectedCardNodes() const
return selectedRows; return selectedRows;
} }
void DeckEditorDeckDockWidget::actIncrement() void DeckEditorDeckDockWidget::actAddCard(const ExactCard &card, const QString &_zoneName)
{
if (!card) {
return;
}
QString zoneName = card.getInfo().getIsToken() ? DECK_ZONE_TOKENS : _zoneName;
emit requestDeckHistorySave(tr("Added (%1): %2 (%3) %4")
.arg(zoneName, card.getName(), card.getPrinting().getSet()->getCorrectedShortName(),
card.getPrinting().getProperty("num")));
QModelIndex newCardIndex = deckModel->addCard(card, zoneName);
if (!newCardIndex.isValid()) {
return;
}
expandAll();
deckView->clearSelection();
deckView->setCurrentIndex(newCardIndex);
emit deckModified();
}
void DeckEditorDeckDockWidget::actIncrementSelection()
{ {
auto selectedRows = getSelectedCardNodes(); auto selectedRows = getSelectedCardNodes();
@@ -591,7 +616,20 @@ void DeckEditorDeckDockWidget::actIncrement()
} }
} }
void DeckEditorDeckDockWidget::actSwapCard() void DeckEditorDeckDockWidget::actSwapCard(const ExactCard &card, const QString &zoneName)
{
QString providerId = card.getPrinting().getUuid();
QString collectorNumber = card.getPrinting().getProperty("num");
QModelIndex foundCard = deckModel->findCard(card.getName(), zoneName, providerId, collectorNumber);
if (!foundCard.isValid()) {
foundCard = deckModel->findCard(card.getName(), zoneName);
}
swapCard(foundCard);
}
void DeckEditorDeckDockWidget::actSwapSelection()
{ {
auto selectedRows = getSelectedCardNodes(); auto selectedRows = getSelectedCardNodes();

View File

@@ -61,14 +61,14 @@ public slots:
void syncDisplayWidgetsToModel(); void syncDisplayWidgetsToModel();
void sortDeckModelToDeckView(); void sortDeckModelToDeckView();
DeckLoader *getDeckLoader(); DeckLoader *getDeckLoader();
DeckList *getDeckList(); const DeckList &getDeckList() const;
void actIncrement(); void actAddCard(const ExactCard &card, const QString &zoneName);
bool swapCard(const QModelIndex &idx); void actIncrementSelection();
void actDecrementCard(const ExactCard &card, QString zoneName); void actDecrementCard(const ExactCard &card, QString zoneName);
void actDecrementSelection(); void actDecrementSelection();
void actSwapCard(); void actSwapCard(const ExactCard &card, const QString &zoneName);
void actSwapSelection();
void actRemoveCard(); void actRemoveCard();
void offsetCountAtIndex(const QModelIndex &idx, int offset);
void initializeFormats(); void initializeFormats();
void expandAll(); void expandAll();
@@ -108,9 +108,11 @@ private:
void recursiveExpand(const QModelIndex &index); void recursiveExpand(const QModelIndex &index);
[[nodiscard]] QModelIndexList getSelectedCardNodes() const; [[nodiscard]] QModelIndexList getSelectedCardNodes() const;
void offsetCountAtIndex(const QModelIndex &idx, int offset);
private slots: private slots:
void decklistCustomMenu(QPoint point); void decklistCustomMenu(QPoint point);
bool swapCard(const QModelIndex &currentIndex);
void updateCard(QModelIndex, const QModelIndex &current); void updateCard(QModelIndex, const QModelIndex &current);
void updateName(const QString &name); void updateName(const QString &name);
void updateComments(); void updateComments();

View File

@@ -150,7 +150,7 @@ DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckList &_deckList, bool _
* @param addComments Whether to add annotations * @param addComments Whether to add annotations
* @return A QString * @return A QString
*/ */
static QString deckListToString(const DeckList *deckList, bool addComments) static QString deckListToString(const DeckList &deckList, bool addComments)
{ {
QString buffer; QString buffer;
QTextStream stream(&buffer); QTextStream stream(&buffer);
@@ -160,7 +160,7 @@ static QString deckListToString(const DeckList *deckList, bool addComments)
void DlgEditDeckInClipboard::actRefresh() void DlgEditDeckInClipboard::actRefresh()
{ {
setText(deckListToString(&deckList, annotated)); setText(deckListToString(deckList, annotated));
} }
void DlgEditDeckInClipboard::actOK() void DlgEditDeckInClipboard::actOK()

View File

@@ -178,7 +178,7 @@ void DlgSelectSetForCards::actOK()
void DlgSelectSetForCards::actClear() void DlgSelectSetForCards::actClear()
{ {
emit deckAboutToBeModified(tr("Cleared all printing information.")); emit deckAboutToBeModified(tr("Cleared all printing information."));
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData()); model->forEachCard(CardNodeFunction::ClearPrintingData());
emit deckModified(); emit deckModified();
accept(); accept();
} }
@@ -186,8 +186,8 @@ void DlgSelectSetForCards::actClear()
void DlgSelectSetForCards::actSetAllToPreferred() void DlgSelectSetForCards::actSetAllToPreferred()
{ {
emit deckAboutToBeModified(tr("Set all printings to preferred.")); emit deckAboutToBeModified(tr("Set all printings to preferred."));
model->getDeckList()->forEachCard(CardNodeFunction::ClearPrintingData()); model->forEachCard(CardNodeFunction::ClearPrintingData());
model->getDeckList()->forEachCard(CardNodeFunction::SetProviderIdToPreferred()); model->forEachCard(CardNodeFunction::SetProviderIdToPreferred());
emit deckModified(); emit deckModified();
accept(); accept();
} }

View File

@@ -124,7 +124,7 @@ void AbstractTabDeckEditor::onDeckModified()
*/ */
void AbstractTabDeckEditor::onDeckHistorySaveRequested(const QString &modificationReason) void AbstractTabDeckEditor::onDeckHistorySaveRequested(const QString &modificationReason)
{ {
historyManager->save(deckDockWidget->getDeckList()->createMemento(modificationReason)); historyManager->save(deckDockWidget->getDeckList().createMemento(modificationReason));
} }
/** /**
@@ -140,23 +140,9 @@ void AbstractTabDeckEditor::onDeckHistoryClearRequested()
* @param card Card to add. * @param card Card to add.
* @param zoneName Zone to add the card to. * @param zoneName Zone to add the card to.
*/ */
void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, QString zoneName) void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, const QString &zoneName)
{ {
if (!card) deckDockWidget->actAddCard(card, zoneName);
return;
if (card.getInfo().getIsToken())
zoneName = DECK_ZONE_TOKENS;
onDeckHistorySaveRequested(QString(tr("Added (%1): %2 (%3) %4"))
.arg(zoneName, card.getName(), card.getPrinting().getSet()->getCorrectedShortName(),
card.getPrinting().getProperty("num")));
QModelIndex newCardIndex = deckDockWidget->deckModel->addCard(card, zoneName);
deckDockWidget->expandAll();
deckDockWidget->deckView->clearSelection();
deckDockWidget->deckView->setCurrentIndex(newCardIndex);
setModified(true);
databaseDisplayDockWidget->searchEdit->setSelection(0, databaseDisplayDockWidget->searchEdit->text().length()); databaseDisplayDockWidget->searchEdit->setSelection(0, databaseDisplayDockWidget->searchEdit->text().length());
} }
@@ -193,24 +179,6 @@ void AbstractTabDeckEditor::actDecrementCardFromSideboard(const ExactCard &card)
emit decrementCard(card, DECK_ZONE_SIDE); emit decrementCard(card, DECK_ZONE_SIDE);
} }
/**
* @brief Swaps a card in a deck zone.
* @param card Card to swap.
* @param zoneName Zone to swap in.
*/
void AbstractTabDeckEditor::actSwapCard(const ExactCard &card, const QString &zoneName)
{
QString providerId = card.getPrinting().getUuid();
QString collectorNumber = card.getPrinting().getProperty("num");
QModelIndex foundCard = deckDockWidget->deckModel->findCard(card.getName(), zoneName, providerId, collectorNumber);
if (!foundCard.isValid()) {
foundCard = deckDockWidget->deckModel->findCard(card.getName(), zoneName);
}
deckDockWidget->swapCard(foundCard);
}
/** /**
* @brief Opens a deck in this tab. * @brief Opens a deck in this tab.
* @param deck The deck * @param deck The deck
@@ -231,7 +199,7 @@ void AbstractTabDeckEditor::openDeck(const LoadedDeck &deck)
void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck) void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
{ {
deckDockWidget->setDeck(_deck); deckDockWidget->setDeck(_deck);
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList()->getCardRefList())); CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList().getCardRefList()));
setModified(false); setModified(false);
aDeckDockVisible->setChecked(true); aDeckDockVisible->setChecked(true);
@@ -245,7 +213,7 @@ DeckLoader *AbstractTabDeckEditor::getDeckLoader() const
} }
/** @brief Returns the currently loaded deck list. */ /** @brief Returns the currently loaded deck list. */
DeckList *AbstractTabDeckEditor::getDeckList() const const DeckList &AbstractTabDeckEditor::getDeckList() const
{ {
return deckDockWidget->getDeckList(); return deckDockWidget->getDeckList();
} }
@@ -446,7 +414,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix("cod"); dialog.setDefaultSuffix("cod");
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS); dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
dialog.selectFile(getDeckList()->getName().trimmed()); dialog.selectFile(getDeckList().getName().trimmed());
if (!dialog.exec()) if (!dialog.exec())
return false; return false;
@@ -591,8 +559,7 @@ void AbstractTabDeckEditor::actLoadDeckFromWebsite()
*/ */
void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website) void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website)
{ {
if (DeckList *deckList = getDeckList()) { QString decklistUrlString = DeckLoader::exportDeckToDecklist(getDeckList(), website);
QString decklistUrlString = DeckLoader::exportDeckToDecklist(deckList, website);
// Check to make sure the string isn't empty. // Check to make sure the string isn't empty.
if (decklistUrlString.isEmpty()) { if (decklistUrlString.isEmpty()) {
// Show an error if the deck is empty, and return. // Show an error if the deck is empty, and return.
@@ -607,10 +574,6 @@ void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite
decklistUrlString = decklistUrl.toEncoded(); decklistUrlString = decklistUrl.toEncoded();
// We open the url in the user's default browser // We open the url in the user's default browser
QDesktopServices::openUrl(decklistUrlString); QDesktopServices::openUrl(decklistUrlString);
} else {
// if there's no deck loader object, return an error
QMessageBox::critical(this, tr("Error"), tr("No deck was selected to be exported."));
}
} }
/** @brief Exports deck to www.decklist.org. */ /** @brief Exports deck to www.decklist.org. */

View File

@@ -77,7 +77,6 @@ class QAction;
* *
* - actAddCard(const ExactCard &card) — Adds a card to the deck. * - actAddCard(const ExactCard &card) — Adds a card to the deck.
* - actDecrementCard(const ExactCard &card) — Removes a single instance of a card from the deck. * - actDecrementCard(const ExactCard &card) — Removes a single instance of a card from the deck.
* - actSwapCard(const ExactCard &card, const QString &zone) — Swaps a card between zones.
* - actRemoveCard() — Removes the currently selected card from the deck. * - actRemoveCard() — Removes the currently selected card from the deck.
* - actSaveDeckAs() — Performs a "Save As" action for the deck. * - actSaveDeckAs() — Performs a "Save As" action for the deck.
* - updateCard(const ExactCard &card) — Updates the currently displayed card info in the dock. * - updateCard(const ExactCard &card) — Updates the currently displayed card info in the dock.
@@ -122,7 +121,7 @@ public:
DeckLoader *getDeckLoader() const; DeckLoader *getDeckLoader() const;
/** @brief Returns the currently active deck list. */ /** @brief Returns the currently active deck list. */
DeckList *getDeckList() const; const DeckList &getDeckList() const;
/** @brief Sets the modified state of the tab. /** @brief Sets the modified state of the tab.
* @param _windowModified Whether the tab is modified. * @param _windowModified Whether the tab is modified.
@@ -320,10 +319,7 @@ protected:
bool isBlankNewDeck() const; bool isBlankNewDeck() const;
/** @brief Helper function to add a card to a specific deck zone. */ /** @brief Helper function to add a card to a specific deck zone. */
void addCardHelper(const ExactCard &card, QString zoneName); void addCardHelper(const ExactCard &card, const QString &zoneName);
/** @brief Swaps a card in the deck view. */
void actSwapCard(const ExactCard &card, const QString &zoneName);
/** @brief Opens a deck from a file. */ /** @brief Opens a deck from a file. */
virtual void openDeckFromFile(const QString &fileName, DeckOpenLocation deckOpenLocation); virtual void openDeckFromFile(const QString &fileName, DeckOpenLocation deckOpenLocation);

View File

@@ -70,9 +70,7 @@ ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWi
connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset); connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset);
model->getDeckList()->loadFromStream_Plain(deckStream, false); model->getDeckList()->loadFromStream_Plain(deckStream, false);
model->getDeckList()->forEachCard(CardNodeFunction::ResolveProviderId()); model->forEachCard(CardNodeFunction::ResolveProviderId());
model->rebuildTree();
retranslateUi(); retranslateUi();
} }

View File

@@ -191,7 +191,7 @@ void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
// Double click = swap // Double click = swap
if (event->type() == QEvent::MouseButtonDblClick && event->button() == Qt::LeftButton) { if (event->type() == QEvent::MouseButtonDblClick && event->button() == Qt::LeftButton) {
actSwapCard(card, zoneName); deckDockWidget->actSwapCard(card, zoneName);
idx = deckDockWidget->deckModel->findCard(card.getName(), zoneName); idx = deckDockWidget->deckModel->findCard(card.getName(), zoneName);
sel->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect); sel->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
return; return;

View File

@@ -334,13 +334,13 @@ QMenu *DeckPreviewWidget::createRightClickMenu()
auto saveToClipboardMenu = menu->addMenu(tr("Save Deck to Clipboard")); auto saveToClipboardMenu = menu->addMenu(tr("Save Deck to Clipboard"));
connect(saveToClipboardMenu->addAction(tr("Annotated")), &QAction::triggered, this, connect(saveToClipboardMenu->addAction(tr("Annotated")), &QAction::triggered, this,
[this] { DeckLoader::saveToClipboard(&deckLoader->getDeck().deckList, true, true); }); [this] { DeckLoader::saveToClipboard(deckLoader->getDeck().deckList, true, true); });
connect(saveToClipboardMenu->addAction(tr("Annotated (No set info)")), &QAction::triggered, this, connect(saveToClipboardMenu->addAction(tr("Annotated (No set info)")), &QAction::triggered, this,
[this] { DeckLoader::saveToClipboard(&deckLoader->getDeck().deckList, true, false); }); [this] { DeckLoader::saveToClipboard(deckLoader->getDeck().deckList, true, false); });
connect(saveToClipboardMenu->addAction(tr("Not Annotated")), &QAction::triggered, this, connect(saveToClipboardMenu->addAction(tr("Not Annotated")), &QAction::triggered, this,
[this] { DeckLoader::saveToClipboard(&deckLoader->getDeck().deckList, false, true); }); [this] { DeckLoader::saveToClipboard(deckLoader->getDeck().deckList, false, true); });
connect(saveToClipboardMenu->addAction(tr("Not Annotated (No set info)")), &QAction::triggered, this, connect(saveToClipboardMenu->addAction(tr("Not Annotated (No set info)")), &QAction::triggered, this,
[this] { DeckLoader::saveToClipboard(&deckLoader->getDeck().deckList, false, false); }); [this] { DeckLoader::saveToClipboard(deckLoader->getDeck().deckList, false, false); });
menu->addSeparator(); menu->addSeparator();

View File

@@ -1,133 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(Dbconverter VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# ------------------------
# Sources
# ------------------------
set(dbconverter_SOURCES src/main.cpp src/mocks.cpp ${VERSION_STRING_CPP})
# ------------------------
# Qt configuration
# ------------------------
set(QT_DONT_USE_QTGUI TRUE)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# ------------------------
# Build executable
# ------------------------
add_executable(dbconverter MACOSX_BUNDLE ${dbconverter_SOURCES})
# ------------------------
# Link libraries
# ------------------------
target_link_libraries(
dbconverter
PRIVATE libcockatrice_card
PRIVATE libcockatrice_interfaces
PRIVATE libcockatrice_settings
PRIVATE ${DB_CONVERTER_QT_MODULES}
)
# ------------------------
# Install rules
# ------------------------
if(UNIX)
if(APPLE)
set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.cockatrice.${PROJECT_NAME}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME}-${PROJECT_VERSION}")
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
install(TARGETS dbconverter BUNDLE DESTINATION ./)
else()
# Linux
install(TARGETS dbconverter RUNTIME DESTINATION bin/)
endif()
elseif(WIN32)
install(TARGETS dbconverter RUNTIME DESTINATION ./)
endif()
# ------------------------
# Qt plugin handling
# ------------------------
if(APPLE)
set(plugin_dest_dir dbconverter.app/Contents/Plugins)
set(qtconf_dest_dir dbconverter.app/Contents/Resources)
install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE
PATTERN "platforms/*.dylib"
)
install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins
Translations = Resources/translations\")
"
COMPONENT Runtime
)
install(
CODE "
file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
"
COMPONENT Runtime
)
endif()
if(WIN32)
set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .)
install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
DESTINATION ./
FILES_MATCHING
PATTERN "*.dll"
)
install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
COMPONENT Runtime
FILES_MATCHING
PATTERN "platforms/qdirect2d.dll"
PATTERN "platforms/qminimal.dll"
PATTERN "platforms/qoffscreen.dll"
PATTERN "platforms/qwindows.dll"
)
install(
CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins
Translations = Resources/translations\")
"
COMPONENT Runtime
)
install(
CODE "
file(GLOB_RECURSE QTPLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/dbconverter.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
"
COMPONENT Runtime
)
endif()

View File

@@ -1,66 +0,0 @@
/***************************************************************************
* Copyright (C) 2019 by Fabio Bas *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "main.h"
#include "mocks.h"
#include "version_string.h"
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QtGlobal>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setOrganizationName("Cockatrice");
app.setApplicationName("Dbconverter");
app.setApplicationVersion(VERSION_STRING);
QCommandLineParser parser;
parser.addPositionalArgument("olddb", "Read existing card database from <file>");
parser.addPositionalArgument("newdb", "Write new card database to <file>");
parser.addHelpOption();
parser.addVersionOption();
parser.process(app);
QString oldDbPath;
QString newDbPath;
QStringList args = parser.positionalArguments();
if (args.count() == 2) {
oldDbPath = QFileInfo(args.at(0)).absoluteFilePath();
newDbPath = QFileInfo(args.at(1)).absoluteFilePath();
} else {
qCritical() << "Usage: dbconverter <olddb> <newdb>";
parser.showHelp(1);
exit(0);
}
CardDatabaseConverter *db = new CardDatabaseConverter;
qInfo() << "---------------------------------------------";
qInfo() << "Loading cards from" << oldDbPath;
db->loadCardDatabase(oldDbPath);
qInfo() << "---------------------------------------------";
qInfo() << "Saving cards to" << newDbPath;
db->saveCardDatabase(newDbPath);
qInfo() << "---------------------------------------------";
}

View File

@@ -1,102 +0,0 @@
#ifndef MAIN_H
#define MAIN_H
#include "libcockatrice/interfaces/noop_card_set_priority_controller.h"
#include <libcockatrice/card/database/card_database.h>
#include <libcockatrice/card/database/parser/cockatrice_xml_4.h>
#include <libcockatrice/interfaces/noop_card_preference_provider.h>
static const QList<AllowedCount> kConstructedCounts = {{4, "legal"}, {0, "banned"}};
static const QList<AllowedCount> kSingletonCounts = {{1, "legal"}, {0, "banned"}};
class CardDatabaseConverter : public CardDatabase
{
public:
explicit CardDatabaseConverter()
{
// Replace querier with one that ignores SettingsCache
delete querier;
querier = new CardDatabaseQuerier(this, this, new NoopCardPreferenceProvider());
};
LoadStatus loadCardDatabase(const QString &path)
{
return loader->loadCardDatabase(path);
}
bool saveCardDatabase(const QString &fileName)
{
CockatriceXml4Parser parser(new NoopCardPreferenceProvider(), new NoopCardSetPriorityController());
return parser.saveToFile(createDefaultMagicFormats(), sets, cards, fileName);
}
FormatRulesNameMap createDefaultMagicFormats()
{
// Predefined common exceptions
CardCondition superTypeIsBasic;
superTypeIsBasic.field = "type";
superTypeIsBasic.matchType = "contains";
superTypeIsBasic.value = "Basic Land";
ExceptionRule basicLands;
basicLands.conditions.append(superTypeIsBasic);
CardCondition anyNumberAllowed;
anyNumberAllowed.field = "text";
anyNumberAllowed.matchType = "contains";
anyNumberAllowed.value = "A deck can have any number of";
ExceptionRule mayContainAnyNumber;
mayContainAnyNumber.conditions.append(anyNumberAllowed);
// Map to store default rules
FormatRulesNameMap defaultFormatRulesNameMap;
// ----------------- Helper lambda to create format -----------------
auto makeFormat = [&](const QString &name, int minDeck = 60, int maxDeck = -1, int maxSideboardSize = 15,
const QList<AllowedCount> &allowedCounts = kConstructedCounts) -> FormatRulesPtr {
FormatRulesPtr f(new FormatRules);
f->formatName = name;
f->allowedCounts = allowedCounts;
f->minDeckSize = minDeck;
f->maxDeckSize = maxDeck;
f->maxSideboardSize = maxSideboardSize;
f->exceptions.append(basicLands);
f->exceptions.append(mayContainAnyNumber);
defaultFormatRulesNameMap.insert(name.toLower(), f);
return f;
};
// ----------------- Standard formats -----------------
makeFormat("Standard");
makeFormat("Modern");
makeFormat("Legacy");
makeFormat("Pioneer");
makeFormat("Historic");
makeFormat("Timeless");
makeFormat("Future");
makeFormat("OldSchool");
makeFormat("Premodern");
makeFormat("Pauper");
makeFormat("Penny");
// ----------------- Singleton formats -----------------
makeFormat("Commander", 100, 100, 15, kSingletonCounts);
makeFormat("Duel", 100, 100, 15, kSingletonCounts);
makeFormat("Brawl", 60, 60, 15, kSingletonCounts);
makeFormat("StandardBrawl", 60, 60, 15, kSingletonCounts);
makeFormat("Oathbreaker", 60, 60, 15, kSingletonCounts);
makeFormat("PauperCommander", 100, 100, 15, kSingletonCounts);
makeFormat("Predh", 100, 100, 15, kSingletonCounts);
// ----------------- Restricted formats -----------------
makeFormat("Vintage", 60, -1, 15, {{4, "legal"}, {1, "restricted"}, {0, "banned"}});
return defaultFormatRulesNameMap;
}
};
#endif

View File

@@ -1,451 +0,0 @@
#include "mocks.h"
CardDatabaseSettings::CardDatabaseSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "cardDatabase.ini", QString(), QString(), parent)
{
}
void CardDatabaseSettings::setSortKey(QString /* shortName */, unsigned int /* sortKey */)
{
}
void CardDatabaseSettings::setEnabled(QString /* shortName */, bool /* enabled */)
{
}
void CardDatabaseSettings::setIsKnown(QString /* shortName */, bool /* isknown */)
{
}
unsigned int CardDatabaseSettings::getSortKey(QString /* shortName */)
{
return 0;
};
bool CardDatabaseSettings::isEnabled(QString /* shortName */)
{
return true;
};
bool CardDatabaseSettings::isKnown(QString /* shortName */)
{
return true;
};
QString SettingsCache::getDataPath()
{
return "";
}
QString SettingsCache::getSettingsPath()
{
return "";
}
void SettingsCache::translateLegacySettings()
{
}
QString SettingsCache::getSafeConfigPath(QString /* configEntry */, QString defaultPath) const
{
return defaultPath;
}
QString SettingsCache::getSafeConfigFilePath(QString /* configEntry */, QString defaultPath) const
{
return defaultPath;
}
void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
{
}
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
{
}
void SettingsCache::setCardViewExpandedRowsMax(int /* value */)
{
}
void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
{
}
void SettingsCache::setCardInfoViewMode(const int /* _viewMode */)
{
}
void SettingsCache::setHighlightWords(const QString & /* _highlightWords */)
{
}
void SettingsCache::setMasterVolume(int /* _masterVolume */)
{
}
void SettingsCache::setLeftJustified(const QT_STATE_CHANGED_T /* _leftJustified */)
{
}
void SettingsCache::setCardScaling(const QT_STATE_CHANGED_T /* _scaleCards */)
{
}
void SettingsCache::setStackCardOverlapPercent(const int /* _verticalCardOverlapPercent */)
{
}
void SettingsCache::setShowMessagePopups(const QT_STATE_CHANGED_T /* _showMessagePopups */)
{
}
void SettingsCache::setShowMentionPopups(const QT_STATE_CHANGED_T /* _showMentionPopus */)
{
}
void SettingsCache::setRoomHistory(const QT_STATE_CHANGED_T /* _roomHistory */)
{
}
void SettingsCache::setLang(const QString & /* _lang */)
{
}
void SettingsCache::setShowTipsOnStartup(bool /* _showTipsOnStartup */)
{
}
void SettingsCache::setSeenTips(const QList<int> & /* _seenTips */)
{
}
void SettingsCache::setDeckPath(const QString & /* _deckPath */)
{
}
void SettingsCache::setFiltersPath(const QString & /*_filtersPath */)
{
}
void SettingsCache::setReplaysPath(const QString & /* _replaysPath */)
{
}
void SettingsCache::setThemesPath(const QString & /* _themesPath */)
{
}
void SettingsCache::setPicsPath(const QString & /* _picsPath */)
{
}
void SettingsCache::setCardDatabasePath(const QString & /* _cardDatabasePath */)
{
}
void SettingsCache::setCustomCardDatabasePath(const QString & /* _customCardDatabasePath */)
{
}
void SettingsCache::setSpoilerDatabasePath(const QString & /* _spoilerDatabasePath */)
{
}
void SettingsCache::setTokenDatabasePath(const QString & /* _tokenDatabasePath */)
{
}
void SettingsCache::setThemeName(const QString & /* _themeName */)
{
}
void SettingsCache::setHomeTabBackgroundSource(const QString & /* _backgroundSource */)
{
}
void SettingsCache::setHomeTabBackgroundShuffleFrequency(int /* frequency */)
{
}
void SettingsCache::setTabVisualDeckStorageOpen(bool /*value*/)
{
}
void SettingsCache::setTabServerOpen(bool /*value*/)
{
}
void SettingsCache::setTabAccountOpen(bool /*value*/)
{
}
void SettingsCache::setTabDeckStorageOpen(bool /*value*/)
{
}
void SettingsCache::setTabReplaysOpen(bool /*value*/)
{
}
void SettingsCache::setTabAdminOpen(bool /*value*/)
{
}
void SettingsCache::setTabLogOpen(bool /*value*/)
{
}
void SettingsCache::setPicDownload(QT_STATE_CHANGED_T /* _picDownload */)
{
}
void SettingsCache::setShowStatusBar(bool /* value */)
{
}
void SettingsCache::setNotificationsEnabled(QT_STATE_CHANGED_T /* _notificationsEnabled */)
{
}
void SettingsCache::setSpectatorNotificationsEnabled(QT_STATE_CHANGED_T /* _spectatorNotificationsEnabled */)
{
}
void SettingsCache::setBuddyConnectNotificationsEnabled(QT_STATE_CHANGED_T /* _buddyConnectNotificationsEnabled */)
{
}
void SettingsCache::setDoubleClickToPlay(QT_STATE_CHANGED_T /* _doubleClickToPlay */)
{
}
void SettingsCache::setClickPlaysAllSelected(QT_STATE_CHANGED_T /* _clickPlaysAllSelected */)
{
}
void SettingsCache::setPlayToStack(QT_STATE_CHANGED_T /* _playToStack */)
{
}
void SettingsCache::setDoNotDeleteArrowsInSubPhases(QT_STATE_CHANGED_T /* _doNotDeleteArrowsInSubPhases */)
{
}
void SettingsCache::setStartingHandSize(int /* _startingHandSize */)
{
}
void SettingsCache::setAnnotateTokens(QT_STATE_CHANGED_T /* _annotateTokens */)
{
}
void SettingsCache::setTabGameSplitterSizes(const QByteArray & /* _tabGameSplitterSizes */)
{
}
void SettingsCache::setShowShortcuts(QT_STATE_CHANGED_T /* _showShortcuts */)
{
}
void SettingsCache::setDisplayCardNames(QT_STATE_CHANGED_T /* _displayCardNames */)
{
}
void SettingsCache::setOverrideAllCardArtWithPersonalPreference(QT_STATE_CHANGED_T /* _displayCardNames */)
{
}
void SettingsCache::setBumpSetsWithCardsInDeckToTop(QT_STATE_CHANGED_T /* _bumpSetsWithCardsInDeckToTop */)
{
}
void SettingsCache::setPrintingSelectorSortOrder(int /* _printingSelectorSortOrder */)
{
}
void SettingsCache::setPrintingSelectorCardSize(int /* _printingSelectorCardSize */)
{
}
void SettingsCache::setIncludeRebalancedCards(bool /* _includeRebalancedCards */)
{
}
void SettingsCache::setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T /* _navigationButtonsVisible */)
{
}
void SettingsCache::setDeckEditorBannerCardComboBoxVisible(
QT_STATE_CHANGED_T /* _deckEditorBannerCardComboBoxVisible */)
{
}
void SettingsCache::setDeckEditorTagsWidgetVisible(QT_STATE_CHANGED_T /* _deckEditorTagsWidgetVisible */)
{
}
void SettingsCache::setVisualDeckStorageSortingOrder(int /* _visualDeckStorageSortingOrder */)
{
}
void SettingsCache::setVisualDeckStorageShowFolders(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setVisualDeckStorageShowTagFilter(QT_STATE_CHANGED_T /* _showTags */)
{
}
void SettingsCache::setVisualDeckStorageDefaultTagsList(QStringList /* _defaultTagsList */)
{
}
void SettingsCache::setVisualDeckStorageSearchFolderNames(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setVisualDeckStorageShowBannerCardComboBox(QT_STATE_CHANGED_T /* _showBannerCardComboBox */)
{
}
void SettingsCache::setVisualDeckStorageShowTagsOnDeckPreviews(QT_STATE_CHANGED_T /* _showTags */)
{
}
void SettingsCache::setVisualDeckStorageCardSize(int /* _visualDeckStorageCardSize */)
{
}
void SettingsCache::setVisualDeckStorageDrawUnusedColorIdentities(
QT_STATE_CHANGED_T /* _visualDeckStorageDrawUnusedColorIdentities */)
{
}
void SettingsCache::setVisualDeckStorageUnusedColorIdentitiesOpacity(
int /* _visualDeckStorageUnusedColorIdentitiesOpacity */)
{
}
void SettingsCache::setVisualDeckStorageTooltipType(int /* value */)
{
}
void SettingsCache::setVisualDeckStoragePromptForConversion(bool /* _visualDeckStoragePromptForConversion */)
{
}
void SettingsCache::setVisualDeckStorageAlwaysConvert(bool /* _visualDeckStorageAlwaysConvert */)
{
}
void SettingsCache::setVisualDeckStorageInGame(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setDefaultDeckEditorType(int /* value */)
{
}
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T /* _enabled */)
{
}
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsAmount(int /* _amount */)
{
}
void SettingsCache::setVisualDeckEditorSampleHandSize(int /* _amount */)
{
}
void SettingsCache::setHorizontalHand(QT_STATE_CHANGED_T /* _horizontalHand */)
{
}
void SettingsCache::setInvertVerticalCoordinate(QT_STATE_CHANGED_T /* _invertVerticalCoordinate */)
{
}
void SettingsCache::setMinPlayersForMultiColumnLayout(int /* _minPlayersForMultiColumnLayout */)
{
}
void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T /* _tapAnimation */)
{
}
void SettingsCache::setAutoRotateSidewaysLayoutCards(QT_STATE_CHANGED_T /* _autoRotateSidewaysLayoutCards */)
{
}
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
{
}
void SettingsCache::setRewindBufferingMs(int /* _rewindBufferingMs */)
{
}
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
{
}
void SettingsCache::setChatMentionCompleter(const QT_STATE_CHANGED_T /* _enableMentionCompleter */)
{
}
void SettingsCache::setChatMentionForeground(QT_STATE_CHANGED_T /* _chatMentionForeground */)
{
}
void SettingsCache::setChatHighlightForeground(QT_STATE_CHANGED_T /* _chatHighlightForeground */)
{
}
void SettingsCache::setChatMentionColor(const QString & /* _chatMentionColor */)
{
}
void SettingsCache::setChatHighlightColor(const QString & /* _chatHighlightColor */)
{
}
void SettingsCache::setZoneViewGroupByIndex(int /* _zoneViewGroupByIndex */)
{
}
void SettingsCache::setZoneViewSortByIndex(int /* _zoneViewSortByIndex */)
{
}
void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */)
{
}
void SettingsCache::setSoundEnabled(QT_STATE_CHANGED_T /* _soundEnabled */)
{
}
void SettingsCache::setSoundThemeName(const QString & /* _soundThemeName */)
{
}
void SettingsCache::setIgnoreUnregisteredUsers(QT_STATE_CHANGED_T /* _ignoreUnregisteredUsers */)
{
}
void SettingsCache::setIgnoreUnregisteredUserMessages(QT_STATE_CHANGED_T /* _ignoreUnregisteredUserMessages */)
{
}
void SettingsCache::setMainWindowGeometry(const QByteArray & /* _mainWindowGeometry */)
{
}
void SettingsCache::setTokenDialogGeometry(const QByteArray & /* _tokenDialogGeometry */)
{
}
void SettingsCache::setSetsDialogGeometry(const QByteArray & /* _setsDialogGeometry */)
{
}
void SettingsCache::setPixmapCacheSize(const int /* _pixmapCacheSize */)
{
}
void SettingsCache::setNetworkCacheSizeInMB(const int /* _networkCacheSize */)
{
}
void SettingsCache::setNetworkRedirectCacheTtl(const int /* _redirectCacheTtl */)
{
}
void SettingsCache::setClientID(const QString & /* _clientID */)
{
}
void SettingsCache::setClientVersion(const QString & /* _clientVersion */)
{
}
QStringList SettingsCache::getCountries() const
{
static QStringList countries = QStringList() << "us";
return countries;
}
void SettingsCache::setGameDescription(const QString /* _gameDescription */)
{
}
void SettingsCache::setMaxPlayers(const int /* _maxPlayers */)
{
}
void SettingsCache::setGameTypes(const QString /* _gameTypes */)
{
}
void SettingsCache::setOnlyBuddies(const bool /* _onlyBuddies */)
{
}
void SettingsCache::setOnlyRegistered(const bool /* _onlyRegistered */)
{
}
void SettingsCache::setSpectatorsAllowed(const bool /* _spectatorsAllowed */)
{
}
void SettingsCache::setSpectatorsNeedPassword(const bool /* _spectatorsNeedPassword */)
{
}
void SettingsCache::setSpectatorsCanTalk(const bool /* _spectatorsCanTalk */)
{
}
void SettingsCache::setSpectatorsCanSeeEverything(const bool /* _spectatorsCanSeeEverything */)
{
}
void SettingsCache::setCreateGameAsSpectator(const bool /* _createGameAsSpectator */)
{
}
void SettingsCache::setDefaultStartingLifeTotal(const int /* _startingLifeTotal */)
{
}
void SettingsCache::setShareDecklistsOnLoad(const bool /* _shareDecklistsOnLoad */)
{
}
void SettingsCache::setRememberGameSettings(const bool /* _rememberGameSettings */)
{
}
void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setStartupCardUpdateCheckPromptForUpdate(bool /* value */)
{
}
void SettingsCache::setStartupCardUpdateCheckAlwaysUpdate(bool /* value */)
{
}
void SettingsCache::setCardUpdateCheckInterval(int /* value */)
{
}
void SettingsCache::setLastCardUpdateCheck(QDate /* value */)
{
}
void SettingsCache::setNotifyAboutUpdate(QT_STATE_CHANGED_T /* _notifyaboutupdate */)
{
}
void SettingsCache::setNotifyAboutNewVersion(QT_STATE_CHANGED_T /* _notifyaboutnewversion */)
{
}
void SettingsCache::setDownloadSpoilerStatus(bool /* _spoilerStatus */)
{
}
void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
{
}
void SettingsCache::setMaxFontSize(int /* _max */)
{
}
void SettingsCache::setRoundCardCorners(bool /* _roundCardCorners */)
{
}
void CardPictureLoader::clearPixmapCache(CardInfoPtr /* card */)
{
}

View File

@@ -1,24 +0,0 @@
/*
* Beware of this preprocessor hack used to redefine the settingCache class
* instead of including it and all of its dependencies.
* Always set header guards of mocked objects before including any headers
* with mocked objects.
*/
#include <QObject>
#include <QString>
#define PICTURELOADER_H
#include "../../cockatrice/src/client/settings/cache_settings.h"
#include <libcockatrice/card/database/card_database.h>
#include <libcockatrice/utility/macros.h>
extern SettingsCache *settingsCache;
class CardPictureLoader
{
public:
static void clearPixmapCache(CardInfoPtr card);
};

View File

@@ -1 +1,3 @@
@page card_database_schema_and_parsing Card Database Schema and Parsing @page card_database_schema_and_parsing Card Database Schema and Parsing
TODO

View File

@@ -5,4 +5,6 @@
This is the **main landing page** of the Cockatrice documentation. This is the **main landing page** of the Cockatrice documentation.
- Go to the @subpage user_reference page - Go to the @subpage user_reference page
- Or check out the @subpage developer_reference - Review the @subpage developer_reference
Or check out the [Cockatrice Webpage](https://cockatrice.github.io/).

View File

@@ -1,7 +1,6 @@
@page editing_decks Editing Decks @page editing_decks Editing Decks
@subpage editing_decks_classic - @subpage editing_decks_classic
- @subpage editing_decks_visual
@subpage editing_decks_visual - @subpage editing_decks_printings
@subpage editing_decks_printings

View File

@@ -1,13 +1,9 @@
@page user_reference User Reference @page user_reference User Reference
@subpage search_syntax_help - @subpage search_syntax_help
- @subpage deck_search_syntax_help
@subpage deck_search_syntax_help - @subpage creating_decks
- @subpage importing_decks
@subpage creating_decks - @subpage editing_decks
- @subpage exporting_decks
@subpage importing_decks
@subpage editing_decks
@subpage exporting_decks

View File

@@ -14,7 +14,6 @@ cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with
# defaults # defaults
include=("cockatrice/src" \ include=("cockatrice/src" \
"dbconverter/src" \
"libcockatrice_card" \ "libcockatrice_card" \
"libcockatrice_deck_list" \ "libcockatrice_deck_list" \
"libcockatrice_network" \ "libcockatrice_network" \

View File

@@ -561,6 +561,11 @@ void DeckListModel::setDeckList(DeckList *_deck)
rebuildTree(); rebuildTree();
} }
void DeckListModel::forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func)
{
deckList->forEachCard(func);
}
static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes) static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
{ {
QList<ExactCard> cards; QList<ExactCard> cards;
@@ -600,6 +605,17 @@ QList<QString> DeckListModel::getCardNames() const
return names; return names;
} }
QList<CardRef> DeckListModel::getCardRefs() const
{
auto nodes = deckList->getCardNodes();
QList<CardRef> cardRefs;
std::transform(nodes.cbegin(), nodes.cend(), std::back_inserter(cardRefs),
[](auto node) { return node->toCardRef(); });
return cardRefs;
}
QList<QString> DeckListModel::getZones() const QList<QString> DeckListModel::getZones() const
{ {
auto zoneNodes = deckList->getZoneNodes(); auto zoneNodes = deckList->getZoneNodes();

View File

@@ -309,6 +309,13 @@ public:
} }
void setDeckList(DeckList *_deck); void setDeckList(DeckList *_deck);
/**
* @brief Apply a function to every card in the deck tree.
*
* @param func Function taking (zone node, card node).
*/
void forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func);
/** /**
* @brief Creates a list consisting of the entries of the model mapped into ExactCards (with each entry looked up * @brief Creates a list consisting of the entries of the model mapped into ExactCards (with each entry looked up
* in the card database). * in the card database).
@@ -323,6 +330,10 @@ public:
* @brief Gets a deduplicated list of all card names that appear in the model * @brief Gets a deduplicated list of all card names that appear in the model
*/ */
[[nodiscard]] QList<QString> getCardNames() const; [[nodiscard]] QList<QString> getCardNames() const;
/**
* @brief Gets a deduplicated list of all CardRefs that appear in the model
*/
[[nodiscard]] QList<CardRef> getCardRefs() const;
/** /**
* @brief Gets a list of all zone names that appear in the model * @brief Gets a list of all zone names that appear in the model
*/ */