Commit 76f9fb05 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Don't use replace(..., QString("")) use directly remove(...)

+ Const'ify + use nullptr
parent c2be8d25
......@@ -669,7 +669,7 @@ KSMServer::KSMServer( const QString& windowManager, InitFlags flags )
qCDebug(KSMSERVER) << fName;
QString display = QString::fromLocal8Bit(::getenv("DISPLAY"));
// strip the screen number from the display
display.replace(QRegExp(QStringLiteral("\\.[0-9]+$")), QStringLiteral(""));
display.remove(QRegExp(QStringLiteral("\\.[0-9]+$")));
int i;
while( (i = display.indexOf(QLatin1Char(':'))) >= 0)
display[i] = '_';
......@@ -741,7 +741,7 @@ void KSMServer::cleanUp()
QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + QLatin1Char('/') + QStringLiteral("KSMserver"));
QString display = QString::fromLocal8Bit(::getenv("DISPLAY"));
// strip the screen number from the display
display.replace(QRegExp(QStringLiteral("\\.[0-9]+$")), QStringLiteral(""));
display.remove(QRegExp(QStringLiteral("\\.[0-9]+$")));
int i;
while( (i = display.indexOf(QLatin1Char(':'))) >= 0)
display[i] = '_';
......
......@@ -43,9 +43,7 @@ const char ZONEINFO_DIR[] = "ZoneinfoDir"; // path to zoneinfo/ directory
const char ZONE_TAB[] = "Zonetab"; // path & name of zone.tab
KTimeZoned::KTimeZoned(QObject* parent, const QList<QVariant>& l)
: KTimeZonedBase(parent, l),
m_dirWatch(0),
m_zoneTabWatch(0)
: KTimeZonedBase(parent, l)
{
init(false);
}
......@@ -53,18 +51,18 @@ KTimeZoned::KTimeZoned(QObject* parent, const QList<QVariant>& l)
KTimeZoned::~KTimeZoned()
{
delete m_dirWatch;
m_dirWatch = 0;
m_dirWatch = nullptr;
delete m_zoneTabWatch;
m_zoneTabWatch = 0;
m_zoneTabWatch = nullptr;
}
void KTimeZoned::init(bool restart)
{
if (restart) {
delete m_dirWatch;
m_dirWatch = 0;
m_dirWatch = nullptr;
delete m_zoneTabWatch;
m_zoneTabWatch = 0;
m_zoneTabWatch = nullptr;
m_localZone = QString();
m_zoneinfoDir = QString();
m_zoneTab = QString();
......
......@@ -33,7 +33,7 @@ class KTimeZoned : public KTimeZonedBase
Q_OBJECT
public:
KTimeZoned(QObject *parent, const QList<QVariant>&);
explicit KTimeZoned(QObject *parent, const QList<QVariant>&);
~KTimeZoned() override;
private Q_SLOTS:
......@@ -44,8 +44,8 @@ private:
void init(bool restart) override;
bool findZoneTab(const QString &pathFromConfig);
KDirWatch *m_dirWatch; // watcher for timezone config changes
KDirWatch *m_zoneTabWatch; // watcher for zone.tab changes
KDirWatch *m_dirWatch = nullptr; // watcher for timezone config changes
KDirWatch *m_zoneTabWatch = nullptr; // watcher for zone.tab changes
QString m_zoneinfoDir; // path to zoneinfo directory
QString m_zoneTab; // path to zone.tab file
};
......
......@@ -59,7 +59,7 @@ void StatusNotifierWatcher::RegisterStatusNotifierItem(const QString &serviceOrP
{
QString service;
QString path;
if (serviceOrPath.startsWith('/')) {
if (serviceOrPath.startsWith(QLatin1Char('/'))) {
service = message().service();
path = serviceOrPath;
} else {
......@@ -93,7 +93,7 @@ void StatusNotifierWatcher::serviceUnregistered(const QString& name)
qDebug()<<"Service "<< name << "unregistered";
m_serviceWatcher->removeWatchedService(name);
QString match = name + '/';
QString match = name + QLatin1Char('/');
QStringList::Iterator it = m_registeredServices.begin();
while (it != m_registeredServices.end()) {
if (it->startsWith(match)) {
......
......@@ -62,7 +62,7 @@ Q_SIGNALS:
void StatusNotifierHostUnregistered();
private:
QDBusServiceWatcher *m_serviceWatcher;
QDBusServiceWatcher *m_serviceWatcher = nullptr;
QStringList m_registeredServices;
QSet<QString> m_statusNotifierHostServices;
};
......
......@@ -71,7 +71,7 @@ void KDEDKSysGuard::showTaskManager()
con.asyncCall(msg);
}
else {
QString exe = QStandardPaths::findExecutable(QStringLiteral("systemmonitor"));
const QString exe = QStandardPaths::findExecutable(QStringLiteral("systemmonitor"));
QProcess::startDetached(exe, QStringList());
}
}
......
......@@ -536,7 +536,7 @@ bool BackgroundFinder::isAcceptableSuffix(const QString &suffix)
// Despite its name, suffixes() returns a list of glob patterns.
// Therefore the file suffix check needs to include the "*." prefix.
const QStringList &globPatterns = suffixes();
return globPatterns.contains("*."+suffix.toLower());
return globPatterns.contains(QStringLiteral("*.") + suffix.toLower());
}
void BackgroundFinder::run()
......
......@@ -219,7 +219,7 @@ void Image::findPreferedImageInPackage(KPackage::Package &package)
QString preferred = findPreferedImage( package.entryList("images") );
package.removeDefinition("preferred");
package.addFileDefinition("preferred", "images/" + preferred, i18n("Recommended wallpaper file"));
package.addFileDefinition("preferred", QStringLiteral("images/") + preferred, i18n("Recommended wallpaper file"));
}
QSize Image::targetSize() const
......@@ -342,7 +342,7 @@ void Image::setSlidePaths(const QStringList &slidePaths)
void Image::showAddSlidePathsDialog()
{
QFileDialog *dialog = new QFileDialog(0, i18n("Directory with the wallpaper to show slides from"), QLatin1String(""));
QFileDialog *dialog = new QFileDialog(nullptr, i18n("Directory with the wallpaper to show slides from"), QString());
dialog->setAttribute(Qt::WA_DeleteOnClose, true );
dialog->setOptions(QFileDialog::ShowDirsOnly);
dialog->setAcceptMode(QFileDialog::AcceptOpen);
......@@ -687,7 +687,7 @@ void Image::wallpaperBrowseCompleted()
void Image::addUsersWallpaper(const QString &file)
{
QString f = file;
f.replace(QLatin1String("file:/"), QLatin1String(""));
f.remove(QLatin1String("file:/"));
const QFileInfo info(f); // FIXME
//the full file path, so it isn't broken when dealing with symlinks
......
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