mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
replace foreach macro with standard for each loop (#5485)
This commit is contained in:
parent
0cbad25385
commit
c148c8df7f
17 changed files with 31 additions and 31 deletions
|
|
@ -167,7 +167,7 @@ bool SpoilerBackgroundUpdater::saveDownloadedFile(QByteArray data)
|
|||
if (trayIcon) {
|
||||
QList<QByteArray> lines = data.split('\n');
|
||||
|
||||
foreach (QByteArray line, lines) {
|
||||
for (const QByteArray &line : lines) {
|
||||
if (line.contains("Created At:")) {
|
||||
QString timeStamp = QString(line).replace("Created At:", "").trimmed();
|
||||
timeStamp.chop(6); // Remove " (UTC)"
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ bool TabSupervisor::closeRequest()
|
|||
}
|
||||
}
|
||||
|
||||
foreach (TabDeckEditor *tab, deckEditorTabs) {
|
||||
for (TabDeckEditor *tab : deckEditorTabs) {
|
||||
if (!tab->confirmClose())
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ VisualDeckStorageTagFilterWidget::filterDecksBySelectedTags(const QList<DeckPrev
|
|||
{
|
||||
// Collect selected tags from DeckPreviewTagDisplayWidget
|
||||
QStringList selectedTags;
|
||||
foreach (DeckPreviewTagDisplayWidget *tagWidget, findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
for (DeckPreviewTagDisplayWidget *tagWidget : findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
if (tagWidget->getSelected()) {
|
||||
selectedTags.append(tagWidget->getTagName());
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ VisualDeckStorageTagFilterWidget::filterDecksBySelectedTags(const QList<DeckPrev
|
|||
void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QStringList &tags)
|
||||
{
|
||||
// Iterate through all DeckPreviewTagDisplayWidgets
|
||||
foreach (DeckPreviewTagDisplayWidget *tagWidget, findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
for (DeckPreviewTagDisplayWidget *tagWidget : findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
// If the tag is not in the provided tags list, remove the widget
|
||||
if (!tags.contains(tagWidget->getTagName())) {
|
||||
auto *flowWidget = findChild<FlowWidget *>();
|
||||
|
|
@ -82,7 +82,7 @@ void VisualDeckStorageTagFilterWidget::addTagIfNotPresent(const QString &tag)
|
|||
{
|
||||
// Check if the tag already exists in the flow widget
|
||||
bool tagExists = false;
|
||||
foreach (DeckPreviewTagDisplayWidget *tagWidget, findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
for (DeckPreviewTagDisplayWidget *tagWidget : findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
if (tagWidget->getTagName() == tag) {
|
||||
tagExists = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ void VisualDeckStorageWidget::refreshBannerCards()
|
|||
allFiles << it.next(); // Add each file path to the list
|
||||
}
|
||||
|
||||
foreach (const QString &file, allFiles) {
|
||||
for (const QString &file : allFiles) {
|
||||
auto *display = new DeckPreviewWidget(this, file);
|
||||
|
||||
connect(display, &DeckPreviewWidget::deckPreviewClicked, this,
|
||||
|
|
@ -116,7 +116,7 @@ void VisualDeckStorageWidget::refreshBannerCards()
|
|||
|
||||
flowWidget->clearLayout(); // Clear existing widgets in the flow layout
|
||||
|
||||
foreach (DeckPreviewWidget *deck, filteredFiles) {
|
||||
for (DeckPreviewWidget *deck : filteredFiles) {
|
||||
flowWidget->addWidget(deck);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ QStringList VisualDeckStorageWidget::gatherAllTagsFromFlowWidget() const
|
|||
|
||||
if (flowWidget) {
|
||||
// Iterate through all DeckPreviewWidgets
|
||||
foreach (DeckPreviewWidget *display, flowWidget->findChildren<DeckPreviewWidget *>()) {
|
||||
for (DeckPreviewWidget *display : flowWidget->findChildren<DeckPreviewWidget *>()) {
|
||||
// Get tags from each DeckPreviewWidget
|
||||
QStringList tags = display->deckLoader->getTags();
|
||||
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ void DeckLoader::saveToStream_DeckHeader(QTextStream &out)
|
|||
|
||||
if (!getComments().isEmpty()) {
|
||||
QStringList commentRows = getComments().split(QRegularExpression("\n|\r\n|\r"));
|
||||
foreach (QString row, commentRows) {
|
||||
for (const QString &row : commentRows) {
|
||||
out << "// " << row << "\n";
|
||||
}
|
||||
out << "\n";
|
||||
|
|
@ -433,7 +433,7 @@ void DeckLoader::saveToStream_DeckZone(QTextStream &out,
|
|||
}
|
||||
|
||||
// print cards to stream
|
||||
foreach (QString cardType, cardsByType.uniqueKeys()) {
|
||||
for (const QString &cardType : cardsByType.uniqueKeys()) {
|
||||
if (addComments) {
|
||||
out << "// " << cardTotalByType[cardType] << " " << cardType << "\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QStrin
|
|||
|
||||
QStringList countries = SettingsCache::instance().getCountries();
|
||||
int i = 1;
|
||||
foreach (QString c, countries) {
|
||||
for (const QString &c : countries) {
|
||||
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);
|
||||
if (c == country)
|
||||
countryEdit->setCurrentIndex(i);
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
|
|||
countryEdit->addItem(QPixmap("theme:countries/zw"), "zw");
|
||||
countryEdit->setCurrentIndex(0);
|
||||
QStringList countries = SettingsCache::instance().getCountries();
|
||||
foreach (QString c, countries)
|
||||
for (const QString &c : countries)
|
||||
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);
|
||||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void DlgViewLog::actCheckBoxChanged(bool abNewValue)
|
|||
void DlgViewLog::loadInitialLogBuffer()
|
||||
{
|
||||
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
|
||||
foreach (QString message, logBuffer)
|
||||
for (const QString &message : logBuffer)
|
||||
logEntryAdded(message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ CardInfoPtr CardDatabase::getCard(const QString &cardName) const
|
|||
QList<CardInfoPtr> CardDatabase::getCards(const QStringList &cardNames) const
|
||||
{
|
||||
QList<CardInfoPtr> cardInfos;
|
||||
foreach (QString cardName, cardNames) {
|
||||
for (const QString &cardName : cardNames) {
|
||||
CardInfoPtr ptr = getCardFromMap(cards, cardName);
|
||||
if (ptr)
|
||||
cardInfos.append(ptr);
|
||||
|
|
@ -783,7 +783,7 @@ void CardDatabase::refreshCachedReverseRelatedCards()
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach (CardRelation *cardRelation, card->getReverseRelatedCards()) {
|
||||
for (CardRelation *cardRelation : card->getReverseRelatedCards()) {
|
||||
const QString &targetCard = cardRelation->getName();
|
||||
if (!cards.contains(targetCard)) {
|
||||
continue;
|
||||
|
|
@ -886,7 +886,7 @@ CardRelation::CardRelation(const QString &_name,
|
|||
|
||||
void CardInfo::resetReverseRelatedCards2Me()
|
||||
{
|
||||
foreach (CardRelation *cardRelation, this->getReverseRelatedCards2Me()) {
|
||||
for (CardRelation *cardRelation : this->getReverseRelatedCards2Me()) {
|
||||
cardRelation->deleteLater();
|
||||
}
|
||||
reverseRelatedCardsToMe = QList<CardRelation *>();
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void installNewTranslator()
|
|||
QString const generateClientID()
|
||||
{
|
||||
QString macList;
|
||||
foreach (QNetworkInterface networkInterface, QNetworkInterface::allInterfaces()) {
|
||||
for (const QNetworkInterface &networkInterface : QNetworkInterface::allInterfaces()) {
|
||||
if (networkInterface.hardwareAddress() != "")
|
||||
if (networkInterface.hardwareAddress() != "00:00:00:00:00:00:00:E0")
|
||||
macList += networkInterface.hardwareAddress() + ".";
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
|
|||
}
|
||||
|
||||
// check word mentions
|
||||
foreach (QString word, highlightedWords) {
|
||||
for (const QString &word : highlightedWords) {
|
||||
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0) {
|
||||
// You have received a valid mention of custom word!!
|
||||
highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue