[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/gwenview
From: Aurélien Gâteau <aurelien.gateau () free ! fr>
Date: 2007-10-11 8:31:37
Message-ID: 1192091497.860244.17152.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 724050 by gateau:
Make ThumbnailView draw modified overlay itself, so that it's not scaled when thumbnail size changes.
M +0 -7 app/thumbnailviewhelper.cpp
M +39 -1 lib/thumbnailview.cpp
M +6 -0 lib/thumbnailview.h
--- trunk/KDE/kdegraphics/gwenview/app/thumbnailviewhelper.cpp #724049:724050
@@ -82,13 +82,6 @@
if (image.width() > THUMBNAIL_SIZE || image.height() > THUMBNAIL_SIZE) {
image = image.scaled(THUMBNAIL_SIZE, THUMBNAIL_SIZE, Qt::KeepAspectRatio);
}
- QPainter painter(&image);
- QPixmap pix = SmallIcon("document-save");
- painter.drawPixmap(
- image.width() - pix.width(),
- image.height() - pix.height(),
- pix);
- painter.end();
thumbnailLoaded(item, QPixmap::fromImage(image));
continue;
}
--- trunk/KDE/kdegraphics/gwenview/lib/thumbnailview.cpp #724049:724050
@@ -32,6 +32,7 @@
// Local
#include "archiveutils.h"
#include "abstractthumbnailviewhelper.h"
+#include <lib/document/documentfactory.h>
namespace Gwenview {
@@ -52,7 +53,9 @@
PreviewItemDelegate(ThumbnailView* view)
: QAbstractItemDelegate(view)
, mView(view)
- {}
+ {
+ mModifiedPixmap = SmallIcon("document-save", 22);
+ }
void clearElidedTextMap() {
@@ -152,6 +155,23 @@
thumbnailRect.top() + (thumbnailRect.height() - thumbnail.height()) / 2,
thumbnail);
+ // Draw modified overlay
+ if (mView->isModified(index)) {
+ QRect overlayRect = QRect(
+ thumbnailRect.right() - mModifiedPixmap.width() + 1,
+ thumbnailRect.bottom() - mModifiedPixmap.height() + 1,
+ mModifiedPixmap.width(),
+ mModifiedPixmap.height());
+ const int overlayMargin = 2;
+ overlayRect.adjust(-2*overlayMargin, -2*overlayMargin, 0, 0);
+
+ painter->fillRect(overlayRect, QColor(0, 0, 0, 128));
+ painter->drawPixmap(
+ overlayRect.left() + overlayMargin,
+ overlayRect.top() + overlayMargin,
+ mModifiedPixmap);
+ }
+
// Draw text
painter->setPen(fgColor);
@@ -196,6 +216,7 @@
mutable QMap<QString, QString> mElidedTextMap;
ThumbnailView* mView;
+ QPixmap mModifiedPixmap;
};
@@ -243,6 +264,7 @@
setSpacing(SPACING);
}
+
int ThumbnailView::thumbnailSize() const {
return d->mThumbnailSize;
}
@@ -328,4 +350,20 @@
return QPixmap();
}
+
+bool ThumbnailView::isModified(const QModelIndex& index) const {
+ QVariant data = index.data(KDirModel::FileItemRole);
+ KFileItem item = qvariant_cast<KFileItem>(data);
+ QUrl url = item.url();
+ DocumentFactory* factory = DocumentFactory::instance();
+
+ if (factory->hasUrl(url)) {
+ Document::Ptr doc = factory->load(item.url());
+ return doc->isLoaded() && doc->isModified();
+ } else {
+ return false;
+ }
+}
+
+
} // namespace
--- trunk/KDE/kdegraphics/gwenview/lib/thumbnailview.h #724049:724050
@@ -60,6 +60,12 @@
QPixmap thumbnailForIndex(const QModelIndex&);
+ /**
+ * Returns true if the document pointed by the index has been modified
+ * inside Gwenview.
+ */
+ bool isModified(const QModelIndex&) const;
+
public Q_SLOTS:
/**
* Sets the thumbnail size, in pixels.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic