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