From a08aff328d4393031d5ba7d622c2b05705a89d73 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 04 Jul 2007 11:23:42 +0000 Subject: initial public commit of qt4 port --- (limited to 'microkde/kurl.cpp') diff --git a/microkde/kurl.cpp b/microkde/kurl.cpp index 2574e25..122ad71 100644 --- a/microkde/kurl.cpp +++ b/microkde/kurl.cpp @@ -34,13 +34,15 @@ #else #include #endif -#include +#include #include #include #include //US#include #include #include +//Added by qt3to4: +#include static const QString fileProt = "file"; @@ -57,7 +59,7 @@ static QString encode( const QString& segment, bool encode_slash, int encoding_h else encode_string = "<>#@\"&%?={}|^~[]\'`\\:+"; - QCString local; + Q3CString local; if (encoding_hint==0) local = segment.local8Bit(); else @@ -100,7 +102,7 @@ static QString encode( const QString& segment, bool encode_slash, int encoding_h } else - new_segment[ new_length++ ] = local[i]; + new_segment[ new_length++ ] = character; } QString result = QString(new_segment, new_length); @@ -205,7 +207,7 @@ static void decode( const QString& segment, QString &decoded, QString &encoded, if (!textCodec) textCodec = QTextCodec::codecForLocale(); - QCString csegment = textCodec->fromUnicode(segment); + Q3CString csegment = textCodec->fromUnicode(segment); // Check if everything went ok if (textCodec->toUnicode(csegment) != segment) { @@ -278,7 +280,7 @@ static void decode( const QString& segment, QString &decoded, QString &encoded, array.setRawData(new_segment, new_length); decoded = textCodec->toUnicode( array, new_length ); array.resetRawData(new_segment, new_length); - QCString validate = textCodec->fromUnicode(decoded); + Q3CString validate = textCodec->fromUnicode(decoded); if (strcmp(validate.data(), new_segment) != 0) { @@ -419,7 +421,7 @@ KURL::KURL( const char * url, int encoding_hint ) parse( QString::fromLatin1(url), encoding_hint ); } -KURL::KURL( const QCString& url, int encoding_hint ) +KURL::KURL( const Q3CString& url, int encoding_hint ) { reset(); parse( QString::fromLatin1(url), encoding_hint ); @@ -460,7 +462,7 @@ QDataStream & operator>> (QDataStream & s, KURL & a) } #ifndef QT_NO_NETWORKPROTOCOL -KURL::KURL( const QUrl &u ) +KURL::KURL( const Q3Url &u ) { *this = u; } @@ -589,13 +591,13 @@ void KURL::parse( const QString& _url, int encoding_hint ) QChar x = buf[pos++]; if ( x == '/' ) goto Node9; - if ( !isalpha( (int)x ) ) + if ( !x.isLetter() ) goto NodeErr; // Node 2: Accept any amount of (alpha|digit|'+'|'-') // '.' is not currently accepted, because current KURL may be confused. // Proceed with :// :/ or : - while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || + while( pos < len && ( buf[pos].isLetter() || buf[pos].isDigit() || buf[pos] == '+' || buf[pos] == '-')) pos++; if ( pos+2 < len && buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' ) @@ -769,11 +771,11 @@ void KURL::parse( const QString& _url, int encoding_hint ) if ( pos == len ) goto NodeErr; start = pos; - if ( !isdigit( buf[pos++] ) ) + if ( !buf[pos++].isDigit() ) goto NodeErr; // Node 8b: Accept any amount of digits - while( pos < len && isdigit( buf[pos] ) ) pos++; + while( pos < len && buf[pos].isDigit() ) pos++; port = QString( buf + start, pos - start ); m_iPort = port.toUShort(); if ( pos == len ) @@ -848,7 +850,7 @@ KURL& KURL::operator=( const char * _url ) } #ifndef QT_NO_NETWORKPROTOCOL -KURL& KURL::operator=( const QUrl & u ) +KURL& KURL::operator=( const Q3Url & u ) { m_strProtocol = u.protocol(); m_strUser = u.user(); @@ -1374,7 +1376,7 @@ KURL KURL::join( const KURL::List & lst ) KURL u(*it); if (it != first) { - if (!u.m_strRef_encoded) u.m_strRef_encoded = tmp.url(); + if (u.m_strRef_encoded.isEmpty()) u.m_strRef_encoded = tmp.url(); else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy } tmp = u; @@ -1418,7 +1420,7 @@ QString KURL::fileName( bool _strip_trailing_slash ) const // unencoded one. int i = m_strPath_encoded.findRev( '/', len - 1 ); QString fileName_encoded = m_strPath_encoded.mid(i+1); - n += fileName_encoded.contains("%2f", false); + n += fileName_encoded.count("%2f", Qt::CaseInsensitive); } int i = len; do { -- cgit v0.9.0.2