0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +03:00

Finish 1.5.43

This commit is contained in:
Arin Alexander 2020-03-19 20:29:37 +03:00
commit efe6fd2cb2
16 changed files with 190 additions and 36 deletions

View File

@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5 LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 42 LIMEREPORT_VERSION_RELEASE = 43
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -0,0 +1,20 @@
#ifndef LREDITABLEIMAGEITEMINTF_H
#define LREDITABLEIMAGEITEMINTF_H
#include <QByteArray>
namespace LimeReport {
class IEditableImageItem{
public:
virtual QByteArray imageAsByteArray() const = 0;
virtual void setImageAsByteArray(QByteArray image) = 0;
virtual QString resourcePath() const = 0;
virtual void setResourcePath(const QString &value) = 0;
virtual QString fileFilter() const = 0;
};
}
#endif // LREDITABLEIMAGEITEMINTF_H

View File

@ -141,6 +141,37 @@ QWidget *ImageItem::defaultEditor()
return editor; return editor;
} }
QByteArray ImageItem::imageAsByteArray() const
{
QByteArray result;
QBuffer buffer(&result);
buffer.open(QIODevice::WriteOnly);
m_picture.save(&buffer,"PNG");
return result;
}
void ImageItem::setImageAsByteArray(QByteArray image)
{
QImage value;
value.loadFromData(image);
if (m_picture != value){
QImage oldValue = m_picture;
m_picture = value;
if (m_autoSize){
setWidth(m_picture.width());
setHeight(m_picture.height());
}
update();
notify("image",oldValue,value);
}
}
QString ImageItem::fileFilter() const
{
return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)");
}
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{ {

View File

@ -30,11 +30,12 @@
#ifndef LRIMAGEITEM_H #ifndef LRIMAGEITEM_H
#define LRIMAGEITEM_H #define LRIMAGEITEM_H
#include "lritemdesignintf.h" #include "lritemdesignintf.h"
#include "lreditableimageitemintf.h"
#include <QtGlobal> #include <QtGlobal>
namespace LimeReport{ namespace LimeReport{
class ImageItem : public ItemDesignIntf, public IPainterProxy class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableImageItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QImage image READ image WRITE setImage) Q_PROPERTY(QImage image READ image WRITE setImage)
@ -95,6 +96,10 @@ public:
void setUseExternalPainter(bool value); void setUseExternalPainter(bool value);
QWidget* defaultEditor(); QWidget* defaultEditor();
QByteArray imageAsByteArray() const;
void setImageAsByteArray(QByteArray image);
QString fileFilter() const;
protected: protected:
BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight); void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
@ -117,6 +122,7 @@ private:
bool m_center; bool m_center;
Format m_format; Format m_format;
QString m_variable; QString m_variable;
}; };
} }

View File

@ -5,12 +5,12 @@
#include <QFileInfo> #include <QFileInfo>
#include <QFileDialog> #include <QFileDialog>
ImageItemEditor::ImageItemEditor(LimeReport::ImageItem *item, QWidget *parent) : ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::ImageItemEditor), m_item(item) ui(new Ui::ImageItemEditor), m_item(item)
{ {
ui->setupUi(this); ui->setupUi(this);
m_image = QPixmap::fromImage(m_item->image()); m_image = item->imageAsByteArray();
ui->resourcePath->setText(m_item->resourcePath()); ui->resourcePath->setText(m_item->resourcePath());
updateImage(); updateImage();
} }
@ -22,30 +22,35 @@ ImageItemEditor::~ImageItemEditor()
void ImageItemEditor::updateImage() void ImageItemEditor::updateImage()
{ {
ui->imageViewer->setPixmap(m_image); QPixmap image;
if (m_image.isNull() && !ui->resourcePath->text().isEmpty()){ if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()){
if (m_resourcePathImage.isNull()) image.load(ui->resourcePath->text());
m_resourcePathImage = QPixmap(ui->resourcePath->text()); } else {
ui->imageViewer->setPixmap(m_resourcePathImage); image.loadFromData(m_image);
} }
ui->imageViewer->setPixmap(image);
} }
void ImageItemEditor::on_tbLoadImage_clicked() void ImageItemEditor::on_tbLoadImage_clicked()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file")); QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter());
m_image = QPixmap(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)){
m_image = file.readAll();
}
updateImage(); updateImage();
} }
void ImageItemEditor::on_tbClearImage_clicked() void ImageItemEditor::on_tbClearImage_clicked()
{ {
m_image = QPixmap(); m_image.clear();
updateImage(); updateImage();
} }
void ImageItemEditor::on_buttonBox_accepted() void ImageItemEditor::on_buttonBox_accepted()
{ {
m_item->setImage(m_image.toImage()); QImage image;
m_item->setImageAsByteArray(m_image);
m_item->setResourcePath(ui->resourcePath->text()); m_item->setResourcePath(ui->resourcePath->text());
this->close(); this->close();
} }

View File

@ -2,6 +2,7 @@
#define LRIMAGEITEMEDITOR_H #define LRIMAGEITEMEDITOR_H
#include <QWidget> #include <QWidget>
#include "lreditableimageitemintf.h"
namespace Ui { namespace Ui {
class ImageItemEditor; class ImageItemEditor;
@ -16,15 +17,17 @@ class ImageItemEditor : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ImageItemEditor(LimeReport::ImageItem* item, QWidget *parent = NULL); explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget *parent = NULL);
~ImageItemEditor(); ~ImageItemEditor();
private: private:
void updateImage(); void updateImage();
private: private:
Ui::ImageItemEditor *ui; Ui::ImageItemEditor *ui;
LimeReport::ImageItem* m_item; LimeReport::IEditableImageItem* m_item;
QPixmap m_image;
QByteArray m_image;
QPixmap m_resourcePathImage; QPixmap m_resourcePathImage;
private slots: private slots:
void on_tbLoadImage_clicked(); void on_tbLoadImage_clicked();
void on_tbClearImage_clicked(); void on_tbClearImage_clicked();

View File

@ -1,5 +1,7 @@
#include "lrsvgitem.h" #include "lrsvgitem.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrimageitemeditor.h"
#include "lrpagedesignintf.h"
#include <QtSvg> #include <QtSvg>
namespace{ namespace{
@ -39,6 +41,51 @@ void SVGItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
} }
ItemDesignIntf::paint(painter,option,widget); ItemDesignIntf::paint(painter,option,widget);
painter->restore(); painter->restore();
}
QByteArray SVGItem::imageAsByteArray() const
{
return m_image;
}
void SVGItem::setImageAsByteArray(QByteArray image)
{
setImage(image);
}
QString SVGItem::fileFilter() const
{
return tr("SVG (*.svg)");
}
void SVGItem::preparePopUpMenu(QMenu &menu)
{
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit"));
menu.insertAction(menu.actions().at(0),editAction);
menu.insertSeparator(menu.actions().at(1));
menu.addSeparator();
QAction* action = menu.addAction(tr("Watermark"));
action->setCheckable(true);
action->setChecked(isWatermark());
}
void SVGItem::processPopUpAction(QAction *action)
{
if (action->text().compare(tr("Watermark")) == 0){
page()->setPropertyToSelectedItems("watermark",action->isChecked());
}
if (action->text().compare(tr("Edit")) == 0){
this->showEditorDialog();
}
ItemDesignIntf::processPopUpAction(action);
}
QWidget *SVGItem::defaultEditor()
{
ImageItemEditor* editor = new ImageItemEditor(this);
editor->setAttribute(Qt::WA_DeleteOnClose);
return editor;
}; };
BaseDesignIntf* SVGItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent){ BaseDesignIntf* SVGItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent){

View File

@ -2,9 +2,10 @@
#define SVGITEM_H #define SVGITEM_H
#include "lritemdesignintf.h" #include "lritemdesignintf.h"
#include "lreditableimageitemintf.h"
namespace LimeReport{ namespace LimeReport{
class SVGItem: public ItemDesignIntf class SVGItem: public ItemDesignIntf, public IEditableImageItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath) Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath)
@ -18,6 +19,14 @@ public:
SVGItem(QObject *owner, QGraphicsItem *parent); SVGItem(QObject *owner, QGraphicsItem *parent);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QByteArray imageAsByteArray() const;
void setImageAsByteArray(QByteArray image);
QString fileFilter() const;
void preparePopUpMenu(QMenu &menu);
void processPopUpAction(QAction *action);
QWidget* defaultEditor();
QString resourcePath() const; QString resourcePath() const;
void setResourcePath(const QString &resourcePath); void setResourcePath(const QString &resourcePath);
QByteArray image() const; QByteArray image() const;
@ -39,6 +48,8 @@ private:
QString m_datasource; QString m_datasource;
QString m_field; QString m_field;
QString m_variable; QString m_variable;
public:
}; };
} // namespace LimeReport } // namespace LimeReport
#endif // SVGITEM_H #endif // SVGITEM_H

View File

@ -89,6 +89,7 @@ contains(CONFIG, svg){
} }
HEADERS += \ HEADERS += \
$$PWD/items/lreditableimageitemintf.h \
$$REPORT_PATH/base/lrsingleton.h \ $$REPORT_PATH/base/lrsingleton.h \
$$REPORT_PATH/base/lrsimpleabstractfactory.h \ $$REPORT_PATH/base/lrsimpleabstractfactory.h \
$$REPORT_PATH/base/lrattribsabstractfactory.h \ $$REPORT_PATH/base/lrattribsabstractfactory.h \

View File

@ -137,6 +137,7 @@ void BandMarker::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void BandMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
Q_UNUSED(event)
m_band->posChanged(m_band, m_band->pos(), m_oldBandPos); m_band->posChanged(m_band, m_band->pos(), m_oldBandPos);
} }
@ -1129,7 +1130,6 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
spaceBorder += m_bottomSpace; spaceBorder += m_bottomSpace;
restoreLinks(); restoreLinks();
snapshotItemsLayout(); snapshotItemsLayout();
BandDesignIntf* patternBand = dynamic_cast<BandDesignIntf*>(patternItem());
arrangeSubItems(pass, dataManager); arrangeSubItems(pass, dataManager);
if (autoHeight()){ if (autoHeight()){

View File

@ -492,6 +492,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer) bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{ {
Q_UNUSED(printer)
if (pages.count()>0){ if (pages.count()>0){
Q_Q(ReportEngine); Q_Q(ReportEngine);
PreviewReportWindow* w = new PreviewReportWindow(q, 0, settings()); PreviewReportWindow* w = new PreviewReportWindow(q, 0, settings());
@ -2054,6 +2055,7 @@ qreal WatermarkHelper::valueToPixels(qreal value)
case LimeReport::ItemGeometry::Pixels: case LimeReport::ItemGeometry::Pixels:
return value; return value;
} }
return -1;
} }

View File

@ -190,6 +190,7 @@ void ReportRender::initDatasource(const QString& name){
} }
void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
Q_UNUSED(band)
if (contentItem){ if (contentItem){
QString content = contentItem->content(); QString content = contentItem->content();
QVector<QString> functions; QVector<QString> functions;

View File

@ -7,18 +7,11 @@
namespace LimeReport{ namespace LimeReport{
SettingDialog::SettingDialog(QWidget *parent) : SettingDialog::SettingDialog(QWidget *parent) :
QDialog(parent), m_settings(0), QDialog(parent),
ui(new Ui::SettingDialog) ui(new Ui::SettingDialog), m_settings(0)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->toolBox->setCurrentIndex(0); ui->toolBox->setCurrentIndex(0);
// ui->cbTheme->addItem(QObject::tr("Default"));
// if (isFileExists(":/qdarkstyle/style.qss")){
// ui->cbTheme->addItem(QObject::tr("Dark"));
// }
// if (isFileExists(":/qlightstyle/lightstyle.qss")){
// ui->cbTheme->addItem(QObject::tr("Light"));
// }
ui->indentSize->setRange(0,10); ui->indentSize->setRange(0,10);
} }

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>419</width> <width>521</width>
<height>378</height> <height>445</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -30,8 +30,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>401</width> <width>503</width>
<height>250</height> <height>301</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -215,8 +215,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>401</width> <width>503</width>
<height>250</height> <height>301</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -304,8 +304,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>401</width> <width>503</width>
<height>250</height> <height>301</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">

View File

@ -29,7 +29,7 @@ QByteArray SvgEditor::image()
void SvgEditor::slotButtonClicked() void SvgEditor::slotButtonClicked()
{ {
QString fileName = QFileDialog::getOpenFileName(this, "", "SVG| *.svg"); QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)");
if (!fileName.isEmpty()){ if (!fileName.isEmpty()){
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)){ if (file.open(QIODevice::ReadOnly)){

View File

@ -1161,6 +1161,10 @@ p, li { white-space: pre-wrap; }
<source>Edit</source> <source>Edit</source>
<translation>Правка</translation> <translation>Правка</translation>
</message> </message>
<message>
<source>Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)</source>
<translation>Изображения (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;Все файлы(*.*)</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::ItemLocationPropItem</name> <name>LimeReport::ItemLocationPropItem</name>
@ -2548,6 +2552,25 @@ This preview is no longer valid.</source>
<translation>Использовать первую строку в качестве заголовка</translation> <translation>Использовать первую строку в качестве заголовка</translation>
</message> </message>
</context> </context>
<context>
<name>LimeReport::SVGItem</name>
<message>
<source>SVG Image</source>
<translation>Изображение в формате SVG</translation>
</message>
<message>
<source>Edit</source>
<translation>Правка</translation>
</message>
<message>
<source>Watermark</source>
<translation>Водный знак</translation>
</message>
<message>
<source>SVG (*.svg)</source>
<translation>SVG (*.svg)</translation>
</message>
</context>
<context> <context>
<name>LimeReport::ScriptBrowser</name> <name>LimeReport::ScriptBrowser</name>
<message> <message>
@ -2797,6 +2820,13 @@ This preview is no longer valid.</source>
<translation>Заголовок подчиненных данных</translation> <translation>Заголовок подчиненных данных</translation>
</message> </message>
</context> </context>
<context>
<name>LimeReport::SvgEditor</name>
<message>
<source>Select image file</source>
<translation>Выбрать файл изображения</translation>
</message>
</context>
<context> <context>
<name>LimeReport::TearOffBand</name> <name>LimeReport::TearOffBand</name>
<message> <message>
@ -3237,5 +3267,9 @@ This preview is no longer valid.</source>
<source>Series</source> <source>Series</source>
<translation>Ряды данных</translation> <translation>Ряды данных</translation>
</message> </message>
<message>
<source>SVG Item</source>
<translation>Элемент SVG избражение</translation>
</message>
</context> </context>
</TS> </TS>