Krita Source Code Documentation
Loading...
Searching...
No Matches
KoStoreDevice.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef koStoreDevice_h
8#define koStoreDevice_h
9
10#include "KoStore.h"
11#include <kritastore_export.h>
12
13
19class KRITASTORE_EXPORT KoStoreDevice : public QIODevice
20{
21 Q_OBJECT
22public:
24 explicit KoStoreDevice(KoStore * store) : m_store(store) {
25 // calligra-1.x behavior compat: a KoStoreDevice is automatically open
26 setOpenMode(m_store->mode() == KoStore::Read ? QIODevice::ReadOnly : QIODevice::WriteOnly);
27 }
28 ~KoStoreDevice() override;
29
30 bool isSequential() const override {
31 return true;
32 }
33
34 bool open(OpenMode m) override {
35 setOpenMode(m);
36 if (m & QIODevice::ReadOnly)
37 return (m_store->mode() == KoStore::Read);
38 if (m & QIODevice::WriteOnly)
39 return (m_store->mode() == KoStore::Write);
40 return false;
41 }
42 void close() override {}
43
44 qint64 size() const override {
45 if (m_store->mode() == KoStore::Read)
46 return m_store->size();
47 else
48 return 0xffffffff;
49 }
50
51 // See QIODevice
52 qint64 pos() const override {
53 return m_store->pos();
54 }
55 bool seek(qint64 pos) override {
56 return m_store->seek(pos);
57 }
58 bool atEnd() const override {
59 return m_store->atEnd();
60 }
61
62protected:
64
65 qint64 readData(char *data, qint64 maxlen) override {
66 return m_store->read(data, maxlen);
67 }
68
69 qint64 writeData(const char *data, qint64 len) override {
70 return m_store->write(data, len);
71 }
72
73};
74
75#endif
qint64 pos() const override
qint64 writeData(const char *data, qint64 len) override
KoStoreDevice(KoStore *store)
Note: KoStore::open() should be called before calling this.
qint64 size() const override
KoStore * m_store
bool isSequential() const override
bool atEnd() const override
qint64 readData(char *data, qint64 maxlen) override
void close() override
bool open(OpenMode m) override
bool seek(qint64 pos) override
qint64 write(const QByteArray &data)
Definition KoStore.cpp:198
@ Read
Definition KoStore.h:29
@ Write
Definition KoStore.h:29
QByteArray read(qint64 max)
Definition KoStore.cpp:181