diff options
Diffstat (limited to 'src/imagefactory.cpp')
-rw-r--r-- | src/imagefactory.cpp | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/src/imagefactory.cpp b/src/imagefactory.cpp index 574b199..0cc6acb 100644 --- a/src/imagefactory.cpp +++ b/src/imagefactory.cpp @@ -316,7 +316,7 @@ bool ImageFactory::writeCachedImage(const TQString& id_, CacheDir dir_, bool for const Tellico::Data::Image& ImageFactory::imageById(const TQString& id_) { if(id_.isEmpty()) { - myDebug() << "ImageFactory::imageById() - empty id" << endl; +// myDebug() << "ImageFactory::imageById() - empty id" << endl; return s_null; } // myLog() << "ImageFactory::imageById() - " << id_ << endl; @@ -348,7 +348,7 @@ const Tellico::Data::Image& ImageFactory::imageById(const TQString& id_) { if((s_imageInfoMap.contains(id_) && s_imageInfoMap[id_].linkOnly) || !KURL::isRelativeURL(id_)) { KURL u = id_; if(u.isValid()) { - return addImageImpl(u, false, KURL(), true); + return addImageImpl(u, true, KURL(), true); } } @@ -385,43 +385,53 @@ const Tellico::Data::Image& ImageFactory::imageById(const TQString& id_) { } } - // don't check Config::writeImagesInFile(), someday we might have problems - // and the image will exist in the data dir, but the app thinks everything should - // be in the zip file instead - bool exists = TQFile::exists(dataDir() + id_); - if(exists) { - // if we're loading from the application data dir, but images are being saved in the - // data file instead, then consider the document to be modified since it needs - // the image saved - if(Config::imageLocation() != Config::ImagesInAppDir) { + if(Config::imageLocation() == Config::ImagesInLocalDir) { + bool exists = TQFile::exists(localDir() + id_); + if(exists) { + const Data::Image& img2 = addCachedImageImpl(id_, LocalDir); + if(img2.isNull()) { + myDebug() << "ImageFactory::imageById() - tried to add from LocalDir, but failed: " << id_ << endl; + } else { +// myLog() << "...imageById() - found in local dir" << endl; + return img2; + } + } + // not an else statement, it might be null + if(TQFile::exists(dataDir() + id_)) { + // the img is in the other location + // consider the document to be modified since it needs the image saved Data::Document::self()->slotSetModified(true); + const Data::Image& img2 = addCachedImageImpl(id_, DataDir); + if(img2.isNull()) { + myDebug() << "ImageFactory::imageById() - tried to add from DataDir, but failed: " << id_ << endl; + } else { +// myLog() << "...imageById() - found in data dir" << endl; + return img2; + } } - const Data::Image& img2 = addCachedImageImpl(id_, DataDir); - if(img2.isNull()) { - myDebug() << "ImageFactory::imageById() - tried to add from DataDir, but failed: " << id_ << endl; - } else { -// myLog() << "...imageById() - found in data dir" << endl; - return img2; + } else if(Config::imageLocation() == Config::ImagesInAppDir) { + bool exists = TQFile::exists(dataDir() + id_); + if(exists) { + const Data::Image& img2 = addCachedImageImpl(id_, DataDir); + if(img2.isNull()) { + myDebug() << "ImageFactory::imageById() - tried to add from DataDir, but failed: " << id_ << endl; + } else { +// myLog() << "...imageById() - found in data dir" << endl; + return img2; + } } - } - // if localDir() == DataDir(), then there's nothing left to check - if(localDir() == dataDir()) { - return s_null; - } - exists = TQFile::exists(localDir() + id_); - if(exists) { - // if we're loading from the application data dir, but images are being saved in the - // data file instead, then consider the document to be modified since it needs - // the image saved - if(Config::imageLocation() != Config::ImagesInLocalDir) { + // not an else statement, it might be null + if(TQFile::exists(localDir() + id_)) { + // the img is in the other location + // consider the document to be modified since it needs the image saved Data::Document::self()->slotSetModified(true); - } - const Data::Image& img2 = addCachedImageImpl(id_, LocalDir); - if(img2.isNull()) { - myDebug() << "ImageFactory::imageById() - tried to add from LocalDir, but failed: " << id_ << endl; - } else { -// myLog() << "...imageById() - found in data dir" << endl; - return img2; + const Data::Image& img2 = addCachedImageImpl(id_, LocalDir); + if(img2.isNull()) { + myDebug() << "ImageFactory::imageById() - tried to add from LocalDir, but failed: " << id_ << endl; + } else { +// myLog() << "...imageById() - found in local dir" << endl; + return img2; + } } } myDebug() << "***ImageFactory::imageById() - not found: " << id_ << endl; |