LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
urloperator.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "urloperator.h"
10 
11 namespace LC
12 {
13 namespace Util
14 {
15  UrlOperator::UrlOperator (QUrl& url)
16  : Url_ (url)
17  , Query_ (url)
18  {
19  }
20 
22  {
23  Flush ();
24  }
25 
26  void UrlOperator::Flush ()
27  {
28  Url_.setQuery (Query_);
29  }
30 
31  UrlOperator& UrlOperator::operator() (const QString& key, const QString& value)
32  {
33  Query_.addQueryItem (key, value);
34  return *this;
35  }
36 
37  UrlOperator& UrlOperator::operator() (const QString& key, const QByteArray& value)
38  {
39  return (*this) (key, QString::fromUtf8 (value));
40  }
41 
42  UrlOperator& UrlOperator::operator() (const QString& key, const char *value)
43  {
44  return (*this) (key, QString::fromLatin1 (value));
45  }
46 
47  UrlOperator& UrlOperator::operator() (const QString& key, int value)
48  {
49  return (*this) (key, QString::number (value));
50  }
51 
52  UrlOperator& UrlOperator::operator-= (const QString& key)
53  {
54  Query_.removeQueryItem (key);
55  return *this;
56  }
57 
59  {
60  Flush ();
61  return Url_;
62  }
63 }
64 }
LC::Util::UrlOperator::operator-=
UrlOperator & operator-=(const QString &key)
Returns the first query parameter under the key.
Definition: urloperator.cpp:64
urloperator.h
LC::Util::UrlOperator::Flush
void Flush()
Flushes any pending changes to the QUrl query.
Definition: urloperator.cpp:38
LC::Util::UrlOperator::UrlOperator
UrlOperator(QUrl &url)
Constructs the object modifying the query of url.
Definition: urloperator.cpp:27
LC
Definition: constants.h:14
LC::Util::UrlOperator
Manipulates query part of an QUrl object.
Definition: urloperator.h:60
LC::Util::UrlOperator::~UrlOperator
~UrlOperator()
Flushes any pending changes to the QUrl query and destroys the UrlOperator.
Definition: urloperator.cpp:33
LC::Util::UrlOperator::operator()
QUrl operator()()
Flushes any pending changes to the QUrl query.
Definition: urloperator.cpp:70