Commit 3bc8f162 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Enable QT_NO_CAST_FROM_ASCII globally and adapt all string code

applets/comic yet to be done
parent 90b5dd23
......@@ -66,7 +66,7 @@ add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050900
-DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_TO_ASCII
# -DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
......
......@@ -45,7 +45,7 @@ static QObject *utils_singletontype_provider(QQmlEngine *, QJSEngine *)
void ColorPickerPlugin::registerTypes(const char* uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.colorpicker"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.colorpicker"));
qmlRegisterType<GrabWidget>(uri, 2, 0, "GrabWidget");
qmlRegisterSingletonType<Utils>(uri, 2, 0, "Utils", utils_singletontype_provider);
}
......
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.comic\")
remove_definitions(
-DQT_NO_CAST_FROM_ASCII
)
set(comic_SRCS
comic.cpp
comicmodel.cpp
......
......@@ -60,7 +60,7 @@ DictObject::DictObject(QObject *parent)
void DictObject::lookup(const QString &word)
{
const QString newSource = m_selectedDict + ':' + word;
const QString newSource = m_selectedDict + QLatin1Char(':') + word;
if (!m_source.isEmpty()) {
m_dataEngine->disconnectSource(m_source, this);
......
......@@ -24,7 +24,7 @@
void DictPlugin::registerTypes (const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.dict"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.dict"));
qmlRegisterType<DictObject>(uri, 1, 0, "DictObject");
qmlRegisterType<DictionariesModel>(uri, 1, 0, "DictionariesModel");
}
......@@ -23,7 +23,7 @@
void DiskQuotaPlugin::registerTypes (const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.diskquota"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.diskquota"));
qmlRegisterType<DiskQuota>(uri, 1, 0, "DiskQuota");
qmlRegisterType<QuotaListModel>(uri, 1, 0, "QuotaListModel");
}
......@@ -34,7 +34,7 @@ QPixmap FifteenImageProvider::requestPixmap(const QString &id, QSize *size, cons
{
// id format is boardSize-imagenumber-pieceWidth-pieceHeight-imagePath
qDebug() << "pixmap requested with id " << id;
QStringList idParts = id.split('-');
QStringList idParts = id.split(QLatin1Char('-'));
if (idParts.size() < 4)
return QPixmap();
......@@ -49,7 +49,7 @@ QPixmap FifteenImageProvider::requestPixmap(const QString &id, QSize *size, cons
update = true;
}
if (idParts.at(1) == "all") {
if (idParts.at(1) == QLatin1String("all")) {
return m_pixmap;
} else {
if (pieceWidth != m_pieceWidth || pieceHeight != m_pieceHeight) {
......
......@@ -26,12 +26,12 @@
void FifteenPuzzlePlugin::registerTypes(const char* uri)
{
Q_UNUSED(uri);
Q_ASSERT(uri == QStringLiteral("org.kde.plasma.private.fifteenpuzzle"));
qmlRegisterTypeNotAvailable(uri, 0, 1, "fifteenpuzzle", "fifteenpuzzle");
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.fifteenpuzzle"));
qmlRegisterTypeNotAvailable(uri, 0, 1, "fifteenpuzzle", QStringLiteral("fifteenpuzzle"));
}
void FifteenPuzzlePlugin::initializeEngine(QQmlEngine * engine, const char * uri)
{
qDebug() << "initializeEngine called, uri is " << uri;
engine->addImageProvider("fifteenpuzzle", new FifteenImageProvider());
engine->addImageProvider(QStringLiteral("fifteenpuzzle"), new FifteenImageProvider());
}
......@@ -81,7 +81,7 @@ void GroupedAppletsContainer::ensureSystrayExists()
}
if (!m_innerContainment) {
m_innerContainment = c->createContainment("org.kde.plasma.private.grouping", QVariantList() << "org.kde.plasma:force-create");
m_innerContainment = c->createContainment(QStringLiteral("org.kde.plasma.private.grouping"), QVariantList() << QStringLiteral("org.kde.plasma:force-create"));
config().writeEntry("ContainmentId", m_innerContainment->id());
}
......@@ -97,7 +97,7 @@ void GroupedAppletsContainer::ensureSystrayExists()
m_internalContainmentItem = m_innerContainment->property("_plasma_graphicObject").value<QQuickItem *>();
emit internalContainmentItemChanged();
actions()->addAction("configure", m_innerContainment->actions()->action("configure"));
actions()->addAction(QStringLiteral("configure"), m_innerContainment->actions()->action(QStringLiteral("configure")));
connect(m_innerContainment.data(), &Plasma::Containment::configureRequested, this,
[this](Plasma::Applet *applet) {
emit containment()->configureRequested(applet);
......@@ -110,7 +110,7 @@ void GroupedAppletsContainer::ensureSystrayExists()
}
//replace internal remove action with ours
m_innerContainment->actions()->addAction("remove", actions()->action("remove"));
m_innerContainment->actions()->addAction(QStringLiteral("remove"), actions()->action(QStringLiteral("remove")));
}
void GroupedAppletsContainer::constraintsEvent(Plasma::Types::Constraints constraints)
......
......@@ -61,7 +61,7 @@ void GroupingContainment::init()
void GroupingContainment::newTask(const QString &task)
{
createApplet(task, QVariantList() << "org.kde.plasma:force-create");
createApplet(task, QVariantList() << QStringLiteral("org.kde.plasma:force-create"));
}
void GroupingContainment::cleanupTask(const QString &task)
......
......@@ -45,7 +45,6 @@ MediaFrame::MediaFrame(QObject *parent) : QObject(parent)
}
qDebug() << "Added" << m_filters.count() << "filters";
//qDebug() << m_filters;
m_watchFile = "";
m_next = 0;
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &MediaFrame::slotItemChanged);
......@@ -91,7 +90,7 @@ QString MediaFrame::getCacheDirectory()
QString MediaFrame::hash(const QString &str)
{
return QString( QCryptographicHash::hash( str.toUtf8(), QCryptographicHash::Md5).toHex() );
return QString::fromLatin1(QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5).toHex());
}
bool MediaFrame::isDir(const QString &path)
......@@ -203,7 +202,7 @@ void MediaFrame::watch(const QString &path)
QString localPath = url.toString(QUrl::PreferLocalFile);
if(isFile(localPath))
{
if(m_watchFile != "")
if(!m_watchFile.isEmpty())
{
//qDebug() << "Removing" << m_watchFile << "from watch list";
m_watcher.removePath(m_watchFile);
......@@ -238,7 +237,7 @@ void MediaFrame::get(QJSValue successCallback, QJSValue errorCallback)
int size = m_allFiles.count() - 1;
QString path;
QString errorMessage = QString("");
QString errorMessage;
QJSValueList args;
if(size < 1) {
......@@ -252,7 +251,7 @@ void MediaFrame::get(QJSValue successCallback, QJSValue errorCallback)
}
return;
} else {
errorMessage = "No files available";
errorMessage = QStringLiteral("No files available");
qWarning() << errorMessage;
args << QJSValue(errorMessage);
......@@ -280,7 +279,7 @@ void MediaFrame::get(QJSValue successCallback, QJSValue errorCallback)
QString localPath = url.toString(QUrl::PreferLocalFile);
if (!isFile(localPath)) {
m_filename = path.section('/', -1);
m_filename = path.section(QLatin1Char('/'), -1);
QString cachedFile = getCacheDirectory()+QLatin1Char('/')+hash(path)+QLatin1Char('_')+m_filename;
......@@ -312,7 +311,7 @@ void MediaFrame::get(QJSValue successCallback, QJSValue errorCallback)
return;
}
} else {
errorMessage = path+" is not a valid URL";
errorMessage = path + QLatin1String(" is not a valid URL");
qCritical() << errorMessage;
if(errorCallback.isCallable()) {
......@@ -336,7 +335,7 @@ void MediaFrame::pushHistory(const QString &string)
QString MediaFrame::popHistory()
{
if(m_history.isEmpty())
return "";
return QString();
return m_history.takeFirst();
}
......@@ -353,7 +352,7 @@ void MediaFrame::pushFuture(const QString &string)
QString MediaFrame::popFuture()
{
if(m_future.isEmpty())
return "";
return QString();
return m_future.takeFirst();
}
......@@ -369,11 +368,11 @@ void MediaFrame::slotItemChanged(const QString &path)
void MediaFrame::slotFinished(KJob *job)
{
QString errorMessage = QString("");
QString errorMessage;
QJSValueList args;
if (job->error()) {
errorMessage = "Error loading image: " + job->errorString();
errorMessage = QLatin1String("Error loading image: ") + job->errorString();
qCritical() << errorMessage;
if(m_errorCallback.isCallable()) {
......@@ -398,7 +397,7 @@ void MediaFrame::slotFinished(KJob *job)
}
}
else {
errorMessage = "Unknown error occured";
errorMessage = QStringLiteral("Unknown error occured");
qCritical() << errorMessage;
......
......@@ -23,7 +23,7 @@
void MediaFramePlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.mediaframe"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mediaframe"));
qmlRegisterType<MediaFrame>(uri, 2, 0, "MediaFrame");
}
......@@ -23,6 +23,6 @@
void MinimizeAllPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.minimizeall"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.minimizeall"));
qmlRegisterType<MinimizeAll>(uri, 1, 0, "MinimizeAll");
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ private:
FileSystemNoteLoader::FileSystemNoteLoader()
{
const QString genericDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
const QString suffix = "plasma_notes";
const QString suffix = QStringLiteral("plasma_notes");
QDir(genericDataLocation).mkdir(suffix);
m_notesDir = genericDataLocation + QDir::separator() + suffix;
}
......@@ -51,7 +51,7 @@ FileSystemNoteLoader::FileSystemNoteLoader()
QStringList FileSystemNoteLoader::allNoteIds()
{
return m_notesDir.entryList(QStringList {"*.txt"});
return m_notesDir.entryList(QStringList {QStringLiteral("*.txt")});
}
void FileSystemNoteLoader::deleteNoteResources(const QString &id)
......@@ -87,7 +87,7 @@ void FileNote::load()
{
QFile file(m_path);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
setNoteText(file.readAll());
setNoteText(QString::fromUtf8(file.readAll()));
}
}
......
......@@ -60,10 +60,10 @@ static QObject *notesHelper_provider(QQmlEngine *, QJSEngine *)
void NotesPlugin::registerTypes (const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.notes"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.notes"));
qmlRegisterType<DocumentHandler>(uri, 0, 1, "DocumentHandler");
qmlRegisterType<NoteManager>(uri, 0, 1, "NoteManager");
qmlRegisterUncreatableType<Note>(uri, 0, 1, "Note", "Create through NoteManager");
qmlRegisterUncreatableType<Note>(uri, 0, 1, "Note", QStringLiteral("Create through NoteManager"));
qmlRegisterSingletonType<NotesHelper>(uri, 0, 1, "NotesHelper", notesHelper_provider);
}
......
......@@ -165,7 +165,7 @@ static QString determineNewDesktopFilePath(const QString &baseName)
// Limit to [0-9] and [a-z] range.
char newChar = qrand() % 36;
newChar += newChar < 10 ? 48 : 97-10;
appendix += newChar;
appendix += QLatin1Char(newChar);
desktopFilePath = locateLocal(baseName + appendix + QLatin1String(".desktop"));
}
......
......@@ -25,7 +25,7 @@
void QuicklaunchPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.quicklaunch"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.quicklaunch"));
qmlRegisterType<QuicklaunchPrivate>(uri, 1, 0, "Logic");
}
......@@ -33,7 +33,7 @@ ContentTracker::ContentTracker(QObject *parent)
: QObject(parent)
{
connectToActivityManager();
QDBusServiceWatcher *watcher = new QDBusServiceWatcher("org.kde.ActivityManager", QDBusConnection::sessionBus(),
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(QStringLiteral("org.kde.ActivityManager"), QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForOwnerChange, this);
connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
this, SLOT(serviceChange(QString,QString,QString)));
......@@ -77,7 +77,7 @@ void ContentTracker::focusChanged(const QString &uri, const QString &mimetype, c
void ContentTracker::connectToActivityManager()
{
delete m_activityManagerIface.data();
m_activityManagerIface = new OrgKdeActivityManagerSLCInterface("org.kde.ActivityManager", "/SLC",
m_activityManagerIface = new OrgKdeActivityManagerSLCInterface(QStringLiteral("org.kde.ActivityManager"), QStringLiteral("/SLC"),
QDBusConnection::sessionBus());
if (m_activityManagerIface->isValid()) {
......
......@@ -23,6 +23,6 @@
void ShowDesktopPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.showdesktop"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.showdesktop"));
qmlRegisterType<ShowDesktop>(uri, 0, 1, "ShowDesktop");
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ static QObject *timer_singletontype_provider(QQmlEngine *engine, QJSEngine *scri
void TimerPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.timer"));
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.timer"));
qmlRegisterSingletonType<Timer>(uri, 0, 1, "Timer", timer_singletontype_provider);
}
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