summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write/qrichtext.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-write/qrichtext.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp5
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
@@ -6051,33 +6051,32 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
6051 6051
6052struct QPixmapInt 6052struct QPixmapInt
6053{ 6053{
6054 QPixmapInt() : ref( 0 ) {} 6054 QPixmapInt() : ref( 0 ) {}
6055 QPixmap pm; 6055 QPixmap pm;
6056 int ref; 6056 int ref;
6057}; 6057};
6058 6058
6059static QMap<QString, QPixmapInt> *pixmap_map = 0; 6059static QMap<QString, QPixmapInt> *pixmap_map = 0;
6060 6060
6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 6061QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
6062 QMimeSourceFactory &factory ) 6062 QMimeSourceFactory &factory )
6063 : QTextCustomItem( p ) 6063 : QTextCustomItem( p ), reg( 0 )
6064{ 6064{
6065 width = height = 0; 6065 width = height = 0;
6066 if ( attr.contains("width") ) 6066 if ( attr.contains("width") )
6067 width = attr["width"].toInt(); 6067 width = attr["width"].toInt();
6068 if ( attr.contains("height") ) 6068 if ( attr.contains("height") )
6069 height = attr["height"].toInt(); 6069 height = attr["height"].toInt();
6070 6070
6071 reg = 0;
6072 QString imageName = attr["src"]; 6071 QString imageName = attr["src"];
6073 6072
6074 if (!imageName) 6073 if (!imageName)
6075 imageName = attr["source"]; 6074 imageName = attr["source"];
6076 6075
6077 if ( !imageName.isEmpty() ) { 6076 if ( !imageName.isEmpty() ) {
6078 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); 6077 imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
6079 if ( !pixmap_map ) 6078 if ( !pixmap_map )
6080 pixmap_map = new QMap<QString, QPixmapInt>; 6079 pixmap_map = new QMap<QString, QPixmapInt>;
6081 if ( pixmap_map->contains( imgId ) ) { 6080 if ( pixmap_map->contains( imgId ) ) {
6082 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6081 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6083 pm = pmi.pm; 6082 pm = pmi.pm;
@@ -6140,36 +6139,36 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co
6140 place = PlaceLeft; 6139 place = PlaceLeft;
6141 else if ( attr["align"] == "right" ) 6140 else if ( attr["align"] == "right" )
6142 place = PlaceRight; 6141 place = PlaceRight;
6143 6142
6144 tmpwidth = width; 6143 tmpwidth = width;
6145 tmpheight = height; 6144 tmpheight = height;
6146 6145
6147 attributes = attr; 6146 attributes = attr;
6148} 6147}
6149 6148
6150QTextImage::~QTextImage() 6149QTextImage::~QTextImage()
6151{ 6150{
6151 delete reg;
6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) { 6152 if ( pixmap_map && pixmap_map->contains( imgId ) ) {
6153 QPixmapInt& pmi = pixmap_map->operator[](imgId); 6153 QPixmapInt& pmi = pixmap_map->operator[](imgId);
6154 pmi.ref--; 6154 pmi.ref--;
6155 if ( !pmi.ref ) { 6155 if ( !pmi.ref ) {
6156 pixmap_map->remove( imgId ); 6156 pixmap_map->remove( imgId );
6157 if ( pixmap_map->isEmpty() ) { 6157 if ( pixmap_map->isEmpty() ) {
6158 delete pixmap_map; 6158 delete pixmap_map;
6159 pixmap_map = 0; 6159 pixmap_map = 0;
6160 } 6160 }
6161 } 6161 }
6162 } 6162 }
6163 delete reg;
6164} 6163}
6165 6164
6166QString QTextImage::richText() const 6165QString QTextImage::richText() const
6167{ 6166{
6168 QString s; 6167 QString s;
6169 s += "<img "; 6168 s += "<img ";
6170 QMap<QString, QString>::ConstIterator it = attributes.begin(); 6169 QMap<QString, QString>::ConstIterator it = attributes.begin();
6171 for ( ; it != attributes.end(); ++it ) 6170 for ( ; it != attributes.end(); ++it )
6172 s += it.key() + "=" + *it + " "; 6171 s += it.key() + "=" + *it + " ";
6173 s += ">"; 6172 s += ">";
6174 return s; 6173 return s;
6175} 6174}