1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

Fix use of QList::first()

This commit is contained in:
David Rosca 2015-10-23 11:55:14 +02:00
parent 8d312ad132
commit 97ce417798
15 changed files with 39 additions and 39 deletions

View File

@ -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));
}

View File

@ -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()) {

View File

@ -223,7 +223,7 @@ QVector<PasswordEntry> 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));
}

View File

@ -76,5 +76,5 @@ void BookmarksExportDialog::init()
ui->format->addItem(exporter->name());
}
m_currentExporter = m_exporters.first();
m_currentExporter = m_exporters.at(0);
}

View File

@ -57,7 +57,7 @@ void BookmarksIcon::checkBookmark(const QUrl &url, bool forceCheck)
}
QList<BookmarkItem*> 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();

View File

@ -94,7 +94,7 @@ void BookmarksManager::bookmarksSelected(const QList<BookmarkItem*> &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());

View File

@ -77,7 +77,7 @@ void BookmarksTreeView::setViewType(BookmarksTreeView::ViewType type)
BookmarkItem* BookmarksTreeView::selectedBookmark() const
{
QList<BookmarkItem*> items = selectedBookmarks();
return items.count() == 1 ? items.first() : 0;
return items.count() == 1 ? items.at(0) : 0;
}
QList<BookmarkItem*> 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()) {

View File

@ -103,7 +103,7 @@ bool CookieJar::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookie
const QList<QNetworkCookie> 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());
}

View File

@ -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();

View File

@ -190,7 +190,7 @@ LoadRequest LocationBar::createLoadRequest() const
// Check for Bookmark keyword
QList<BookmarkItem*> items = mApp->bookmarks()->searchKeyword(t);
if (!items.isEmpty()) {
BookmarkItem* item = items.first();
BookmarkItem* item = items.at(0);
item->updateVisitCount();
req.setUrl(item->url());
}

View File

@ -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);
}

View File

@ -194,7 +194,7 @@ QScriptValue ProxyAutoConfig::isInNet(QScriptContext* context, QScriptEngine* en
if (host.isNull()) {
QList<QHostAddress> 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

View File

@ -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<QGraphicsPixmapItem*>(graphicsItem);
if (graphicsItem->type() != QGraphicsPixmapItem::Type || !pixmapItem)
return;

View File

@ -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();

View File

@ -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;
}