KD Reports API Documentation
2.2
|
#include <KDReportsImageElement.h>
Public Member Functions | |
ImageElement (const ImageElement &other) | |
ImageElement (const QImage &image) | |
ImageElement (const QPixmap &pixmap) | |
~ImageElement () override | |
void | build (ReportBuilder &) const override |
Element * | clone () const override |
bool | fitToPage () const |
qreal | height () const |
QString | id () const |
QImage | image () const |
ImageElement & | operator= (const ImageElement &other) |
QPixmap | pixmap () const |
void | setFitToPage () |
void | setHeight (qreal height, Unit unit=Millimeters) |
void | setId (const QString &id) |
void | setImage (const QImage &image) |
void | setPixmap (const QPixmap &pixmap) |
void | setUnit (Unit unit) |
void | setWidth (qreal width, Unit unit=Millimeters) |
Unit | unit () const |
qreal | width () const |
Public Member Functions inherited from KDReports::Element | |
virtual | ~Element () |
QBrush | background () const |
void | setBackground (const QBrush &brush) |
Additional Inherited Members | |
Protected Member Functions inherited from KDReports::Element | |
Element () | |
Element (const Element &other) | |
Element & | operator= (const Element &other) |
The KDReports::ImageElement class represents an image in the report.
Definition at line 29 of file KDReportsImageElement.h.
|
explicit |
Creates a image element from the given pixmap. This constructor can only be used in the GUI thread.
Definition at line 35 of file KDReportsImageElement.cpp.
References pixmap(), and setPixmap().
|
explicit |
Creates a image element from the given image. This constructor can be used from secondary threads as well.
Definition at line 41 of file KDReportsImageElement.cpp.
References image(), and setImage().
|
override |
Destroys this image element.
Definition at line 62 of file KDReportsImageElement.cpp.
KDReports::ImageElement::ImageElement | ( | const ImageElement & | other | ) |
Copies a image element.
Definition at line 47 of file KDReportsImageElement.cpp.
|
overridevirtual |
Implements KDReports::Element.
Definition at line 128 of file KDReportsImageElement.cpp.
References KDReports::TextDocumentData::addResourceName(), KDReports::ReportBuilder::currentDocument(), KDReports::ReportBuilder::currentDocumentData(), KDReports::ReportBuilder::cursor(), KDReports::Millimeters, KDReports::mmToPixels(), KDReports::ReportBuilder::report(), KDReports::ResizableImageProperty, KDReports::TextDocumentData::setHasResizableImages(), and KDReports::TextDocumentData::updatePercentSize().
|
overridevirtual |
Implements KDReports::Element.
Definition at line 197 of file KDReportsImageElement.cpp.
bool KDReports::ImageElement::fitToPage | ( | ) | const |
Definition at line 123 of file KDReportsImageElement.cpp.
qreal KDReports::ImageElement::height | ( | ) | const |
QString KDReports::ImageElement::id | ( | ) | const |
Definition at line 192 of file KDReportsImageElement.cpp.
QImage KDReports::ImageElement::image | ( | ) | const |
Definition at line 85 of file KDReportsImageElement.cpp.
Referenced by ImageElement().
KDReports::ImageElement & KDReports::ImageElement::operator= | ( | const ImageElement & | other | ) |
Copies the data from another image element.
Definition at line 53 of file KDReportsImageElement.cpp.
References KDReports::Element::operator=().
QPixmap KDReports::ImageElement::pixmap | ( | ) | const |
Definition at line 74 of file KDReportsImageElement.cpp.
Referenced by ImageElement().
void KDReports::ImageElement::setFitToPage | ( | ) |
Requests that the image be scaled so that it fills the page as much as possible, while still preserving aspect ratio. This is mutually exclusive with setHeight/setWidth.
Definition at line 116 of file KDReportsImageElement.cpp.
void KDReports::ImageElement::setHeight | ( | qreal | height, |
Unit | unit = Millimeters |
||
) |
Sets the height of the image. The width of the image is calculated so that the aspect ratio is preserved. This is mutually exclusive with setWidth().
Definition at line 103 of file KDReportsImageElement.cpp.
void KDReports::ImageElement::setId | ( | const QString & | id | ) |
Set the ID associated with this image element.
Definition at line 187 of file KDReportsImageElement.cpp.
void KDReports::ImageElement::setImage | ( | const QImage & | image | ) |
Sets a new image for this image element. This replaces the pixmap or image set previously.
Definition at line 79 of file KDReportsImageElement.cpp.
Referenced by ImageElement().
void KDReports::ImageElement::setPixmap | ( | const QPixmap & | pixmap | ) |
Sets the pixmap for this image element. This replaces the pixmap or image set previously.
Definition at line 66 of file KDReportsImageElement.cpp.
Referenced by ImageElement().
void KDReports::ImageElement::setUnit | ( | KDReports::Unit | unit | ) |
Set the unit for the image size (percent or millimeters).
Definition at line 207 of file KDReportsImageElement.cpp.
void KDReports::ImageElement::setWidth | ( | qreal | width, |
Unit | unit = Millimeters |
||
) |
Sets the width of the image. The height of the image is calculated so that the aspect ratio is preserved.
The default size, if setWidth is not called, is the pixmap's size in pixels, which might lead to a different size depending on the resolution of the output device but avoids any resizing. On the other hand, setWidth makes sure that the layout of the document is always the same by resizing the pixmap if necessary.
For an image that should take half of the width of the page, call setWidth(50, KDReports::Percent).
Note that images inside table cells still have their width relative to the page, not to the cell. For instance setWidth(10, KDReports::Percent) means that the image width will be 10% of the page width, not 10% of the containing cell's width.
Definition at line 90 of file KDReportsImageElement.cpp.
KDReports::Unit KDReports::ImageElement::unit | ( | ) | const |
Definition at line 202 of file KDReportsImageElement.cpp.
qreal KDReports::ImageElement::width | ( | ) | const |