From 97ce4177983ebe88d096ae3098f6b5d984ecd93c Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 23 Oct 2015 11:55:14 +0200 Subject: [PATCH] Fix use of QList::first() --- src/lib/app/datapaths.cpp | 30 +++++++++---------- src/lib/app/mainapplication.cpp | 10 +++---- src/lib/autofill/autofill.cpp | 2 +- .../bookmarksexport/bookmarksexportdialog.cpp | 2 +- src/lib/bookmarks/bookmarksicon.cpp | 2 +- src/lib/bookmarks/bookmarksmanager.cpp | 4 +-- src/lib/bookmarks/bookmarkstreeview.cpp | 4 +-- src/lib/cookies/cookiejar.cpp | 2 +- src/lib/history/historytreeview.cpp | 4 +-- src/lib/navigation/locationbar.cpp | 2 +- src/lib/network/networkmanager.cpp | 4 +-- src/lib/network/pac/proxyautoconfig.cpp | 4 +-- src/lib/other/siteinfo.cpp | 2 +- src/lib/tools/qztools.cpp | 2 +- src/lib/webengine/webpage.cpp | 4 +-- 15 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/lib/app/datapaths.cpp b/src/lib/app/datapaths.cpp index 02cf63b00..3c22a82c7 100644 --- a/src/lib/app/datapaths.cpp +++ b/src/lib/app/datapaths.cpp @@ -50,8 +50,8 @@ void DataPaths::setPortableVersion() // Make sure the Config and Temp paths exists QDir dir; - dir.mkpath(d->m_paths[Config].first()); - dir.mkpath(d->m_paths[Temp].first()); + dir.mkpath(d->m_paths[Config].at(0)); + dir.mkpath(d->m_paths[Temp].at(0)); } // static @@ -59,7 +59,7 @@ QString DataPaths::path(DataPaths::Path path) { Q_ASSERT(!qz_data_paths()->m_paths[path].isEmpty()); - return qz_data_paths()->m_paths[path].first(); + return qz_data_paths()->m_paths[path].at(0); } // static @@ -93,9 +93,9 @@ void DataPaths::init() m_paths[AppData].append(QApplication::applicationDirPath()); #endif - m_paths[Translations].append(m_paths[AppData].first() + QLatin1String("/locale")); - m_paths[Themes].append(m_paths[AppData].first() + QLatin1String("/themes")); - m_paths[Plugins].append(m_paths[AppData].first() + QLatin1String("/plugins")); + m_paths[Translations].append(m_paths[AppData].at(0) + QLatin1String("/locale")); + m_paths[Themes].append(m_paths[AppData].at(0) + QLatin1String("/themes")); + m_paths[Plugins].append(m_paths[AppData].at(0) + QLatin1String("/plugins")); // Config #if defined(Q_OS_WIN) || defined(Q_OS_OS2) @@ -112,7 +112,7 @@ void DataPaths::init() #endif // Profiles - m_paths[Profiles].append(m_paths[Config].first() + QLatin1String("/profiles")); + m_paths[Profiles].append(m_paths[Config].at(0) + QLatin1String("/profiles")); // Temp #ifdef Q_OS_UNIX @@ -120,18 +120,18 @@ void DataPaths::init() const QString &tempPath = QString(QSL("%1/qupzilla-%2/tmp")).arg(QDir::tempPath(), user.constData()); m_paths[Temp].append(tempPath); #else - m_paths[Temp].append(m_paths[Config].first() + QLatin1String("/tmp")); + m_paths[Temp].append(m_paths[Config].at(0) + QLatin1String("/tmp")); #endif // Make sure the Config and Temp paths exists QDir dir; - dir.mkpath(m_paths[Config].first()); - dir.mkpath(m_paths[Temp].first()); + dir.mkpath(m_paths[Config].at(0)); + dir.mkpath(m_paths[Temp].at(0)); // We also allow to load data from Config path - m_paths[Translations].append(m_paths[Config].first() + QLatin1String("/locale")); - m_paths[Themes].append(m_paths[Config].first() + QLatin1String("/themes")); - m_paths[Plugins].append(m_paths[Config].first() + QLatin1String("/plugins")); + m_paths[Translations].append(m_paths[Config].at(0) + QLatin1String("/locale")); + m_paths[Themes].append(m_paths[Config].at(0) + QLatin1String("/themes")); + m_paths[Plugins].append(m_paths[Config].at(0) + QLatin1String("/plugins")); #ifdef USE_LIBPATH m_paths[Plugins].append(QLatin1String(USE_LIBPATH "/qupzilla")); @@ -150,7 +150,7 @@ void DataPaths::initCurrentProfile(const QString &profilePath) #endif if (m_paths[Cache].isEmpty()) - m_paths[Cache].append(m_paths[CurrentProfile].first() + QLatin1String("/cache")); + m_paths[Cache].append(m_paths[CurrentProfile].at(0) + QLatin1String("/cache")); - QDir().mkpath(m_paths[Cache].first()); + QDir().mkpath(m_paths[Cache].at(0)); } diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index b48931aa4..159e38402 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -128,7 +128,7 @@ MainApplication::MainApplication(int &argc, char** argv) if (fontId != -1) { const QStringList families = QFontDatabase::applicationFontFamilies(fontId); if (!families.empty()) - setFont(QFont(families.first())); + setFont(QFont(families.at(0))); } #endif @@ -372,7 +372,7 @@ BrowserWindow* MainApplication::getWindow() const return m_lastActiveWindow.data(); } - return m_windows.isEmpty() ? 0 : m_windows.first(); + return m_windows.isEmpty() ? 0 : m_windows.at(0); } BrowserWindow* MainApplication::createWindow(Qz::BrowserWindowType type, const QUrl &startUrl) @@ -413,7 +413,7 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD // Instead create new one and restore pinned tabs there BrowserWindow* newWin = createWindow(Qz::BW_OtherRestoredWindow); newWin->setUpdatesEnabled(false); - newWin->restoreWindowState(restoreData.first()); + newWin->restoreWindowState(restoreData.at(0)); newWin->setUpdatesEnabled(true); restoreData.remove(0); } @@ -423,7 +423,7 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD // update: it seems with ComboTabBar QTabWidget::count() is updated, // we add pinnedTabCounts to currentTab! int tabCount = window->tabWidget()->pinnedTabsCount(); - RestoreManager::WindowData data = restoreData.first(); + RestoreManager::WindowData data = restoreData.at(0); data.currentTab += tabCount; restoreData.remove(0); window->restoreWindowState(data); @@ -980,7 +980,7 @@ void MainApplication::translateApp() const QStringList translations = dir.entryList(QStringList(lang)); // If no translation can be found, default English will be used - file = translations.isEmpty() ? QString() : translations.first(); + file = translations.isEmpty() ? QString() : translations.at(0); } if (!file.isEmpty() && QFile(QString("%1/%2").arg(path, file)).exists()) { diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index 13393f6a1..79b1e8012 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -223,7 +223,7 @@ QVector AutoFill::completePage(QWebEnginePage *page, const QUrl & list = getFormData(frameUrl); if (!list.isEmpty()) { - const PasswordEntry entry = list.first(); + const PasswordEntry entry = list.at(0); page->runJavaScript(Scripts::completeFormData(entry.data)); } diff --git a/src/lib/bookmarks/bookmarksexport/bookmarksexportdialog.cpp b/src/lib/bookmarks/bookmarksexport/bookmarksexportdialog.cpp index d232967b1..bf70f9112 100644 --- a/src/lib/bookmarks/bookmarksexport/bookmarksexportdialog.cpp +++ b/src/lib/bookmarks/bookmarksexport/bookmarksexportdialog.cpp @@ -76,5 +76,5 @@ void BookmarksExportDialog::init() ui->format->addItem(exporter->name()); } - m_currentExporter = m_exporters.first(); + m_currentExporter = m_exporters.at(0); } diff --git a/src/lib/bookmarks/bookmarksicon.cpp b/src/lib/bookmarks/bookmarksicon.cpp index 2af875e35..f1337de99 100644 --- a/src/lib/bookmarks/bookmarksicon.cpp +++ b/src/lib/bookmarks/bookmarksicon.cpp @@ -57,7 +57,7 @@ void BookmarksIcon::checkBookmark(const QUrl &url, bool forceCheck) } QList items = mApp->bookmarks()->searchBookmarks(url); - m_bookmark = items.isEmpty() ? 0 : items.first(); + m_bookmark = items.isEmpty() ? 0 : items.at(0); if (m_bookmark || mApp->plugins()->speedDial()->pageForUrl(url).isValid()) { setBookmarkSaved(); diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index d8c0ddcff..9dd5b4c14 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -94,7 +94,7 @@ void BookmarksManager::bookmarksSelected(const QList &items) updateEditBox(0); } else { - m_selectedBookmark = items.first(); + m_selectedBookmark = items.at(0); updateEditBox(m_selectedBookmark); } } @@ -201,7 +201,7 @@ void BookmarksManager::bookmarkEdited() { Q_ASSERT(ui->tree->selectedBookmarks().count() == 1); - BookmarkItem* item = ui->tree->selectedBookmarks().first(); + BookmarkItem* item = ui->tree->selectedBookmarks().at(0); item->setTitle(ui->title->text()); item->setUrl(QUrl::fromEncoded(ui->address->text().toUtf8())); item->setKeyword(ui->keyword->text()); diff --git a/src/lib/bookmarks/bookmarkstreeview.cpp b/src/lib/bookmarks/bookmarkstreeview.cpp index ff9739a7f..07018a3ed 100644 --- a/src/lib/bookmarks/bookmarkstreeview.cpp +++ b/src/lib/bookmarks/bookmarkstreeview.cpp @@ -77,7 +77,7 @@ void BookmarksTreeView::setViewType(BookmarksTreeView::ViewType type) BookmarkItem* BookmarksTreeView::selectedBookmark() const { QList items = selectedBookmarks(); - return items.count() == 1 ? items.first() : 0; + return items.count() == 1 ? items.at(0) : 0; } QList BookmarksTreeView::selectedBookmarks() const @@ -262,7 +262,7 @@ void BookmarksTreeView::keyPressEvent(QKeyEvent* event) QTreeView::keyPressEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = selectionModel()->selectedRows().first(); + QModelIndex index = selectionModel()->selectedRows().at(0); BookmarkItem* item = m_model->item(m_filter->mapToSource(index)); switch (event->key()) { diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index f5f41c764..09006feef 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -103,7 +103,7 @@ bool CookieJar::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookie const QList cookies = QNetworkCookie::parseCookies(cookieLine); Q_ASSERT(cookies.size() == 1); - QNetworkCookie cookie = cookies.first(); + const QNetworkCookie cookie = cookies.at(0); return !rejectCookie(firstPartyUrl.host(), cookie, cookieSource.host()); } diff --git a/src/lib/history/historytreeview.cpp b/src/lib/history/historytreeview.cpp index b1c381f74..ffe8972d0 100644 --- a/src/lib/history/historytreeview.cpp +++ b/src/lib/history/historytreeview.cpp @@ -85,7 +85,7 @@ QUrl HistoryTreeView::selectedUrl() const return QUrl(); // TopLevelItems have invalid (empty) UrlRole data - return indexes.first().data(HistoryModel::UrlRole).toUrl(); + return indexes.at(0).data(HistoryModel::UrlRole).toUrl(); } HeaderView* HistoryTreeView::header() const @@ -220,7 +220,7 @@ void HistoryTreeView::keyPressEvent(QKeyEvent* event) QTreeView::keyPressEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = selectionModel()->selectedRows().first(); + QModelIndex index = selectionModel()->selectedRows().at(0); const QUrl url = index.data(HistoryModel::UrlRole).toUrl(); const bool isTopLevel = index.data(HistoryModel::IsTopLevelRole).toBool(); diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 7b6b0b0b8..5ebb3fdd9 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -190,7 +190,7 @@ LoadRequest LocationBar::createLoadRequest() const // Check for Bookmark keyword QList items = mApp->bookmarks()->searchKeyword(t); if (!items.isEmpty()) { - BookmarkItem* item = items.first(); + BookmarkItem* item = items.at(0); item->updateVisitCount(); req.setUrl(item->url()); } diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 85cc3e462..20aa9a6f4 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -135,8 +135,8 @@ void NetworkManager::authentication(const QUrl &url, QAuthenticator *auth, QWidg if (!data.isEmpty()) { save->setChecked(true); shouldUpdateEntry = true; - storedUser = data.first().username; - storedPassword = data.first().password; + storedUser = data.at(0).username; + storedPassword = data.at(0).password; user->setText(storedUser); pass->setText(storedPassword); } diff --git a/src/lib/network/pac/proxyautoconfig.cpp b/src/lib/network/pac/proxyautoconfig.cpp index 252b8f97a..b4410019e 100644 --- a/src/lib/network/pac/proxyautoconfig.cpp +++ b/src/lib/network/pac/proxyautoconfig.cpp @@ -194,7 +194,7 @@ QScriptValue ProxyAutoConfig::isInNet(QScriptContext* context, QScriptEngine* en if (host.isNull()) { QList addresses = hostResolve(context->argument(0).toString()); - host = addresses.isEmpty() ? QHostAddress() : addresses.first(); + host = addresses.isEmpty() ? QHostAddress() : addresses.at(0); } if ((pattern.toIPv4Address() & mask.toIPv4Address()) == (host.toIPv4Address() & mask.toIPv4Address())) { @@ -217,7 +217,7 @@ QScriptValue ProxyAutoConfig::dnsResolve(QScriptContext* context, QScriptEngine* return engine->nullValue(); } - return QScriptValue(engine, addresses.first().toString()); + return QScriptValue(engine, addresses.at(0).toString()); } // string myIpAddress diff --git a/src/lib/other/siteinfo.cpp b/src/lib/other/siteinfo.cpp index de590f844..e741eb49c 100644 --- a/src/lib/other/siteinfo.cpp +++ b/src/lib/other/siteinfo.cpp @@ -177,7 +177,7 @@ void SiteInfo::saveImage() if (!ui->mediaPreview->scene() || ui->mediaPreview->scene()->items().isEmpty()) return; - QGraphicsItem *graphicsItem = ui->mediaPreview->scene()->items().first(); + QGraphicsItem *graphicsItem = ui->mediaPreview->scene()->items().at(0); QGraphicsPixmapItem *pixmapItem = static_cast(graphicsItem); if (graphicsItem->type() != QGraphicsPixmapItem::Type || !pixmapItem) return; diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index b9e27ec43..70ce591cf 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -636,7 +636,7 @@ QStringList QzTools::getOpenFileNames(const QString &name, QWidget* parent, cons QStringList paths = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, selectedFilter, options); if (!paths.isEmpty()) { - settings.setValue(name, QFileInfo(paths.first()).absolutePath()); + settings.setValue(name, QFileInfo(paths.at(0)).absolutePath()); } settings.endGroup(); diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp index 40ad90499..7733158cc 100644 --- a/src/lib/webengine/webpage.cpp +++ b/src/lib/webengine/webpage.cpp @@ -383,7 +383,7 @@ QStringList WebPage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const Q QStringList files; QString suggestedFileName = s_lastUploadLocation; if (!oldFiles.isEmpty()) - suggestedFileName = oldFiles.first(); + suggestedFileName = oldFiles.at(0); switch (mode) { case FileSelectOpen: @@ -400,7 +400,7 @@ QStringList WebPage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const Q } if (!files.isEmpty()) - s_lastUploadLocation = files.first(); + s_lastUploadLocation = files.at(0); return files; }