Commit a4639631 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Minor code optimization

A lot of const and some string fixes
parent c64e3731
......@@ -50,14 +50,14 @@ void CreateKioService::gotCredentials(KJob *job)
}
GetCredentialsJob *gjob = qobject_cast<GetCredentialsJob*>(job);
QVariantMap data = gjob->credentialsData();
const QVariantMap data = gjob->credentialsData();
Accounts::Service service = m_manager->service(m_serviceName);
QString host = m_account->value(QStringLiteral("dav/host")).toString();
QString path = m_account->value(QStringLiteral("dav/storagePath")).toString();
const Accounts::Service service = m_manager->service(m_serviceName);
const QString host = m_account->value(QStringLiteral("dav/host")).toString();
const QString path = m_account->value(QStringLiteral("dav/storagePath")).toString();
m_account->selectService(service);
QString username = data[QStringLiteral("UserName")].toString();
const QString username = data[QStringLiteral("UserName")].toString();
CreateNetAttachJob *netJob = new CreateNetAttachJob(this);
connect(netJob, &CreateNetAttachJob::finished, this, &CreateKioService::netAttachCreated);
......
......@@ -103,16 +103,15 @@ void CreateNetAttachJob::createDesktopFile(const QUrl &url)
{
qDebug();
QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
path.append(QStringLiteral("/remoteview/"));
const QString folderPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/remoteview/");
QDir saveDir(path);
QDir saveDir(folderPath);
if (!saveDir.exists()) {
if (!saveDir.mkpath(path)) {
qWarning() << "Directory" << path << "for storage couldn't be created!";
if (!saveDir.mkpath(folderPath)) {
qWarning() << "Directory" << folderPath << "for storage couldn't be created!";
}
}
path += m_uniqueId + QStringLiteral(".desktop");
const QString path = folderPath + m_uniqueId + QStringLiteral(".desktop");
qDebug() << "Creating knetAttach place";
qDebug() << path;
......
......@@ -46,10 +46,9 @@ void KIOServices::onAccountCreated(const Accounts::AccountId accId, const Accoun
void KIOServices::onAccountRemoved(const Accounts::AccountId accId)
{
qDebug();
QString accountId = QString::number(accId) + QStringLiteral("_");
const QString accountId = QString::number(accId) + QStringLiteral("_");
QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
path.append(QStringLiteral("/remoteview/"));
const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/remoteview/");
QDirIterator i(path, QDir::NoDotAndDotDot | QDir::Files);
while (i.hasNext()) {
......@@ -113,7 +112,7 @@ void KIOServices::disableService(const Accounts::AccountId accId, const QString
bool KIOServices::isEnabled(const Accounts::AccountId accId, const QString &serviceName)
{
QString uniqueId(QString::number(accId) + QStringLiteral("_") + serviceName);
const QString uniqueId(QString::number(accId) + QStringLiteral("_") + serviceName);
QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
path += QStringLiteral("/remoteview/") + uniqueId + QStringLiteral(".desktop");
......
......@@ -64,7 +64,7 @@ void RemoveNetAttachJob::deleteDesktopFile()
KConfig _desktopFile(path, KConfig::SimpleConfig);
KConfigGroup desktopFile(&_desktopFile, "Desktop Entry");
QUrl url(desktopFile.readEntry("URL", QUrl()));
const QUrl url(desktopFile.readEntry("URL", QUrl()));
Q_ASSERT(!url.isEmpty());
qDebug() << url.userName() << url.host() << url;
......
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