src/corelib/io/qurl.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
  4956     query. The contents of \a query are converted to a string
  4956     query. The contents of \a query are converted to a string
  4957     internally, each pair delimited by the character returned by
  4957     internally, each pair delimited by the character returned by
  4958     pairDelimiter(), and the key and value are delimited by
  4958     pairDelimiter(), and the key and value are delimited by
  4959     valueDelimiter().
  4959     valueDelimiter().
  4960 
  4960 
       
  4961     \note This method does not encode spaces (ASCII 0x20) as plus (+) signs,
       
  4962     like HTML forms do. If you need that kind of encoding, you must encode
       
  4963     the value yourself and use QUrl::setEncodedQueryItems.
       
  4964 
  4961     \sa setQueryDelimiters(), queryItems(), setEncodedQueryItems()
  4965     \sa setQueryDelimiters(), queryItems(), setEncodedQueryItems()
  4962 */
  4966 */
  4963 void QUrl::setQueryItems(const QList<QPair<QString, QString> > &query)
  4967 void QUrl::setQueryItems(const QList<QPair<QString, QString> > &query)
  4964 {
  4968 {
  4965     if (!d) d = new QUrlPrivate;
  4969     if (!d) d = new QUrlPrivate;
  5026     pair is converted into separate strings internally. The \a key and 
  5030     pair is converted into separate strings internally. The \a key and 
  5027     \a value is first encoded into UTF-8 and then delimited by the 
  5031     \a value is first encoded into UTF-8 and then delimited by the 
  5028     character returned by valueDelimiter(). Each key/value pair is 
  5032     character returned by valueDelimiter(). Each key/value pair is 
  5029     delimited by the character returned by pairDelimiter().
  5033     delimited by the character returned by pairDelimiter().
  5030 
  5034 
       
  5035     \note This method does not encode spaces (ASCII 0x20) as plus (+) signs,
       
  5036     like HTML forms do. If you need that kind of encoding, you must encode
       
  5037     the value yourself and use QUrl::addEncodedQueryItem.
       
  5038 
  5031     \sa addEncodedQueryItem()
  5039     \sa addEncodedQueryItem()
  5032 */
  5040 */
  5033 void QUrl::addQueryItem(const QString &key, const QString &value)
  5041 void QUrl::addQueryItem(const QString &key, const QString &value)
  5034 {
  5042 {
  5035     if (!d) d = new QUrlPrivate;
  5043     if (!d) d = new QUrlPrivate;
  5081     d->hasQuery = !d->query.isEmpty();
  5089     d->hasQuery = !d->query.isEmpty();
  5082 }
  5090 }
  5083 
  5091 
  5084 /*!
  5092 /*!
  5085     Returns the query string of the URL, as a map of keys and values.
  5093     Returns the query string of the URL, as a map of keys and values.
       
  5094 
       
  5095     \note This method does not decode spaces plus (+) signs as spaces (ASCII
       
  5096     0x20), like HTML forms do. If you need that kind of decoding, you must
       
  5097     use QUrl::encodedQueryItems and decode the data yourself.
  5086 
  5098 
  5087     \sa setQueryItems(), setEncodedQuery()
  5099     \sa setQueryItems(), setEncodedQuery()
  5088 */
  5100 */
  5089 QList<QPair<QString, QString> > QUrl::queryItems() const
  5101 QList<QPair<QString, QString> > QUrl::queryItems() const
  5090 {
  5102 {
  5186 
  5198 
  5187 /*!
  5199 /*!
  5188     Returns the first query string value whose key is equal to \a key
  5200     Returns the first query string value whose key is equal to \a key
  5189     from the URL.
  5201     from the URL.
  5190 
  5202 
       
  5203     \note This method does not decode spaces plus (+) signs as spaces (ASCII
       
  5204     0x20), like HTML forms do. If you need that kind of decoding, you must
       
  5205     use QUrl::encodedQueryItemValue and decode the data yourself.
       
  5206 
  5191     \sa allQueryItemValues()
  5207     \sa allQueryItemValues()
  5192 */
  5208 */
  5193 QString QUrl::queryItemValue(const QString &key) const
  5209 QString QUrl::queryItemValue(const QString &key) const
  5194 {
  5210 {
  5195     if (!d) return QString();
  5211     if (!d) return QString();
  5229 }
  5245 }
  5230 
  5246 
  5231 /*!
  5247 /*!
  5232     Returns the a list of query string values whose key is equal to
  5248     Returns the a list of query string values whose key is equal to
  5233     \a key from the URL.
  5249     \a key from the URL.
       
  5250 
       
  5251     \note This method does not decode spaces plus (+) signs as spaces (ASCII
       
  5252     0x20), like HTML forms do. If you need that kind of decoding, you must
       
  5253     use QUrl::allEncodedQueryItemValues and decode the data yourself.
  5234 
  5254 
  5235     \sa queryItemValue()
  5255     \sa queryItemValue()
  5236 */
  5256 */
  5237 QStringList QUrl::allQueryItemValues(const QString &key) const
  5257 QStringList QUrl::allQueryItemValues(const QString &key) const
  5238 {
  5258 {
  5608         url += d->scheme + QLatin1Char(':');
  5628         url += d->scheme + QLatin1Char(':');
  5609     QString ourPath = path();
  5629     QString ourPath = path();
  5610     if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) {
  5630     if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) {
  5611         bool doFileScheme = d->scheme == QLatin1String("file") && ourPath.startsWith(QLatin1Char('/'));
  5631         bool doFileScheme = d->scheme == QLatin1String("file") && ourPath.startsWith(QLatin1Char('/'));
  5612         QString tmp = d->authority(options);
  5632         QString tmp = d->authority(options);
  5613         if (!tmp.isEmpty() || doFileScheme) {
  5633         if (!tmp.isNull() || doFileScheme) {
  5614             if (doFileScheme && !ourPath.startsWith(QLatin1Char('/')))
  5634             if (doFileScheme && !ourPath.startsWith(QLatin1Char('/')))
  5615                 url += QLatin1Char('/');
  5635                 url += QLatin1Char('/');
  5616             url += QLatin1String("//");
  5636             url += QLatin1String("//");
  5617             url += tmp;
  5637             url += tmp;
  5618         }
  5638         }