]> git.sur5r.net Git - minitube/blob - src/compatibility/qurlqueryhelper.h
617769e818c7647c26470106ccd3eb0e2b8eff2a
[minitube] / src / compatibility / qurlqueryhelper.h
1 #ifndef QURLQUERYHELPER_H
2 #define QURLQUERYHELPER_H
3
4 #include <QtGlobal>
5
6 QT_FORWARD_DECLARE_CLASS(QUrl)
7
8 #if QT_VERSION >= 0x050000
9 #include <QUrlQuery>
10
11 class QUrlQueryHelper {
12 public:
13     QUrlQueryHelper(QUrl &url) : m_url(url), m_urlQuery(url) {}
14
15     bool hasQueryItem(const QString &itemKey) const {
16         return m_urlQuery.hasQueryItem(itemKey);
17     }
18
19     void addQueryItem(const QString &key, const QString &value) {
20         m_urlQuery.addQueryItem(key, value);
21     }
22
23     void removeQueryItem(const QString &key) {
24         m_urlQuery.removeQueryItem(key);
25     }
26
27     ~QUrlQueryHelper() {
28         m_url.setQuery(m_urlQuery);
29     }
30
31 private:
32     QUrlQueryHelper(const QUrlQueryHelper&);
33     QUrlQueryHelper& operator=(const QUrlQueryHelper&);
34
35     QUrl &m_url;
36     QUrlQuery m_urlQuery;
37 };
38 #else
39 typedef QUrl& QUrlQueryHelper;
40 #endif  // QT_VERSION >= 0x050000
41
42 #endif // QURLQUERYHELPER_H