Verified Commit bf80bd6b authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

clazy fixes

parent ee5ec9c5
...@@ -71,14 +71,14 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -71,14 +71,14 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
return 1; return 1;
} }
const QString fileName = parser.positionalArguments().first(); const QString fileName = parser.positionalArguments().constFirst();
KDesktopFile desktopFile(fileName); KDesktopFile desktopFile(fileName);
if (desktopFile.readUrl().isEmpty()) { if (desktopFile.readUrl().isEmpty()) {
return 2; return 2;
} }
const QString initialUrl = QUrl::fromUserInput(desktopFile.readUrl()).toString(); const QString initialUrl = QUrl::fromUserInput(desktopFile.readUrl()).toString();
const QString appName = desktopFile.readName().toLower().replace(QLatin1Char(' '), QLatin1Char('-')) + QLatin1String("-angelfish-webapp"); const QString appName = desktopFile.readName().toLower().replace(QLatin1Char(' '), QLatin1Char('-')) + QStringLiteral("-angelfish-webapp");
KAboutData aboutData(appName.toLower(), desktopFile.readName(), KAboutData aboutData(appName.toLower(), desktopFile.readName(),
QStringLiteral("0.1"), QStringLiteral("0.1"),
i18n("Angelfish Web App runtime"), i18n("Angelfish Web App runtime"),
......
...@@ -36,9 +36,7 @@ BrowserManager::BrowserManager(QObject *parent) ...@@ -36,9 +36,7 @@ BrowserManager::BrowserManager(QObject *parent)
connect(m_dbmanager, &DBManager::databaseTableChanged, this, &BrowserManager::databaseTableChanged); connect(m_dbmanager, &DBManager::databaseTableChanged, this, &BrowserManager::databaseTableChanged);
} }
BrowserManager::~BrowserManager() BrowserManager::~BrowserManager() = default;
{
}
void BrowserManager::addBookmark(const QVariantMap &bookmarkdata) void BrowserManager::addBookmark(const QVariantMap &bookmarkdata)
{ {
......
...@@ -48,7 +48,7 @@ DBManager::DBManager(QObject *parent) ...@@ -48,7 +48,7 @@ DBManager::DBManager(QObject *parent)
throw std::runtime_error("Database directory does not exist and cannot be created: " + dbpath.toStdString()); throw std::runtime_error("Database directory does not exist and cannot be created: " + dbpath.toStdString());
} }
QSqlDatabase database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE")); QSqlDatabase database = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
database.setDatabaseName(dbname); database.setDatabaseName(dbname);
if (!database.open()) { if (!database.open()) {
qCritical() << "Failed to open database" << dbname; qCritical() << "Failed to open database" << dbname;
...@@ -66,7 +66,7 @@ DBManager::DBManager(QObject *parent) ...@@ -66,7 +66,7 @@ DBManager::DBManager(QObject *parent)
int DBManager::version() int DBManager::version()
{ {
QSqlQuery query(QLatin1String("PRAGMA user_version")); QSqlQuery query(QStringLiteral("PRAGMA user_version"));
if (query.next()) { if (query.next()) {
bool ok; bool ok;
int value = query.value(0).toInt(&ok); int value = query.value(0).toInt(&ok);
......
...@@ -59,7 +59,7 @@ void DesktopFileGenerator::createDesktopFile(const QString &name, const QString ...@@ -59,7 +59,7 @@ void DesktopFileGenerator::createDesktopFile(const QString &name, const QString
void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName) void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName)
{ {
auto *provider = static_cast<QQuickImageProvider *>(m_engine->imageProvider(QStringLiteral("favicon"))); auto *provider = dynamic_cast<QQuickImageProvider *>(m_engine->imageProvider(QStringLiteral("favicon")));
QLatin1String prefix_favicon = QLatin1String("image://favicon/"); QLatin1String prefix_favicon = QLatin1String("image://favicon/");
QString providerIconName = url.mid(prefix_favicon.size()); QString providerIconName = url.mid(prefix_favicon.size());
...@@ -102,7 +102,7 @@ void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName ...@@ -102,7 +102,7 @@ void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName
QString DesktopFileGenerator::webappCommand() QString DesktopFileGenerator::webappCommand()
{ {
if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty()) { if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QStringLiteral("flatpak-info")).isEmpty()) {
return QStringLiteral("flatpak run " return QStringLiteral("flatpak run "
"--command=angelfish-webapp " "--command=angelfish-webapp "
"--filesystem=%1 " "--filesystem=%1 "
......
...@@ -58,7 +58,7 @@ QString IconImageProvider::storeImage(const QString &iconSource) ...@@ -58,7 +58,7 @@ QString IconImageProvider::storeImage(const QString &iconSource)
} }
// new uri for image // new uri for image
QString url = QStringLiteral("image://%1/%2").arg(providerId()).arg(iconSource.mid(prefix_favicon.size())); QString url = QStringLiteral("image://%1/%2").arg(providerId(), iconSource.mid(prefix_favicon.size()));
// check if we have that image already // check if we have that image already
QSqlQuery query_check; QSqlQuery query_check;
...@@ -79,7 +79,7 @@ QString IconImageProvider::storeImage(const QString &iconSource) ...@@ -79,7 +79,7 @@ QString IconImageProvider::storeImage(const QString &iconSource)
query_check.finish(); query_check.finish();
// Store new icon // Store new icon
QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(s_engine->imageProvider(QStringLiteral("favicon"))); QQuickImageProvider *provider = dynamic_cast<QQuickImageProvider *>(s_engine->imageProvider(QStringLiteral("favicon")));
if (provider == nullptr) { if (provider == nullptr) {
qWarning() << Q_FUNC_INFO << "Failed to load image provider" << url; qWarning() << Q_FUNC_INFO << "Failed to load image provider" << url;
return iconSource; // as something is wrong return iconSource; // as something is wrong
...@@ -132,7 +132,7 @@ QImage IconImageProvider::requestImage(const QString &id, QSize *size, const QSi ...@@ -132,7 +132,7 @@ QImage IconImageProvider::requestImage(const QString &id, QSize *size, const QSi
{ {
QSqlQuery query; QSqlQuery query;
query.prepare(QStringLiteral("SELECT icon FROM icons WHERE url LIKE :url LIMIT 1")); query.prepare(QStringLiteral("SELECT icon FROM icons WHERE url LIKE :url LIMIT 1"));
query.bindValue(QStringLiteral(":url"), QStringLiteral("image://%1/%2%").arg(providerId()).arg(id)); query.bindValue(QStringLiteral(":url"), QStringLiteral("image://%1/%2%").arg(providerId(), id));
if (!query.exec()) { if (!query.exec()) {
qWarning() << Q_FUNC_INFO << "Failed to execute SQL statement"; qWarning() << Q_FUNC_INFO << "Failed to execute SQL statement";
qWarning() << query.lastQuery(); qWarning() << query.lastQuery();
......
...@@ -69,7 +69,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -69,7 +69,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// initial url command line parameter // initial url command line parameter
QString initialUrl; QString initialUrl;
if (!parser.positionalArguments().isEmpty()) if (!parser.positionalArguments().isEmpty())
initialUrl = QUrl::fromUserInput(parser.positionalArguments().first()).toString(); initialUrl = QUrl::fromUserInput(parser.positionalArguments().constFirst()).toString();
// Exported types // Exported types
qmlRegisterType<BookmarksHistoryModel>("org.kde.mobile.angelfish", 1, 0, "BookmarksHistoryModel"); qmlRegisterType<BookmarksHistoryModel>("org.kde.mobile.angelfish", 1, 0, "BookmarksHistoryModel");
......
...@@ -127,7 +127,7 @@ void TabsModel::setCurrentTab(int index) ...@@ -127,7 +127,7 @@ void TabsModel::setCurrentTab(int index)
return; return;
m_currentTab = index; m_currentTab = index;
currentTabChanged(); emit currentTabChanged();
saveTabs(); saveTabs();
} }
...@@ -157,7 +157,8 @@ bool TabsModel::loadTabs() ...@@ -157,7 +157,8 @@ bool TabsModel::loadTabs()
const auto tabsStorage = QJsonDocument::fromJson(inputFile.readAll()).object(); const auto tabsStorage = QJsonDocument::fromJson(inputFile.readAll()).object();
m_tabs.clear(); m_tabs.clear();
for (const auto tab : tabsStorage.value(QLatin1String("tabs")).toArray()) { const auto tabs = tabsStorage.value(QLatin1String("tabs")).toArray();
for (const auto tab : tabs) {
m_tabs.append(TabState::fromJson(tab.toObject())); m_tabs.append(TabState::fromJson(tab.toObject()));
} }
...@@ -170,7 +171,7 @@ bool TabsModel::loadTabs() ...@@ -170,7 +171,7 @@ bool TabsModel::loadTabs()
createEmptyTab(); createEmptyTab();
} }
endResetModel(); emit endResetModel();
currentTabChanged(); currentTabChanged();
return true; return true;
...@@ -225,7 +226,7 @@ bool TabsModel::isMobileDefault() const ...@@ -225,7 +226,7 @@ bool TabsModel::isMobileDefault() const
void TabsModel::setIsMobileDefault(bool def) void TabsModel::setIsMobileDefault(bool def)
{ {
m_isMobileDefault = def; m_isMobileDefault = def;
isMobileDefaultChanged(); emit isMobileDefaultChanged();
// used in initialization of the tab // used in initialization of the tab
if (m_tabs.count() == 1) { if (m_tabs.count() == 1) {
...@@ -241,7 +242,7 @@ bool TabsModel::privateMode() const ...@@ -241,7 +242,7 @@ bool TabsModel::privateMode() const
void TabsModel::setPrivateMode(bool privateMode) void TabsModel::setPrivateMode(bool privateMode)
{ {
m_privateMode = privateMode; m_privateMode = privateMode;
privateModeChanged(); emit privateModeChanged();
} }
/** /**
...@@ -267,7 +268,7 @@ void TabsModel::newTab(const QString &url) ...@@ -267,7 +268,7 @@ void TabsModel::newTab(const QString &url)
// Switch to last tab // Switch to last tab
m_currentTab = m_tabs.count() - 1; m_currentTab = m_tabs.count() - 1;
currentTabChanged(); emit currentTabChanged();
saveTabs(); saveTabs();
} }
...@@ -309,7 +310,7 @@ void TabsModel::closeTab(int index) ...@@ -309,7 +310,7 @@ void TabsModel::closeTab(int index)
m_tabs.removeAt(index); m_tabs.removeAt(index);
endRemoveRows(); endRemoveRows();
currentTabChanged(); emit currentTabChanged();
saveTabs(); saveTabs();
} }
...@@ -322,7 +323,7 @@ void TabsModel::setIsMobile(int index, bool isMobile) ...@@ -322,7 +323,7 @@ void TabsModel::setIsMobile(int index, bool isMobile)
m_tabs[index].setIsMobile(isMobile); m_tabs[index].setIsMobile(isMobile);
QModelIndex mindex = createIndex(index, index); QModelIndex mindex = createIndex(index, index);
dataChanged(mindex, mindex, {RoleNames::IsMobileRole}); emit dataChanged(mindex, mindex, {RoleNames::IsMobileRole});
saveTabs(); saveTabs();
} }
...@@ -335,7 +336,7 @@ void TabsModel::setUrl(int index, const QString &url) ...@@ -335,7 +336,7 @@ void TabsModel::setUrl(int index, const QString &url)
m_tabs[index].setUrl(url); m_tabs[index].setUrl(url);
QModelIndex mindex = createIndex(index, index); QModelIndex mindex = createIndex(index, index);
dataChanged(mindex, mindex, {RoleNames::UrlRole}); emit dataChanged(mindex, mindex, {RoleNames::UrlRole});
saveTabs(); saveTabs();
} }
......
...@@ -34,9 +34,7 @@ UrlUtils::UrlUtils(QObject *parent) ...@@ -34,9 +34,7 @@ UrlUtils::UrlUtils(QObject *parent)
{ {
} }
UrlUtils::~UrlUtils() UrlUtils::~UrlUtils() = default;
{
}
QString UrlUtils::urlFromUserInput(const QString &input) QString UrlUtils::urlFromUserInput(const QString &input)
{ {
......
...@@ -13,9 +13,9 @@ QString UserAgent::userAgent() const ...@@ -13,9 +13,9 @@ QString UserAgent::userAgent() const
return QStringLiteral( return QStringLiteral(
"Mozilla/5.0 (%1) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/%2 " "Mozilla/5.0 (%1) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/%2 "
"Chrome/75.0.3770.116 %3 Safari/537.36") "Chrome/75.0.3770.116 %3 Safari/537.36")
.arg(m_isMobile ? QStringLiteral("Linux; Plasma Mobile, like Android 9.0") : QStringLiteral("X11; Linux x86_64")) .arg(m_isMobile ? QStringLiteral("Linux; Plasma Mobile, like Android 9.0") : QStringLiteral("X11; Linux x86_64"),
.arg(QStringLiteral(QTWEBENGINE_VERSION_STR)) QStringLiteral(QTWEBENGINE_VERSION_STR),
.arg(m_isMobile ? QStringLiteral("Mobile") : QStringLiteral("Desktop")); m_isMobile ? QStringLiteral("Mobile") : QStringLiteral("Desktop"));
} }
bool UserAgent::isMobile() const bool UserAgent::isMobile() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment