From 18ac6803e416138fd3a6061810e9806ad8b641f1 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 12 Oct 2015 18:13:00 +0300 Subject: [PATCH] kfile: code shrinks --- kfile/kfilewidget.cpp | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/kfile/kfilewidget.cpp b/kfile/kfilewidget.cpp index 5b97f8a0..ed78205b 100644 --- a/kfile/kfilewidget.cpp +++ b/kfile/kfilewidget.cpp @@ -292,30 +292,6 @@ static const char autocompletionWhatsThisText[] = I18N_NOOP("While typing in "This feature can be controlled by clicking with the right mouse button " "and selecting a preferred mode from the Text Completion menu."); -// returns true if the string contains ":/" sequence, where is at least 2 alpha chars -static bool containsProtocolSection( const QString& string ) -{ - int len = string.length(); - static const char prot[] = ":/"; - for (int i=0; i < len;) { - i = string.indexOf( QLatin1String(prot), i ); - if (i == -1) - return false; - int j=i-1; - for (; j >= 0; j--) { - const QChar& ch( string[j] ); - if (ch.toLatin1() == 0 || !ch.isLetter()) - break; - if (ch.isSpace() && (i-j-1) >= 2) - return true; - } - if (j < 0 && i >= 2) - return true; // at least two letters before ":/" - i += 3; // skip : and / and one char - } - return false; -} - KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent ) : QWidget(parent), KAbstractFileWidget(), d(new KFileWidgetPrivate(this)) { @@ -875,7 +851,7 @@ void KFileWidget::slotOk() // the user, convert it to relative if (!locationEditCurrentText.isEmpty() && !(mode & KFile::Directory) && (QDir::isAbsolutePath(locationEditCurrentText) || - containsProtocolSection(locationEditCurrentText))) { + !KUrl::isRelativeUrl(locationEditCurrentText))) { QString fileName; KUrl url(locationEditCurrentText); @@ -1597,7 +1573,7 @@ KUrl::List& KFileWidgetPrivate::parseSelectedUrls() urlList.clear(); if ( filenames.contains( '/' )) { // assume _one_ absolute filename KUrl u; - if ( containsProtocolSection( filenames ) ) + if ( !KUrl::isRelativeUrl(filenames) ) u = filenames; else u.setPath( filenames );