Commit d4bbd530 authored by Fathi Boudra's avatar Fathi Boudra
Browse files

avoid implicit conversion, more efficient.

parent 1e6d111e
......@@ -179,12 +179,16 @@ newFTPGUI::~newFTPGUI()
void newFTPGUI::slotTextChanged(const QString& string)
{
if (string.startsWith("ftp") || string.startsWith("sftp") || string.startsWith("fish")) {
if (port->value() == 21 || port->value() == 22)
port->setValue(string.startsWith("ftp") ? 21 : 22);
if (string.startsWith(QLatin1String("ftp")) ||
string.startsWith(QLatin1String("sftp")) ||
string.startsWith(QLatin1String("fish"))) {
if (port->value() == 21 || port->value() == 22) {
port->setValue(string.startsWith(QLatin1String("ftp")) ? 21 : 22);
}
port->setEnabled(true);
} else
} else {
port->setEnabled(false);
}
}
/*
......
......@@ -219,7 +219,7 @@ void MediaButton::slotPopupActivated(QAction * action)
{
if (action && action->data().canConvert<QString>()) {
QString id = action->data().toString();
if (id.startsWith("remote:")) {
if (id.startsWith(QLatin1String("remote:"))) {
QString mountPoint = id.mid(7);
bool mounted = false;
......@@ -286,7 +286,7 @@ void MediaButton::rightClickMenu(QString udi)
if (rightMenu)
rightMenu->close();
bool network = udi.startsWith("remote:");
bool network = udi.startsWith(QLatin1String("remote:"));
bool ejectable = false;
bool mounted = false;
KUrl openURL;
......@@ -375,7 +375,7 @@ void MediaButton::rightClickMenu(QString udi)
void MediaButton::mount(QString udi, bool open, bool newtab)
{
if (udi.startsWith("remote:")) {
if (udi.startsWith(QLatin1String("remote:"))) {
QString mp = udi.mid(7);
krMtMan.mount(mp, true);
if (newtab)
......@@ -427,7 +427,7 @@ void MediaButton::slotSetupDone(Solid::ErrorType error, QVariant errorData, cons
void MediaButton::umount(QString udi)
{
if (udi.startsWith("remote:")) {
if (udi.startsWith(QLatin1String("remote:"))) {
krMtMan.unmount(udi.mid(7), false);
return;
}
......@@ -526,7 +526,9 @@ void MediaButton::slotTimeout()
QList<QAction *> actionList = popupMenu->actions();
foreach(QAction * act, actionList) {
if (act && act->data().canConvert<QString>() && act->data().toString().startsWith("remote:")) {
if (act &&
act->data().canConvert<QString>() &&
act->data().toString().startsWith(QLatin1String("remote:"))) {
QString mountPoint = act->data().toString().mid(7);
bool available = false;
......
......@@ -340,8 +340,9 @@ void LocateDlg::processStdout()
if (dontSearchPath) {
QRegExp regExp(pattern, isCs ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard);
QString fileName = (*it).trimmed();
if (fileName.endsWith("/") && fileName != "/")
if (fileName.endsWith(QLatin1String("/")) && fileName != "/") {
fileName.truncate(fileName.length() - 1);
}
fileName = fileName.mid(fileName.lastIndexOf('/') + 1);
if (!regExp.exactMatch(fileName))
......
......@@ -215,7 +215,7 @@ void SynchronizerDirList::slotEntries(KIO::Job * job, const KIO::UDSEntryList& e
while (it != end) {
KFileItem kfi(*it, ((KIO::ListJob *)job)->url(), true, true);
QString key = kfi.text();
if (key != "." && key != ".." && (!ignoreHidden || !key.startsWith("."))) {
if (key != "." && key != ".." && (!ignoreHidden || !key.startsWith(QLatin1String(".")))) {
mode_t mode = kfi.mode() | kfi.permissions();
QString perm = KRpermHandler::mode2QString(mode);
if (kfi.isDir())
......
......@@ -662,13 +662,15 @@ bool KRarcHandler::isArchive(const KUrl& url)
QString KRarcHandler::getType(bool &encrypted, QString fileName, QString mime, bool checkEncrypted)
{
QString result = detectArchive(encrypted, fileName, checkEncrypted);
if (result.isNull())
if (result.isNull()) {
result = mime;
else
} else {
result = '-' + result;
}
if (result.endsWith("-7z"))
if (result.endsWith(QLatin1String("-7z"))) {
result = "-7z";
}
return result.right(4);
}
......@@ -828,10 +830,13 @@ QString KRarcHandler::detectArchive(bool &encrypted, QString fileName, bool chec
}
}
if (fileName.endsWith(".tar.lzma") || fileName.endsWith(".tlz"))
if (fileName.endsWith(QLatin1String(".tar.lzma")) ||
fileName.endsWith(QLatin1String(".tlz"))) {
return "tlz";
if (fileName.endsWith(".lzma"))
}
if (fileName.endsWith(QLatin1String(".lzma"))) {
return "lzma";
}
return QString();
}
......
......@@ -112,8 +112,8 @@ void KonqMultiRestoreJob::slotStart()
const KUrl& url = *m_urlsIterator;
KUrl new_url = url;
if (new_url.protocol() == "system"
&& new_url.path().startsWith("/trash")) {
if (new_url.protocol() == "system" &&
new_url.path().startsWith(QLatin1String("/trash"))) {
QString path = new_url.path();
path.remove(0, 6);
new_url.setProtocol("trash");
......
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