mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 12:03:25 -08:00
Apply else-after-return across the tree (#7884)
This commit is contained in:
parent
e97d3e5519
commit
c27b5e9fcf
22 changed files with 48 additions and 25 deletions
|
|
@ -37,7 +37,8 @@ bool parseDeckUrl(const QString &url, ParsedDeckInfo &outInfo)
|
||||||
.fullUrl = TAPPEDOUT_BASE + slug + TAPPEDOUT_SUFFIX,
|
.fullUrl = TAPPEDOUT_BASE + slug + TAPPEDOUT_SUFFIX,
|
||||||
.provider = DeckProvider::TappedOut};
|
.provider = DeckProvider::TappedOut};
|
||||||
return true;
|
return true;
|
||||||
} else if ((match = rxArchidekt.match(url)).hasMatch()) {
|
}
|
||||||
|
if ((match = rxArchidekt.match(url)).hasMatch()) {
|
||||||
QString deckID = match.captured(1);
|
QString deckID = match.captured(1);
|
||||||
outInfo = ParsedDeckInfo{.baseUrl = ARCHIDEKT_BASE,
|
outInfo = ParsedDeckInfo{.baseUrl = ARCHIDEKT_BASE,
|
||||||
.deckID = deckID,
|
.deckID = deckID,
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,8 @@ bool ThemeManager::isDarkMode(const QString &themeDirPath) const
|
||||||
const ThemeConfig themeConfig = loadColorSchemeConfig(themeDirPath, systemThemeDir);
|
const ThemeConfig themeConfig = loadColorSchemeConfig(themeDirPath, systemThemeDir);
|
||||||
if (themeConfig.colorScheme.compare("Dark", Qt::CaseInsensitive) == 0) {
|
if (themeConfig.colorScheme.compare("Dark", Qt::CaseInsensitive) == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else if (themeConfig.colorScheme.compare("Light", Qt::CaseInsensitive) == 0) {
|
}
|
||||||
|
if (themeConfig.colorScheme.compare("Light", Qt::CaseInsensitive) == 0) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,8 @@ bool ResizablePanel::eventFilter(QObject *obj, QEvent *event)
|
||||||
dragButton->setCursor(Qt::ClosedHandCursor);
|
dragButton->setCursor(Qt::ClosedHandCursor);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (event->type() == QEvent::MouseMove) {
|
}
|
||||||
|
if (event->type() == QEvent::MouseMove) {
|
||||||
auto *mouseEvent = static_cast<QMouseEvent *>(event);
|
auto *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
if (mouseEvent->buttons() & Qt::LeftButton) {
|
if (mouseEvent->buttons() & Qt::LeftButton) {
|
||||||
QPoint currentPos = mouseEvent->globalPosition().toPoint();
|
QPoint currentPos = mouseEvent->globalPosition().toPoint();
|
||||||
|
|
@ -207,7 +208,8 @@ bool ResizablePanel::eventFilter(QObject *obj, QEvent *event)
|
||||||
resizeStartHeight = currentHeight;
|
resizeStartHeight = currentHeight;
|
||||||
resizeHandle->grabMouse();
|
resizeHandle->grabMouse();
|
||||||
return true;
|
return true;
|
||||||
} else if (event->type() == QEvent::MouseMove && isResizing) {
|
}
|
||||||
|
if (event->type() == QEvent::MouseMove && isResizing) {
|
||||||
auto *mouseEvent = static_cast<QMouseEvent *>(event);
|
auto *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
int deltaY = mouseEvent->globalPosition().y() - resizeStartY;
|
int deltaY = mouseEvent->globalPosition().y() - resizeStartY;
|
||||||
int newHeight = resizeStartHeight + deltaY;
|
int newHeight = resizeStartHeight + deltaY;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ void DlgEditPassword::actOk()
|
||||||
if (newPasswordEdit->text().length() < 8) {
|
if (newPasswordEdit->text().length() < 8) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
|
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
|
||||||
return;
|
return;
|
||||||
} else if (newPasswordEdit->text() != newPasswordEdit2->text()) {
|
}
|
||||||
|
if (newPasswordEdit->text() != newPasswordEdit2->text()) {
|
||||||
QMessageBox::warning(this, tr("Error"), tr("The new passwords don't match."));
|
QMessageBox::warning(this, tr("Error"), tr("The new passwords don't match."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,8 @@ void DlgForgotPasswordReset::actOk()
|
||||||
if (newpasswordEdit->text().length() < 8) {
|
if (newpasswordEdit->text().length() < 8) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
|
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
|
||||||
return;
|
return;
|
||||||
} else if (newpasswordEdit->text() != newpasswordverifyEdit->text()) {
|
}
|
||||||
|
if (newpasswordEdit->text() != newpasswordverifyEdit->text()) {
|
||||||
QMessageBox::critical(this, tr("Reset Password Error"), tr("The passwords do not match."));
|
QMessageBox::critical(this, tr("Reset Password Error"), tr("The passwords do not match."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,8 @@ void DlgRegister::actOk()
|
||||||
if (passwordEdit->text().length() < 8) {
|
if (passwordEdit->text().length() < 8) {
|
||||||
QMessageBox::critical(this, tr("Registration Warning"), tr("Your password is too short."));
|
QMessageBox::critical(this, tr("Registration Warning"), tr("Your password is too short."));
|
||||||
return;
|
return;
|
||||||
} else if (passwordEdit->text() != passwordConfirmationEdit->text()) {
|
}
|
||||||
|
if (passwordEdit->text() != passwordConfirmationEdit->text()) {
|
||||||
QMessageBox::critical(this, tr("Registration Warning"), tr("Your passwords do not match, please try again."));
|
QMessageBox::critical(this, tr("Registration Warning"), tr("Your passwords do not match, please try again."));
|
||||||
return;
|
return;
|
||||||
} else if (emailConfirmationEdit->text() != emailEdit->text()) {
|
} else if (emailConfirmationEdit->text() != emailEdit->text()) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ TipsOfTheDay::TipsOfTheDay(QString xmlPath, QObject *parent) : QAbstractListMode
|
||||||
if (!QFile::exists(xmlPath)) {
|
if (!QFile::exists(xmlPath)) {
|
||||||
errorStream << tr("File does not exist.\n");
|
errorStream << tr("File does not exist.\n");
|
||||||
return;
|
return;
|
||||||
} else if (!xmlFile.open(QIODevice::ReadOnly)) {
|
}
|
||||||
|
if (!xmlFile.open(QIODevice::ReadOnly)) {
|
||||||
errorStream << tr("Failed to open file.\n");
|
errorStream << tr("Failed to open file.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,8 @@ static QString zoneLogName(const QString &zone)
|
||||||
{
|
{
|
||||||
if (zone == DECK_ZONE_MAIN) {
|
if (zone == DECK_ZONE_MAIN) {
|
||||||
return "mainboard";
|
return "mainboard";
|
||||||
} else if (zone == DECK_ZONE_SIDE) {
|
}
|
||||||
|
if (zone == DECK_ZONE_SIDE) {
|
||||||
return "sideboard";
|
return "sideboard";
|
||||||
} else if (zone == DECK_ZONE_TOKENS) {
|
} else if (zone == DECK_ZONE_TOKENS) {
|
||||||
return "tokens";
|
return "tokens";
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,8 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon
|
||||||
if (resp.response_code() == Response::RespNameNotFound) {
|
if (resp.response_code() == Response::RespNameNotFound) {
|
||||||
QMessageBox::critical(static_cast<QWidget *>(parent()), tr("Error"), tr("This user does not exist."));
|
QMessageBox::critical(static_cast<QWidget *>(parent()), tr("Error"), tr("This user does not exist."));
|
||||||
return;
|
return;
|
||||||
} else if (resp.response_code() == Response::RespInIgnoreList) {
|
}
|
||||||
|
if (resp.response_code() == Response::RespInIgnoreList) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
static_cast<QWidget *>(parent()), tr("Error"),
|
static_cast<QWidget *>(parent()), tr("Error"),
|
||||||
tr("You are being ignored by %1 and can't see their games.").arg(QString::fromStdString(cmd.user_name())));
|
tr("You are being ignored by %1 and can't see their games.").arg(QString::fromStdString(cmd.user_name())));
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,8 @@ bool UserListTWI::operator<(const QTreeWidgetItem &other) const
|
||||||
if (lhsUserLevelFlags.testFlag(userLevelEntry) &&
|
if (lhsUserLevelFlags.testFlag(userLevelEntry) &&
|
||||||
lhsUserLevelFlags.testFlag(userLevelEntry) == rhsUserLevelFlags.testFlag(userLevelEntry)) {
|
lhsUserLevelFlags.testFlag(userLevelEntry) == rhsUserLevelFlags.testFlag(userLevelEntry)) {
|
||||||
return collator.compare(data(2, Qt::UserRole).toString(), other.data(2, Qt::UserRole).toString()) < 0;
|
return collator.compare(data(2, Qt::UserRole).toString(), other.data(2, Qt::UserRole).toString()) < 0;
|
||||||
} else if (lhsUserLevelFlags.testFlag(userLevelEntry) != rhsUserLevelFlags.testFlag(userLevelEntry)) {
|
}
|
||||||
|
if (lhsUserLevelFlags.testFlag(userLevelEntry) != rhsUserLevelFlags.testFlag(userLevelEntry)) {
|
||||||
return lhsUserLevelFlags.testFlag(userLevelEntry) > rhsUserLevelFlags.testFlag(userLevelEntry);
|
return lhsUserLevelFlags.testFlag(userLevelEntry) > rhsUserLevelFlags.testFlag(userLevelEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -621,7 +621,8 @@ bool AbstractTabDeckEditor::confirmClose()
|
||||||
int ret = createSaveConfirmationWindow()->exec();
|
int ret = createSaveConfirmationWindow()->exec();
|
||||||
if (ret == QMessageBox::Save) {
|
if (ret == QMessageBox::Save) {
|
||||||
return actSaveDeck();
|
return actSaveDeck();
|
||||||
} else if (ret == QMessageBox::Cancel) {
|
}
|
||||||
|
if (ret == QMessageBox::Cancel) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,8 @@ void TabRoom::sendMessage()
|
||||||
}
|
}
|
||||||
if (sayEdit->text().isEmpty()) {
|
if (sayEdit->text().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
} else if (sayEdit->hasVisibleCompleterPopup()) {
|
}
|
||||||
|
if (sayEdit->hasVisibleCompleterPopup()) {
|
||||||
sayEdit->hideCompleterPopups();
|
sayEdit->hideCompleterPopups();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1447,7 +1447,8 @@ void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||||
!userLevel.testFlag(ServerInfo_User::IsRegistered)) {
|
!userLevel.testFlag(ServerInfo_User::IsRegistered)) {
|
||||||
// Flags are additive, so reg/mod/admin are all IsRegistered
|
// Flags are additive, so reg/mod/admin are all IsRegistered
|
||||||
return;
|
return;
|
||||||
} else if (SettingsCache::instance().chat().getIgnoreNonBuddyUserMessages() &&
|
}
|
||||||
|
if (SettingsCache::instance().chat().getIgnoreNonBuddyUserMessages() &&
|
||||||
!userListManager->isUserBuddy(senderName) && !userLevel.testFlag(ServerInfo_User::IsModerator) &&
|
!userListManager->isUserBuddy(senderName) && !userLevel.testFlag(ServerInfo_User::IsModerator) &&
|
||||||
!userLevel.testFlag(ServerInfo_User::IsAdmin)) {
|
!userLevel.testFlag(ServerInfo_User::IsAdmin)) {
|
||||||
// Ignore private messages from non-buddies
|
// Ignore private messages from non-buddies
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,8 @@ static QString zoneForClickModifiers(const Qt::KeyboardModifiers &modifiers)
|
||||||
{
|
{
|
||||||
if (modifiers.testFlag(Qt::ControlModifier)) {
|
if (modifiers.testFlag(Qt::ControlModifier)) {
|
||||||
return DECK_ZONE_SIDE;
|
return DECK_ZONE_SIDE;
|
||||||
} else if (modifiers.testFlag(Qt::ShiftModifier)) {
|
}
|
||||||
|
if (modifiers.testFlag(Qt::ShiftModifier)) {
|
||||||
return DECK_ZONE_MAYBEBOARD;
|
return DECK_ZONE_MAYBEBOARD;
|
||||||
} else {
|
} else {
|
||||||
return DECK_ZONE_MAIN;
|
return DECK_ZONE_MAIN;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ QVariant CardInfoComparator::getProperty(const CardInfoPtr &card, const QString
|
||||||
// Check if the property exists in the main fields of the class
|
// Check if the property exists in the main fields of the class
|
||||||
if (property == "name") {
|
if (property == "name") {
|
||||||
return card->getName();
|
return card->getName();
|
||||||
} else if (property == "text") {
|
}
|
||||||
|
if (property == "text") {
|
||||||
return card->getText();
|
return card->getText();
|
||||||
} else if (property == "isToken") {
|
} else if (property == "isToken") {
|
||||||
return card->getIsToken();
|
return card->getIsToken();
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ void CardSetList::defaultSort()
|
||||||
// Sort by priority, then by release date, then by short name
|
// Sort by priority, then by release date, then by short name
|
||||||
if (a->getPriority() != b->getPriority()) {
|
if (a->getPriority() != b->getPriority()) {
|
||||||
return a->getPriority() < b->getPriority(); // lowest first
|
return a->getPriority() < b->getPriority(); // lowest first
|
||||||
} else if (a->getReleaseDate() != b->getReleaseDate()) {
|
}
|
||||||
|
if (a->getReleaseDate() != b->getReleaseDate()) {
|
||||||
return a->getReleaseDate() > b->getReleaseDate(); // most recent first
|
return a->getReleaseDate() > b->getReleaseDate(); // most recent first
|
||||||
} else {
|
} else {
|
||||||
return a->getShortName() < b->getShortName(); // alphabetically
|
return a->getShortName() < b->getShortName(); // alphabetically
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ QString InnerDecklistNode::visibleNameFromName(const QString &_name)
|
||||||
{
|
{
|
||||||
if (_name == DECK_ZONE_MAIN) {
|
if (_name == DECK_ZONE_MAIN) {
|
||||||
return QObject::tr("Maindeck");
|
return QObject::tr("Maindeck");
|
||||||
} else if (_name == DECK_ZONE_SIDE) {
|
}
|
||||||
|
if (_name == DECK_ZONE_SIDE) {
|
||||||
return QObject::tr("Sideboard");
|
return QObject::tr("Sideboard");
|
||||||
} else if (_name == DECK_ZONE_TOKENS) {
|
} else if (_name == DECK_ZONE_TOKENS) {
|
||||||
return QObject::tr("Tokens");
|
return QObject::tr("Tokens");
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ AbstractClient *AbstractGame::getClientForPlayer(int playerId) const
|
||||||
}
|
}
|
||||||
|
|
||||||
return gameState->getClients().at(playerId);
|
return gameState->getClients().at(playerId);
|
||||||
} else if (gameState->getClients().isEmpty()) {
|
}
|
||||||
|
if (gameState->getClients().isEmpty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
return gameState->getClients().first();
|
return gameState->getClients().first();
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,8 @@ void PlayerLogic::deleteCard(CardState *card)
|
||||||
{
|
{
|
||||||
if (card == nullptr) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
} else if (dialogSemaphore) {
|
}
|
||||||
|
if (dialogSemaphore) {
|
||||||
cardsToDelete.append(card);
|
cardsToDelete.append(card);
|
||||||
} else {
|
} else {
|
||||||
card->deleteView();
|
card->deleteView();
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,8 @@ QString CardZoneLogic::getTranslatedName(bool theirOwn, GrammaticalCase gc) cons
|
||||||
QString ownerName = player->getPlayerInfo()->getName();
|
QString ownerName = player->getPlayerInfo()->getName();
|
||||||
if (name == ZoneNames::HAND) {
|
if (name == ZoneNames::HAND) {
|
||||||
return (theirOwn ? tr("their hand", "nominative") : tr("%1's hand", "nominative").arg(ownerName));
|
return (theirOwn ? tr("their hand", "nominative") : tr("%1's hand", "nominative").arg(ownerName));
|
||||||
} else if (name == ZoneNames::DECK) {
|
}
|
||||||
|
if (name == ZoneNames::DECK) {
|
||||||
switch (gc) {
|
switch (gc) {
|
||||||
case CaseLookAtZone:
|
case CaseLookAtZone:
|
||||||
return (theirOwn ? tr("their library", "look at zone")
|
return (theirOwn ? tr("their library", "look at zone")
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ int CardDatabaseDisplayModel::lessThanNumerically(QStringView left, QStringView
|
||||||
if (okLeft && okRight) {
|
if (okLeft && okRight) {
|
||||||
if (leftNum < rightNum) {
|
if (leftNum < rightNum) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (leftNum > rightNum) {
|
}
|
||||||
|
if (leftNum > rightNum) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ double Expression::eval(const peg::Ast &ast)
|
||||||
const auto &nodes = ast.nodes;
|
const auto &nodes = ast.nodes;
|
||||||
if (ast.name == "NUMBER") {
|
if (ast.name == "NUMBER") {
|
||||||
return stod(std::string(ast.token));
|
return stod(std::string(ast.token));
|
||||||
} else if (ast.name == "FUNCTION") {
|
}
|
||||||
|
if (ast.name == "FUNCTION") {
|
||||||
QString name = QString::fromStdString(std::string(nodes[0]->token));
|
QString name = QString::fromStdString(std::string(nodes[0]->token));
|
||||||
if (!fns.contains(name)) {
|
if (!fns.contains(name)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue