add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
endif()
+add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5003)
+
## Dependencies
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
struct ImageOpsContextManagerItem::Private
{
ImageOpsContextManagerItem* q;
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
/**
* This widget is capable of showing multiple lines of key/value pairs.
*/
void InfoContextManagerItem::updateSideBarContent()
{
- LOG("updateSideBarContent");
+ kDebug() << "updateSideBarContent";
if (!d->mGroup->isVisible()) {
- LOG("updateSideBarContent: not visible, not updating");
+ kDebug() << "updateSideBarContent: not visible, not updating";
return;
}
- LOG("updateSideBarContent: really updating");
+ kDebug() << "updateSideBarContent: really updating";
KFileItemList itemList = contextManager()->selectedFileItemList();
if (itemList.count() == 0) {
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
static const int BROWSE_PRELOAD_DELAY = 1000;
static const int VIEW_PRELOAD_DELAY = 100;
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
struct PreloaderPrivate
{
Preloader* q;
void Preloader::preload(const KUrl& url, const QSize& size)
{
- LOG("url=" << url);
+ kDebug() << "url=" << url;
if (d->mDocument) {
disconnect(d->mDocument.data(), 0, this, 0);
}
SLOT(doPreload()));
if (d->mDocument->size().isValid()) {
- LOG("size is already available");
+ kDebug() << "size is already available";
doPreload();
}
}
}
if (d->mDocument->loadingState() == Document::LoadingFailed) {
- LOG("loading failed");
+ kDebug() << "loading failed";
d->forgetDocument();
return;
}
if (!d->mDocument->size().isValid()) {
- LOG("size not available yet");
+ kDebug() << "size not available yet";
return;
}
);
if (zoom < Document::maxDownSampledZoom()) {
- LOG("preloading down sampled, zoom=" << zoom);
+ kDebug() << "preloading down sampled, zoom=" << zoom;
d->mDocument->prepareDownSampledImageForZoom(zoom);
} else {
- LOG("preloading full image");
+ kDebug() << "preloading full image";
d->mDocument->startLoadingFullImage();
}
d->forgetDocument();
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
const int ViewMainPage::MaxViewCount = 6;
static QString rgba(const QColor &color)
Document::Ptr ViewMainPage::currentDocument() const
{
if (!d->currentView()) {
- LOG("!d->documentView()");
+ kDebug() << "!d->documentView()";
return Document::Ptr();
}
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
-#ifdef ENABLE_LOG
-
static void logQueue(DocumentPrivate* d)
{
#define PREFIX " QUEUE: "
}
#define LOG_QUEUE(msg, d) \
- LOG(msg); \
+ kDebug() << msg; \
logQueue(d)
-#else
-
-#define LOG_QUEUE(msg, d)
-
-#endif
-
//- DocumentPrivate ---------------------------------------
void DocumentPrivate::scheduleImageLoading(int invertedZoom)
{
void DocumentPrivate::scheduleImageDownSampling(int invertedZoom)
{
- LOG("invertedZoom=" << invertedZoom);
+ kDebug() << "invertedZoom=" << invertedZoom;
DownSamplingJob* job = qobject_cast<DownSamplingJob*>(mCurrentJob.data());
if (job && job->mInvertedZoom == invertedZoom) {
- LOG("Current job is already doing it");
+ kDebug() << "Current job is already doing it";
return;
}
}
if (job->mInvertedZoom == invertedZoom) {
// Already scheduled, nothing to do
- LOG("Already scheduled");
+ kDebug() << "Already scheduled";
return;
} else {
- LOG("Removing downsampling job");
+ kDebug() << "Removing downsampling job";
mJobQueue.erase(it);
delete job;
}
void Document::switchToImpl(AbstractDocumentImpl* impl)
{
Q_ASSERT(impl);
- LOG("old impl:" << d->mImpl << "new impl:" << impl);
+ kDebug() << "old impl:" << d->mImpl << "new impl:" << impl;
if (d->mImpl) {
d->mImpl->deleteLater();
}
int invertedZoom = invertedZoomForZoom(zoom);
if (d->mDownSampledImageMap.contains(invertedZoom)) {
- LOG("downSampledImageForZoom=" << zoom << "invertedZoom=" << invertedZoom << "ready");
+ kDebug() << "downSampledImageForZoom=" << zoom << "invertedZoom=" << invertedZoom << "ready";
return true;
}
- LOG("downSampledImageForZoom=" << zoom << "invertedZoom=" << invertedZoom << "not ready");
+ kDebug() << "downSampledImageForZoom=" << zoom << "invertedZoom=" << invertedZoom << "not ready";
if (loadingState() == LoadingFailed) {
kWarning() << "Image has failed to load, not doing anything";
return false;
void Document::enqueueJob(DocumentJob* job)
{
- LOG("job=" << job);
+ kDebug() << "job=" << job;
job->setDocument(Ptr(this));
connect(job, SIGNAL(finished(KJob*)),
SLOT(slotJobFinished(KJob*)));
d->mJobQueue.enqueue(job);
} else {
d->mCurrentJob = job;
- LOG("Starting first job");
+ kDebug() << "Starting first job";
job->start();
busyChanged(d->mUrl, true);
}
void Document::slotJobFinished(KJob* job)
{
- LOG("job=" << job);
+ kDebug() << "job=" << job;
GV_RETURN_IF_FAIL(job == d->mCurrentJob.data());
if (d->mJobQueue.isEmpty()) {
- LOG("All done");
+ kDebug() << "All done";
d->mCurrentJob.clear();
busyChanged(d->mUrl, false);
allTasksDone();
} else {
- LOG("Starting next job");
+ kDebug() << "Starting next job";
d->mCurrentJob = d->mJobQueue.dequeue();
GV_RETURN_IF_FAIL(d->mCurrentJob);
d->mCurrentJob.data()->start();
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
inline int getMaxUnreferencedImages()
{
int defaultValue = 3;
unreferencedIt = unreferencedImages.erase(unreferencedIt))
{
KUrl url = unreferencedIt.value();
- LOG("Collecting" << url);
+ kDebug() << "Collecting" << url;
it = map.find(url);
Q_ASSERT(it != map.end());
delete it.value();
map.erase(it);
}
-#ifdef ENABLE_LOG
logDocumentMap(map);
-#endif
}
void logDocumentMap(const DocumentMap& map)
DocumentMap::Iterator it = d->mDocumentMap.find(url);
if (it != d->mDocumentMap.end()) {
- LOG(url.fileName() << "url in mDocumentMap");
+ kDebug() << url.fileName() << "url in mDocumentMap";
info = it.value();
info->mLastAccess = QDateTime::currentDateTime();
return info->mDocument;
// At this point we couldn't find the document in the map
// Start loading the document
- LOG(url.fileName() << "loading");
+ kDebug() << url.fileName() << "loading";
Document* doc = new Document(url);
connect(doc, SIGNAL(loaded(KUrl)),
SLOT(slotLoaded(KUrl)));
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
const int HEADER_SIZE = 256;
struct LoadingDocumentImplPrivate
mimeType = KMimeType::findByContent(mData)->name();
}
MimeTypeUtils::Kind kind = MimeTypeUtils::mimeTypeKind(mimeType);
- LOG("mimeType:" << mimeType);
- LOG("kind:" << kind);
+ kDebug() << "mimeType:" << mimeType << ", kind:" << kind;
q->setDocumentKind(kind);
switch (kind) {
void startImageDataLoading()
{
- LOG("");
+ kDebug() << "Starting image loading";
Q_ASSERT(mMetaInfoLoaded);
Q_ASSERT(mImageDataInvertedZoom != 0);
Q_ASSERT(!mImageDataFutureWatcher->isRunning());
bool loadMetaInfo()
{
- LOG("mFormatHint" << mFormatHint);
+ kDebug() << "mFormatHint" << mFormatHint;
QBuffer buffer;
buffer.setBuffer(&mData);
buffer.open(QIODevice::ReadOnly);
mFormat = reader.format();
- LOG("mFormat" << mFormat);
+ kDebug() << "mFormat" << mFormat;
GV_RETURN_VALUE_IF_FAIL(!mFormat.isEmpty(), false);
- LOG("mImageSize" << mImageSize);
+ kDebug() << "mImageSize" << mImageSize;
return true;
}
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer, mFormat);
- LOG("mImageDataInvertedZoom=" << mImageDataInvertedZoom);
+ kDebug() << "mImageDataInvertedZoom=" << mImageDataInvertedZoom;
if (mImageSize.isValid()
&& mImageDataInvertedZoom != 1
&& reader.supportsOption(QImageIOHandler::ScaledSize)
// image size
QSize size = reader.size() / mImageDataInvertedZoom;
if (!size.isEmpty()) {
- LOG("Setting scaled size to" << size);
+ kDebug() << "Setting scaled size to" << size;
reader.setScaledSize(size);
} else {
- LOG("Not setting scaled size as it is empty" << size);
+ kDebug() << "Not setting scaled size as it is empty" << size;
}
}
bool ok = reader.read(&mImage);
if (!ok) {
- LOG("QImageReader::read() failed");
+ kDebug() << "QImageReader::read() failed";
return;
}
&& reader.nextImageDelay() > 0 // Assume delay == 0 <=> only one frame
) {
if (reader.imageCount() > 0) {
- LOG("Really an animated image");
+ kDebug() << "Really an animated image";
mAnimated = true;
return;
}
* Decoding the next frame is the only reliable way I found to
* detect an animated images
*/
- LOG("May be an animated image. delay:" << reader.nextImageDelay());
+ kDebug() << "May be an animated image. delay:" << reader.nextImageDelay();
QImage nextImage;
if (reader.read(&nextImage)) {
- LOG("Really an animated image (more than one frame)");
+ kDebug() << "Really an animated image (more than one frame)";
mAnimated = true;
} else {
kWarning() << q->document()->url() << "is not really an animated image (only one frame)";
LoadingDocumentImpl::~LoadingDocumentImpl()
{
- LOG("");
// Disconnect watchers to make sure they do not trigger further work
if (d->mMetaInfoFutureWatcher) {
d->mMetaInfoFutureWatcher->disconnect();
void LoadingDocumentImpl::loadImage(int invertedZoom)
{
if (d->mImageDataInvertedZoom == invertedZoom) {
- LOG("Already loading an image at invertedZoom=" << invertedZoom);
+ kDebug() << "Already loading an image at invertedZoom=" << invertedZoom;
return;
}
if (d->mImageDataInvertedZoom == 1) {
- LOG("Ignoring request: we are loading a full image");
+ kDebug() << "Ignoring request: we are loading a full image";
return;
}
if (d->mImageDataFutureWatcher) {
void LoadingDocumentImpl::slotMetaInfoLoaded()
{
- LOG("");
+ kDebug() << "Meta information loaded";
Q_ASSERT(!d->mMetaInfoFutureWatcher->isRunning());
if (!d->mMetaInfoFutureWatcher->result()) {
setDocumentErrorString(
void LoadingDocumentImpl::slotImageLoaded()
{
- LOG("");
+ kDebug() << "Image loaded";
if (d->mImage.isNull()) {
setDocumentErrorString(
i18nc("@info", "Loading image failed.")
}
if (d->mImageDataInvertedZoom != 1 && d->mImage.size() != d->mImageSize) {
- LOG("Loaded a down sampled image");
+ kDebug() << "Loaded a down sampled image";
d->mDownSampledImageLoaded = true;
// We loaded a down sampled image
setDocumentDownSampledImage(d->mImage, d->mImageDataInvertedZoom);
return;
}
- LOG("Loaded a full image");
+ kDebug() << "Loaded a full image";
setDocumentImage(d->mImage);
DocumentLoadedImpl* impl;
impl = new DocumentLoadedImpl(
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
static const qreal REAL_DELTA = 0.001;
static const qreal MAXIMUM_ZOOM_VALUE = qreal(DocumentView::MaximumZoom);
const MimeTypeUtils::Kind documentKind = d->mDocument->kind();
if (d->mAdapter && documentKind == d->mAdapter->kind() && documentKind != MimeTypeUtils::KIND_UNKNOWN) {
// Do not reuse for KIND_UNKNOWN: we may need to change the message
- LOG("Reusing current adapter");
+ kDebug() << "Reusing current adapter";
return;
}
AbstractDocumentViewAdapter* adapter = 0;
#include <lib/document/document.h>
#include <lib/paintutils.h>
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
namespace Gwenview
{
void ImageScaler::setDestinationRegion(const QRegion& region)
{
- LOG(region);
+ kDebug() << region;
d->mRegion = region;
if (d->mRegion.isEmpty()) {
return;
{
if (d->mZoom < Document::maxDownSampledZoom()) {
if (!d->mDocument->prepareDownSampledImageForZoom(d->mZoom)) {
- LOG("Asked for a down sampled image");
+ kDebug() << "Asked for a down sampled image";
return;
}
} else if (d->mDocument->image().isNull()) {
- LOG("Asked for the full image");
+ kDebug() << "Asked for the full image";
d->mDocument->startLoadingFullImage();
return;
}
- LOG("Starting");
+ kDebug() << "Starting";
Q_FOREACH(const QRect & rect, d->mRegion.rects()) {
- LOG(rect);
+ kDebug() << rect;
scaleRect(rect);
}
- LOG("Done");
+ kDebug() << "Done";
}
void ImageScaler::scaleRect(const QRect& rect)
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
enum State {
Stopped,
Started,
void doStart()
{
- LOG("mState = Started");
+ kDebug() << "mState = Started";
mTimer->start();
mState = Started;
}
void SlideShow::stop()
{
- LOG("Stopping timer");
+ kDebug() << "Stopping timer";
d->mTimer->stop();
d->mState = Stopped;
stateChanged(false);
void SlideShow::resumeAndGoToNextUrl()
{
- LOG("");
if (d->mState == WaitForEndOfUrl) {
goToNextUrl();
}
void SlideShow::goToNextUrl()
{
- LOG("");
KUrl url = d->findNextUrl();
- LOG("url:" << url);
+ kDebug() << "Next url:" << url;
if (!url.isValid()) {
stop();
return;
void SlideShow::setCurrentUrl(const KUrl& url)
{
- LOG(url);
+ kDebug() << "Current url" << url;
if (d->mCurrentUrl == url) {
return;
}
namespace Gwenview
{
-#undef ENABLE_LOG
-#undef LOG
-//#define ENABLE_LOG
-#ifdef ENABLE_LOG
-#define LOG(x) kDebug() << x
-#else
-#define LOG(x) ;
-#endif
-
/** How many msec to wait before starting to smooth thumbnails */
static const int THUMBNAIL_DELAY = 500;
static KFileItem fileItemForIndex(const QModelIndex& index)
{
if (!index.isValid()) {
- LOG("Invalid index");
+ kDebug() << "Invalid index";
return KFileItem();
}
QVariant data = index.data(KDirModel::FileItemRole);
{
KFileItem item = fileItemForIndex(index);
if (item.isNull()) {
- LOG("Invalid item");
+ kDebug() << "Invalid item";
if (fullSize) {
*fullSize = QSize();
}