Clang script (#3085)
This commit is contained in:
parent
fcfb2b12b7
commit
35159ef61a
24 changed files with 2098 additions and 2054 deletions
18
clangify.sh
Executable file
18
clangify.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will run clang-format on all non-3rd-party C++/Header files.
|
||||
|
||||
set -e
|
||||
|
||||
if hash clang-format 2>/dev/null; then
|
||||
find . \( -name "*.cpp" -o -name "*.h" \) \
|
||||
-not -path "./cockatrice/src/qt-json/*" \
|
||||
-not -path "./servatrice/src/smtp/*" \
|
||||
-not -path "./common/sfmt/*" \
|
||||
-not -path "./oracle/src/zip/*" \
|
||||
-not -path "./build*/*" \
|
||||
-exec clang-format -style=file -i {} \;
|
||||
echo "Repository properly formatted"
|
||||
else
|
||||
echo "Please install clang-format to use this program"
|
||||
fi
|
|
@ -1,23 +1,28 @@
|
|||
#include <QTextEdit>
|
||||
#include <QDateTime>
|
||||
#include <QScrollBar>
|
||||
#include <QMouseEvent>
|
||||
#include <QDesktopServices>
|
||||
#include <QApplication>
|
||||
#include "chatview.h"
|
||||
#include "user_level.h"
|
||||
#include "../user_context_menu.h"
|
||||
#include "../pixmapgenerator.h"
|
||||
#include "../settingscache.h"
|
||||
#include "../tab_userlists.h"
|
||||
#include "../soundengine.h"
|
||||
#include "../tab_userlists.h"
|
||||
#include "../user_context_menu.h"
|
||||
#include "user_level.h"
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDesktopServices>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QTextEdit>
|
||||
|
||||
const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);
|
||||
const QColor OTHER_USER_COLOR = QColor(0, 65, 255); // dark blue
|
||||
const QString SERVER_MESSAGE_COLOR = "#851515";
|
||||
|
||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor, const UserlistProxy *_userlistProxy, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
||||
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), userlistProxy(_userlistProxy), evenNumber(true), showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor,
|
||||
const UserlistProxy *_userlistProxy,
|
||||
TabGame *_game,
|
||||
bool _showTimestamps,
|
||||
QWidget *parent)
|
||||
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), userlistProxy(_userlistProxy), evenNumber(true),
|
||||
showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
||||
{
|
||||
document()->setDefaultStyleSheet("a { text-decoration: none; color: blue; }");
|
||||
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||
|
@ -47,7 +52,7 @@ void ChatView::retranslateUi()
|
|||
QTextCursor ChatView::prepareBlock(bool same)
|
||||
{
|
||||
lastSender.clear();
|
||||
|
||||
|
||||
QTextCursor cursor(document()->lastBlock());
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
if (same) {
|
||||
|
@ -59,7 +64,7 @@ QTextCursor ChatView::prepareBlock(bool same)
|
|||
blockFormat.setBottomMargin(4);
|
||||
cursor.insertBlock(blockFormat);
|
||||
}
|
||||
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
|
@ -75,7 +80,8 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
|||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
|
||||
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : SERVER_MESSAGE_COLOR) + ">" + QDateTime::currentDateTime().toString("[hh:mm:ss] ")+ html + "</font>";
|
||||
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : SERVER_MESSAGE_COLOR) +
|
||||
">" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
@ -103,7 +109,7 @@ void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
|
|||
{
|
||||
if (!url.contains("://"))
|
||||
url.prepend("http://");
|
||||
|
||||
|
||||
QTextCharFormat oldFormat = cursor.charFormat();
|
||||
QTextCharFormat anchorFormat = oldFormat;
|
||||
anchorFormat.setForeground(Qt::blue);
|
||||
|
@ -111,19 +117,24 @@ void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
|
|||
anchorFormat.setAnchorHref(url);
|
||||
anchorFormat.setUnderlineColor(Qt::blue);
|
||||
anchorFormat.setFontUnderline(true);
|
||||
|
||||
|
||||
cursor.setCharFormat(anchorFormat);
|
||||
cursor.insertText(url);
|
||||
cursor.setCharFormat(oldFormat);
|
||||
}
|
||||
|
||||
void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType, QString sender, UserLevelFlags userLevel, QString UserPrivLevel, bool playerBold)
|
||||
void ChatView::appendMessage(QString message,
|
||||
RoomMessageTypeFlags messageType,
|
||||
QString sender,
|
||||
UserLevelFlags userLevel,
|
||||
QString UserPrivLevel,
|
||||
bool playerBold)
|
||||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
|
||||
QTextCursor cursor = prepareBlock(sameSender);
|
||||
lastSender = sender;
|
||||
|
||||
|
||||
// timestamp
|
||||
if (showTimestamps && (!sameSender || sender.toLower() == "servatrice") && !sender.isEmpty()) {
|
||||
QTextCharFormat timeFormat;
|
||||
|
@ -153,7 +164,8 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType,
|
|||
if (!sender.isEmpty()) {
|
||||
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
|
||||
bool isBuddy = userlistProxy->isUserBuddy(sender);
|
||||
cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, isBuddy, UserPrivLevel).toImage());
|
||||
cursor.insertImage(
|
||||
UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, isBuddy, UserPrivLevel).toImage());
|
||||
cursor.insertText(" ");
|
||||
}
|
||||
cursor.setCharFormat(senderFormat);
|
||||
|
@ -163,7 +175,7 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType,
|
|||
}
|
||||
}
|
||||
|
||||
// use different color for server messages
|
||||
// use different color for server messages
|
||||
defaultFormat = QTextCharFormat();
|
||||
if (sender.isEmpty()) {
|
||||
switch (messageType) {
|
||||
|
@ -190,16 +202,14 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType,
|
|||
highlightedWords = settingsCache->getHighlightWords().split(' ', QString::SkipEmptyParts);
|
||||
|
||||
// parse the message
|
||||
while (message.size())
|
||||
{
|
||||
QChar c = message.at(0);
|
||||
switch(c.toLatin1())
|
||||
{
|
||||
while (message.size()) {
|
||||
QChar c = message.at(0);
|
||||
switch (c.toLatin1()) {
|
||||
case '[':
|
||||
checkTag(cursor, message);
|
||||
break;
|
||||
case '@':
|
||||
if(mentionEnabled) {
|
||||
if (mentionEnabled) {
|
||||
checkMention(cursor, message, sender, userLevel);
|
||||
} else {
|
||||
cursor.insertText(c, defaultFormat);
|
||||
|
@ -211,7 +221,7 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType,
|
|||
message = message.mid(1);
|
||||
break;
|
||||
default:
|
||||
if(c.isLetterOrNumber()) {
|
||||
if (c.isLetterOrNumber()) {
|
||||
checkWord(cursor, message);
|
||||
} else {
|
||||
cursor.insertText(c, defaultFormat);
|
||||
|
@ -225,11 +235,9 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType,
|
|||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
|
||||
void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
||||
{
|
||||
if (message.startsWith("[card]"))
|
||||
{
|
||||
if (message.startsWith("[card]")) {
|
||||
message = message.mid(6);
|
||||
int closeTagIndex = message.indexOf("[/card]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
|
@ -237,13 +245,12 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 7);
|
||||
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.startsWith("[["))
|
||||
{
|
||||
if (message.startsWith("[[")) {
|
||||
message = message.mid(2);
|
||||
int closeTagIndex = message.indexOf("]]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
|
@ -251,13 +258,12 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 2);
|
||||
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.startsWith("[url]"))
|
||||
{
|
||||
if (message.startsWith("[url]")) {
|
||||
message = message.mid(5);
|
||||
int closeTagIndex = message.indexOf("[/url]");
|
||||
QString url = message.left(closeTagIndex);
|
||||
|
@ -265,7 +271,7 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 6);
|
||||
|
||||
|
||||
appendUrlTag(cursor, url);
|
||||
return;
|
||||
}
|
||||
|
@ -282,8 +288,7 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &send
|
|||
QString fullMentionUpToSpaceOrEnd = (firstSpace == -1) ? message.mid(1) : message.mid(1, firstSpace - 1);
|
||||
QString mentionIntact = fullMentionUpToSpaceOrEnd;
|
||||
|
||||
while (fullMentionUpToSpaceOrEnd.size())
|
||||
{
|
||||
while (fullMentionUpToSpaceOrEnd.size()) {
|
||||
const ServerInfo_User *onlineUser = userlistProxy->getOnlineUser(fullMentionUpToSpaceOrEnd);
|
||||
if (onlineUser) // Is there a user online named this?
|
||||
{
|
||||
|
@ -292,13 +297,15 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &send
|
|||
// You have received a valid mention!!
|
||||
soundEngine->playSound("chat_mention");
|
||||
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white)
|
||||
: QBrush(Qt::black));
|
||||
cursor.insertText(mention, mentionFormat);
|
||||
message = message.mid(mention.size());
|
||||
showSystemPopup(sender);
|
||||
} else {
|
||||
QString correctUserName = QString::fromStdString(onlineUser->name());
|
||||
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(onlineUser->user_level()) + "_" + correctUserName);
|
||||
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(onlineUser->user_level()) + "_" +
|
||||
correctUserName);
|
||||
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
|
||||
|
||||
message = message.mid(correctUserName.size() + 1);
|
||||
|
@ -312,7 +319,8 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &send
|
|||
// Moderator Sending Global Message
|
||||
soundEngine->playSound("all_mention");
|
||||
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white)
|
||||
: QBrush(Qt::black));
|
||||
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
|
||||
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
|
||||
showSystemPopup(sender);
|
||||
|
@ -321,8 +329,8 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &send
|
|||
return;
|
||||
}
|
||||
|
||||
if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 || fullMentionUpToSpaceOrEnd.size() < 2)
|
||||
{
|
||||
if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 ||
|
||||
fullMentionUpToSpaceOrEnd.size() < 2) {
|
||||
cursor.insertText("@" + mentionIntact, defaultFormat);
|
||||
message = message.mid(mentionIntact.size() + 1);
|
||||
cursor.setCharFormat(defaultFormat);
|
||||
|
@ -345,11 +353,9 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
|
|||
// check urls
|
||||
if (fullWordUpToSpaceOrEnd.startsWith("http://", Qt::CaseInsensitive) ||
|
||||
fullWordUpToSpaceOrEnd.startsWith("https://", Qt::CaseInsensitive) ||
|
||||
fullWordUpToSpaceOrEnd.startsWith("www.", Qt::CaseInsensitive))
|
||||
{
|
||||
fullWordUpToSpaceOrEnd.startsWith("www.", Qt::CaseInsensitive)) {
|
||||
QUrl qUrl(fullWordUpToSpaceOrEnd);
|
||||
if (qUrl.isValid())
|
||||
{
|
||||
if (qUrl.isValid()) {
|
||||
appendUrlTag(cursor, fullWordUpToSpaceOrEnd);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
return;
|
||||
|
@ -357,13 +363,12 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
|
|||
}
|
||||
|
||||
// check word mentions
|
||||
foreach (QString word, highlightedWords)
|
||||
{
|
||||
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
foreach (QString word, highlightedWords) {
|
||||
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0) {
|
||||
// You have received a valid mention of custom word!!
|
||||
highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
|
||||
highlightFormat.setForeground(settingsCache->getChatHighlightForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
highlightFormat.setForeground(settingsCache->getChatHighlightForeground() ? QBrush(Qt::white)
|
||||
: QBrush(Qt::black));
|
||||
cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
QApplication::alert(this);
|
||||
|
@ -380,8 +385,7 @@ QString ChatView::extractNextWord(QString &message, QString &rest)
|
|||
// get the first next space and extract the word
|
||||
QString word;
|
||||
int firstSpace = message.indexOf(' ');
|
||||
if(firstSpace == -1)
|
||||
{
|
||||
if (firstSpace == -1) {
|
||||
word = message;
|
||||
message.clear();
|
||||
} else {
|
||||
|
@ -390,10 +394,8 @@ QString ChatView::extractNextWord(QString &message, QString &rest)
|
|||
}
|
||||
|
||||
// remove any punctuation from the end and pass it separately
|
||||
for (int len = word.size() - 1; len >= 0; --len)
|
||||
{
|
||||
if(word.at(len).isLetterOrNumber())
|
||||
{
|
||||
for (int len = word.size() - 1; len >= 0; --len) {
|
||||
if (word.at(len).isLetterOrNumber()) {
|
||||
rest = word.mid(len + 1);
|
||||
return word.mid(0, len + 1);
|
||||
}
|
||||
|
@ -403,7 +405,6 @@ QString ChatView::extractNextWord(QString &message, QString &rest)
|
|||
return QString();
|
||||
}
|
||||
|
||||
|
||||
bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message)
|
||||
{
|
||||
int userLevel = QString::number(userLevelFlag).toInt();
|
||||
|
@ -411,17 +412,17 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
|
|||
QStringList getAttentionList;
|
||||
getAttentionList << "/all"; // Send a message to all users
|
||||
|
||||
return (getAttentionList.contains(message)
|
||||
&& (userLevel & ServerInfo_User::IsModerator
|
||||
|| userLevel & ServerInfo_User::IsAdmin));
|
||||
|
||||
return (getAttentionList.contains(message) &&
|
||||
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin));
|
||||
}
|
||||
|
||||
void ChatView::actMessageClicked() {
|
||||
void ChatView::actMessageClicked()
|
||||
{
|
||||
emit messageClickedSignal();
|
||||
}
|
||||
|
||||
void ChatView::showSystemPopup(QString &sender) {
|
||||
void ChatView::showSystemPopup(QString &sender)
|
||||
{
|
||||
QApplication::alert(this);
|
||||
if (settingsCache->getShowMentionPopup()) {
|
||||
QString ref = sender.left(sender.length() - 2);
|
||||
|
@ -429,19 +430,22 @@ void ChatView::showSystemPopup(QString &sender) {
|
|||
}
|
||||
}
|
||||
|
||||
QColor ChatView::getCustomMentionColor() {
|
||||
QColor ChatView::getCustomMentionColor()
|
||||
{
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatMentionColor());
|
||||
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
|
||||
}
|
||||
|
||||
QColor ChatView::getCustomHighlightColor() {
|
||||
QColor ChatView::getCustomHighlightColor()
|
||||
{
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatHighlightColor());
|
||||
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
|
||||
}
|
||||
|
||||
void ChatView::clearChat() {
|
||||
void ChatView::clearChat()
|
||||
{
|
||||
document()->clear();
|
||||
lastSender = "";
|
||||
}
|
||||
|
@ -493,7 +497,7 @@ void ChatView::mouseMoveEvent(QMouseEvent *event)
|
|||
hoveredItemType = HoveredNothing;
|
||||
viewport()->setCursor(Qt::IBeamCursor);
|
||||
}
|
||||
|
||||
|
||||
QTextBrowser::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -509,21 +513,21 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
if (event->button() != Qt::MidButton) {
|
||||
const int delimiterIndex = hoveredContent.indexOf("_");
|
||||
const QString userName = hoveredContent.mid(delimiterIndex + 1);
|
||||
switch(event->button()) {
|
||||
case Qt::RightButton :{
|
||||
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
|
||||
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel);
|
||||
break;
|
||||
}
|
||||
case Qt::LeftButton :{
|
||||
if (event->modifiers() == Qt::ControlModifier) {
|
||||
emit openMessageDialog(userName, true);
|
||||
} else
|
||||
emit addMentionTag("@" + userName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
switch (event->button()) {
|
||||
case Qt::RightButton: {
|
||||
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
|
||||
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel);
|
||||
break;
|
||||
}
|
||||
case Qt::LeftButton: {
|
||||
if (event->modifiers() == Qt::ControlModifier) {
|
||||
emit openMessageDialog(userName, true);
|
||||
} else
|
||||
emit addMentionTag("@" + userName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -538,7 +542,7 @@ void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
|||
{
|
||||
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
||||
emit deleteCardInfoPopup(QString("_"));
|
||||
|
||||
|
||||
QTextBrowser::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
@ -546,6 +550,6 @@ void ChatView::openLink(const QUrl &link)
|
|||
{
|
||||
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
||||
return;
|
||||
|
||||
|
||||
QDesktopServices::openUrl(link);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,38 @@
|
|||
#ifndef CHATVIEW_H
|
||||
#define CHATVIEW_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QTextFragment>
|
||||
#include <QTextCursor>
|
||||
#include <QColor>
|
||||
#include <QAction>
|
||||
#include "../userlist.h"
|
||||
#include "user_level.h"
|
||||
#include "room_message_type.h"
|
||||
#include "../tab_supervisor.h"
|
||||
#include "../userlist.h"
|
||||
#include "room_message_type.h"
|
||||
#include "user_level.h"
|
||||
#include "userlistProxy.h"
|
||||
#include <QAction>
|
||||
#include <QColor>
|
||||
#include <QTextBrowser>
|
||||
#include <QTextCursor>
|
||||
#include <QTextFragment>
|
||||
|
||||
class QTextTable;
|
||||
class QMouseEvent;
|
||||
class UserContextMenu;
|
||||
class TabGame;
|
||||
|
||||
class ChatView : public QTextBrowser {
|
||||
class ChatView : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
const TabSupervisor * const tabSupervisor;
|
||||
TabGame * const game;
|
||||
const TabSupervisor *const tabSupervisor;
|
||||
TabGame *const game;
|
||||
|
||||
private:
|
||||
enum HoveredItemType { HoveredNothing, HoveredUrl, HoveredCard, HoveredUser };
|
||||
const UserlistProxy * const userlistProxy;
|
||||
enum HoveredItemType
|
||||
{
|
||||
HoveredNothing,
|
||||
HoveredUrl,
|
||||
HoveredCard,
|
||||
HoveredUser
|
||||
};
|
||||
const UserlistProxy *const userlistProxy;
|
||||
UserContextMenu *userContextMenu;
|
||||
QString lastSender;
|
||||
QString userName;
|
||||
|
@ -54,13 +62,25 @@ private:
|
|||
private slots:
|
||||
void openLink(const QUrl &link);
|
||||
void actMessageClicked();
|
||||
|
||||
public:
|
||||
ChatView(const TabSupervisor *_tabSupervisor, const UserlistProxy *_userlistProxy, TabGame *_game, bool _showTimestamps, QWidget *parent = 0);
|
||||
ChatView(const TabSupervisor *_tabSupervisor,
|
||||
const UserlistProxy *_userlistProxy,
|
||||
TabGame *_game,
|
||||
bool _showTimestamps,
|
||||
QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
void appendHtml(const QString &html);
|
||||
void appendHtmlServerMessage(const QString &html, bool optionalIsBold = false, QString optionalFontColor = QString());
|
||||
void appendMessage(QString message, RoomMessageTypeFlags messageType = 0, QString sender = QString(), UserLevelFlags userLevel = UserLevelFlags(), QString UserPrivLevel = "NONE", bool playerBold = false);
|
||||
void
|
||||
appendHtmlServerMessage(const QString &html, bool optionalIsBold = false, QString optionalFontColor = QString());
|
||||
void appendMessage(QString message,
|
||||
RoomMessageTypeFlags messageType = 0,
|
||||
QString sender = QString(),
|
||||
UserLevelFlags userLevel = UserLevelFlags(),
|
||||
QString UserPrivLevel = "NONE",
|
||||
bool playerBold = false);
|
||||
void clearChat();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
|
|
@ -8,13 +8,14 @@ class ServerInfo_User;
|
|||
* Responsible for providing a bare-bones minimal interface into userlist information,
|
||||
* including your current connection to the server as well as buddy/ignore/alluser lists.
|
||||
*/
|
||||
class UserlistProxy {
|
||||
class UserlistProxy
|
||||
{
|
||||
public:
|
||||
virtual bool isOwnUserRegistered() const = 0;
|
||||
virtual QString getOwnUsername() const = 0;
|
||||
virtual bool isUserBuddy(const QString &userName) const = 0;
|
||||
virtual bool isUserIgnored(const QString &userName) const = 0;
|
||||
virtual const ServerInfo_User* getOnlineUser(const QString &userName) const = 0; // Can return nullptr
|
||||
virtual const ServerInfo_User *getOnlineUser(const QString &userName) const = 0; // Can return nullptr
|
||||
};
|
||||
|
||||
#endif //COCKATRICE_USERLISTPROXY_H
|
||||
#endif // COCKATRICE_USERLISTPROXY_H
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "sequenceedit.h"
|
||||
#include "../settingscache.h"
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QToolTip>
|
||||
#include <utility>
|
||||
|
||||
|
@ -32,14 +32,14 @@ SequenceEdit::SequenceEdit(QString _shorcutName, QWidget *parent) : QWidget(pare
|
|||
defaultButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(1);
|
||||
layout->addWidget(lineEdit);
|
||||
layout->addWidget(clearButton);
|
||||
layout->addWidget(defaultButton);
|
||||
|
||||
connect(clearButton,SIGNAL(clicked()),this,SLOT(removeLastShortcut()));
|
||||
connect(defaultButton,SIGNAL(clicked()),this,SLOT(restoreDefault()));
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(removeLastShortcut()));
|
||||
connect(defaultButton, SIGNAL(clicked()), this, SLOT(restoreDefault()));
|
||||
lineEdit->installEventFilter(this);
|
||||
|
||||
lineEdit->setText(settingsCache->shortcuts().getShortcutString(shorcutName));
|
||||
|
@ -53,15 +53,11 @@ QString SequenceEdit::getSecuence()
|
|||
void SequenceEdit::removeLastShortcut()
|
||||
{
|
||||
QString secuences = lineEdit->text();
|
||||
if (!secuences.isEmpty())
|
||||
{
|
||||
if (secuences.lastIndexOf(";") > 0)
|
||||
{
|
||||
if (!secuences.isEmpty()) {
|
||||
if (secuences.lastIndexOf(";") > 0) {
|
||||
QString valid = secuences.left(secuences.lastIndexOf(";"));
|
||||
lineEdit->setText(valid);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
lineEdit->clear();
|
||||
}
|
||||
|
||||
|
@ -85,18 +81,14 @@ void SequenceEdit::clear()
|
|||
this->lineEdit->setText("");
|
||||
}
|
||||
|
||||
bool SequenceEdit::eventFilter(QObject *, QEvent * event)
|
||||
bool SequenceEdit::eventFilter(QObject *, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
|
||||
auto *keyEvent = reinterpret_cast<QKeyEvent *>(event);
|
||||
|
||||
if (event->type() == QEvent::KeyPress && !keyEvent->isAutoRepeat())
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress && !keyEvent->isAutoRepeat()) {
|
||||
processKey(keyEvent);
|
||||
}
|
||||
else if (event->type() == QEvent::KeyRelease && !keyEvent->isAutoRepeat())
|
||||
{
|
||||
} else if (event->type() == QEvent::KeyRelease && !keyEvent->isAutoRepeat()) {
|
||||
finishShortcut();
|
||||
}
|
||||
|
||||
|
@ -105,19 +97,17 @@ bool SequenceEdit::eventFilter(QObject *, QEvent * event)
|
|||
return false;
|
||||
}
|
||||
|
||||
void SequenceEdit::processKey(QKeyEvent* e)
|
||||
void SequenceEdit::processKey(QKeyEvent *e)
|
||||
{
|
||||
int key = e->key();
|
||||
if (key != Qt::Key_Control && key != Qt::Key_Shift && key != Qt::Key_Meta && key != Qt::Key_Alt)
|
||||
{
|
||||
if (key != Qt::Key_Control && key != Qt::Key_Shift && key != Qt::Key_Meta && key != Qt::Key_Alt) {
|
||||
valid = true;
|
||||
key |= translateModifiers(e->modifiers(), e->text());
|
||||
}
|
||||
|
||||
keys = key;
|
||||
currentKey++;
|
||||
if (currentKey >= key)
|
||||
{
|
||||
if (currentKey >= key) {
|
||||
finishShortcut();
|
||||
}
|
||||
}
|
||||
|
@ -127,26 +117,20 @@ int SequenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString
|
|||
int result = 0;
|
||||
// The shift modifier only counts when it is not used to type a symbol
|
||||
// that is only reachable using the shift key anyway
|
||||
if ((state & Qt::ShiftModifier) && (text.isEmpty() ||
|
||||
!text.at(0).isPrint() ||
|
||||
text.at(0).isLetterOrNumber() ||
|
||||
text.at(0).isSpace()))
|
||||
{
|
||||
if ((state & Qt::ShiftModifier) &&
|
||||
(text.isEmpty() || !text.at(0).isPrint() || text.at(0).isLetterOrNumber() || text.at(0).isSpace())) {
|
||||
result |= Qt::SHIFT;
|
||||
}
|
||||
|
||||
if (state & Qt::ControlModifier)
|
||||
{
|
||||
if (state & Qt::ControlModifier) {
|
||||
result |= Qt::CTRL;
|
||||
}
|
||||
|
||||
if (state & Qt::MetaModifier)
|
||||
{
|
||||
if (state & Qt::MetaModifier) {
|
||||
result |= Qt::META;
|
||||
}
|
||||
|
||||
if (state & Qt::AltModifier)
|
||||
{
|
||||
if (state & Qt::AltModifier) {
|
||||
result |= Qt::ALT;
|
||||
}
|
||||
|
||||
|
@ -156,23 +140,17 @@ int SequenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString
|
|||
void SequenceEdit::finishShortcut()
|
||||
{
|
||||
QKeySequence secuence(keys);
|
||||
if (!secuence.isEmpty() && valid)
|
||||
{
|
||||
if (!secuence.isEmpty() && valid) {
|
||||
QString secuenceString = secuence.toString();
|
||||
if (settingsCache->shortcuts().isValid(shorcutName,secuenceString))
|
||||
{
|
||||
if (!lineEdit->text().isEmpty())
|
||||
{
|
||||
if (lineEdit->text().contains(secuenceString))
|
||||
{
|
||||
if (settingsCache->shortcuts().isValid(shorcutName, secuenceString)) {
|
||||
if (!lineEdit->text().isEmpty()) {
|
||||
if (lineEdit->text().contains(secuenceString)) {
|
||||
return;
|
||||
}
|
||||
lineEdit->setText(lineEdit->text() + ";");
|
||||
}
|
||||
lineEdit->setText(lineEdit->text() + secuenceString);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
QToolTip::showText(lineEdit->mapToGlobal(QPoint()), tr("Shortcut already in use"));
|
||||
}
|
||||
}
|
||||
|
@ -185,5 +163,5 @@ void SequenceEdit::finishShortcut()
|
|||
|
||||
void SequenceEdit::updateSettings()
|
||||
{
|
||||
settingsCache->shortcuts().setShortcuts(shorcutName,lineEdit->text());
|
||||
settingsCache->shortcuts().setShortcuts(shorcutName, lineEdit->text());
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef SECUENCEEDIT_H
|
||||
#define SECUENCEEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QKeySequence>
|
||||
#include <QWidget>
|
||||
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
|
@ -11,32 +11,32 @@ class QEvent;
|
|||
class SequenceEdit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SequenceEdit(QString _shorcutName, QWidget *parent = nullptr);
|
||||
QString getSecuence();
|
||||
void refreshShortcut();
|
||||
void clear();
|
||||
public:
|
||||
SequenceEdit(QString _shorcutName, QWidget *parent = nullptr);
|
||||
QString getSecuence();
|
||||
void refreshShortcut();
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void removeLastShortcut();
|
||||
void restoreDefault();
|
||||
private slots:
|
||||
void removeLastShortcut();
|
||||
void restoreDefault();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *event);
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *event);
|
||||
|
||||
private:
|
||||
QString shorcutName;
|
||||
QLineEdit *lineEdit;
|
||||
QPushButton *clearButton;
|
||||
QPushButton *defaultButton;
|
||||
int keys;
|
||||
int currentKey;
|
||||
bool valid;
|
||||
private:
|
||||
QString shorcutName;
|
||||
QLineEdit *lineEdit;
|
||||
QPushButton *clearButton;
|
||||
QPushButton *defaultButton;
|
||||
int keys;
|
||||
int currentKey;
|
||||
bool valid;
|
||||
|
||||
void processKey(QKeyEvent *e);
|
||||
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
||||
void finishShortcut();
|
||||
void updateSettings();
|
||||
void processKey(QKeyEvent *e);
|
||||
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
||||
void finishShortcut();
|
||||
void updateSettings();
|
||||
};
|
||||
|
||||
#endif // SECUENCEEDIT_H
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
ShortcutsTab::ShortcutsTab() : ui(new Ui::shortcutsTab)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->btnResetAll,SIGNAL(clicked()),this,SLOT(resetShortcuts()));
|
||||
connect(ui->btnClearAll,SIGNAL(clicked()),this,SLOT(clearShortcuts()));
|
||||
connect(&settingsCache->shortcuts(),SIGNAL(allShortCutsReset()),this,SLOT(refreshEdits()));
|
||||
connect(&settingsCache->shortcuts(),SIGNAL(allShortCutsClear()),this,SLOT(afterClear()));
|
||||
connect(ui->btnResetAll, SIGNAL(clicked()), this, SLOT(resetShortcuts()));
|
||||
connect(ui->btnClearAll, SIGNAL(clicked()), this, SLOT(clearShortcuts()));
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(allShortCutsReset()), this, SLOT(refreshEdits()));
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(allShortCutsClear()), this, SLOT(afterClear()));
|
||||
}
|
||||
|
||||
void ShortcutsTab::retranslateUi()
|
||||
|
@ -25,36 +25,32 @@ ShortcutsTab::~ShortcutsTab()
|
|||
|
||||
void ShortcutsTab::resetShortcuts()
|
||||
{
|
||||
if (QMessageBox::question(this,tr("Restore all default shortcuts"),
|
||||
tr("Do you really want to restore all default shortcuts?")) == QMessageBox::Yes)
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Restore all default shortcuts"),
|
||||
tr("Do you really want to restore all default shortcuts?")) == QMessageBox::Yes) {
|
||||
settingsCache->shortcuts().resetAllShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsTab::refreshEdits()
|
||||
{
|
||||
QList<SequenceEdit*> edits = this->findChildren<SequenceEdit*>();
|
||||
for (auto edit : edits)
|
||||
{
|
||||
{
|
||||
QList<SequenceEdit *> edits = this->findChildren<SequenceEdit *>();
|
||||
for (auto edit : edits) {
|
||||
edit->refreshShortcut();
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsTab::clearShortcuts()
|
||||
{
|
||||
if (QMessageBox::question(this,tr("Clear all default shortcuts"),
|
||||
tr("Do you really want to clear all shortcuts?")) == QMessageBox::Yes)
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Clear all default shortcuts"),
|
||||
tr("Do you really want to clear all shortcuts?")) == QMessageBox::Yes) {
|
||||
settingsCache->shortcuts().clearAllShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsTab::afterClear()
|
||||
{
|
||||
QList<SequenceEdit*> edits = this->findChildren<SequenceEdit*>();
|
||||
for (auto edit : edits)
|
||||
{
|
||||
{
|
||||
QList<SequenceEdit *> edits = this->findChildren<SequenceEdit *>();
|
||||
for (auto edit : edits) {
|
||||
edit->clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
|
||||
namespace Ui
|
||||
{
|
||||
class shortcutsTab;
|
||||
class shortcutsTab;
|
||||
}
|
||||
|
||||
class ShortcutsTab : public AbstractSettingsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShortcutsTab();
|
||||
void retranslateUi();
|
||||
~ShortcutsTab();
|
||||
public:
|
||||
ShortcutsTab();
|
||||
void retranslateUi();
|
||||
~ShortcutsTab();
|
||||
|
||||
private slots:
|
||||
void resetShortcuts();
|
||||
void refreshEdits();
|
||||
void clearShortcuts();
|
||||
void afterClear();
|
||||
private slots:
|
||||
void resetShortcuts();
|
||||
void refreshEdits();
|
||||
void clearShortcuts();
|
||||
void afterClear();
|
||||
|
||||
private:
|
||||
Ui::shortcutsTab *ui;
|
||||
private:
|
||||
Ui::shortcutsTab *ui;
|
||||
};
|
||||
|
||||
#endif // SHORTCUTSTAB_H
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
|||
#include "carddatabasesettings.h"
|
||||
|
||||
CardDatabaseSettings::CardDatabaseSettings(QString settingPath, QObject *parent) : SettingsManager(settingPath+"cardDatabase.ini", parent)
|
||||
CardDatabaseSettings::CardDatabaseSettings(QString settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath + "cardDatabase.ini", parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CardDatabaseSettings::setSortKey(QString shortName, unsigned int sortKey)
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
#include "settingsmanager.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QSettings>
|
||||
#include <QVariant>
|
||||
|
||||
class CardDatabaseSettings : public SettingsManager
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
public:
|
||||
|
||||
public:
|
||||
void setSortKey(QString shortName, unsigned int sortKey);
|
||||
void setEnabled(QString shortName, bool enabled);
|
||||
void setIsKnown(QString shortName, bool isknown);
|
||||
|
@ -25,7 +26,7 @@ public slots:
|
|||
|
||||
private:
|
||||
explicit CardDatabaseSettings(QString settingPath, QObject *parent = nullptr);
|
||||
CardDatabaseSettings( const CardDatabaseSettings& /*other*/ );
|
||||
CardDatabaseSettings(const CardDatabaseSettings & /*other*/);
|
||||
};
|
||||
|
||||
#endif // CARDDATABASESETTINGS_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <QCryptographicHash>
|
||||
|
||||
GameFiltersSettings::GameFiltersSettings(QString settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath+"gamefilters.ini", parent)
|
||||
: SettingsManager(settingPath + "gamefilters.ini", parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,72 +28,70 @@ bool GameFiltersSettings::isShowBuddiesOnlyGames()
|
|||
|
||||
void GameFiltersSettings::setUnavailableGamesVisible(bool enabled)
|
||||
{
|
||||
setValue(enabled, "unavailable_games_visible","filter_games");
|
||||
setValue(enabled, "unavailable_games_visible", "filter_games");
|
||||
}
|
||||
|
||||
bool GameFiltersSettings::isUnavailableGamesVisible()
|
||||
{
|
||||
QVariant previous = getValue("unavailable_games_visible","filter_games");
|
||||
QVariant previous = getValue("unavailable_games_visible", "filter_games");
|
||||
return previous == QVariant() ? false : previous.toBool();
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setShowPasswordProtectedGames(bool show)
|
||||
{
|
||||
setValue(show, "show_password_protected_games","filter_games");
|
||||
setValue(show, "show_password_protected_games", "filter_games");
|
||||
}
|
||||
|
||||
bool GameFiltersSettings::isShowPasswordProtectedGames()
|
||||
{
|
||||
QVariant previous = getValue("show_password_protected_games","filter_games");
|
||||
QVariant previous = getValue("show_password_protected_games", "filter_games");
|
||||
return previous == QVariant() ? true : previous.toBool();
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setGameNameFilter(QString gameName)
|
||||
{
|
||||
setValue(gameName, "game_name_filter","filter_games");
|
||||
setValue(gameName, "game_name_filter", "filter_games");
|
||||
}
|
||||
|
||||
QString GameFiltersSettings::getGameNameFilter()
|
||||
{
|
||||
return getValue("game_name_filter","filter_games").toString();
|
||||
return getValue("game_name_filter", "filter_games").toString();
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setMinPlayers(int min)
|
||||
{
|
||||
setValue(min, "min_players","filter_games");
|
||||
setValue(min, "min_players", "filter_games");
|
||||
}
|
||||
|
||||
int GameFiltersSettings::getMinPlayers()
|
||||
{
|
||||
QVariant previous = getValue("min_players","filter_games");
|
||||
QVariant previous = getValue("min_players", "filter_games");
|
||||
return previous == QVariant() ? 1 : previous.toInt();
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setMaxPlayers(int max)
|
||||
{
|
||||
setValue(max, "max_players","filter_games");
|
||||
setValue(max, "max_players", "filter_games");
|
||||
}
|
||||
|
||||
int GameFiltersSettings::getMaxPlayers()
|
||||
{
|
||||
QVariant previous = getValue("max_players","filter_games");
|
||||
QVariant previous = getValue("max_players", "filter_games");
|
||||
return previous == QVariant() ? 99 : previous.toInt();
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setGameTypeEnabled(QString gametype, bool enabled)
|
||||
{
|
||||
setValue(enabled, "game_type/"+hashGameType(gametype),"filter_games");
|
||||
setValue(enabled, "game_type/" + hashGameType(gametype), "filter_games");
|
||||
}
|
||||
|
||||
void GameFiltersSettings::setGameHashedTypeEnabled(QString gametypeHASHED, bool enabled)
|
||||
{
|
||||
setValue(enabled, gametypeHASHED,"filter_games");
|
||||
setValue(enabled, gametypeHASHED, "filter_games");
|
||||
}
|
||||
|
||||
bool GameFiltersSettings::isGameTypeEnabled(QString gametype)
|
||||
{
|
||||
QVariant previous = getValue("game_type/"+hashGameType(gametype),"filter_games");
|
||||
QVariant previous = getValue("game_type/" + hashGameType(gametype), "filter_games");
|
||||
return previous == QVariant() ? false : previous.toBool();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class GameFiltersSettings : public SettingsManager
|
|||
{
|
||||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
|
||||
public:
|
||||
bool isShowBuddiesOnlyGames();
|
||||
bool isUnavailableGamesVisible();
|
||||
|
@ -29,8 +30,8 @@ signals:
|
|||
public slots:
|
||||
|
||||
private:
|
||||
explicit GameFiltersSettings(QString settingPath,QObject *parent = nullptr);
|
||||
GameFiltersSettings( const GameFiltersSettings& /*other*/ );
|
||||
explicit GameFiltersSettings(QString settingPath, QObject *parent = nullptr);
|
||||
GameFiltersSettings(const GameFiltersSettings & /*other*/);
|
||||
|
||||
QString hashGameType(const QString &gameType) const;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "layoutssettings.h"
|
||||
|
||||
LayoutsSettings::LayoutsSettings(QString settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath+"layouts.ini", parent)
|
||||
: SettingsManager(settingPath + "layouts.ini", parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ const QByteArray LayoutsSettings::getDeckEditorLayoutState()
|
|||
|
||||
void LayoutsSettings::setDeckEditorLayoutState(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditor_state");
|
||||
setValue(value, "layouts/deckEditor_state");
|
||||
}
|
||||
|
||||
const QByteArray LayoutsSettings::getDeckEditorGeometry()
|
||||
|
@ -22,40 +22,40 @@ const QByteArray LayoutsSettings::getDeckEditorGeometry()
|
|||
|
||||
void LayoutsSettings::setDeckEditorGeometry(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditor_geometry");
|
||||
setValue(value, "layouts/deckEditor_geometry");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getDeckEditorCardSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/deckEditor_CardSize");
|
||||
return previous == QVariant() ? QSize(250,500) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 500) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setDeckEditorCardSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditor_CardSize");
|
||||
setValue(value, "layouts/deckEditor_CardSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getDeckEditorDeckSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/deckEditor_DeckSize");
|
||||
return previous == QVariant() ? QSize(250,360) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 360) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setDeckEditorDeckSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditor_DeckSize");
|
||||
setValue(value, "layouts/deckEditor_DeckSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getDeckEditorFilterSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/deckEditor_FilterSize");
|
||||
return previous == QVariant() ? QSize(250,250) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 250) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setDeckEditorFilterSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditor_FilterSize");
|
||||
setValue(value, "layouts/deckEditor_FilterSize");
|
||||
}
|
||||
|
||||
const QByteArray LayoutsSettings::getDeckEditorDbHeaderState()
|
||||
|
@ -65,17 +65,17 @@ const QByteArray LayoutsSettings::getDeckEditorDbHeaderState()
|
|||
|
||||
void LayoutsSettings::setDeckEditorDbHeaderState(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/deckEditorDbHeader_state");
|
||||
setValue(value, "layouts/deckEditorDbHeader_state");
|
||||
}
|
||||
|
||||
void LayoutsSettings::setGamePlayAreaGeometry(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/gameplayarea_geometry");
|
||||
setValue(value, "layouts/gameplayarea_geometry");
|
||||
}
|
||||
|
||||
void LayoutsSettings::setGamePlayAreaState(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/gameplayarea_state");
|
||||
setValue(value, "layouts/gameplayarea_state");
|
||||
}
|
||||
|
||||
const QByteArray LayoutsSettings::getGamePlayAreaLayoutState()
|
||||
|
@ -91,44 +91,44 @@ const QByteArray LayoutsSettings::getGamePlayAreaGeometry()
|
|||
const QSize LayoutsSettings::getGameCardInfoSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/gameplayarea_CardInfoSize");
|
||||
return previous == QVariant() ? QSize(250,360) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 360) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setGameCardInfoSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/gameplayarea_CardInfoSize");
|
||||
setValue(value, "layouts/gameplayarea_CardInfoSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getGameMessageLayoutSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/gameplayarea_MessageLayoutSize");
|
||||
return previous == QVariant() ? QSize(250,250) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 250) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setGameMessageLayoutSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/gameplayarea_MessageLayoutSize");
|
||||
setValue(value, "layouts/gameplayarea_MessageLayoutSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getGamePlayerListSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/gameplayarea_PlayerListSize");
|
||||
return previous == QVariant() ? QSize(250,50) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 50) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setGamePlayerListSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/gameplayarea_PlayerListSize");
|
||||
setValue(value, "layouts/gameplayarea_PlayerListSize");
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayPlayAreaGeometry(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_geometry");
|
||||
setValue(value, "layouts/replayplayarea_geometry");
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_state");
|
||||
setValue(value, "layouts/replayplayarea_state");
|
||||
}
|
||||
|
||||
const QByteArray LayoutsSettings::getReplayPlayAreaLayoutState()
|
||||
|
@ -144,43 +144,43 @@ const QByteArray LayoutsSettings::getReplayPlayAreaGeometry()
|
|||
const QSize LayoutsSettings::getReplayCardInfoSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/replayplayarea_CardInfoSize");
|
||||
return previous == QVariant() ? QSize(250,360) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 360) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayCardInfoSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_CardInfoSize");
|
||||
setValue(value, "layouts/replayplayarea_CardInfoSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getReplayMessageLayoutSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/replayplayarea_MessageLayoutSize");
|
||||
return previous == QVariant() ? QSize(250,200) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 200) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayMessageLayoutSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_MessageLayoutSize");
|
||||
setValue(value, "layouts/replayplayarea_MessageLayoutSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getReplayPlayerListSize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/replayplayarea_PlayerListSize");
|
||||
return previous == QVariant() ? QSize(250,50) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(250, 50) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayPlayerListSize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_PlayerListSize");
|
||||
setValue(value, "layouts/replayplayarea_PlayerListSize");
|
||||
}
|
||||
|
||||
const QSize LayoutsSettings::getReplayReplaySize()
|
||||
{
|
||||
QVariant previous = getValue("layouts/replayplayarea_ReplaySize");
|
||||
return previous == QVariant() ? QSize(900,100) : previous.toSize();
|
||||
return previous == QVariant() ? QSize(900, 100) : previous.toSize();
|
||||
}
|
||||
|
||||
void LayoutsSettings::setReplayReplaySize(const QSize &value)
|
||||
{
|
||||
setValue(value,"layouts/replayplayarea_ReplaySize");
|
||||
setValue(value, "layouts/replayplayarea_ReplaySize");
|
||||
}
|
|
@ -8,6 +8,7 @@ class LayoutsSettings : public SettingsManager
|
|||
{
|
||||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
|
||||
public:
|
||||
void setDeckEditorLayoutState(const QByteArray &value);
|
||||
void setDeckEditorGeometry(const QByteArray &value);
|
||||
|
@ -53,8 +54,8 @@ signals:
|
|||
public slots:
|
||||
|
||||
private:
|
||||
explicit LayoutsSettings(QString settingPath,QObject *parent = nullptr);
|
||||
LayoutsSettings( const LayoutsSettings& /*other*/ );
|
||||
explicit LayoutsSettings(QString settingPath, QObject *parent = nullptr);
|
||||
LayoutsSettings(const LayoutsSettings & /*other*/);
|
||||
};
|
||||
|
||||
#endif // LAYOUTSSETTINGS_H
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "messagesettings.h"
|
||||
|
||||
MessageSettings::MessageSettings(QString settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath+"messages.ini",parent)
|
||||
: SettingsManager(settingPath + "messages.ini", parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString MessageSettings::getMessageAt(int index)
|
||||
{
|
||||
return getValue(QString("msg%1").arg(index),"messages").toString();
|
||||
return getValue(QString("msg%1").arg(index), "messages").toString();
|
||||
}
|
||||
|
||||
int MessageSettings::getCount()
|
||||
|
@ -17,10 +17,10 @@ int MessageSettings::getCount()
|
|||
|
||||
void MessageSettings::setCount(int count)
|
||||
{
|
||||
setValue(count,"count","messages");
|
||||
setValue(count, "count", "messages");
|
||||
}
|
||||
|
||||
void MessageSettings::setMessageAt(int index, QString message)
|
||||
{
|
||||
setValue(message,QString("msg%1").arg(index),"messages");
|
||||
setValue(message, QString("msg%1").arg(index), "messages");
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public slots:
|
|||
|
||||
private:
|
||||
explicit MessageSettings(QString settingPath, QObject *parent = nullptr);
|
||||
MessageSettings( const MessageSettings& /*other*/ );
|
||||
MessageSettings(const MessageSettings & /*other*/);
|
||||
};
|
||||
|
||||
#endif // MESSAGESETTINGS_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
ServersSettings::ServersSettings(QString settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath+"servers.ini", parent)
|
||||
: SettingsManager(settingPath + "servers.ini", parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,12 @@ bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue)
|
|||
return cbFlushLog == QVariant() ? abDefaultValue : cbFlushLog.toBool();
|
||||
}
|
||||
|
||||
void ServersSettings::addNewServer(QString saveName, QString serv, QString port, QString username, QString password, bool savePassword)
|
||||
void ServersSettings::addNewServer(QString saveName,
|
||||
QString serv,
|
||||
QString port,
|
||||
QString username,
|
||||
QString password,
|
||||
bool savePassword)
|
||||
{
|
||||
if (updateExistingServer(saveName, serv, port, username, password, savePassword))
|
||||
return;
|
||||
|
@ -189,17 +194,19 @@ void ServersSettings::addNewServer(QString saveName, QString serv, QString port,
|
|||
setValue(savePassword, QString("savePassword%1").arg(index), "server", "server_details");
|
||||
setValue(index, "totalServers", "server", "server_details");
|
||||
setValue(password, QString("password%1").arg(index), "server", "server_details");
|
||||
|
||||
}
|
||||
|
||||
bool ServersSettings::updateExistingServer(QString saveName, QString serv, QString port, QString username, QString password, bool savePassword)
|
||||
bool ServersSettings::updateExistingServer(QString saveName,
|
||||
QString serv,
|
||||
QString port,
|
||||
QString username,
|
||||
QString password,
|
||||
bool savePassword)
|
||||
{
|
||||
int size = getValue("totalServers", "server", "server_details").toInt() + 1;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (saveName == getValue(QString("saveName%1").arg(i), "server", "server_details").toString())
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (saveName == getValue(QString("saveName%1").arg(i), "server", "server_details").toString()) {
|
||||
setValue(serv, QString("server%1").arg(i), "server", "server_details");
|
||||
setValue(port, QString("port%1").arg(i), "server", "server_details");
|
||||
setValue(username, QString("username%1").arg(i), "server", "server_details");
|
||||
|
|
|
@ -9,7 +9,7 @@ class ServersSettings : public SettingsManager
|
|||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
|
||||
public:
|
||||
public:
|
||||
int getPreviousHostLogin();
|
||||
int getPrevioushostindex(const QString &);
|
||||
QStringList getPreviousHostList();
|
||||
|
@ -37,8 +37,14 @@ public:
|
|||
void setFPPort(QString port);
|
||||
void setSavePassword(int save);
|
||||
void setFPPlayerName(QString playerName);
|
||||
void addNewServer(QString saveName, QString serv, QString port, QString username, QString password, bool savePassword);
|
||||
bool updateExistingServer(QString saveName, QString serv, QString port, QString username, QString password, bool savePassword);
|
||||
void
|
||||
addNewServer(QString saveName, QString serv, QString port, QString username, QString password, bool savePassword);
|
||||
bool updateExistingServer(QString saveName,
|
||||
QString serv,
|
||||
QString port,
|
||||
QString username,
|
||||
QString password,
|
||||
bool savePassword);
|
||||
void setClearDebugLogStatus(bool abIsChecked);
|
||||
bool getClearDebugLogStatus(bool abDefaultValue);
|
||||
|
||||
|
@ -47,8 +53,8 @@ signals:
|
|||
public slots:
|
||||
|
||||
private:
|
||||
explicit ServersSettings(QString settingPath,QObject *parent = nullptr);
|
||||
ServersSettings( const ServersSettings& /*other*/ );
|
||||
explicit ServersSettings(QString settingPath, QObject *parent = nullptr);
|
||||
ServersSettings(const ServersSettings & /*other*/);
|
||||
};
|
||||
|
||||
#endif // SERVERSSETTINGS_H
|
||||
|
|
|
@ -1,56 +1,48 @@
|
|||
#include "settingsmanager.h"
|
||||
|
||||
SettingsManager::SettingsManager(QString settingPath, QObject *parent) : QObject(parent), settings(settingPath, QSettings::IniFormat)
|
||||
SettingsManager::SettingsManager(QString settingPath, QObject *parent)
|
||||
: QObject(parent), settings(settingPath, QSettings::IniFormat)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SettingsManager::setValue(QVariant value, QString name, QString group, QString subGroup)
|
||||
{
|
||||
if (!group.isEmpty())
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
settings.beginGroup(group);
|
||||
}
|
||||
|
||||
if (!subGroup.isEmpty())
|
||||
{
|
||||
if (!subGroup.isEmpty()) {
|
||||
settings.beginGroup(subGroup);
|
||||
}
|
||||
|
||||
settings.setValue(name, value);
|
||||
|
||||
if (!subGroup.isEmpty())
|
||||
{
|
||||
if (!subGroup.isEmpty()) {
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
if (!group.isEmpty())
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant SettingsManager::getValue(QString name, QString group, QString subGroup)
|
||||
{
|
||||
if (!group.isEmpty())
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
settings.beginGroup(group);
|
||||
}
|
||||
|
||||
if (!subGroup.isEmpty())
|
||||
{
|
||||
if (!subGroup.isEmpty()) {
|
||||
settings.beginGroup(subGroup);
|
||||
}
|
||||
|
||||
QVariant value = settings.value(name);
|
||||
|
||||
if (!subGroup.isEmpty())
|
||||
{
|
||||
if (!subGroup.isEmpty()) {
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
if (!group.isEmpty())
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,57 +2,92 @@
|
|||
|
||||
#include "carddatabase_test.h"
|
||||
|
||||
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; };
|
||||
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;
|
||||
};
|
||||
|
||||
SettingsCache::SettingsCache() { cardDatabaseSettings = new CardDatabaseSettings(); };
|
||||
SettingsCache::~SettingsCache() { delete cardDatabaseSettings; };
|
||||
QString SettingsCache::getCustomCardDatabasePath() const { return QString("%1/customsets/").arg(CARDDB_DATADIR); }
|
||||
QString SettingsCache::getCardDatabasePath() const { return QString("%1/cards.xml").arg(CARDDB_DATADIR); }
|
||||
QString SettingsCache::getTokenDatabasePath() const { return QString("%1/tokens.xml").arg(CARDDB_DATADIR); }
|
||||
QString SettingsCache::getSpoilerCardDatabasePath() const { return QString("%1/spoiler.xml").arg(CARDDB_DATADIR); }
|
||||
CardDatabaseSettings& SettingsCache::cardDatabase() const { return *cardDatabaseSettings; }
|
||||
SettingsCache::SettingsCache()
|
||||
{
|
||||
cardDatabaseSettings = new CardDatabaseSettings();
|
||||
};
|
||||
SettingsCache::~SettingsCache()
|
||||
{
|
||||
delete cardDatabaseSettings;
|
||||
};
|
||||
QString SettingsCache::getCustomCardDatabasePath() const
|
||||
{
|
||||
return QString("%1/customsets/").arg(CARDDB_DATADIR);
|
||||
}
|
||||
QString SettingsCache::getCardDatabasePath() const
|
||||
{
|
||||
return QString("%1/cards.xml").arg(CARDDB_DATADIR);
|
||||
}
|
||||
QString SettingsCache::getTokenDatabasePath() const
|
||||
{
|
||||
return QString("%1/tokens.xml").arg(CARDDB_DATADIR);
|
||||
}
|
||||
QString SettingsCache::getSpoilerCardDatabasePath() const
|
||||
{
|
||||
return QString("%1/spoiler.xml").arg(CARDDB_DATADIR);
|
||||
}
|
||||
CardDatabaseSettings &SettingsCache::cardDatabase() const
|
||||
{
|
||||
return *cardDatabaseSettings;
|
||||
}
|
||||
|
||||
SettingsCache *settingsCache;
|
||||
|
||||
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */) { }
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(CardDatabaseTest, LoadXml) {
|
||||
settingsCache = new SettingsCache;
|
||||
CardDatabase *db = new CardDatabase;
|
||||
|
||||
// ensure the card database is empty at start
|
||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
|
||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
|
||||
ASSERT_EQ(0, db->getAllColors().size()) << "Colors not empty at start";
|
||||
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty at start";
|
||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
|
||||
|
||||
// load dummy cards and test result
|
||||
db->loadCardDatabases();
|
||||
ASSERT_EQ(6, db->getCardList().size()) << "Wrong card count after load";
|
||||
ASSERT_EQ(3, db->getSetList().size()) << "Wrong sets count after load";
|
||||
ASSERT_EQ(4, db->getAllColors().size()) << "Wrong colors count after load";
|
||||
ASSERT_EQ(2, db->getAllMainCardTypes().size()) << "Wrong types count after load";
|
||||
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
|
||||
|
||||
// ensure the card database is empty after clear()
|
||||
db->clear();
|
||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
|
||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
|
||||
ASSERT_EQ(0, db->getAllColors().size()) << "Colors not empty after clear";
|
||||
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty after clear";
|
||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
|
||||
}
|
||||
void PictureLoader::clearPixmapCache(CardInfoPtr /* card */)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
namespace
|
||||
{
|
||||
|
||||
TEST(CardDatabaseTest, LoadXml)
|
||||
{
|
||||
settingsCache = new SettingsCache;
|
||||
CardDatabase *db = new CardDatabase;
|
||||
|
||||
// ensure the card database is empty at start
|
||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
|
||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
|
||||
ASSERT_EQ(0, db->getAllColors().size()) << "Colors not empty at start";
|
||||
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty at start";
|
||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
|
||||
|
||||
// load dummy cards and test result
|
||||
db->loadCardDatabases();
|
||||
ASSERT_EQ(6, db->getCardList().size()) << "Wrong card count after load";
|
||||
ASSERT_EQ(3, db->getSetList().size()) << "Wrong sets count after load";
|
||||
ASSERT_EQ(4, db->getAllColors().size()) << "Wrong colors count after load";
|
||||
ASSERT_EQ(2, db->getAllMainCardTypes().size()) << "Wrong types count after load";
|
||||
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
|
||||
|
||||
// ensure the card database is empty after clear()
|
||||
db->clear();
|
||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
|
||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
|
||||
ASSERT_EQ(0, db->getAllColors().size()) << "Colors not empty after clear";
|
||||
ASSERT_EQ(0, db->getAllMainCardTypes().size()) << "Types not empty after clear";
|
||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
class CardDatabaseSettings
|
||||
{
|
||||
public:
|
||||
public:
|
||||
void setSortKey(QString shortName, unsigned int sortKey);
|
||||
void setEnabled(QString shortName, bool enabled);
|
||||
void setIsKnown(QString shortName, bool isknown);
|
||||
|
@ -22,10 +22,12 @@ public:
|
|||
bool isKnown(QString shortName);
|
||||
};
|
||||
|
||||
class SettingsCache: public QObject {
|
||||
class SettingsCache : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
CardDatabaseSettings *cardDatabaseSettings;
|
||||
|
||||
public:
|
||||
SettingsCache();
|
||||
~SettingsCache();
|
||||
|
@ -33,14 +35,14 @@ public:
|
|||
QString getCardDatabasePath() const;
|
||||
QString getTokenDatabasePath() const;
|
||||
QString getSpoilerCardDatabasePath() const;
|
||||
CardDatabaseSettings& cardDatabase() const;
|
||||
CardDatabaseSettings &cardDatabase() const;
|
||||
signals:
|
||||
void cardDatabasePathChanged();
|
||||
};
|
||||
|
||||
|
||||
#define PICTURELOADER_H
|
||||
|
||||
class PictureLoader {
|
||||
class PictureLoader
|
||||
{
|
||||
void clearPixmapCache(CardInfoPtr card);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
class FooTest : public ::testing::Test {
|
||||
namespace
|
||||
{
|
||||
class FooTest : public ::testing::Test
|
||||
{
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
TEST(DummyTest, Works) {
|
||||
ASSERT_EQ(1, 1) << "One is not equal to one";
|
||||
}
|
||||
TEST(DummyTest, Works)
|
||||
{
|
||||
ASSERT_EQ(1, 1) << "One is not equal to one";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "loading_from_clipboard_test.h"
|
||||
#include <QTextStream>
|
||||
#include "../../common/decklist.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <QTextStream>
|
||||
|
||||
DeckList *fromClipboard(QString *clipboard);
|
||||
DeckList *fromClipboard(QString *clipboard) {
|
||||
DeckList *fromClipboard(QString *clipboard)
|
||||
{
|
||||
DeckList *deckList = new DeckList;
|
||||
QTextStream *stream = new QTextStream(clipboard);
|
||||
deckList->loadFromStream_Plain(*stream);
|
||||
|
@ -13,13 +14,17 @@ DeckList *fromClipboard(QString *clipboard) {
|
|||
|
||||
using CardRows = QMap<QString, int>;
|
||||
|
||||
struct DecklistBuilder {
|
||||
struct DecklistBuilder
|
||||
{
|
||||
CardRows actualMainboard;
|
||||
CardRows actualSideboard;
|
||||
|
||||
explicit DecklistBuilder() : actualMainboard({}), actualSideboard({}) {}
|
||||
explicit DecklistBuilder() : actualMainboard({}), actualSideboard({})
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const InnerDecklistNode *innerDecklistNode, const DecklistCardNode *card) {
|
||||
void operator()(const InnerDecklistNode *innerDecklistNode, const DecklistCardNode *card)
|
||||
{
|
||||
if (innerDecklistNode->getName() == DECK_ZONE_MAIN) {
|
||||
actualMainboard[card->getName()] += card->getNumber();
|
||||
} else if (innerDecklistNode->getName() == DECK_ZONE_SIDE) {
|
||||
|
@ -29,239 +34,204 @@ struct DecklistBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
CardRows mainboard() {
|
||||
CardRows mainboard()
|
||||
{
|
||||
return actualMainboard;
|
||||
}
|
||||
|
||||
CardRows sideboard() {
|
||||
CardRows sideboard()
|
||||
{
|
||||
return actualSideboard;
|
||||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
TEST(LoadingFromClipboardTest, EmptyDeck)
|
||||
{
|
||||
DeckList *deckList = fromClipboard(new QString(""));
|
||||
ASSERT_TRUE(deckList->getCardList().isEmpty());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, EmptySideboard) {
|
||||
DeckList *deckList = fromClipboard(new QString("Sideboard"));
|
||||
ASSERT_TRUE(deckList->getCardList().isEmpty());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, QuantityPrefixed) {
|
||||
QString *clipboard = new QString(
|
||||
"1 Mountain\n"
|
||||
"2x Island\n"
|
||||
"3X FOREST\n"
|
||||
);
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"mountain", 1},
|
||||
{"island", 2},
|
||||
{"forest", 3}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, CommentsAreIgnored) {
|
||||
QString *clipboard = new QString(
|
||||
"//1 Mountain\n"
|
||||
"//2x Island\n"
|
||||
"//SB:2x Island\n"
|
||||
);
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, SideboardPrefix) {
|
||||
QString *clipboard = new QString(
|
||||
"1 Mountain\n"
|
||||
"SB: 1 Mountain\n"
|
||||
"SB: 2x Island\n"
|
||||
);
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"mountain", 1}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({
|
||||
{"mountain", 1},
|
||||
{"island", 2}
|
||||
});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, UnknownCardsAreNotDiscarded) {
|
||||
QString *clipboard = new QString(
|
||||
"1 CardThatDoesNotExistInCardsXml\n"
|
||||
);
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"cardthatdoesnotexistincardsxml", 1}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, RemoveBlankEntriesFromBeginningAndEnd) {
|
||||
QString *clipboard = new QString(
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"2x Phelddagrif\n"
|
||||
"\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"algae gharial", 1},
|
||||
{"cardthatdoesnotexistincardsxml", 3},
|
||||
{"phelddagrif", 2}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, UseFirstBlankIfOnlyOneBlankToSplitSideboard) {
|
||||
QString *clipboard = new QString(
|
||||
"1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"\n"
|
||||
"2x Phelddagrif\n"
|
||||
);
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"algae gharial", 1},
|
||||
{"cardthatdoesnotexistincardsxml", 3}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({
|
||||
{"phelddagrif", 2}
|
||||
});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, IfMultipleScatteredBlanksAllMainBoard) {
|
||||
QString *clipboard = new QString(
|
||||
"1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"\n"
|
||||
"2x Phelddagrif\n"
|
||||
"\n"
|
||||
"3 Giant Growth\n"
|
||||
);
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"algae gharial", 1},
|
||||
{"cardthatdoesnotexistincardsxml", 3},
|
||||
{"phelddagrif", 2},
|
||||
{"giant growth", 3}
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, LotsOfStuffInBulkTesting) {
|
||||
QString *clipboard = new QString(
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"1x test1\n"
|
||||
"testNoValueMB\n"
|
||||
"2x test2\n"
|
||||
"SB: 10 testSB\n"
|
||||
"3 test3\n"
|
||||
"4X test4\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"5x test5\n"
|
||||
"6X test6\n"
|
||||
"testNoValueSB\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({
|
||||
{"test1", 1},
|
||||
{"test2", 2},
|
||||
{"test3", 3},
|
||||
{"test4", 4},
|
||||
{"testnovaluemb", 1}
|
||||
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({
|
||||
{"testsb", 10},
|
||||
{"test5", 5},
|
||||
{"test6", 6},
|
||||
{"testnovaluesb", 1}
|
||||
|
||||
});
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
namespace
|
||||
{
|
||||
TEST(LoadingFromClipboardTest, EmptyDeck)
|
||||
{
|
||||
DeckList *deckList = fromClipboard(new QString(""));
|
||||
ASSERT_TRUE(deckList->getCardList().isEmpty());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
TEST(LoadingFromClipboardTest, EmptySideboard)
|
||||
{
|
||||
DeckList *deckList = fromClipboard(new QString("Sideboard"));
|
||||
ASSERT_TRUE(deckList->getCardList().isEmpty());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, QuantityPrefixed)
|
||||
{
|
||||
QString *clipboard = new QString("1 Mountain\n"
|
||||
"2x Island\n"
|
||||
"3X FOREST\n");
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({{"mountain", 1}, {"island", 2}, {"forest", 3}});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, CommentsAreIgnored)
|
||||
{
|
||||
QString *clipboard = new QString("//1 Mountain\n"
|
||||
"//2x Island\n"
|
||||
"//SB:2x Island\n");
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, SideboardPrefix)
|
||||
{
|
||||
QString *clipboard = new QString("1 Mountain\n"
|
||||
"SB: 1 Mountain\n"
|
||||
"SB: 2x Island\n");
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({{"mountain", 1}});
|
||||
CardRows expectedSideboard = CardRows({{"mountain", 1}, {"island", 2}});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, UnknownCardsAreNotDiscarded)
|
||||
{
|
||||
QString *clipboard = new QString("1 CardThatDoesNotExistInCardsXml\n");
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({{"cardthatdoesnotexistincardsxml", 1}});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, RemoveBlankEntriesFromBeginningAndEnd)
|
||||
{
|
||||
QString *clipboard = new QString("\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"2x Phelddagrif\n"
|
||||
"\n"
|
||||
"\n");
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard =
|
||||
CardRows({{"algae gharial", 1}, {"cardthatdoesnotexistincardsxml", 3}, {"phelddagrif", 2}});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, UseFirstBlankIfOnlyOneBlankToSplitSideboard)
|
||||
{
|
||||
QString *clipboard = new QString("1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"\n"
|
||||
"2x Phelddagrif\n");
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({{"algae gharial", 1}, {"cardthatdoesnotexistincardsxml", 3}});
|
||||
CardRows expectedSideboard = CardRows({{"phelddagrif", 2}});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, IfMultipleScatteredBlanksAllMainBoard)
|
||||
{
|
||||
QString *clipboard = new QString("1x Algae Gharial\n"
|
||||
"3x CardThatDoesNotExistInCardsXml\n"
|
||||
"\n"
|
||||
"2x Phelddagrif\n"
|
||||
"\n"
|
||||
"3 Giant Growth\n");
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows(
|
||||
{{"algae gharial", 1}, {"cardthatdoesnotexistincardsxml", 3}, {"phelddagrif", 2}, {"giant growth", 3}});
|
||||
CardRows expectedSideboard = CardRows({});
|
||||
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
|
||||
TEST(LoadingFromClipboardTest, LotsOfStuffInBulkTesting)
|
||||
{
|
||||
QString *clipboard = new QString("\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"1x test1\n"
|
||||
"testNoValueMB\n"
|
||||
"2x test2\n"
|
||||
"SB: 10 testSB\n"
|
||||
"3 test3\n"
|
||||
"4X test4\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"5x test5\n"
|
||||
"6X test6\n"
|
||||
"testNoValueSB\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n");
|
||||
|
||||
DeckList *deckList = fromClipboard(clipboard);
|
||||
|
||||
DecklistBuilder decklistBuilder = DecklistBuilder();
|
||||
deckList->forEachCard(decklistBuilder);
|
||||
|
||||
CardRows expectedMainboard = CardRows({{"test1", 1}, {"test2", 2}, {"test3", 3}, {"test4", 4}, {"testnovaluemb", 1}
|
||||
|
||||
});
|
||||
CardRows expectedSideboard = CardRows({{"testsb", 10}, {"test5", 5}, {"test6", 6}, {"testnovaluesb", 1}
|
||||
|
||||
});
|
||||
ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard());
|
||||
ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Loading…
Reference in a new issue