|
Qyoto
4.0.7
Qyoto is a C# language binding for Qt
|
The QNetworkDiskCache class provides a very basic disk cache. More...


Public Member Functions | |
| QNetworkDiskCache (QObject parent=null) | |
| More... | |
| override void | CreateProxy () |
| override void | Clear () |
| More... | |
| override QIODevice | Data (QUrl url) |
| More... | |
| new QNetworkCacheMetaData | FileMetaData (string fileName) |
| More... | |
| override void | Insert (QIODevice device) |
| More... | |
| override QNetworkCacheMetaData | MetaData (QUrl url) |
| More... | |
| override QIODevice | Prepare (QNetworkCacheMetaData metaData) |
| More... | |
| override bool | Remove (QUrl url) |
| More... | |
| override void | UpdateMetaData (QNetworkCacheMetaData metaData) |
| More... | |
| new void | Dispose () |
Public Member Functions inherited from QtNetwork.QAbstractNetworkCache | |
| new void | Dispose () |
Public Member Functions inherited from QtCore.QObject | |
| QObject (QObject parent=null) | |
| More... | |
| new bool | BlockSignals (bool b) |
| More... | |
| new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| More... | |
| new void | DeleteLater () |
| More... | |
| new bool | Disconnect (QObject receiver, string member=null) |
| More... | |
| new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
| More... | |
| new void | DumpObjectInfo () |
| More... | |
| new void | DumpObjectTree () |
| More... | |
| virtual bool | OnEvent (QEvent e) |
| More... | |
| virtual bool | EventFilter (QObject watched, QEvent @event) |
| More... | |
| new bool | Inherits (string classname) |
| More... | |
| new void | InstallEventFilter (QObject filterObj) |
| More... | |
| new void | KillTimer (int id) |
| More... | |
| new object | Property (string name) |
| More... | |
| new void | RemoveEventFilter (QObject obj) |
| More... | |
| new bool | SetProperty (string name, object value) |
| More... | |
| new void | SetUserData (uint id, QObjectUserData data) |
| new int | StartTimer (int interval) |
| More... | |
| new QObjectUserData | UserData (uint id) |
| new void | Dispose () |
Public Member Functions inherited from QtCore.Qt | |
| delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
| delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
| delegate QObject | FuncQObject () |
| delegate string | FuncStringQByteArray (QByteArray qByteArray) |
| delegate QByteArray | FuncQByteArrayString (string @string) |
Static Public Member Functions | |
| static string | Tr (string s, string c=null) |
| static string | Tr (string s, string c, int n) |
| static string | TrUtf8 (string s, string c=null) |
| static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtNetwork.QAbstractNetworkCache | |
| static string | Tr (string s, string c=null) |
| static string | Tr (string s, string c, int n) |
| static string | TrUtf8 (string s, string c=null) |
| static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtCore.QObject | |
| static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| More... | |
| static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| More... | |
| static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
| More... | |
| static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
| More... | |
| static string | Tr (string s, string c=null) |
| More... | |
| static string | Tr (string s, string c, int n) |
| More... | |
| static string | TrUtf8 (string s, string c=null) |
| More... | |
| static string | TrUtf8 (string s, string c, int n) |
| More... | |
Static Public Member Functions inherited from QtCore.Qt | |
| static QDataStream | Write (QDataStream s, object p) |
| static QDataStream | Write (QDataStream stream, QSizeF size) |
| More... | |
| static QDataStream | Write (QDataStream stream, QPoint point) |
| More... | |
| static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
| static QDataStream | Write (QDataStream stream, QLineF line) |
| More... | |
| static QDataStream | Write (QDataStream stream, QPointF point) |
| More... | |
| static QDataStream | Write (QDataStream @out, QChar chr) |
| More... | |
| static QDataStream | Write (QDataStream @out, QByteArray ba) |
| More... | |
| static QDataStream | Write (QDataStream stream, QEasingCurve easing) |
| More... | |
| static QDataStream | Write (QDataStream stream, QRectF rectangle) |
| More... | |
| static QDataStream | Write (QDataStream @out, QDateTime dateTime) |
| More... | |
| static QDataStream | Write (QDataStream @out, QUrl url) |
| More... | |
| static QDataStream | Write (QDataStream @out, QTime time) |
| More... | |
| static QDataStream | Write (QDataStream arg1, QLocale arg2) |
| static QDataStream | Write (QDataStream @out, QBitArray ba) |
| More... | |
| static QDataStream | Write (QDataStream s, QUuid id) |
| More... | |
| static QDataStream | Write (QDataStream stream, QLine line) |
| More... | |
| static QDataStream | Write (QDataStream @out, QDate date) |
| More... | |
| static QDataStream | Write (QDataStream @out, QRegExp regExp) |
| More... | |
| static QDataStream | Write (QDataStream stream, QRect rectangle) |
| More... | |
| static QDataStream | Write (QDataStream stream, QSize size) |
| More... | |
| static QDataStream | Write (QDataStream s, QVariant.Type p) |
| static QDataStream | Write (QDataStream arg1, string arg2) |
| static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
| More... | |
| static QDataStream | Read (QDataStream @in, QChar chr) |
| More... | |
| static QDataStream | Read (QDataStream arg1, QLocale arg2) |
| static QDataStream | Read (QDataStream stream, QRect rectangle) |
| More... | |
| static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
| static QDataStream | Read (QDataStream @in, QDate date) |
| More... | |
| static QDataStream | Read (QDataStream @in, QUrl url) |
| More... | |
| static QDataStream | Read (QDataStream s, QUuid id) |
| More... | |
| static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
| static QDataStream | Read (QDataStream stream, QLineF line) |
| More... | |
| static QDataStream | Read (QDataStream stream, QRectF rectangle) |
| More... | |
| static QDataStream | Read (QDataStream stream, QPointF point) |
| More... | |
| static QDataStream | Read (QDataStream stream, QLine line) |
| More... | |
| static QDataStream | Read (QDataStream @in, QBitArray ba) |
| More... | |
| static QDataStream | Read (QDataStream stream, QSize size) |
| More... | |
| static QDataStream | Read (QDataStream @in, QDateTime dateTime) |
| More... | |
| static QDataStream | Read (QDataStream @in, QTime time) |
| More... | |
| static QDataStream | Read (QDataStream stream, QPoint point) |
| More... | |
| static QDataStream | Read (QDataStream @in, QRegExp regExp) |
| More... | |
| static QDataStream | Read (QDataStream s, object p) |
| static QDataStream | Read (QDataStream @in, QByteArray ba) |
| More... | |
| static QDataStream | Read (QDataStream stream, QSizeF size) |
| More... | |
| static QDataStream | Read (QDataStream arg1, string arg2) |
| static QDataStream | Read (QDataStream s, QVariant.Type p) |
| static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
| More... | |
| static double | QAcos (double v) |
| More... | |
| static void | QAddPostRoutine (System.Action ptr) |
| More... | |
| static double | QAsin (double v) |
| More... | |
| static double | QAtan (double v) |
| More... | |
| static double | QAtan2 (double x, double y) |
| More... | |
| static void | QBadAlloc () |
| static int | QCeil (double v) |
| More... | |
| static ushort | QChecksum (string s, uint len) |
| More... | |
| static QByteArray | QCompress (QByteArray data, int compressionLevel=-1) |
| More... | |
| static QByteArray | QCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
| More... | |
| static double | QCos (double v) |
| More... | |
| static double | QExp (double v) |
| More... | |
| static double | QFabs (double v) |
| static double | QFastCos (double x) |
| static double | QFastSin (double x) |
| static string | QFlagLocation (string method) |
| static int | QFloor (double v) |
| More... | |
| static bool | QFuzzyCompare (double p1, double p2) |
| More... | |
| static bool | QFuzzyCompare (float p1, float p2) |
| More... | |
| static bool | QFuzzyIsNull (double d) |
| static bool | QFuzzyIsNull (float f) |
| static uint | QHash (QBitArray key) |
| More... | |
| static uint | QHash (QChar key) |
| More... | |
| static uint | QHash (QStringRef key) |
| static uint | QHash (QUrl url) |
| More... | |
| static uint | QHash (QPersistentModelIndex index) |
| static uint | QHash (QByteArray key) |
| More... | |
| static uint | QHash (QModelIndex index) |
| static uint | QHash (uint key) |
| More... | |
| static uint | QHash (char key) |
| More... | |
| static uint | QHash (byte key) |
| More... | |
| static uint | QHash (short key) |
| More... | |
| static uint | QHash (NativeLong key) |
| More... | |
| static uint | QHash (ushort key) |
| More... | |
| static uint | QHash (long key) |
| More... | |
| static uint | QHash (ulong key) |
| More... | |
| static uint | QHash (int key) |
| More... | |
| static uint | QHash (string key) |
| More... | |
| static uint | QHash (NativeULong key) |
| More... | |
| static Qt.ActionQtMsgTypeString | QInstallMsgHandler (Qt.ActionQtMsgTypeString handler) |
| More... | |
| static int | QIntCast (float f) |
| static int | QIntCast (double f) |
| static bool | QIsFinite (double d) |
| static bool | QIsFinite (float f) |
| static bool | QIsInf (float f) |
| static bool | QIsInf (double d) |
| static bool | QIsNaN (float f) |
| static bool | QIsNaN (double d) |
| static bool | QIsNull (float f) |
| static bool | QIsNull (double d) |
| static double | QLn (double v) |
| More... | |
| static double | QPow (double x, double y) |
| More... | |
| static void | QRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
| More... | |
| static void | QRemovePostRoutine (System.Action arg1) |
| static int | QRound (double d) |
| More... | |
| static long | QRound64 (double d) |
| More... | |
| static double | QSin (double v) |
| More... | |
| static double | QSqrt (double v) |
| More... | |
| static bool | QStringComparisonHelper (QStringRef s1, string s2) |
| static double | QTan (double v) |
| More... | |
| static QByteArray | QUncompress (QByteArray data) |
| More... | |
| static QByteArray | QUncompress (Pointer< byte > data, int nbytes) |
| More... | |
| static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
| static QByteArray | Qgetenv (string varName) |
| More... | |
| static bool | Qputenv (string varName, QByteArray value) |
| More... | |
| static void | Qsrand (uint seed) |
| More... | |
| static int | Qstrcmp (QByteArray str1, QByteArray str2) |
| static int | Qstrcmp (QByteArray str1, string str2) |
| static int | Qstrcmp (string str1, QByteArray str2) |
| static int | Qstrcmp (string str1, string str2) |
| More... | |
| static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
| More... | |
| static Pointer< sbyte > | Qstrdup (string src) |
| More... | |
| static int | Qstricmp (string str1, string str2) |
| More... | |
| static uint | Qstrlen (string str) |
| More... | |
| static int | Qstrncmp (string str1, string str2, uint len) |
| More... | |
| static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
| More... | |
| static int | Qstrnicmp (string str1, string str2, uint len) |
| More... | |
| static uint | Qstrnlen (string str, uint maxlen) |
| More... | |
Protected Member Functions | |
| QNetworkDiskCache (System.Type dummy) | |
| virtual long | Expire () |
| More... | |
Protected Member Functions inherited from QtNetwork.QAbstractNetworkCache | |
| QAbstractNetworkCache (System.Type dummy) | |
| QAbstractNetworkCache (QObject parent=null) | |
| More... | |
Protected Member Functions inherited from QtCore.QObject | |
| QObject (System.Type dummy) | |
| virtual void | OnChildEvent (QChildEvent @event) |
| More... | |
| virtual void | ConnectNotify (string signal) |
| More... | |
| virtual void | OnCustomEvent (QEvent @event) |
| More... | |
| new void | OnDestroyed (QObject obj=null) |
| More... | |
| virtual void | DisconnectNotify (string signal) |
| More... | |
| new int | Receivers (string signal) |
| More... | |
| virtual void | OnTimerEvent (QTimerEvent @event) |
| More... | |
Properties | |
| string | CacheDirectory [get, set] |
| More... | |
| long | MaximumCacheSize [get, set] |
| More... | |
| override long | CacheSize [get] |
| More... | |
| static new QMetaObject | StaticMetaObject [get] |
| new IQNetworkDiskCacheSignals | Emit [get] |
Properties inherited from QtNetwork.QAbstractNetworkCache | |
| virtual long | CacheSize [get] |
| More... | |
| static new QMetaObject | StaticMetaObject [get] |
| new IQAbstractNetworkCacheSignals | Emit [get] |
Properties inherited from QtCore.QObject | |
| virtual EventHandler < QEventArgs< QChildEvent > > | ChildEvent |
| More... | |
| virtual EventHandler < QEventArgs< QEvent > > | CustomEvent |
| More... | |
| virtual EventHandler < QEventArgs< QEvent > > | Event |
| More... | |
| virtual EventHandler < QEventArgs< QTimerEvent > > | TimerEvent |
| More... | |
| Slot< QObject > | DestroyedObj |
| More... | |
| Slot | Destroyed |
| More... | |
| QObject | Parent [get, set] |
| More... | |
| System.Collections.Generic.List < QObject > | Children [get] |
| More... | |
| System.Collections.Generic.List < QByteArray > | DynamicPropertyNames [get] |
| More... | |
| bool | IsWidgetType [get] |
| More... | |
| static uint | RegisterUserData [get] |
| QObject | Sender [get] |
| More... | |
| int | SenderSignalIndex [get] |
| More... | |
| bool | SignalsBlocked [get] |
| More... | |
| virtual System.IntPtr | SmokeObject [get, set] |
| new string | ObjectName [get, set] |
| More... | |
| static new QMetaObject | StaticMetaObject [get] |
| More... | |
| static new QMetaObject | StaticQtMetaObject [get] |
| new IQObjectSignals | Emit [get] |
Properties inherited from QtCore.Qt | |
| static string | QAppName [get] |
| static double | QInf [get] |
| static double | QQNaN [get] |
| static double | QSNaN [get] |
| static bool | QSharedBuild [get] |
| static string | QVersion [get] |
| More... | |
| static int | Qrand [get] |
| More... | |
The QNetworkDiskCache class provides a very basic disk cache.
QNetworkDiskCache stores each url in its own file inside of the cacheDirectory using QDataStream. Files with a text MimeType are compressed using qCompress. Each cache file starts with "cache_" and ends in ".cache". Data is written to disk only in insert() and updateMetaData().
Currently you can not share the same cache files with more then one disk cache.
QNetworkDiskCache by default limits the amount of space that the cache will use on the system to 50MB.
Note you have to set the cache directory before it will work.
A network disk cache can be enabled by:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
diskCache->setCacheDirectory("cacheDir");
manager->setCache(diskCache);
When sending requests, to control the preference of when to use the cache and when to use the network, consider the following:
// do a normal request (preferred from network, as this is the default)
QNetworkRequest request(QUrl(QString("http://qt.nokia.com")));
manager->get(request);
// do a request preferred from cache
QNetworkRequest request2(QUrl(QString("http://qt.nokia.com")));
request2.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
manager->get(request2);
To check whether the response came from the cache or from the network, the following can be applied:
void replyFinished(QNetworkReply *reply) {
QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
qDebug() << "page from cache?" << fromCache.toBool();
}
|
protected |
| QtNetwork.QNetworkDiskCache.QNetworkDiskCache | ( | QObject | parent = null | ) |
Creates a new disk cache. The parent argument is passed to QAbstractNetworkCache's constructor.

|
virtual |
Reimplemented from QAbstractNetworkCache::clear().
Implements QtNetwork.QAbstractNetworkCache.
|
virtual |
Reimplemented from QAbstractNetworkCache::data().
Implements QtNetwork.QAbstractNetworkCache.
| new void QtNetwork.QNetworkDiskCache.Dispose | ( | ) |
|
protectedvirtual |
Cleans the cache so that its size is under the maximum cache size. Returns the current size of the cache.
When the current size of the cache is greater than the maximumCacheSize() older cache files are removed until the total size is less then 90% of maximumCacheSize() starting with the oldest ones first using the file creation date to determine how old a cache file is.
Subclasses can reimplement this function to change the order that cache files are removed taking into account information in the application knows about that QNetworkDiskCache does not, for example the number of times a cache is accessed.
Note: cacheSize() calls expire if the current cache size is unknown.
See also maximumCacheSize() and fileMetaData().
| new QNetworkCacheMetaData QtNetwork.QNetworkDiskCache.FileMetaData | ( | string | fileName | ) |
Returns the QNetworkCacheMetaData for the cache file fileName.
If fileName is not a cache file QNetworkCacheMetaData will be invalid.
|
virtual |
Reimplemented from QAbstractNetworkCache::insert().
Implements QtNetwork.QAbstractNetworkCache.
|
virtual |
Reimplemented from QAbstractNetworkCache::metaData().
Implements QtNetwork.QAbstractNetworkCache.
|
virtual |
Reimplemented from QAbstractNetworkCache::prepare().
Implements QtNetwork.QAbstractNetworkCache.
|
virtual |
Reimplemented from QAbstractNetworkCache::remove().
Implements QtNetwork.QAbstractNetworkCache.
|
static |
|
static |
|
static |
|
static |
|
virtual |
Reimplemented from QAbstractNetworkCache::updateMetaData().
Implements QtNetwork.QAbstractNetworkCache.
|
getset |
Returns the location where cached files will be stored.
Sets the directory where cached files will be stored to cacheDir
QNetworkDiskCache will create this directory if it does not exists.
Prepared cache items will be stored in the new cache directory when they are inserted.
|
get |
Reimplemented from QAbstractNetworkCache::cacheSize().
|
getprotected |
|
getset |
Returns the current maximum size in bytes for the disk cache.
Sets the maximum size of the disk cache to be size in bytes.
If the new size is smaller then the current cache size then the cache will call expire().
|
staticget |