Diffstat (limited to 'noncore/apps/opie-write/qrichtext.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qrichtext.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp index c27eb1e..f040f1e 100644 --- a/noncore/apps/opie-write/qrichtext.cpp +++ b/noncore/apps/opie-write/qrichtext.cpp @@ -6031,73 +6031,72 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa QString s = style.mid( 16 ).stripWhiteSpace(); format.fn.setUnderline( s == "underline" ); } else if ( style.startsWith("vertical-align:" ) ) { QString s = style.mid( 15 ).stripWhiteSpace(); if ( s == "sub" ) format.setVAlign( QTextFormat::AlignSubScript ); else if ( s == "super" ) format.setVAlign( QTextFormat::AlignSuperScript ); else format.setVAlign( QTextFormat::AlignNormal ); } else if ( style.startsWith("color:" ) ) { format.col.setNamedColor( style.mid(6) ); format.linkColor = FALSE; } } } format.update(); return format; } struct QPixmapInt { QPixmapInt() : ref( 0 ) {} QPixmap pm; int ref; }; static QMap<QString, QPixmapInt> *pixmap_map = 0; QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, QMimeSourceFactory &factory ) - : QTextCustomItem( p ) + : QTextCustomItem( p ), reg( 0 ) { width = height = 0; if ( attr.contains("width") ) width = attr["width"].toInt(); if ( attr.contains("height") ) height = attr["height"].toInt(); - reg = 0; QString imageName = attr["src"]; if (!imageName) imageName = attr["source"]; if ( !imageName.isEmpty() ) { imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); if ( !pixmap_map ) pixmap_map = new QMap<QString, QPixmapInt>; if ( pixmap_map->contains( imgId ) ) { QPixmapInt& pmi = pixmap_map->operator[](imgId); pm = pmi.pm; pmi.ref++; width = pm.width(); height = pm.height(); } else { QImage img; const QMimeSource* m = factory.data( imageName, context ); if ( !m ) { owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl; } else { if ( !QImageDrag::decode( m, img ) ) { owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl; } } if ( !img.isNull() ) { if ( width == 0 ) { width = img.width(); if ( height != 0 ) { @@ -6120,76 +6119,76 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co pm.convertFromImage( img ); } if ( !pm.isNull() ) { QPixmapInt& pmi = pixmap_map->operator[](imgId); pmi.pm = pm; pmi.ref++; } } if ( pm.mask() ) { QRegion mask( *pm.mask() ); QRegion all( 0, 0, pm.width(), pm.height() ); reg = new QRegion( all.subtract( mask ) ); } } if ( pm.isNull() && (width*height)==0 ) width = height = 50; place = PlaceInline; if ( attr["align"] == "left" ) place = PlaceLeft; else if ( attr["align"] == "right" ) place = PlaceRight; tmpwidth = width; tmpheight = height; attributes = attr; } QTextImage::~QTextImage() { + delete reg; if ( pixmap_map && pixmap_map->contains( imgId ) ) { QPixmapInt& pmi = pixmap_map->operator[](imgId); pmi.ref--; if ( !pmi.ref ) { pixmap_map->remove( imgId ); if ( pixmap_map->isEmpty() ) { delete pixmap_map; pixmap_map = 0; } } } - delete reg; } QString QTextImage::richText() const { QString s; s += "<img "; QMap<QString, QString>::ConstIterator it = attributes.begin(); for ( ; it != attributes.end(); ++it ) s += it.key() + "=" + *it + " "; s += ">"; return s; } void QTextImage::adjustToPainter( QPainter* p ) { width = scale( tmpwidth, p ); height = scale( tmpheight, p ); } #if !defined(Q_WS_X11) #include <qbitmap.h> #include "qcleanuphandler.h" static QPixmap *qrt_selection = 0; static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap; static void qrt_createSelectionPixmap( const QColorGroup &cg ) { qrt_selection = new QPixmap( 2, 2 ); qrt_cleanup_pixmap.set( &qrt_selection ); qrt_selection->fill( Qt::color0 ); QBitmap m( 2, 2 ); m.fill( Qt::color1 ); QPainter p( &m ); |