mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Combine qAsConst() with copyAsConst() to asConst()
This commit is contained in:
committed by
sledgehammer999
parent
e2ee928017
commit
bd4d2fa424
@@ -111,7 +111,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
QStringList files;
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
for (const QUrl &url : copyAsConst(event->mimeData()->urls())) {
|
||||
for (const QUrl &url : asConst(event->mimeData()->urls())) {
|
||||
if (!url.isEmpty()) {
|
||||
if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
|
||||
files << url.toLocalFile();
|
||||
@@ -126,7 +126,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
for (const QString &file : qAsConst(files)) {
|
||||
for (const QString &file : asConst(files)) {
|
||||
qDebug("dropped %s", qUtf8Printable(file));
|
||||
startAsyncOp();
|
||||
m_pluginManager->installPlugin(file);
|
||||
@@ -136,7 +136,7 @@ void PluginSelectDialog::dropEvent(QDropEvent *event)
|
||||
// Decode if we accept drag 'n drop or not
|
||||
void PluginSelectDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
for (const QString &mime : copyAsConst(event->mimeData()->formats())) {
|
||||
for (const QString &mime : asConst(event->mimeData()->formats())) {
|
||||
qDebug("mimeData: %s", qUtf8Printable(mime));
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ void PluginSelectDialog::on_closeButton_clicked()
|
||||
void PluginSelectDialog::on_actionUninstall_triggered()
|
||||
{
|
||||
bool error = false;
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_ui->pluginsTree->selectedItems())) {
|
||||
for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems())) {
|
||||
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
||||
Q_ASSERT(index != -1);
|
||||
QString id = item->text(PLUGIN_ID);
|
||||
@@ -212,7 +212,7 @@ void PluginSelectDialog::on_actionUninstall_triggered()
|
||||
|
||||
void PluginSelectDialog::enableSelection(bool enable)
|
||||
{
|
||||
for (QTreeWidgetItem *item : copyAsConst(m_ui->pluginsTree->selectedItems())) {
|
||||
for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems())) {
|
||||
int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
|
||||
Q_ASSERT(index != -1);
|
||||
QString id = item->text(PLUGIN_ID);
|
||||
@@ -265,7 +265,7 @@ void PluginSelectDialog::loadSupportedSearchPlugins()
|
||||
{
|
||||
// Some clean up first
|
||||
m_ui->pluginsTree->clear();
|
||||
for (const QString &name : copyAsConst(m_pluginManager->allPlugins()))
|
||||
for (const QString &name : asConst(m_pluginManager->allPlugins()))
|
||||
addNewPlugin(name);
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ void PluginSelectDialog::iconDownloaded(const QString &url, QString filePath)
|
||||
QList<QSize> sizes = icon.availableSizes();
|
||||
bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
|
||||
if (!invalid) {
|
||||
for (QTreeWidgetItem *item : copyAsConst(findItemsWithUrl(url))) {
|
||||
for (QTreeWidgetItem *item : asConst(findItemsWithUrl(url))) {
|
||||
QString id = item->text(PLUGIN_ID);
|
||||
PluginInfo *plugin = m_pluginManager->pluginInfo(id);
|
||||
if (!plugin) continue;
|
||||
|
||||
@@ -128,7 +128,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
|
||||
const QAbstractItemModel *const sourceModel = this->sourceModel();
|
||||
if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) {
|
||||
QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString();
|
||||
for (const QString &word : qAsConst(m_searchTermWords)) {
|
||||
for (const QString &word : asConst(m_searchTermWords)) {
|
||||
int i = name.indexOf(word, 0, Qt::CaseInsensitive);
|
||||
if (i == -1) {
|
||||
return false;
|
||||
|
||||
@@ -167,11 +167,11 @@ void SearchWidget::fillCatCombobox()
|
||||
|
||||
using QStrPair = QPair<QString, QString>;
|
||||
QList<QStrPair> tmpList;
|
||||
for (const QString &cat : copyAsConst(SearchPluginManager::instance()->getPluginCategories(selectedPlugin())))
|
||||
for (const QString &cat : asConst(SearchPluginManager::instance()->getPluginCategories(selectedPlugin())))
|
||||
tmpList << qMakePair(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 : qAsConst(tmpList)) {
|
||||
for (const QStrPair &p : asConst(tmpList)) {
|
||||
qDebug("Supported category: %s", qUtf8Printable(p.second));
|
||||
m_ui->comboCategory->addItem(p.first, QVariant(p.second));
|
||||
}
|
||||
@@ -189,11 +189,11 @@ void SearchWidget::fillPluginComboBox()
|
||||
|
||||
using QStrPair = QPair<QString, QString>;
|
||||
QList<QStrPair> tmpList;
|
||||
for (const QString &name : copyAsConst(SearchPluginManager::instance()->enabledPlugins()))
|
||||
for (const QString &name : asConst(SearchPluginManager::instance()->enabledPlugins()))
|
||||
tmpList << qMakePair(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 : qAsConst(tmpList))
|
||||
for (const QStrPair &p : asConst(tmpList))
|
||||
m_ui->selectPlugin->addItem(p.first, QVariant(p.second));
|
||||
|
||||
if (m_ui->selectPlugin->count() > 3)
|
||||
|
||||
Reference in New Issue
Block a user