KNewStuff

provider.cpp
1 /*
2  knewstuff3/provider.cpp
3  SPDX-FileCopyrightText: 2002 Cornelius Schumacher <[email protected]>
4  SPDX-FileCopyrightText: 2003-2007 Josef Spillner <[email protected]>
5  SPDX-FileCopyrightText: 2009 Jeremy Whiting <[email protected]>
6  SPDX-FileCopyrightText: 2009 Frederik Gladhorn <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.1-or-later
9 */
10 
11 #include "provider.h"
12 
13 #include "xmlloader.h"
14 
15 #include <KLocalizedString>
16 
17 namespace KNSCore
18 {
19 
20 // TODO KF6 BCI: Add a real d-pointer
21 class ProviderPrivate {
22 public:
23  QStringList tagFilter;
24  QStringList downloadTagFilter;
25 };
26 typedef QHash<const Provider *, ProviderPrivate *> ProviderPrivateHash;
27 Q_GLOBAL_STATIC(ProviderPrivateHash, d_func)
28 
29 static ProviderPrivate *d(const Provider *provider)
30 {
31  ProviderPrivate *ret = d_func()->value(provider);
32  if (!ret) {
33  ret = new ProviderPrivate;
34  d_func()->insert(provider, ret);
35  }
36  return ret;
37 }
38 
39 static void delete_d(const Provider *provider)
40 {
41  if (auto d = d_func()) {
42  delete d->take(provider);
43  }
44 }
45 
46 QString Provider::SearchRequest::hashForRequest() const
47 {
48  return QString(QString::number((int)sortMode) + QLatin1Char(',')
49  + searchTerm + QLatin1Char(',')
50  + categories.join(QLatin1Char('-')) + QLatin1Char(',')
51  + QString::number(page) + QLatin1Char(',')
52  + QString::number(pageSize));
53 }
54 
56 {}
57 
59 {
60  delete_d(this);
61 }
62 
64 {
65  return mName;
66 }
67 
69 {
70  return mIcon;
71 }
72 
73 void Provider::setTagFilter(const QStringList &tagFilter)
74 {
75  d(this)->tagFilter = tagFilter;
76 }
77 
79 {
80  return d(this)->tagFilter;
81 }
82 
83 void Provider::setDownloadTagFilter(const QStringList &downloadTagFilter)
84 {
85  d(this)->downloadTagFilter = downloadTagFilter;
86 }
87 
89 {
90  return d(this)->downloadTagFilter;
91 }
92 
94 {
95  QDebugStateSaver saver(dbg);
96  dbg.nospace();
97  dbg << "Provider::SearchRequest(";
98  dbg << "searchTerm: " << search.searchTerm << ',';
99  dbg << "categories: " << search.categories << ',';
100  dbg << "filter: " << search.filter << ',';
101  dbg << "page: " << search.page << ',';
102  dbg << "pageSize: " << search.pageSize;
103  dbg << ')';
104  return dbg;
105 }
106 
107 }
108 
Provider()
Constructor.
Definition: provider.cpp:55
QStringList tagFilter() const
The tag filter used for downloads by this provider.
Definition: provider.cpp:78
void setTagFilter(const QStringList &tagFilter)
Set the tag filter used for entries by this provider.
Definition: provider.cpp:73
Contains the core functionality for handling interaction with NewStuff providers. ...
QDebug & nospace()
void setDownloadTagFilter(const QStringList &downloadTagFilter)
Set the tag filter used for download items by this provider.
Definition: provider.cpp:83
used to keep track of a search
Definition: provider.h:67
virtual ~Provider()
Destructor.
Definition: provider.cpp:58
QString number(int n, int base)
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
virtual QString name() const
Retrieves the common name of the provider.
Definition: provider.cpp:63
virtual QUrl icon() const
Retrieves the icon URL for this provider.
Definition: provider.cpp:68
QStringList downloadTagFilter() const
The tag filter used for downloads by this provider.
Definition: provider.cpp:88
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.