kioslaves/thumbnail patch
Matthew Woehlke
mw_triad at users.sourceforge.net
Tue Aug 7 16:37:32 BST 2007
Anyone want to comment before I apply this (and later, similar patches
to kaddressbook, kbabel and ksim)?
(Actually, if someone else could patch kaddressbook that would be great,
as I currently don't build kdepim. I am also not subscribed to kde-pim,
so please CC me if replying only to that list.)
This is against kdebase/runtime/kioslaves/thumbnail:
Index: textcreator.cpp
===================================================================
--- textcreator.cpp (revision 697345)
+++ textcreator.cpp (working copy)
@@ -27,6 +27,35 @@
#include "textcreator.h"
+class FontSplitter {
+public:
+ FontSplitter() {}
+ virtual ~FontSplitter() {}
+
+protected:
+ int m_width;
+ QSize m_itemSize;
+ QPixmap m_pixmap;
+
+public:
+ void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; }
+ const QPixmap& pixmap() const { return m_pixmap; }
+
+ void setItemSize(const QSize &size) { m_itemSize = size; }
+ const QSize& itemSize() const { return m_itemSize; }
+
+ QRect coordinates(const QChar& ch) const {
+ int pos = (unsigned char)ch.toLatin1();
+ int numCols = m_pixmap.width() / m_itemSize.width();
+ if ( numCols == 0 )
+ return QRect();
+ int row = pos / numCols;
+ int col = pos % numCols;
+ return QRect( QPoint( col * m_itemSize.width(), row *
m_itemSize.height() ),
+ m_itemSize );
+ }
+};
+
extern "C"
{
KDE_EXPORT ThumbCreator *new_creator()
@@ -52,7 +81,7 @@
{
if ( !m_splitter )
{
- m_splitter = new KPixmapSplitter;
+ m_splitter = new FontSplitter;
QString pixmap = KStandardDirs::locate( "data",
"konqueror/pics/thumbnailfont_7x4.png" );
if ( !pixmap.isEmpty() )
{
Index: textcreator.h
===================================================================
--- textcreator.h (revision 697345)
+++ textcreator.h (working copy)
@@ -23,7 +23,7 @@
#include <QPixmap>
#include <kio/thumbcreator.h>
-class KPixmapSplitter;
+class FontSplitter;
class TextCreator : public ThumbCreator
{
@@ -34,7 +34,7 @@
virtual Flags flags() const;
private:
- KPixmapSplitter *m_splitter;
+ FontSplitter *m_splitter;
char *m_data;
int m_dataSize;
QPixmap m_pixmap;
--
Matthew
Somewhere, there is a .sig so funny that reading it will cause an
aneurism. This is not that .sig.
More information about the kde-core-devel
mailing list