mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-23 07:28:24 -08:00
Compare commits
10 Commits
tooomm-dox
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
421d6b334a | ||
|
|
e7af1bbec9 | ||
|
|
01e8e4d589 | ||
|
|
be17ee1902 | ||
|
|
e557ae0f2a | ||
|
|
e80f13b78e | ||
|
|
c12f4e9d2a | ||
|
|
a0f977e80c | ||
|
|
73a90bdf38 | ||
|
|
7f1d891e26 |
@@ -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"
|
||||||
|
|||||||
6
.github/workflows/desktop-build.yml
vendored
6
.github/workflows/desktop-build.yml
vendored
@@ -213,7 +213,7 @@ jobs:
|
|||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
id: upload_artifact
|
id: upload_artifact
|
||||||
if: matrix.package != 'skip'
|
if: matrix.package != 'skip'
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{matrix.distro}}${{matrix.version}}-package
|
name: ${{matrix.distro}}${{matrix.version}}-package
|
||||||
path: ${{steps.build.outputs.path}}
|
path: ${{steps.build.outputs.path}}
|
||||||
@@ -450,7 +450,7 @@ jobs:
|
|||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
id: upload_artifact
|
id: upload_artifact
|
||||||
if: matrix.make_package
|
if: matrix.make_package
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{matrix.artifact_name}}
|
name: ${{matrix.artifact_name}}
|
||||||
path: ${{steps.build.outputs.path}}
|
path: ${{steps.build.outputs.path}}
|
||||||
@@ -458,7 +458,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload pdb database
|
- name: Upload pdb database
|
||||||
if: matrix.os == 'Windows'
|
if: matrix.os == 'Windows'
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: Windows${{matrix.target}}-debug-pdbs
|
name: Windows${{matrix.target}}-debug-pdbs
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
1
Doxyfile
1
Doxyfile
@@ -1068,7 +1068,6 @@ RECURSIVE = YES
|
|||||||
|
|
||||||
EXCLUDE = build/ \
|
EXCLUDE = build/ \
|
||||||
cmake/ \
|
cmake/ \
|
||||||
dbconverter/ \
|
|
||||||
vcpkg/ \
|
vcpkg/ \
|
||||||
webclient/
|
webclient/
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|
||||||
|
|||||||
@@ -287,6 +287,10 @@ set(cockatrice_SOURCES
|
|||||||
src/interface/widgets/tabs/visual_deck_storage/tab_deck_storage_visual.cpp
|
src/interface/widgets/tabs/visual_deck_storage/tab_deck_storage_visual.cpp
|
||||||
src/interface/key_signals.cpp
|
src/interface/key_signals.cpp
|
||||||
src/interface/logger.cpp
|
src/interface/logger.cpp
|
||||||
|
src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.cpp
|
||||||
|
src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_bracket_navigation_widget.h
|
||||||
|
src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.cpp
|
||||||
|
src/interface/widgets/tabs/api/edhrec/display/commander/edhrec_commander_api_response_budget_navigation_widget.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(sounds)
|
add_subdirectory(sounds)
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -91,8 +91,9 @@ QWidget *CardGroupDisplayWidget::constructWidgetForIndex(QPersistentModelIndex i
|
|||||||
if (indexToWidgetMap.contains(index)) {
|
if (indexToWidgetMap.contains(index)) {
|
||||||
return indexToWidgetMap[index];
|
return indexToWidgetMap[index];
|
||||||
}
|
}
|
||||||
auto cardName = deckListModel->data(index.sibling(index.row(), 1), Qt::EditRole).toString();
|
auto cardName = index.sibling(index.row(), DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
auto cardProviderId = deckListModel->data(index.sibling(index.row(), 4), Qt::EditRole).toString();
|
auto cardProviderId =
|
||||||
|
index.sibling(index.row(), DeckListModelColumns::CARD_PROVIDER_ID).data(Qt::EditRole).toString();
|
||||||
|
|
||||||
auto widget = new CardInfoPictureWithTextOverlayWidget(getLayoutParent(), true);
|
auto widget = new CardInfoPictureWithTextOverlayWidget(getLayoutParent(), true);
|
||||||
widget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
widget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
||||||
@@ -114,7 +115,7 @@ void CardGroupDisplayWidget::updateCardDisplays()
|
|||||||
|
|
||||||
// This doesn't really matter since overwrite the whole lessThan function to just compare dynamically anyway.
|
// This doesn't really matter since overwrite the whole lessThan function to just compare dynamically anyway.
|
||||||
proxy.setSortRole(Qt::EditRole);
|
proxy.setSortRole(Qt::EditRole);
|
||||||
proxy.sort(1, Qt::AscendingOrder);
|
proxy.sort(DeckListModelColumns::CARD_NAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
// 1. trackedIndex is a source index → map it to proxy space
|
// 1. trackedIndex is a source index → map it to proxy space
|
||||||
QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
|
QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
|
||||||
|
|||||||
@@ -82,10 +82,11 @@ void DeckCardZoneDisplayWidget::cleanupInvalidCardGroup(CardGroupDisplayWidget *
|
|||||||
|
|
||||||
void DeckCardZoneDisplayWidget::constructAppropriateWidget(QPersistentModelIndex index)
|
void DeckCardZoneDisplayWidget::constructAppropriateWidget(QPersistentModelIndex index)
|
||||||
{
|
{
|
||||||
auto categoryName = deckListModel->data(index.sibling(index.row(), 1), Qt::EditRole).toString();
|
|
||||||
if (indexToWidgetMap.contains(index)) {
|
if (indexToWidgetMap.contains(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto categoryName = index.sibling(index.row(), DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
if (displayType == DisplayType::Overlap) {
|
if (displayType == DisplayType::Overlap) {
|
||||||
auto *displayWidget = new OverlappedCardGroupDisplayWidget(
|
auto *displayWidget = new OverlappedCardGroupDisplayWidget(
|
||||||
cardGroupContainer, deckListModel, selectionModel, index, zoneName, categoryName, activeGroupCriteria,
|
cardGroupContainer, deckListModel, selectionModel, index, zoneName, categoryName, activeGroupCriteria,
|
||||||
@@ -120,7 +121,7 @@ void DeckCardZoneDisplayWidget::displayCards()
|
|||||||
QSortFilterProxyModel proxy;
|
QSortFilterProxyModel proxy;
|
||||||
proxy.setSourceModel(deckListModel);
|
proxy.setSourceModel(deckListModel);
|
||||||
proxy.setSortRole(Qt::EditRole);
|
proxy.setSortRole(Qt::EditRole);
|
||||||
proxy.sort(1, Qt::AscendingOrder);
|
proxy.sort(DeckListModelColumns::CARD_NAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
// 1. trackedIndex is a source index → map it to proxy space
|
// 1. trackedIndex is a source index → map it to proxy space
|
||||||
QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
|
QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ void DeckEditorDatabaseDisplayWidget::clearAllDatabaseFilters()
|
|||||||
|
|
||||||
void DeckEditorDatabaseDisplayWidget::updateCard(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
void DeckEditorDatabaseDisplayWidget::updateCard(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
||||||
{
|
{
|
||||||
const QString cardName = current.sibling(current.row(), 0).data().toString();
|
|
||||||
|
|
||||||
if (!current.isValid()) {
|
if (!current.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!current.model()->hasChildren(current.sibling(current.row(), 0))) {
|
const QString cardName = current.siblingAtColumn(CardDatabaseModel::NameColumn).data().toString();
|
||||||
|
|
||||||
|
if (!current.model()->hasChildren(current.siblingAtColumn(CardDatabaseModel::NameColumn))) {
|
||||||
emit cardChanged(CardDatabaseManager::query()->getPreferredCard(cardName));
|
emit cardChanged(CardDatabaseManager::query()->getPreferredCard(cardName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ ExactCard DeckEditorDatabaseDisplayWidget::currentCard() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString cardName = currentIndex.sibling(currentIndex.row(), 0).data().toString();
|
const QString cardName = currentIndex.siblingAtColumn(CardDatabaseModel::NameColumn).data().toString();
|
||||||
|
|
||||||
return CardDatabaseManager::query()->getPreferredCard(cardName);
|
return CardDatabaseManager::query()->getPreferredCard(cardName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
@@ -156,6 +156,9 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
|||||||
// Delay the update to avoid race conditions
|
// Delay the update to avoid race conditions
|
||||||
QTimer::singleShot(100, this, &DeckEditorDeckDockWidget::updateBannerCardComboBox);
|
QTimer::singleShot(100, this, &DeckEditorDeckDockWidget::updateBannerCardComboBox);
|
||||||
});
|
});
|
||||||
|
connect(deckModel, &DeckListModel::cardAddedAt, this, &DeckEditorDeckDockWidget::recursiveExpand);
|
||||||
|
connect(deckModel, &DeckListModel::deckReplaced, this, &DeckEditorDeckDockWidget::expandAll);
|
||||||
|
|
||||||
connect(bannerCardComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(bannerCardComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
&DeckEditorDeckDockWidget::setBannerCard);
|
&DeckEditorDeckDockWidget::setBannerCard);
|
||||||
bannerCardComboBox->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
|
bannerCardComboBox->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
|
||||||
@@ -175,13 +178,11 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
|||||||
deckModel->setActiveGroupCriteria(static_cast<DeckListModelGroupCriteria::Type>(
|
deckModel->setActiveGroupCriteria(static_cast<DeckListModelGroupCriteria::Type>(
|
||||||
activeGroupCriteriaComboBox->currentData(Qt::UserRole).toInt()));
|
activeGroupCriteriaComboBox->currentData(Qt::UserRole).toInt()));
|
||||||
deckModel->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
deckModel->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
||||||
deckView->expandAll();
|
|
||||||
deckView->expandAll();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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 +200,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);
|
||||||
|
|
||||||
@@ -319,17 +320,17 @@ ExactCard DeckEditorDeckDockWidget::getCurrentCard()
|
|||||||
QModelIndex current = deckView->selectionModel()->currentIndex();
|
QModelIndex current = deckView->selectionModel()->currentIndex();
|
||||||
if (!current.isValid())
|
if (!current.isValid())
|
||||||
return {};
|
return {};
|
||||||
const QString cardName = current.sibling(current.row(), 1).data().toString();
|
const QString cardName = current.siblingAtColumn(DeckListModelColumns::CARD_NAME).data().toString();
|
||||||
const QString cardProviderID = current.sibling(current.row(), 4).data().toString();
|
const QString cardProviderID = current.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data().toString();
|
||||||
const QModelIndex gparent = current.parent().parent();
|
const QModelIndex gparent = current.parent().parent();
|
||||||
|
|
||||||
if (!gparent.isValid()) {
|
if (!gparent.isValid()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString zoneName = gparent.sibling(gparent.row(), 1).data(Qt::EditRole).toString();
|
const QString zoneName = gparent.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
|
|
||||||
if (!current.model()->hasChildren(current.sibling(current.row(), 0))) {
|
if (!current.model()->hasChildren(current.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT))) {
|
||||||
if (ExactCard selectedCard = CardDatabaseManager::query()->getCard({cardName, cardProviderID})) {
|
if (ExactCard selectedCard = CardDatabaseManager::query()->getCard({cardName, cardProviderID})) {
|
||||||
return selectedCard;
|
return selectedCard;
|
||||||
}
|
}
|
||||||
@@ -386,15 +387,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
|
||||||
@@ -506,7 +507,6 @@ void DeckEditorDeckDockWidget::syncDisplayWidgetsToModel()
|
|||||||
bannerCardComboBox->blockSignals(false);
|
bannerCardComboBox->blockSignals(false);
|
||||||
updateHash();
|
updateHash();
|
||||||
sortDeckModelToDeckView();
|
sortDeckModelToDeckView();
|
||||||
expandAll();
|
|
||||||
|
|
||||||
deckTagsDisplayWidget->setTags(deckModel->getDeckList()->getTags());
|
deckTagsDisplayWidget->setTags(deckModel->getDeckList()->getTags());
|
||||||
}
|
}
|
||||||
@@ -516,8 +516,6 @@ void DeckEditorDeckDockWidget::sortDeckModelToDeckView()
|
|||||||
deckModel->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
deckModel->sort(deckView->header()->sortIndicatorSection(), deckView->header()->sortIndicatorOrder());
|
||||||
deckModel->setActiveFormat(deckModel->getDeckList()->getGameFormat());
|
deckModel->setActiveFormat(deckModel->getDeckList()->getGameFormat());
|
||||||
formatComboBox->setCurrentIndex(formatComboBox->findData(deckModel->getDeckList()->getGameFormat()));
|
formatComboBox->setCurrentIndex(formatComboBox->findData(deckModel->getDeckList()->getGameFormat()));
|
||||||
deckView->expandAll();
|
|
||||||
deckView->expandAll();
|
|
||||||
|
|
||||||
emit deckChanged();
|
emit deckChanged();
|
||||||
}
|
}
|
||||||
@@ -527,9 +525,9 @@ DeckLoader *DeckEditorDeckDockWidget::getDeckLoader()
|
|||||||
return deckLoader;
|
return deckLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckList *DeckEditorDeckDockWidget::getDeckList()
|
const DeckList &DeckEditorDeckDockWidget::getDeckList() const
|
||||||
{
|
{
|
||||||
return deckModel->getDeckList();
|
return *deckModel->getDeckList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -550,17 +548,26 @@ void DeckEditorDeckDockWidget::cleanDeck()
|
|||||||
deckTagsDisplayWidget->setTags(deckModel->getDeckList()->getTags());
|
deckTagsDisplayWidget->setTags(deckModel->getDeckList()->getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::recursiveExpand(const QModelIndex &index)
|
/**
|
||||||
|
* @brief Expands all parents of the given index.
|
||||||
|
* @param sourceIndex The index to expand (model source index)
|
||||||
|
*/
|
||||||
|
void DeckEditorDeckDockWidget::recursiveExpand(const QModelIndex &sourceIndex)
|
||||||
{
|
{
|
||||||
if (index.parent().isValid())
|
auto index = proxy->mapFromSource(sourceIndex);
|
||||||
recursiveExpand(index.parent());
|
|
||||||
|
while (index.parent().isValid()) {
|
||||||
|
index = index.parent();
|
||||||
deckView->expand(index);
|
deckView->expand(index);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fully expands all levels of the deck view
|
||||||
|
*/
|
||||||
void DeckEditorDeckDockWidget::expandAll()
|
void DeckEditorDeckDockWidget::expandAll()
|
||||||
{
|
{
|
||||||
deckView->expandAll();
|
deckView->expandRecursively(deckView->rootIndex());
|
||||||
deckView->expandAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -582,16 +589,53 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
deckView->clearSelection();
|
||||||
|
deckView->setCurrentIndex(newCardIndex);
|
||||||
|
|
||||||
|
emit deckModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckEditorDeckDockWidget::actIncrementSelection()
|
||||||
{
|
{
|
||||||
auto selectedRows = getSelectedCardNodes();
|
auto selectedRows = getSelectedCardNodes();
|
||||||
|
|
||||||
for (const auto &index : selectedRows) {
|
for (const auto &index : selectedRows) {
|
||||||
offsetCountAtIndex(index, 1);
|
offsetCountAtIndex(index, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@@ -627,22 +671,24 @@ bool DeckEditorDeckDockWidget::swapCard(const QModelIndex ¤tIndex)
|
|||||||
{
|
{
|
||||||
if (!currentIndex.isValid())
|
if (!currentIndex.isValid())
|
||||||
return false;
|
return false;
|
||||||
const QString cardName = currentIndex.sibling(currentIndex.row(), 1).data().toString();
|
const QString cardName = currentIndex.siblingAtColumn(DeckListModelColumns::CARD_NAME).data().toString();
|
||||||
const QString cardProviderID = currentIndex.sibling(currentIndex.row(), 4).data().toString();
|
const QString cardProviderID =
|
||||||
|
currentIndex.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data().toString();
|
||||||
const QModelIndex gparent = currentIndex.parent().parent();
|
const QModelIndex gparent = currentIndex.parent().parent();
|
||||||
|
|
||||||
if (!gparent.isValid())
|
if (!gparent.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString zoneName = gparent.sibling(gparent.row(), 1).data(Qt::EditRole).toString();
|
const QString zoneName = gparent.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
offsetCountAtIndex(currentIndex, -1);
|
offsetCountAtIndex(currentIndex, false);
|
||||||
const QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN;
|
const QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN;
|
||||||
|
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({cardName, cardProviderID});
|
if (ExactCard card = CardDatabaseManager::query()->getCard({cardName, cardProviderID})) {
|
||||||
QModelIndex newCardIndex = card ? deckModel->addCard(card, otherZoneName)
|
deckModel->addCard(card, otherZoneName);
|
||||||
|
} else {
|
||||||
// Third argument (true) says create the card no matter what, even if not in DB
|
// Third argument (true) says create the card no matter what, even if not in DB
|
||||||
: deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
|
deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
|
||||||
recursiveExpand(proxy->mapToSource(newCardIndex));
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -664,7 +710,7 @@ void DeckEditorDeckDockWidget::actDecrementCard(const ExactCard &card, QString z
|
|||||||
|
|
||||||
deckView->clearSelection();
|
deckView->clearSelection();
|
||||||
deckView->setCurrentIndex(proxy->mapToSource(idx));
|
deckView->setCurrentIndex(proxy->mapToSource(idx));
|
||||||
offsetCountAtIndex(idx, -1);
|
offsetCountAtIndex(idx, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::actDecrementSelection()
|
void DeckEditorDeckDockWidget::actDecrementSelection()
|
||||||
@@ -678,7 +724,7 @@ void DeckEditorDeckDockWidget::actDecrementSelection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &index : selectedRows) {
|
for (const auto &index : selectedRows) {
|
||||||
offsetCountAtIndex(index, -1);
|
offsetCountAtIndex(index, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
@@ -700,7 +746,7 @@ void DeckEditorDeckDockWidget::actRemoveCard()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QModelIndex sourceIndex = proxy->mapToSource(index);
|
QModelIndex sourceIndex = proxy->mapToSource(index);
|
||||||
QString cardName = sourceIndex.sibling(sourceIndex.row(), 1).data().toString();
|
QString cardName = sourceIndex.siblingAtColumn(DeckListModelColumns::CARD_NAME).data().toString();
|
||||||
|
|
||||||
emit requestDeckHistorySave(QString(tr("Removed \"%1\" (all copies)")).arg(cardName));
|
emit requestDeckHistorySave(QString(tr("Removed \"%1\" (all copies)")).arg(cardName));
|
||||||
|
|
||||||
@@ -715,7 +761,12 @@ void DeckEditorDeckDockWidget::actRemoveCard()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
/**
|
||||||
|
* @brief Increments or decrements the amount of the card node at the index by 1.
|
||||||
|
* @param idx The proxy index
|
||||||
|
* @param isIncrement If true, increments the count. If false, decrements the count
|
||||||
|
*/
|
||||||
|
void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, bool isIncrement)
|
||||||
{
|
{
|
||||||
if (!idx.isValid() || deckModel->hasChildren(idx)) {
|
if (!idx.isValid() || deckModel->hasChildren(idx)) {
|
||||||
return;
|
return;
|
||||||
@@ -723,26 +774,22 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
|
|||||||
|
|
||||||
QModelIndex sourceIndex = proxy->mapToSource(idx);
|
QModelIndex sourceIndex = proxy->mapToSource(idx);
|
||||||
|
|
||||||
const QModelIndex numberIndex = sourceIndex.sibling(sourceIndex.row(), 0);
|
QString cardName = sourceIndex.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
const QModelIndex nameIndex = sourceIndex.sibling(sourceIndex.row(), 1);
|
QString providerId =
|
||||||
|
sourceIndex.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data(Qt::DisplayRole).toString();
|
||||||
|
|
||||||
const QString cardName = deckModel->data(nameIndex, Qt::EditRole).toString();
|
const auto reason = QString(tr("%1 %2 × \"%3\" (%4)"))
|
||||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
.arg(isIncrement ? tr("Added") : tr("Removed"))
|
||||||
const int new_count = count + offset;
|
.arg(1)
|
||||||
|
|
||||||
const auto reason =
|
|
||||||
QString(tr("%1 %2 × \"%3\" (%4)"))
|
|
||||||
.arg(offset > 0 ? tr("Added") : tr("Removed"))
|
|
||||||
.arg(qAbs(offset))
|
|
||||||
.arg(cardName)
|
.arg(cardName)
|
||||||
.arg(deckModel->data(sourceIndex.sibling(sourceIndex.row(), 4), Qt::DisplayRole).toString());
|
.arg(providerId);
|
||||||
|
|
||||||
emit requestDeckHistorySave(reason);
|
emit requestDeckHistorySave(reason);
|
||||||
|
|
||||||
if (new_count <= 0) {
|
if (isIncrement) {
|
||||||
deckModel->removeRow(sourceIndex.row(), sourceIndex.parent());
|
deckModel->incrementAmountAtIndex(sourceIndex);
|
||||||
} else {
|
} else {
|
||||||
deckModel->setData(numberIndex, new_count, Qt::EditRole);
|
deckModel->decrementAmountAtIndex(sourceIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit deckModified();
|
emit deckModified();
|
||||||
|
|||||||
@@ -61,16 +61,15 @@ 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();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
@@ -106,11 +105,12 @@ private:
|
|||||||
|
|
||||||
QAction *aRemoveCard, *aIncrement, *aDecrement, *aSwapCard;
|
QAction *aRemoveCard, *aIncrement, *aDecrement, *aSwapCard;
|
||||||
|
|
||||||
void recursiveExpand(const QModelIndex &index);
|
|
||||||
[[nodiscard]] QModelIndexList getSelectedCardNodes() const;
|
[[nodiscard]] QModelIndexList getSelectedCardNodes() const;
|
||||||
|
void offsetCountAtIndex(const QModelIndex &idx, bool isIncrement);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void decklistCustomMenu(QPoint point);
|
void decklistCustomMenu(QPoint point);
|
||||||
|
bool swapCard(const QModelIndex ¤tIndex);
|
||||||
void updateCard(QModelIndex, const QModelIndex ¤t);
|
void updateCard(QModelIndex, const QModelIndex ¤t);
|
||||||
void updateName(const QString &name);
|
void updateName(const QString &name);
|
||||||
void updateComments();
|
void updateComments();
|
||||||
@@ -122,6 +122,8 @@ private slots:
|
|||||||
void updateShowBannerCardComboBox(bool visible);
|
void updateShowBannerCardComboBox(bool visible);
|
||||||
void updateShowTagsWidget(bool visible);
|
void updateShowTagsWidget(bool visible);
|
||||||
void syncBannerCardComboBoxSelectionWithDeck();
|
void syncBannerCardComboBoxSelectionWithDeck();
|
||||||
|
void recursiveExpand(const QModelIndex &parent);
|
||||||
|
void expandAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECK_EDITOR_DECK_DOCK_WIDGET_H
|
#endif // DECK_EDITOR_DECK_DOCK_WIDGET_H
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,9 +151,10 @@ void CardAmountWidget::addPrinting(const QString &zone)
|
|||||||
bool replacingProviderless = false;
|
bool replacingProviderless = false;
|
||||||
|
|
||||||
if (existing.isValid()) {
|
if (existing.isValid()) {
|
||||||
QString providerId = deckModel->data(existing.sibling(existing.row(), 4), Qt::DisplayRole).toString();
|
QString providerId =
|
||||||
|
existing.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data(Qt::DisplayRole).toString();
|
||||||
if (providerId.isEmpty()) {
|
if (providerId.isEmpty()) {
|
||||||
int amount = deckModel->data(existing, Qt::DisplayRole).toInt();
|
int amount = existing.data(Qt::DisplayRole).toInt();
|
||||||
extraCopies = amount - 1; // One less because we *always* add one
|
extraCopies = amount - 1; // One less because we *always* add one
|
||||||
replacingProviderless = true;
|
replacingProviderless = true;
|
||||||
}
|
}
|
||||||
@@ -174,12 +175,12 @@ void CardAmountWidget::addPrinting(const QString &zone)
|
|||||||
|
|
||||||
// Add the card and expand the list UI
|
// Add the card and expand the list UI
|
||||||
auto newCardIndex = deckModel->addCard(rootCard, zone);
|
auto newCardIndex = deckModel->addCard(rootCard, zone);
|
||||||
recursiveExpand(newCardIndex);
|
|
||||||
|
|
||||||
// Check if a card without a providerId already exists in the deckModel and replace it, if so.
|
// Check if a card without a providerId already exists in the deckModel and replace it, if so.
|
||||||
QString foundProviderId = deckModel->data(existing.sibling(existing.row(), 4), Qt::DisplayRole).toString();
|
QString foundProviderId =
|
||||||
|
existing.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data(Qt::DisplayRole).toString();
|
||||||
if (existing.isValid() && existing != newCardIndex && foundProviderId == "") {
|
if (existing.isValid() && existing != newCardIndex && foundProviderId == "") {
|
||||||
auto amount = deckModel->data(existing, Qt::DisplayRole);
|
auto amount = existing.data(Qt::DisplayRole);
|
||||||
for (int i = 0; i < amount.toInt() - 1; i++) {
|
for (int i = 0; i < amount.toInt() - 1; i++) {
|
||||||
deckModel->addCard(rootCard, zone);
|
deckModel->addCard(rootCard, zone);
|
||||||
}
|
}
|
||||||
@@ -227,46 +228,6 @@ void CardAmountWidget::removePrintingSideboard()
|
|||||||
decrementCardHelper(DECK_ZONE_SIDE);
|
decrementCardHelper(DECK_ZONE_SIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Recursively expands the card in the deck view starting from the given index.
|
|
||||||
*
|
|
||||||
* @param index The model index of the card to expand.
|
|
||||||
*/
|
|
||||||
void CardAmountWidget::recursiveExpand(const QModelIndex &index)
|
|
||||||
{
|
|
||||||
if (index.parent().isValid()) {
|
|
||||||
recursiveExpand(index.parent());
|
|
||||||
}
|
|
||||||
deckView->expand(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Offsets the card count at the specified index by the given amount.
|
|
||||||
*
|
|
||||||
* @param idx The model index of the card.
|
|
||||||
* @param offset The amount to add or subtract from the card count.
|
|
||||||
*/
|
|
||||||
void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
|
||||||
{
|
|
||||||
if (!idx.isValid() || offset == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QModelIndex numberIndex = idx.sibling(idx.row(), 0);
|
|
||||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
|
||||||
const int new_count = count + offset;
|
|
||||||
|
|
||||||
deckView->setCurrentIndex(numberIndex);
|
|
||||||
|
|
||||||
if (new_count <= 0) {
|
|
||||||
deckModel->removeRow(idx.row(), idx.parent());
|
|
||||||
} else {
|
|
||||||
deckModel->setData(numberIndex, new_count, Qt::EditRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
deckEditor->setModified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper function to decrement the card count for a given zone.
|
* @brief Helper function to decrement the card count for a given zone.
|
||||||
*
|
*
|
||||||
@@ -286,7 +247,7 @@ void CardAmountWidget::decrementCardHelper(const QString &zone)
|
|||||||
QModelIndex idx = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
QModelIndex idx = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
||||||
rootCard.getPrinting().getProperty("num"));
|
rootCard.getPrinting().getProperty("num"));
|
||||||
|
|
||||||
offsetCountAtIndex(idx, -1);
|
deckModel->decrementAmountAtIndex(idx);
|
||||||
deckEditor->setModified(true);
|
deckEditor->setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ private:
|
|||||||
|
|
||||||
bool hovered;
|
bool hovered;
|
||||||
|
|
||||||
void offsetCountAtIndex(const QModelIndex &idx, int offset);
|
|
||||||
void decrementCardHelper(const QString &zoneName);
|
void decrementCardHelper(const QString &zoneName);
|
||||||
void recursiveExpand(const QModelIndex &index);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addPrintingMainboard();
|
void addPrintingMainboard();
|
||||||
|
|||||||
@@ -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. */
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
@@ -85,7 +83,7 @@ void ArchidektApiResponseDeckDisplayWidget::retranslateUi()
|
|||||||
void ArchidektApiResponseDeckDisplayWidget::onGroupCriteriaChange(const QString &activeGroupCriteria)
|
void ArchidektApiResponseDeckDisplayWidget::onGroupCriteriaChange(const QString &activeGroupCriteria)
|
||||||
{
|
{
|
||||||
model->setActiveGroupCriteria(DeckListModelGroupCriteria::fromString(activeGroupCriteria));
|
model->setActiveGroupCriteria(DeckListModelGroupCriteria::fromString(activeGroupCriteria));
|
||||||
model->sort(1, Qt::AscendingOrder);
|
model->sort(DeckListModelColumns::CARD_NAME, Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchidektApiResponseDeckDisplayWidget::actOpenInDeckEditor()
|
void ArchidektApiResponseDeckDisplayWidget::actOpenInDeckEditor()
|
||||||
@@ -122,7 +120,7 @@ void ArchidektApiResponseDeckDisplayWidget::constructZoneWidgetsFromDeckListMode
|
|||||||
QSortFilterProxyModel proxy;
|
QSortFilterProxyModel proxy;
|
||||||
proxy.setSourceModel(model);
|
proxy.setSourceModel(model);
|
||||||
proxy.setSortRole(Qt::EditRole);
|
proxy.setSortRole(Qt::EditRole);
|
||||||
proxy.sort(1, Qt::AscendingOrder);
|
proxy.sort(DeckListModelColumns::CARD_NAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
for (int i = 0; i < proxy.rowCount(); ++i) {
|
for (int i = 0; i < proxy.rowCount(); ++i) {
|
||||||
QModelIndex proxyIndex = proxy.index(i, 0);
|
QModelIndex proxyIndex = proxy.index(i, 0);
|
||||||
@@ -135,10 +133,12 @@ void ArchidektApiResponseDeckDisplayWidget::constructZoneWidgetsFromDeckListMode
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString zoneName =
|
||||||
|
persistent.sibling(persistent.row(), DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
|
|
||||||
DeckCardZoneDisplayWidget *zoneDisplayWidget =
|
DeckCardZoneDisplayWidget *zoneDisplayWidget =
|
||||||
new DeckCardZoneDisplayWidget(zoneContainer, model, nullptr, persistent,
|
new DeckCardZoneDisplayWidget(zoneContainer, model, nullptr, persistent, zoneName, "maintype", {"name"},
|
||||||
model->data(persistent.sibling(persistent.row(), 1), Qt::EditRole).toString(),
|
DisplayType::Overlap, 20, 10, cardSizeSlider);
|
||||||
"maintype", {"name"}, DisplayType::Overlap, 20, 10, cardSizeSlider);
|
|
||||||
|
|
||||||
connect(displayOptionsWidget, &VisualDeckDisplayOptionsWidget::sortCriteriaChanged, zoneDisplayWidget,
|
connect(displayOptionsWidget, &VisualDeckDisplayOptionsWidget::sortCriteriaChanged, zoneDisplayWidget,
|
||||||
&DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged);
|
&DeckCardZoneDisplayWidget::onActiveSortCriteriaChanged);
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWi
|
|||||||
nameLabel = new QLabel(this);
|
nameLabel = new QLabel(this);
|
||||||
nameLabel->setText(toDisplay.name);
|
nameLabel->setText(toDisplay.name);
|
||||||
nameLabel->setAlignment(Qt::AlignHCenter);
|
nameLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
nameLabel->setStyleSheet("font-size: 20px; font-weight: bold");
|
||||||
|
|
||||||
inclusionDisplayWidget = new EdhrecApiResponseCardInclusionDisplayWidget(this, toDisplay);
|
inclusionDisplayWidget = new EdhrecApiResponseCardInclusionDisplayWidget(this, toDisplay);
|
||||||
|
|
||||||
synergyDisplayWidget = new EdhrecApiResponseCardSynergyDisplayWidget(this, toDisplay);
|
synergyDisplayWidget = new EdhrecApiResponseCardSynergyDisplayWidget(this, toDisplay);
|
||||||
|
|
||||||
layout->addWidget(nameLabel);
|
|
||||||
layout->addWidget(cardPictureWidget);
|
|
||||||
|
|
||||||
backgroundPlateWidget = new BackgroundPlateWidget(this);
|
backgroundPlateWidget = new BackgroundPlateWidget(this);
|
||||||
auto plateLayout = new QVBoxLayout(backgroundPlateWidget);
|
auto plateLayout = new QVBoxLayout(backgroundPlateWidget);
|
||||||
|
|
||||||
|
plateLayout->addWidget(nameLabel);
|
||||||
|
plateLayout->addWidget(cardPictureWidget);
|
||||||
plateLayout->addWidget(inclusionDisplayWidget);
|
plateLayout->addWidget(inclusionDisplayWidget);
|
||||||
plateLayout->addWidget(synergyDisplayWidget);
|
plateLayout->addWidget(synergyDisplayWidget);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "../../../../../cards/card_info_picture_widget.h"
|
#include "../../../../../cards/card_info_picture_widget.h"
|
||||||
#include "../../tab_edhrec_main.h"
|
#include "../../tab_edhrec_main.h"
|
||||||
#include "../card_prices/edhrec_api_response_card_prices_display_widget.h"
|
#include "../card_prices/edhrec_api_response_card_prices_display_widget.h"
|
||||||
|
#include "edhrec_commander_api_response_bracket_navigation_widget.h"
|
||||||
|
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
#include <libcockatrice/card/database/card_database_manager.h>
|
||||||
|
|
||||||
@@ -12,9 +13,14 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
|
|||||||
QString baseUrl)
|
QString baseUrl)
|
||||||
: QWidget(parent), commanderDetails(_commanderDetails)
|
: QWidget(parent), commanderDetails(_commanderDetails)
|
||||||
{
|
{
|
||||||
layout = new QVBoxLayout(this);
|
layout = new QHBoxLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
commanderLayout = new QHBoxLayout();
|
||||||
|
commanderDetailsLayout = new QVBoxLayout();
|
||||||
|
commanderDetailsLayout->setAlignment(Qt::AlignCenter);
|
||||||
|
navigationAndPricesLayout = new QVBoxLayout();
|
||||||
|
|
||||||
commanderPicture = new CardInfoPictureWidget(this);
|
commanderPicture = new CardInfoPictureWidget(this);
|
||||||
commanderPicture->setCard(CardDatabaseManager::query()->getCard({commanderDetails.getName()}));
|
commanderPicture->setCard(CardDatabaseManager::query()->getCard({commanderDetails.getName()}));
|
||||||
|
|
||||||
@@ -36,20 +42,35 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
|
|||||||
|
|
||||||
commanderDetails.debugPrint();
|
commanderDetails.debugPrint();
|
||||||
|
|
||||||
|
commanderName = new QLabel(this);
|
||||||
|
commanderName->setText(commanderDetails.getName());
|
||||||
|
commanderName->setAlignment(Qt::AlignCenter);
|
||||||
|
commanderName->setStyleSheet("font-size: 28px; font-weight: bold");
|
||||||
|
|
||||||
label = new QLabel(this);
|
label = new QLabel(this);
|
||||||
label->setAlignment(Qt::AlignCenter);
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
label->setStyleSheet("font-size: 16px");
|
||||||
|
|
||||||
salt = new QLabel(this);
|
salt = new QLabel(this);
|
||||||
salt->setAlignment(Qt::AlignCenter);
|
salt->setAlignment(Qt::AlignCenter);
|
||||||
|
salt->setStyleSheet("font-size: 16px");
|
||||||
|
|
||||||
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
|
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
|
||||||
|
|
||||||
navigationWidget = new EdhrecCommanderApiResponseNavigationWidget(this, commanderDetails, baseUrl);
|
navigationWidget = new EdhrecCommanderApiResponseNavigationWidget(this, commanderDetails, baseUrl);
|
||||||
|
|
||||||
layout->addWidget(commanderPicture);
|
commanderLayout->addWidget(commanderPicture);
|
||||||
layout->addWidget(label);
|
commanderDetailsLayout->addWidget(commanderName);
|
||||||
layout->addWidget(salt);
|
commanderDetailsLayout->addSpacing(1);
|
||||||
layout->addWidget(cardPricesDisplayWidget);
|
commanderDetailsLayout->addWidget(label);
|
||||||
layout->addWidget(navigationWidget);
|
commanderDetailsLayout->addWidget(salt);
|
||||||
|
commanderDetailsLayout->addWidget(cardPricesDisplayWidget);
|
||||||
|
commanderLayout->addLayout(commanderDetailsLayout);
|
||||||
|
navigationAndPricesLayout->addWidget(navigationWidget);
|
||||||
|
// navigationAndPricesLayout->addWidget(cardPricesDisplayWidget);
|
||||||
|
|
||||||
|
layout->addLayout(commanderLayout);
|
||||||
|
layout->addLayout(navigationAndPricesLayout);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||||
QVBoxLayout *layout;
|
QHBoxLayout *layout;
|
||||||
|
QHBoxLayout *commanderLayout;
|
||||||
|
QVBoxLayout *commanderDetailsLayout;
|
||||||
|
QVBoxLayout *navigationAndPricesLayout;
|
||||||
CardInfoPictureWidget *commanderPicture;
|
CardInfoPictureWidget *commanderPicture;
|
||||||
|
QLabel *commanderName;
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
QLabel *salt;
|
QLabel *salt;
|
||||||
EdhrecApiResponseCardPricesDisplayWidget *cardPricesDisplayWidget;
|
EdhrecApiResponseCardPricesDisplayWidget *cardPricesDisplayWidget;
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#include "edhrec_commander_api_response_bracket_navigation_widget.h"
|
||||||
|
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
EdhrecCommanderApiResponseBracketNavigationWidget::EdhrecCommanderApiResponseBracketNavigationWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &baseUrl)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
layout = new QGridLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
gameChangerLabel = new QLabel(this);
|
||||||
|
|
||||||
|
layout->addWidget(gameChangerLabel, 1, 0, 1, 2);
|
||||||
|
|
||||||
|
for (int i = 0; i < gameChangerOptions.length(); i++) {
|
||||||
|
QString option = gameChangerOptions.at(i);
|
||||||
|
QString label = option.isEmpty() ? "All" : option.at(0).toUpper() + option.mid(1);
|
||||||
|
QPushButton *optionButton = new QPushButton(label, this);
|
||||||
|
optionButton->setMinimumHeight(84);
|
||||||
|
optionButton->setStyleSheet("font-size: 24px");
|
||||||
|
gameChangerButtons[option] = optionButton;
|
||||||
|
layout->addWidget(optionButton, 2, i);
|
||||||
|
connect(optionButton, &QPushButton::clicked, this, [=, this]() {
|
||||||
|
selectedGameChanger = option;
|
||||||
|
updateOptionButtonSelection(gameChangerButtons, option);
|
||||||
|
emit requestNavigation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOptionButtonSelection(gameChangerButtons, "");
|
||||||
|
|
||||||
|
retranslateUi();
|
||||||
|
applyOptionsFromUrl(baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBracketNavigationWidget::retranslateUi()
|
||||||
|
{
|
||||||
|
gameChangerLabel->setText(tr("Game Changers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBracketNavigationWidget::applyOptionsFromUrl(const QString &url)
|
||||||
|
{
|
||||||
|
QString cleanedUrl = url;
|
||||||
|
|
||||||
|
// Remove base and file extension
|
||||||
|
if (cleanedUrl.startsWith("https://json.edhrec.com/pages/")) {
|
||||||
|
cleanedUrl = cleanedUrl.mid(QString("https://json.edhrec.com/pages/").length());
|
||||||
|
}
|
||||||
|
if (cleanedUrl.endsWith(".json")) {
|
||||||
|
cleanedUrl.chop(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expecting something like: "commanders/the-ur-dragon/core/expensive"
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
QStringList parts = cleanedUrl.split('/', Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
|
QStringList parts = cleanedUrl.split('/', QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (parts.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString commanderName = parts[1];
|
||||||
|
QString gameChangerOpt;
|
||||||
|
|
||||||
|
// Define valid sets
|
||||||
|
QSet<QString> validGameChangers = {"exhibition", "core", "upgraded", "optimized", "cedh"};
|
||||||
|
|
||||||
|
// Check remaining parts after commander
|
||||||
|
for (int i = 2; i < parts.size(); ++i) {
|
||||||
|
QString part = parts[i].toLower();
|
||||||
|
if (validGameChangers.contains(part)) {
|
||||||
|
gameChangerOpt = part;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate and apply
|
||||||
|
if (!gameChangerButtons.contains(gameChangerOpt)) {
|
||||||
|
gameChangerOpt.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedGameChanger = gameChangerOpt;
|
||||||
|
|
||||||
|
updateOptionButtonSelection(gameChangerButtons, selectedGameChanger);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBracketNavigationWidget::updateOptionButtonSelection(
|
||||||
|
QMap<QString, QPushButton *> &buttons,
|
||||||
|
const QString &selectedKey)
|
||||||
|
{
|
||||||
|
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
|
||||||
|
it.value()->setStyleSheet(it.key() == selectedKey
|
||||||
|
? "background-color: lightblue; font-weight: bold; font-size: 24px;"
|
||||||
|
: "font-size: 24px");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BRACKET_NAVIGATION_WIDGET_H
|
||||||
|
#define COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BRACKET_NAVIGATION_WIDGET_H
|
||||||
|
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class EdhrecCommanderApiResponseBracketNavigationWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EdhrecCommanderApiResponseBracketNavigationWidget(QWidget *parent, const QString &baseUrl);
|
||||||
|
void retranslateUi();
|
||||||
|
void applyOptionsFromUrl(const QString &url);
|
||||||
|
QString getSelectedGameChanger() const
|
||||||
|
{
|
||||||
|
return selectedGameChanger;
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void requestNavigation();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGridLayout *layout;
|
||||||
|
QLabel *gameChangerLabel;
|
||||||
|
|
||||||
|
QStringList gameChangerOptions = {"", "exhibition", "core", "upgraded", "optimized", "cedh"};
|
||||||
|
QString selectedGameChanger;
|
||||||
|
|
||||||
|
QMap<QString, QPushButton *> gameChangerButtons;
|
||||||
|
|
||||||
|
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BRACKET_NAVIGATION_WIDGET_H
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#include "edhrec_commander_api_response_budget_navigation_widget.h"
|
||||||
|
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
EdhrecCommanderApiResponseBudgetNavigationWidget::EdhrecCommanderApiResponseBudgetNavigationWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &baseUrl)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
layout = new QGridLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
budgetLabel = new QLabel(this);
|
||||||
|
|
||||||
|
layout->addWidget(budgetLabel, 3, 0, 1, 2);
|
||||||
|
|
||||||
|
for (int i = 0; i < budgetOptions.length(); i++) {
|
||||||
|
QString option = budgetOptions.at(i);
|
||||||
|
QString label = option.isEmpty() ? "Any" : option.at(0).toUpper() + option.mid(1);
|
||||||
|
QPushButton *btn = new QPushButton(label, this);
|
||||||
|
btn->setMinimumHeight(84);
|
||||||
|
btn->setStyleSheet("font-size: 24px");
|
||||||
|
budgetButtons[option] = btn;
|
||||||
|
layout->addWidget(btn, 4, i);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=, this]() {
|
||||||
|
selectedBudget = option;
|
||||||
|
updateOptionButtonSelection(budgetButtons, option);
|
||||||
|
emit requestNavigation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOptionButtonSelection(budgetButtons, "");
|
||||||
|
|
||||||
|
retranslateUi();
|
||||||
|
applyOptionsFromUrl(baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBudgetNavigationWidget::retranslateUi()
|
||||||
|
{
|
||||||
|
budgetLabel->setText(tr("Budget"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBudgetNavigationWidget::applyOptionsFromUrl(const QString &url)
|
||||||
|
{
|
||||||
|
QString cleanedUrl = url;
|
||||||
|
|
||||||
|
// Remove base and file extension
|
||||||
|
if (cleanedUrl.startsWith("https://json.edhrec.com/pages/")) {
|
||||||
|
cleanedUrl = cleanedUrl.mid(QString("https://json.edhrec.com/pages/").length());
|
||||||
|
}
|
||||||
|
if (cleanedUrl.endsWith(".json")) {
|
||||||
|
cleanedUrl.chop(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expecting something like: "commanders/the-ur-dragon/core/expensive"
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
QStringList parts = cleanedUrl.split('/', Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
|
QStringList parts = cleanedUrl.split('/', QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (parts.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString commanderName = parts[1];
|
||||||
|
QString gameChangerOpt, budgetOpt;
|
||||||
|
|
||||||
|
// Define valid sets
|
||||||
|
QSet<QString> validGameChangers = {"exhibition", "core", "upgraded", "optimized", "cedh"};
|
||||||
|
QSet<QString> validBudgets = {"budget", "expensive"};
|
||||||
|
|
||||||
|
// Check remaining parts after commander
|
||||||
|
for (int i = 2; i < parts.size(); ++i) {
|
||||||
|
QString part = parts[i].toLower();
|
||||||
|
if (validGameChangers.contains(part)) {
|
||||||
|
gameChangerOpt = part;
|
||||||
|
} else if (validBudgets.contains(part)) {
|
||||||
|
budgetOpt = part;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!budgetButtons.contains(budgetOpt)) {
|
||||||
|
budgetOpt.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedBudget = budgetOpt;
|
||||||
|
|
||||||
|
updateOptionButtonSelection(budgetButtons, selectedBudget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseBudgetNavigationWidget::updateOptionButtonSelection(
|
||||||
|
QMap<QString, QPushButton *> &buttons,
|
||||||
|
const QString &selectedKey)
|
||||||
|
{
|
||||||
|
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
|
||||||
|
it.value()->setStyleSheet(it.key() == selectedKey
|
||||||
|
? "background-color: lightblue; font-weight: bold; font-size: 24px;"
|
||||||
|
: "font-size: 24px");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BUDGET_NAVIGATION_WIDGET_H
|
||||||
|
#define COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BUDGET_NAVIGATION_WIDGET_H
|
||||||
|
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class EdhrecCommanderApiResponseBudgetNavigationWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EdhrecCommanderApiResponseBudgetNavigationWidget(QWidget *parent, const QString &baseUrl);
|
||||||
|
void retranslateUi();
|
||||||
|
void applyOptionsFromUrl(const QString &url);
|
||||||
|
QString getSelectedBudget() const
|
||||||
|
{
|
||||||
|
return selectedBudget;
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void requestNavigation();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGridLayout *layout;
|
||||||
|
QLabel *budgetLabel;
|
||||||
|
|
||||||
|
QStringList budgetOptions = {"", "budget", "expensive"};
|
||||||
|
QString selectedBudget;
|
||||||
|
|
||||||
|
QMap<QString, QPushButton *> budgetButtons;
|
||||||
|
|
||||||
|
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COCKATRICE_EDHREC_COMMANDER_API_RESPONSE_BUDGET_NAVIGATION_WIDGET_H
|
||||||
@@ -11,47 +11,28 @@ EdhrecCommanderApiResponseNavigationWidget::EdhrecCommanderApiResponseNavigation
|
|||||||
layout = new QGridLayout(this);
|
layout = new QGridLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
gameChangerLabel = new QLabel(this);
|
bracketNavigationWidget = new EdhrecCommanderApiResponseBracketNavigationWidget(this, baseUrl);
|
||||||
budgetLabel = new QLabel(this);
|
|
||||||
|
connect(bracketNavigationWidget, &EdhrecCommanderApiResponseBracketNavigationWidget::requestNavigation, this,
|
||||||
|
&EdhrecCommanderApiResponseNavigationWidget::actRequestCommanderNavigation);
|
||||||
|
|
||||||
|
budgetNavigationWidget = new EdhrecCommanderApiResponseBudgetNavigationWidget(this, baseUrl);
|
||||||
|
|
||||||
|
connect(budgetNavigationWidget, &EdhrecCommanderApiResponseBudgetNavigationWidget::requestNavigation, this,
|
||||||
|
&EdhrecCommanderApiResponseNavigationWidget::actRequestCommanderNavigation);
|
||||||
|
|
||||||
comboPushButton = new QPushButton(this);
|
comboPushButton = new QPushButton(this);
|
||||||
|
comboPushButton->setMinimumHeight(84);
|
||||||
|
comboPushButton->setStyleSheet("font-size: 24px");
|
||||||
averageDeckPushButton = new QPushButton(this);
|
averageDeckPushButton = new QPushButton(this);
|
||||||
|
averageDeckPushButton->setMinimumHeight(84);
|
||||||
|
averageDeckPushButton->setStyleSheet("font-size: 24px");
|
||||||
|
|
||||||
layout->addWidget(comboPushButton, 0, 0, 1, 1);
|
layout->addWidget(comboPushButton, 0, 0, 1, 1);
|
||||||
layout->addWidget(averageDeckPushButton, 0, 1, 1, 1);
|
layout->addWidget(averageDeckPushButton, 0, 1, 1, 1);
|
||||||
|
|
||||||
layout->addWidget(gameChangerLabel, 1, 0, 1, 2);
|
layout->addWidget(bracketNavigationWidget, 1, 0, 1, 2);
|
||||||
|
layout->addWidget(budgetNavigationWidget, 2, 0, 1, 2);
|
||||||
for (int i = 0; i < gameChangerOptions.length(); i++) {
|
|
||||||
QString option = gameChangerOptions.at(i);
|
|
||||||
QString label = option.isEmpty() ? "All" : option.at(0).toUpper() + option.mid(1);
|
|
||||||
QPushButton *optionButton = new QPushButton(label, this);
|
|
||||||
gameChangerButtons[option] = optionButton;
|
|
||||||
layout->addWidget(optionButton, 2, i);
|
|
||||||
connect(optionButton, &QPushButton::clicked, this, [=, this]() {
|
|
||||||
selectedGameChanger = option;
|
|
||||||
updateOptionButtonSelection(gameChangerButtons, option);
|
|
||||||
actRequestCommanderNavigation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
layout->addWidget(budgetLabel, 3, 0, 1, 2);
|
|
||||||
|
|
||||||
for (int i = 0; i < budgetOptions.length(); i++) {
|
|
||||||
QString option = budgetOptions.at(i);
|
|
||||||
QString label = option.isEmpty() ? "Any" : option.at(0).toUpper() + option.mid(1);
|
|
||||||
QPushButton *btn = new QPushButton(label, this);
|
|
||||||
budgetButtons[option] = btn;
|
|
||||||
layout->addWidget(btn, 4, i);
|
|
||||||
connect(btn, &QPushButton::clicked, this, [=, this]() {
|
|
||||||
selectedBudget = option;
|
|
||||||
updateOptionButtonSelection(budgetButtons, option);
|
|
||||||
actRequestCommanderNavigation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOptionButtonSelection(gameChangerButtons, "");
|
|
||||||
updateOptionButtonSelection(budgetButtons, "");
|
|
||||||
|
|
||||||
QWidget *currentParent = parentWidget();
|
QWidget *currentParent = parentWidget();
|
||||||
TabEdhRecMain *parentTab = nullptr;
|
TabEdhRecMain *parentTab = nullptr;
|
||||||
@@ -73,87 +54,21 @@ EdhrecCommanderApiResponseNavigationWidget::EdhrecCommanderApiResponseNavigation
|
|||||||
}
|
}
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
applyOptionsFromUrl(baseUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseNavigationWidget::retranslateUi()
|
void EdhrecCommanderApiResponseNavigationWidget::retranslateUi()
|
||||||
{
|
{
|
||||||
comboPushButton->setText(tr("Combos"));
|
comboPushButton->setText(tr("Combos"));
|
||||||
averageDeckPushButton->setText(tr("Average Deck"));
|
averageDeckPushButton->setText(tr("Average Deck"));
|
||||||
gameChangerLabel->setText(tr("Game Changers"));
|
|
||||||
budgetLabel->setText(tr("Budget"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseNavigationWidget::applyOptionsFromUrl(const QString &url)
|
|
||||||
{
|
|
||||||
QString cleanedUrl = url;
|
|
||||||
|
|
||||||
// Remove base and file extension
|
|
||||||
if (cleanedUrl.startsWith("https://json.edhrec.com/pages/")) {
|
|
||||||
cleanedUrl = cleanedUrl.mid(QString("https://json.edhrec.com/pages/").length());
|
|
||||||
}
|
|
||||||
if (cleanedUrl.endsWith(".json")) {
|
|
||||||
cleanedUrl.chop(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expecting something like: "commanders/the-ur-dragon/core/expensive"
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
||||||
QStringList parts = cleanedUrl.split('/', Qt::SkipEmptyParts);
|
|
||||||
#else
|
|
||||||
QStringList parts = cleanedUrl.split('/', QString::SkipEmptyParts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (parts.size() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString commanderName = parts[1];
|
|
||||||
QString gameChangerOpt, budgetOpt;
|
|
||||||
|
|
||||||
// Define valid sets
|
|
||||||
QSet<QString> validGameChangers = {"core", "upgraded", "optimized"};
|
|
||||||
QSet<QString> validBudgets = {"budget", "expensive"};
|
|
||||||
|
|
||||||
// Check remaining parts after commander
|
|
||||||
for (int i = 2; i < parts.size(); ++i) {
|
|
||||||
QString part = parts[i].toLower();
|
|
||||||
if (validGameChangers.contains(part)) {
|
|
||||||
gameChangerOpt = part;
|
|
||||||
} else if (validBudgets.contains(part)) {
|
|
||||||
budgetOpt = part;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate and apply
|
|
||||||
if (!gameChangerButtons.contains(gameChangerOpt)) {
|
|
||||||
gameChangerOpt.clear();
|
|
||||||
}
|
|
||||||
if (!budgetButtons.contains(budgetOpt)) {
|
|
||||||
budgetOpt.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedGameChanger = gameChangerOpt;
|
|
||||||
selectedBudget = budgetOpt;
|
|
||||||
|
|
||||||
updateOptionButtonSelection(gameChangerButtons, selectedGameChanger);
|
|
||||||
updateOptionButtonSelection(budgetButtons, selectedBudget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseNavigationWidget::updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons,
|
|
||||||
const QString &selectedKey)
|
|
||||||
{
|
|
||||||
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
|
|
||||||
it.value()->setStyleSheet(it.key() == selectedKey ? "background-color: lightblue; font-weight: bold;" : "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EdhrecCommanderApiResponseNavigationWidget::addNavigationOptionsToUrl(QString baseUrl)
|
QString EdhrecCommanderApiResponseNavigationWidget::addNavigationOptionsToUrl(QString baseUrl)
|
||||||
{
|
{
|
||||||
if (!selectedGameChanger.isEmpty()) {
|
if (!bracketNavigationWidget->getSelectedGameChanger().isEmpty()) {
|
||||||
baseUrl += "/" + selectedGameChanger;
|
baseUrl += "/" + bracketNavigationWidget->getSelectedGameChanger();
|
||||||
}
|
}
|
||||||
if (!selectedBudget.isEmpty()) {
|
if (!budgetNavigationWidget->getSelectedBudget().isEmpty()) {
|
||||||
baseUrl += "/" + selectedBudget;
|
baseUrl += "/" + budgetNavigationWidget->getSelectedBudget();
|
||||||
}
|
}
|
||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#define EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
#define EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||||
|
|
||||||
#include "edhrec_api_response_commander_details_display_widget.h"
|
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||||
|
#include "edhrec_commander_api_response_bracket_navigation_widget.h"
|
||||||
|
#include "edhrec_commander_api_response_budget_navigation_widget.h"
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -23,7 +25,6 @@ public:
|
|||||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||||
QString baseUrl);
|
QString baseUrl);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void applyOptionsFromUrl(const QString &url);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void actRequestCommanderNavigation();
|
void actRequestCommanderNavigation();
|
||||||
@@ -35,24 +36,14 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QGridLayout *layout;
|
QGridLayout *layout;
|
||||||
|
|
||||||
QLabel *gameChangerLabel;
|
EdhrecCommanderApiResponseBracketNavigationWidget *bracketNavigationWidget;
|
||||||
QLabel *budgetLabel;
|
EdhrecCommanderApiResponseBudgetNavigationWidget *budgetNavigationWidget;
|
||||||
|
|
||||||
QStringList gameChangerOptions = {"", "core", "upgraded", "optimized"};
|
|
||||||
QStringList budgetOptions = {"", "budget", "expensive"};
|
|
||||||
|
|
||||||
QString selectedGameChanger;
|
|
||||||
QString selectedBudget;
|
|
||||||
|
|
||||||
QMap<QString, QPushButton *> gameChangerButtons;
|
|
||||||
QMap<QString, QPushButton *> budgetButtons;
|
|
||||||
|
|
||||||
QPushButton *comboPushButton;
|
QPushButton *comboPushButton;
|
||||||
QPushButton *averageDeckPushButton;
|
QPushButton *averageDeckPushButton;
|
||||||
|
|
||||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||||
|
|
||||||
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
|
|
||||||
QString addNavigationOptionsToUrl(QString baseUrl);
|
QString addNavigationOptionsToUrl(QString baseUrl);
|
||||||
QString buildComboUrl() const;
|
QString buildComboUrl() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -264,9 +264,10 @@ void VisualDeckEditorWidget::onCardRemoval(const QModelIndex &parent, int first,
|
|||||||
|
|
||||||
void VisualDeckEditorWidget::constructZoneWidgetForIndex(QPersistentModelIndex persistent)
|
void VisualDeckEditorWidget::constructZoneWidgetForIndex(QPersistentModelIndex persistent)
|
||||||
{
|
{
|
||||||
|
QString zoneName =
|
||||||
|
persistent.sibling(persistent.row(), DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
DeckCardZoneDisplayWidget *zoneDisplayWidget = new DeckCardZoneDisplayWidget(
|
DeckCardZoneDisplayWidget *zoneDisplayWidget = new DeckCardZoneDisplayWidget(
|
||||||
zoneContainer, deckListModel, selectionModel, persistent,
|
zoneContainer, deckListModel, selectionModel, persistent, zoneName,
|
||||||
deckListModel->data(persistent.sibling(persistent.row(), 1), Qt::EditRole).toString(),
|
|
||||||
displayOptionsWidget->getActiveGroupCriteria(), displayOptionsWidget->getActiveSortCriteria(),
|
displayOptionsWidget->getActiveGroupCriteria(), displayOptionsWidget->getActiveSortCriteria(),
|
||||||
displayOptionsWidget->getDisplayType(), 20, 10, cardSizeWidget);
|
displayOptionsWidget->getDisplayType(), 20, 10, cardSizeWidget);
|
||||||
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardHovered, this, &VisualDeckEditorWidget::onHover);
|
connect(zoneDisplayWidget, &DeckCardZoneDisplayWidget::cardHovered, this, &VisualDeckEditorWidget::onHover);
|
||||||
@@ -290,7 +291,7 @@ void VisualDeckEditorWidget::constructZoneWidgetsFromDeckListModel()
|
|||||||
QSortFilterProxyModel proxy;
|
QSortFilterProxyModel proxy;
|
||||||
proxy.setSourceModel(deckListModel);
|
proxy.setSourceModel(deckListModel);
|
||||||
proxy.setSortRole(Qt::EditRole);
|
proxy.setSortRole(Qt::EditRole);
|
||||||
proxy.sort(1, Qt::AscendingOrder);
|
proxy.sort(DeckListModelColumns::CARD_NAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
for (int i = 0; i < proxy.rowCount(); ++i) {
|
for (int i = 0; i < proxy.rowCount(); ++i) {
|
||||||
QModelIndex proxyIndex = proxy.index(i, 0);
|
QModelIndex proxyIndex = proxy.index(i, 0);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
|
||||||
@@ -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() << "---------------------------------------------";
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -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 */)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
};
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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/).
|
||||||
|
|||||||
@@ -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
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
|
|||||||
@@ -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" \
|
||||||
|
|||||||
@@ -436,7 +436,51 @@ QModelIndex DeckListModel::addCard(const ExactCard &card, const QString &zoneNam
|
|||||||
}
|
}
|
||||||
sort(lastKnownColumn, lastKnownOrder);
|
sort(lastKnownColumn, lastKnownOrder);
|
||||||
emitRecursiveUpdates(parentIndex);
|
emitRecursiveUpdates(parentIndex);
|
||||||
return nodeToIndex(cardNode);
|
auto index = nodeToIndex(cardNode);
|
||||||
|
|
||||||
|
emit cardAddedAt(index);
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeckListModel::incrementAmountAtIndex(const QModelIndex &idx)
|
||||||
|
{
|
||||||
|
return offsetAmountAtIndex(idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeckListModel::decrementAmountAtIndex(const QModelIndex &idx)
|
||||||
|
{
|
||||||
|
return offsetAmountAtIndex(idx, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeckListModel::offsetAmountAtIndex(const QModelIndex &idx, int offset)
|
||||||
|
{
|
||||||
|
if (!idx.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *node = static_cast<AbstractDecklistNode *>(idx.internalPointer());
|
||||||
|
auto *card = dynamic_cast<DecklistModelCardNode *>(node);
|
||||||
|
|
||||||
|
if (!card) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QModelIndex numberIndex = idx.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT);
|
||||||
|
const int count = numberIndex.data(Qt::EditRole).toInt();
|
||||||
|
const int newCount = count + offset;
|
||||||
|
|
||||||
|
if (newCount <= 0) {
|
||||||
|
removeRow(idx.row(), idx.parent());
|
||||||
|
} else {
|
||||||
|
setData(numberIndex, newCount, Qt::EditRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset > 0) {
|
||||||
|
emit cardAddedAt(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeckListModel::findSortedInsertRow(InnerDecklistNode *parent, CardInfoPtr cardInfo) const
|
int DeckListModel::findSortedInsertRow(InnerDecklistNode *parent, CardInfoPtr cardInfo) const
|
||||||
@@ -559,6 +603,12 @@ void DeckListModel::setDeckList(DeckList *_deck)
|
|||||||
deckList = _deck;
|
deckList = _deck;
|
||||||
}
|
}
|
||||||
rebuildTree();
|
rebuildTree();
|
||||||
|
emit deckReplaced();
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
@@ -600,6 +650,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();
|
||||||
|
|||||||
@@ -226,6 +226,18 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void deckHashChanged();
|
void deckHashChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Emitted whenever a card is added to the deck, regardless of whether it's an entirely new card or an
|
||||||
|
* existing card that got incremented.
|
||||||
|
* @param index The index of the card that got added.
|
||||||
|
*/
|
||||||
|
void cardAddedAt(const QModelIndex &index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Emitted whenever the deck in the model has been replaced with a new one
|
||||||
|
*/
|
||||||
|
void deckReplaced();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeckListModel(QObject *parent = nullptr);
|
explicit DeckListModel(QObject *parent = nullptr);
|
||||||
~DeckListModel() override;
|
~DeckListModel() override;
|
||||||
@@ -250,7 +262,6 @@ public:
|
|||||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||||
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
||||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||||
void emitBackgroundUpdates(const QModelIndex &parent);
|
|
||||||
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
||||||
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
|
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
|
||||||
@@ -258,6 +269,12 @@ public:
|
|||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively emits the dataChanged signal for all child nodes.
|
||||||
|
* @param parent The parent node
|
||||||
|
*/
|
||||||
|
void emitBackgroundUpdates(const QModelIndex &parent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finds a card by name, zone, and optional identifiers.
|
* @brief Finds a card by name, zone, and optional identifiers.
|
||||||
* @param cardName The card's name.
|
* @param cardName The card's name.
|
||||||
@@ -289,6 +306,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
QModelIndex addCard(const ExactCard &card, const QString &zoneName);
|
QModelIndex addCard(const ExactCard &card, const QString &zoneName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Increments the `amount` field of the card node at the index by 1.
|
||||||
|
* @param idx The index of a card node. No-ops if the index is invalid or not a card node
|
||||||
|
* @return Whether the operation was successful
|
||||||
|
*/
|
||||||
|
bool incrementAmountAtIndex(const QModelIndex &idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decrements the `amount` field of the card node at the index by 1.
|
||||||
|
* Removes the node if it causes the amount to fall to 0.
|
||||||
|
* @param idx The index of a card node. No-ops if the index is invalid or not a card node
|
||||||
|
* @return Whether the operation was successful
|
||||||
|
*/
|
||||||
|
bool decrementAmountAtIndex(const QModelIndex &idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Determines the sorted insertion row for a card.
|
* @brief Determines the sorted insertion row for a card.
|
||||||
* @param parent The parent node where the card will be inserted.
|
* @param parent The parent node where the card will be inserted.
|
||||||
@@ -309,6 +341,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 +362,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
|
||||||
*/
|
*/
|
||||||
@@ -351,6 +394,9 @@ private:
|
|||||||
const QString &zoneName,
|
const QString &zoneName,
|
||||||
const QString &providerId = "",
|
const QString &providerId = "",
|
||||||
const QString &cardNumber = "") const;
|
const QString &cardNumber = "") const;
|
||||||
|
|
||||||
|
bool offsetAmountAtIndex(const QModelIndex &idx, int offset);
|
||||||
|
|
||||||
void emitRecursiveUpdates(const QModelIndex &index);
|
void emitRecursiveUpdates(const QModelIndex &index);
|
||||||
void sortHelper(InnerDecklistNode *node, Qt::SortOrder order);
|
void sortHelper(InnerDecklistNode *node, Qt::SortOrder order);
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ bool DeckListSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
|||||||
bool rightIsCard = src->data(right, Qt::UserRole + 1).toBool();
|
bool rightIsCard = src->data(right, Qt::UserRole + 1).toBool();
|
||||||
|
|
||||||
if (!leftIsCard || !rightIsCard) {
|
if (!leftIsCard || !rightIsCard) {
|
||||||
QString lName = src->data(left.siblingAtColumn(1), Qt::EditRole).toString();
|
QString lName = src->data(left.siblingAtColumn(DeckListModelColumns::CARD_NAME), Qt::EditRole).toString();
|
||||||
QString rName = src->data(right.siblingAtColumn(1), Qt::EditRole).toString();
|
QString rName = src->data(right.siblingAtColumn(DeckListModelColumns::CARD_NAME), Qt::EditRole).toString();
|
||||||
return lName.localeAwareCompare(rName) < 0;
|
return lName.localeAwareCompare(rName) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user