LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
standardnamfactory.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 "standardnamfactory.h"
10 #include <QNetworkAccessManager>
11 #include <QQmlEngine>
13 
14 namespace LC::Util
15 {
17  CacheSizeGetter_f getter,
18  QQmlEngine *engine)
19  : Subpath_ (std::move (subpath))
20  , CacheSizeGetter_ (std::move (getter))
21  {
22  if (engine)
23  engine->setNetworkAccessManagerFactory (this);
24  }
25 
26  QNetworkAccessManager* StandardNAMFactory::create (QObject *parent)
27  {
28  auto nam = new QNetworkAccessManager (parent);
29 
30  auto cache = new NetworkDiskCache (Subpath_, nam);
31  cache->setMaximumCacheSize (CacheSizeGetter_ ());
32  nam->setCache (cache);
33 
34  return nam;
35  }
36 }
LC::Util::StandardNAMFactory::StandardNAMFactory
StandardNAMFactory(QString subpath, CacheSizeGetter_f getter, QQmlEngine *engine=nullptr)
Constructs a new StandardNAMFactory.
Definition: standardnamfactory.cpp:22
LC::Util::StandardNAMFactory::create
QNetworkAccessManager * create(QObject *parent) override
Creates the network access manager with the given parent.
Definition: standardnamfactory.cpp:32
standardnamfactory.h
LC::Util
Definition: icoreproxy.h:33
networkdiskcache.h
LC::Util::NetworkDiskCache
A thread-safe garbage-collected network disk cache.
Definition: networkdiskcache.h:38