Commit 39a2377f authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Port most literals to QStringLiteral

parent 63609a4b
......@@ -26,8 +26,8 @@
#include <KIO/Job>
QString AccountManager::s_apiKey = QLatin1String("554041944266.apps.googleusercontent.com");
QString AccountManager::s_apiSecret = QLatin1String("mdT1DjzohxN3npUUzkENT0gO");
QString AccountManager::s_apiKey = QStringLiteral("554041944266.apps.googleusercontent.com");
QString AccountManager::s_apiSecret = QStringLiteral("mdT1DjzohxN3npUUzkENT0gO");
AccountManager::AccountManager()
......@@ -91,15 +91,15 @@ KGAPI2::AccountPtr AccountManager::account(const QString &accountName)
QMap<QString, QString> entry;
m_wallet->readMap(accountName, entry);
const QStringList scopes = entry.value(QLatin1String("scopes")).split(QLatin1Char(','), QString::SkipEmptyParts);
const QStringList scopes = entry.value(QStringLiteral("scopes")).split(QLatin1Char(','), QString::SkipEmptyParts);
QList<QUrl> scopeUrls;
Q_FOREACH (const QString &scope, scopes) {
scopeUrls << QUrl::fromUserInput(scope);
}
account = KGAPI2::AccountPtr(new KGAPI2::Account(accountName,
entry.value(QLatin1String("accessToken")),
entry.value(QLatin1String("refreshToken")),
entry.value(QStringLiteral("accessToken")),
entry.value(QStringLiteral("refreshToken")),
scopeUrls));
}
......@@ -115,13 +115,13 @@ void AccountManager::storeAccount(const KGAPI2::AccountPtr &account)
qCDebug(LOG_KIO_GDRIVE) << "Storing account" << account->accessToken();
QMap<QString, QString> entry;
entry[ QLatin1String("accessToken") ] = account->accessToken();
entry[ QLatin1String("refreshToken") ] = account->refreshToken();
entry[ QStringLiteral("accessToken") ] = account->accessToken();
entry[ QStringLiteral("refreshToken") ] = account->refreshToken();
QStringList scopes;
Q_FOREACH (const QUrl &scope, account->scopes()) {
scopes << scope.toString();
}
entry[ QLatin1String("scopes") ] = scopes.join(QLatin1String(","));
entry[ QStringLiteral("scopes") ] = scopes.join(QLatin1Char(','));
m_wallet->writeMap(account->accountName(), entry);
}
......@@ -151,7 +151,7 @@ KIO::UDSEntry AccountManager::accountToUDSEntry(const QString &accountNAme)
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QLatin1String("im-google"));
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("im-google"));
return entry;
}
......
......@@ -25,42 +25,42 @@
using namespace KGAPI2::Drive;
#define VND_GOOGLE_APPS_DOCUMENT QLatin1String("application/vnd.google-apps.document")
#define VND_GOOGLE_APPS_DRAWING QLatin1String("application/vnd.google-apps.drawing")
#define VND_GOOGLE_APPS_FILE QLatin1String("application/vnd.google-apps.file")
#define VND_GOOGLE_APPS_FORM QLatin1String("application/vnd.google-apps.form")
#define VND_GOOGLE_APPS_PRESENTATION QLatin1String("application/vnd.google-apps.presentation")
#define VND_GOOGLE_APPS_SPREADSHEET QLatin1String("application/vnd.google-apps.spreadsheet")
#define VND_GOOGLE_APPS_FOLDER QLatin1String("application/vnd.google-apps.folder")
#define VND_OASIS_OPENDOCUMENT_TEXT QLatin1String("application/vnd.oasis.opendocument.text")
#define VND_OASIS_OPENDOCUMENT_PRESENTATION QLatin1String("application/vnd.oasis.opendocument.presentation")
#define VND_OASIS_OPENDOCUMENT_SPREADSHEED QLatin1String("application/x-vnd.oasis.opendocument.spreadsheet")
#define VND_GOOGLE_APPS_DOCUMENT QStringLiteral("application/vnd.google-apps.document")
#define VND_GOOGLE_APPS_DRAWING QStringLiteral("application/vnd.google-apps.drawing")
#define VND_GOOGLE_APPS_FILE QStringLiteral("application/vnd.google-apps.file")
#define VND_GOOGLE_APPS_FORM QStringLiteral("application/vnd.google-apps.form")
#define VND_GOOGLE_APPS_PRESENTATION QStringLiteral("application/vnd.google-apps.presentation")
#define VND_GOOGLE_APPS_SPREADSHEET QStringLiteral("application/vnd.google-apps.spreadsheet")
#define VND_GOOGLE_APPS_FOLDER QStringLiteral("application/vnd.google-apps.folder")
#define VND_OASIS_OPENDOCUMENT_TEXT QStringLiteral("application/vnd.oasis.opendocument.text")
#define VND_OASIS_OPENDOCUMENT_PRESENTATION QStringLiteral("application/vnd.oasis.opendocument.presentation")
#define VND_OASIS_OPENDOCUMENT_SPREADSHEED QStringLiteral("application/x-vnd.oasis.opendocument.spreadsheet")
#define VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT \
QLatin1String("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
QStringLiteral("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
#define VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION \
QLatin1String("application/vnd.openxmlformats-officedocument.presentationml.presentation")
QStringLiteral("application/vnd.openxmlformats-officedocument.presentationml.presentation")
#define VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET \
QLatin1String("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
QStringLiteral("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
#define IMAGE_PNG QLatin1String("image/png")
#define IMAGE_JPEG QLatin1String("image/jpeg")
#define APPLICATION_PDF QLatin1String("application/pdf")
#define IMAGE_PNG QStringLiteral("image/png")
#define IMAGE_JPEG QStringLiteral("image/jpeg")
#define APPLICATION_PDF QStringLiteral("application/pdf")
namespace GDriveHelper {
static const QMap<QString /* mimetype */, QString /* .ext */> ExtensionsMap = []() {
QMap<QString, QString> ext;
ext[VND_OASIS_OPENDOCUMENT_TEXT] = QLatin1String(".odt");
ext[VND_OASIS_OPENDOCUMENT_SPREADSHEED] = QLatin1String(".ods");
ext[VND_OASIS_OPENDOCUMENT_PRESENTATION] = QLatin1String(".odp");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT] = QLatin1String(".docx");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET] = QLatin1String(".xlsx");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION] = QLatin1String(".pptx");
ext[IMAGE_PNG] = QLatin1String(".png");
ext[IMAGE_JPEG] = QLatin1String(".jpg");
ext[APPLICATION_PDF] = QLatin1String(".pdf");
ext[VND_OASIS_OPENDOCUMENT_TEXT] = QStringLiteral(".odt");
ext[VND_OASIS_OPENDOCUMENT_SPREADSHEED] = QStringLiteral(".ods");
ext[VND_OASIS_OPENDOCUMENT_PRESENTATION] = QStringLiteral(".odp");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT] = QStringLiteral(".docx");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET] = QStringLiteral(".xlsx");
ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION] = QStringLiteral(".pptx");
ext[IMAGE_PNG] = QStringLiteral(".png");
ext[IMAGE_JPEG] = QStringLiteral(".jpg");
ext[APPLICATION_PDF] = QStringLiteral(".pdf");
return ext;
}();
......@@ -130,10 +130,10 @@ QUrl GDriveHelper::convertFromGDocs(KGAPI2::Drive::FilePtr &file)
KIO::UDSEntry GDriveHelper::trash()
{
KIO::UDSEntry trashEntry;
trashEntry.insert(KIO::UDSEntry::UDS_NAME, QLatin1String("trash"));
trashEntry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral("trash"));
trashEntry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Trash"));
trashEntry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
trashEntry.insert(KIO::UDSEntry::UDS_ICON_NAME, QLatin1String("user-trash"));
trashEntry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("user-trash"));
return trashEntry;
}
......
......@@ -98,7 +98,7 @@ extern "C"
int Q_DECL_EXPORT kdemain(int argc, char **argv)
{
QApplication app(argc, argv);
app.setApplicationName(QLatin1String("kio_gdrive"));
app.setApplicationName(QStringLiteral("kio_gdrive"));
if (argc != 4) {
fprintf(stderr, "Usage: kio_gdrive protocol domain-socket1 domain-socket2\n");
......@@ -266,10 +266,10 @@ void KIOGDrive::listAccounts()
listEntry(entry);
}
KIO::UDSEntry newAccountEntry;
newAccountEntry.insert(KIO::UDSEntry::UDS_NAME, QLatin1String("new-account"));
newAccountEntry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral("new-account"));
newAccountEntry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("New account"));
newAccountEntry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
newAccountEntry.insert(KIO::UDSEntry::UDS_ICON_NAME, QLatin1String("list-add-user"));
newAccountEntry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("list-add-user"));
listEntry(newAccountEntry);
finished();
return;
......@@ -432,7 +432,7 @@ void KIOGDrive::listDir(const QUrl &url)
const KIO::UDSEntry entry = fileToUDSEntry(file, url.adjusted(QUrl::StripTrailingSlash).path());
listEntry(entry);
QString path = url.path().endsWith("/") ? url.path() : url.path() + "/";
const QString path = url.path().endsWith(QLatin1Char('/')) ? url.path() : url.path() + QLatin1Char('/');
m_cache.insertPath(path + file->title(), file->id());
}
......@@ -628,7 +628,7 @@ bool KIOGDrive::readPutData(QTemporaryFile &tempFile)
bool KIOGDrive::putUpdate(const QUrl &url, const QString &accountId, const QStringList &pathComponents)
{
const QString fileId = QUrlQuery(url).queryItemValue(QLatin1String("id"));
const QString fileId = QUrlQuery(url).queryItemValue(QStringLiteral("id"));
qCDebug(LOG_KIO_GDRIVE) << url << fileId;
FileFetchJob fetchJob(fileId, getAccount(accountId));
......@@ -703,7 +703,7 @@ void KIOGDrive::put(const QUrl &url, int permissions, KIO::JobFlags flags)
const QString accountId = accountFromPath(url);
const QStringList components = pathComponents(url);
if (url.hasQueryItem(QLatin1String("id"))) {
if (url.hasQueryItem(QStringLiteral("id"))) {
if (!putUpdate(url, accountId, components)) {
return;
}
......@@ -754,7 +754,7 @@ void KIOGDrive::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::Jo
const QString sourceFileId
= src.hasQueryItem(QLatin1String("id"))
? QUrlQuery(src).queryItemValue(QLatin1String("id"))
? QUrlQuery(src).queryItemValue(QStringLiteral("id"))
: resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path());
if (sourceFileId.isEmpty()) {
error(KIO::ERR_DOES_NOT_EXIST, src.path());
......
Supports Markdown
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