Browse Source

Replace QPair with std::pair

adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
3ea4c66d41
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 7
      src/base/rss/rss_feed.cpp
  2. 3
      src/gui/rss/automatedrssdownloader.cpp
  3. 5
      src/gui/rss/automatedrssdownloader.h
  4. 10
      src/gui/search/searchwidget.cpp

7
src/base/rss/rss_feed.cpp

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include "rss_feed.h"
#include <algorithm>
#include <utility>
#include <vector>
#include <QDir>
@ -461,19 +462,19 @@ int Feed::updateArticles(const QList<QVariantHash> &loadedArticles) @@ -461,19 +462,19 @@ int Feed::updateArticles(const QList<QVariantHash> &loadedArticles)
if (newArticles.empty())
return 0;
using ArticleSortAdaptor = QPair<QDateTime, const QVariantHash *>;
using ArticleSortAdaptor = std::pair<QDateTime, const QVariantHash *>;
std::vector<ArticleSortAdaptor> sortData;
const QList<Article *> existingArticles = articles();
sortData.reserve(existingArticles.size() + newArticles.size());
std::transform(existingArticles.begin(), existingArticles.end(), std::back_inserter(sortData)
, [](const Article *article)
{
return qMakePair(article->date(), nullptr);
return std::make_pair(article->date(), nullptr);
});
std::transform(newArticles.begin(), newArticles.end(), std::back_inserter(sortData)
, [](const QVariantHash &article)
{
return qMakePair(article[Article::KeyDate].toDateTime(), &article);
return std::make_pair(article[Article::KeyDate].toDateTime(), &article);
});
// Sort article list in reverse chronological order

3
src/gui/rss/automatedrssdownloader.cpp

@ -33,7 +33,6 @@ @@ -33,7 +33,6 @@
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
#include <QPair>
#include <QRegularExpression>
#include <QShortcut>
#include <QSignalBlocker>
@ -664,7 +663,7 @@ void AutomatedRssDownloader::addFeedArticlesToTree(RSS::Feed *feed, const QStrin @@ -664,7 +663,7 @@ void AutomatedRssDownloader::addFeedArticlesToTree(RSS::Feed *feed, const QStrin
// Insert the articles
for (const QString &article : articles)
{
QPair<QString, QString> key(feed->name(), article);
const std::pair<QString, QString> key(feed->name(), article);
if (!m_treeListEntries.contains(key))
{

5
src/gui/rss/automatedrssdownloader.h

@ -29,9 +29,10 @@ @@ -29,9 +29,10 @@
#pragma once
#include <utility>
#include <QDialog>
#include <QHash>
#include <QPair>
#include <QSet>
#include "base/rss/rss_autodownloadrule.h"
@ -101,7 +102,7 @@ private: @@ -101,7 +102,7 @@ private:
Ui::AutomatedRssDownloader *m_ui;
QListWidgetItem *m_currentRuleItem;
QSet<QPair<QString, QString>> m_treeListEntries;
QSet<std::pair<QString, QString>> m_treeListEntries;
RSS::AutoDownloadRule m_currentRule;
QHash<QString, QListWidgetItem *> m_itemsByRuleName;
QRegularExpression *m_episodeRegex;

10
src/gui/search/searchwidget.cpp

@ -32,6 +32,8 @@ @@ -32,6 +32,8 @@
#include <QtGlobal>
#include <utility>
#ifdef Q_OS_WIN
#include <cstdlib>
#endif
@ -182,10 +184,10 @@ void SearchWidget::fillCatCombobox() @@ -182,10 +184,10 @@ void SearchWidget::fillCatCombobox()
m_ui->comboCategory->clear();
m_ui->comboCategory->addItem(SearchPluginManager::categoryFullName("all"), "all");
using QStrPair = QPair<QString, QString>;
using QStrPair = std::pair<QString, QString>;
QVector<QStrPair> tmpList;
for (const QString &cat : asConst(SearchPluginManager::instance()->getPluginCategories(selectedPlugin())))
tmpList << qMakePair(SearchPluginManager::categoryFullName(cat), cat);
tmpList << std::make_pair(SearchPluginManager::categoryFullName(cat), cat);
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (QString::localeAwareCompare(l.first, r.first) < 0); });
for (const QStrPair &p : asConst(tmpList))
@ -205,10 +207,10 @@ void SearchWidget::fillPluginComboBox() @@ -205,10 +207,10 @@ void SearchWidget::fillPluginComboBox()
m_ui->selectPlugin->addItem(tr("All plugins"), "all");
m_ui->selectPlugin->addItem(tr("Select..."), "multi");
using QStrPair = QPair<QString, QString>;
using QStrPair = std::pair<QString, QString>;
QVector<QStrPair> tmpList;
for (const QString &name : asConst(SearchPluginManager::instance()->enabledPlugins()))
tmpList << qMakePair(SearchPluginManager::instance()->pluginFullName(name), name);
tmpList << std::make_pair(SearchPluginManager::instance()->pluginFullName(name), name);
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } );
for (const QStrPair &p : asConst(tmpList))

Loading…
Cancel
Save