#include <q3richtext_p.h>
Inheritance diagram for Q3TextImage:


Definition at line 472 of file q3richtext_p.h.
Public Member Functions | |
| Q3TextImage (Q3TextDocument *p, const QMap< QString, QString > &attr, const QString &context, Q3MimeSourceFactory &factory) | |
| virtual | ~Q3TextImage () |
| Placement | placement () const |
| void | adjustToPainter (QPainter *) |
| int | minimumWidth () const |
| QString | richText () const |
| void | draw (QPainter *p, int x, int y, int cx, int cy, int cw, int ch, const QPalette &pal, bool selected) |
Private Attributes | |
| QRegion * | reg |
| QPixmap | pm |
| Placement | place |
| int | tmpwidth |
| int | tmpheight |
| QMap< QString, QString > | attributes |
| QString | imgId |
| Q3TextImage::Q3TextImage | ( | Q3TextDocument * | p, | |
| const QMap< QString, QString > & | attr, | |||
| const QString & | context, | |||
| Q3MimeSourceFactory & | factory | |||
| ) |
Definition at line 6585 of file q3richtext.cpp.
References QString::arg(), attributes, Q3ImageDrag::decode(), QMap< Key, T >::end(), QMap< Key, T >::find(), QPixmap::hasAlphaChannel(), QImage::height(), QPixmap::height(), Q3TextCustomItem::height, imgId, QString::isEmpty(), QImage::isNull(), QPixmap::isNull(), m, mask, QPixmap::mask(), pixmap_map, place, Q3TextCustomItem::PlaceInline, Q3TextCustomItem::PlaceLeft, Q3TextCustomItem::PlaceRight, pm, qCritical(), reg, QString::size(), tmpheight, tmpwidth, QPixmap::width(), Q3TextCustomItem::width, and QImage::width().
06587 : Q3TextCustomItem(p) 06588 { 06589 width = height = 0; 06590 06591 QMap<QString, QString>::ConstIterator it, end = attr.end(); 06592 it = attr.find("width"); 06593 if (it != end) 06594 width = (*it).toInt(); 06595 it = attr.find("height"); 06596 if (it != end) 06597 height = (*it).toInt(); 06598 06599 reg = 0; 06600 QString imageName = attr["src"]; 06601 06602 if (imageName.size() == 0) 06603 imageName = attr["source"]; 06604 06605 if (!imageName.isEmpty()) { 06606 imgId = QString("%1,%2,%3,%4").arg(imageName).arg(width).arg(height).arg((ulong)&factory); 06607 if (!pixmap_map) 06608 pixmap_map = new QMap<QString, QPixmapInt>; 06609 if (pixmap_map->contains(imgId)) { 06610 QPixmapInt& pmi = pixmap_map->operator[](imgId); 06611 pm = pmi.pm; 06612 pmi.ref++; 06613 width = pm.width(); 06614 height = pm.height(); 06615 } else { 06616 QImage img; 06617 const QMimeSource* m = 06618 factory.data(imageName, context); 06619 if (!m) { 06620 qCritical("Q3TextImage: no mimesource for %s", imageName.latin1()); 06621 } 06622 else { 06623 if (!Q3ImageDrag::decode(m, img)) { 06624 qCritical("Q3TextImage: cannot decode %s", imageName.latin1()); 06625 } 06626 } 06627 06628 if (!img.isNull()) { 06629 if (width == 0) { 06630 width = img.width(); 06631 if (height != 0) { 06632 width = img.width() * height / img.height(); 06633 } 06634 } 06635 if (height == 0) { 06636 height = img.height(); 06637 if (width != img.width()) { 06638 height = img.height() * width / img.width(); 06639 } 06640 } 06641 if (img.width() != width || img.height() != height){ 06642 #ifndef QT_NO_IMAGE_SMOOTHSCALE 06643 img = img.smoothScale(width, height); 06644 #endif 06645 width = img.width(); 06646 height = img.height(); 06647 } 06648 pm.convertFromImage(img); 06649 } 06650 if (!pm.isNull()) { 06651 QPixmapInt& pmi = pixmap_map->operator[](imgId); 06652 pmi.pm = pm; 06653 pmi.ref++; 06654 } 06655 } 06656 if (pm.hasAlphaChannel()) { 06657 QRegion mask(pm.mask()); 06658 QRegion all(0, 0, pm.width(), pm.height()); 06659 reg = new QRegion(all.subtracted(mask)); 06660 } 06661 } 06662 06663 if (pm.isNull() && (width*height)==0) 06664 width = height = 50; 06665 06666 place = PlaceInline; 06667 if (attr["align"] == "left") 06668 place = PlaceLeft; 06669 else if (attr["align"] == "right") 06670 place = PlaceRight; 06671 06672 tmpwidth = width; 06673 tmpheight = height; 06674 06675 attributes = attr; 06676 }
Here is the call graph for this function:

| Q3TextImage::~Q3TextImage | ( | ) | [virtual] |
Definition at line 6678 of file q3richtext.cpp.
References imgId, pixmap_map, and reg.
06679 { 06680 if (pixmap_map && pixmap_map->contains(imgId)) { 06681 QPixmapInt& pmi = pixmap_map->operator[](imgId); 06682 pmi.ref--; 06683 if (!pmi.ref) { 06684 pixmap_map->remove(imgId); 06685 if (pixmap_map->isEmpty()) { 06686 delete pixmap_map; 06687 pixmap_map = 0; 06688 } 06689 } 06690 } 06691 delete reg; 06692 }
| Placement Q3TextImage::placement | ( | ) | const [inline, virtual] |
Reimplemented from Q3TextCustomItem.
Definition at line 479 of file q3richtext_p.h.
Referenced by draw().
00479 { return place; }
| void Q3TextImage::adjustToPainter | ( | QPainter * | ) | [virtual] |
Reimplemented from Q3TextCustomItem.
Definition at line 6710 of file q3richtext.cpp.
References Q3TextCustomItem::height, p, scale(), tmpheight, tmpwidth, and Q3TextCustomItem::width.
Here is the call graph for this function:

| int Q3TextImage::minimumWidth | ( | ) | const [inline, virtual] |
Reimplemented from Q3TextCustomItem.
Definition at line 481 of file q3richtext_p.h.
References width.
00481 { return width; }
| QString Q3TextImage::richText | ( | ) | const [virtual] |
Reimplemented from Q3TextCustomItem.
Definition at line 6694 of file q3richtext.cpp.
References attributes, QMap< Key, T >::begin(), QMap< Key, T >::end(), QMap< Key, T >::key(), and s.
06695 { 06696 QString s; 06697 s += "<img "; 06698 QMap<QString, QString>::ConstIterator it = attributes.begin(); 06699 for (; it != attributes.end(); ++it) { 06700 s += it.key() + "="; 06701 if ((*it).contains(' ')) 06702 s += "\"" + *it + "\" "; 06703 else 06704 s += *it + " "; 06705 } 06706 s += ">"; 06707 return s; 06708 }
Here is the call graph for this function:

| void Q3TextImage::draw | ( | QPainter * | p, | |
| int | x, | |||
| int | y, | |||
| int | cx, | |||
| int | cy, | |||
| int | cw, | |||
| int | ch, | |||
| const QPalette & | pal, | |||
| bool | selected | |||
| ) | [virtual] |
Implements Q3TextCustomItem.
Definition at line 6737 of file q3richtext.cpp.
References QPalette::dark(), Qt::Dense4Pattern, QPixmap::height(), Q3TextCustomItem::height, QPalette::highlight(), is_printer(), QPixmap::isNull(), p, Q3TextCustomItem::PlaceInline, placement(), pm, QPixmap::size(), QPixmap::width(), Q3TextCustomItem::width, Q3TextCustomItem::xpos, and Q3TextCustomItem::ypos.
06739 { 06740 if (placement() != PlaceInline) { 06741 x = xpos; 06742 y = ypos; 06743 } 06744 06745 if (pm.isNull()) { 06746 p->fillRect(x , y, width, height, pal.dark()); 06747 return; 06748 } 06749 06750 if (is_printer(p)) { 06751 p->drawPixmap(QRect(x, y, width, height), pm); 06752 return; 06753 } 06754 06755 if (placement() != PlaceInline && !QRect(xpos, ypos, width, height).intersects(QRect(cx, cy, cw, ch))) 06756 return; 06757 06758 if (placement() == PlaceInline) 06759 p->drawPixmap(x , y, pm); 06760 else 06761 p->drawPixmap(cx , cy, pm, cx - x, cy - y, cw, ch); 06762 06763 if (selected && placement() == PlaceInline && is_printer(p)) { 06764 #if defined(Q_WS_X11) 06765 p->fillRect(QRect(QPoint(x, y), pm.size()), QBrush(pal.highlight(), 06766 Qt::Dense4Pattern)); 06767 #else // in WIN32 Qt::Dense4Pattern doesn't work correctly (transparency problem), so work around it 06768 if (!qrt_selection) 06769 qrt_createSelectionPixmap(pal); 06770 p->drawTiledPixmap(x, y, pm.width(), pm.height(), *qrt_selection); 06771 #endif 06772 } 06773 }
Here is the call graph for this function:

QRegion* Q3TextImage::reg [private] |
QPixmap Q3TextImage::pm [private] |
Placement Q3TextImage::place [private] |
int Q3TextImage::tmpwidth [private] |
int Q3TextImage::tmpheight [private] |
QMap<QString, QString> Q3TextImage::attributes [private] |
QString Q3TextImage::imgId [private] |
1.5.1