Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a29b20e1 authored by Thomas Zander's avatar Thomas Zander

Make the load method available for reuse and rename it more generally

svn path=/trunk/koffice/; revision=691897
parent 6eabaea9
......@@ -55,7 +55,7 @@ bool KoImageCollection::loadFromStore(KoStore *store) {
foreach(KoImageData *image, d->images) {
if(! store->open(image->storeHref()))
return false;
bool ok = image->loadFromStore(new KoStoreDevice(store));
bool ok = image->loadFromFile(new KoStoreDevice(store));
store->close();
if(! ok)
return false;
......
......@@ -131,7 +131,7 @@ QString KoImageData::storeHref() const {
return d->storeHref;
}
bool KoImageData::loadFromStore(QIODevice *device) {
bool KoImageData::loadFromFile(QIODevice *device) {
struct Finally {
Finally(QIODevice *d) : device (d), bytes(0) {}
~Finally() {
......@@ -143,6 +143,11 @@ bool KoImageData::loadFromStore(QIODevice *device) {
};
Finally finally(device);
// remove prev data
delete d->tempImageFile;
d->tempImageFile = 0;
d->image = QImage();
if(device->size() > 25E4) { // larger than 250Kb, save to tmp file.
d->tempImageFile = new KTemporaryFile();
if(! d->tempImageFile->open())
......@@ -166,7 +171,7 @@ bool KoImageData::loadFromStore(QIODevice *device) {
}
bytes -= written;
}
if(failed) { // read or write failed; so lets clealy abort.
if(failed) { // read or write failed; so lets cleanly abort.
delete d->tempImageFile;
d->tempImageFile = 0;
return false;
......@@ -186,4 +191,3 @@ bool KoImageData::loadFromStore(QIODevice *device) {
const QImage KoImageData::image() const {
return d->image;
}
......@@ -122,7 +122,7 @@ public:
* @para device the device that is used to get the data from.
* @return returns true if load was successful.
*/
bool loadFromStore(QIODevice *device);
bool loadFromFile(QIODevice *device);
bool operator==(const KoImageData &other) {
return other.d == d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment