Logo Search packages:      
Sourcecode: kbiff version File versions

void KBiffURL::setSearchPar ( const QString &  _parName,
const QString &  _newParVal 
)

Sets a parameter value in the search part of the URL

Definition at line 81 of file kbiffurl.cpp.

References findPos().

{
  QString _newSearchPart;
  const char *_searchPart, *_searchPos, *_parVal;
  int index, len;

  // Get the search part of the URL, i.e. the stuff after "?"
  QString query_str(query());

  if (!query_str.isNull())
    query_str = query_str.remove(0,1);
  _searchPart = query_str.ascii();

  // Try to find the given parameter in the search part string
  index = findPos( _searchPart, _parName );

  // If the parameter name is not found it is simply appended
  if (index < 0) 
  {
    if (query_str.length() > 0) 
    {
      _newSearchPart = query_str;
      _newSearchPart += "&";
    }
    _newSearchPart += _parName;
    _newSearchPart += "=";
    _newSearchPart += _newParVal;
  }
  else
  {
    _newSearchPart = _searchPart;

    // If no value is assigned, the new value is inserted
    if (_searchPart[index] != '=') 
    {
      _newSearchPart.insert( index, _newParVal );
      _newSearchPart.insert( index, '=' );
    }

    // Otherwise, the old value is replaced with the new one
    else
    {
      // Point to the first character of the assigned value
      index++;

      // Set the beginning of the parameter value string
      _parVal = &(_searchPart[index]);

      // Get the length of the old parameter value
      _searchPos = strpbrk( _parVal, ";:@&=" );

      if (_searchPos == NULL)
        len = strlen( _parVal );
      else
        len = _searchPos - _parVal;

      _newSearchPart.replace( index, len, _newParVal );
    }
  }

  setQuery( _newSearchPart );
}


Generated by  Doxygen 1.6.0   Back to index