fralx / limereport Goto Github PK
View Code? Open in Web Editor NEWReport generator for Qt Framework
Home Page: http://limereport.ru/
License: Other
Report generator for Qt Framework
Home Page: http://limereport.ru/
License: Other
I right clicked the toolbar of the print preview dialog and unchecked the visible action.
Now I can no longer make it visible again.
Right clicking does not provide the previous popup menu and no menu action allow that.
Report Designer:
Sometimes you do want to load/create a new report.
So you load it from byte array, but you can not give a pre defined file path for the future save of this report.
Please expose a ReportEngine::setReportFileName() as we already have a reportFileName().
This would allow to create a new report for a given file name already known in advance.
Файл: lrxmlbasetypesserializators.cpp
строка 180:
saveBool(_node,"undeline",font.underline());
строка 193:
font.setUnderline(node()->attribute("underline").toInt());
Есть во всех версиях.
Я понимаю, что до этого идёт if else, и оба они возвращают значение, но тогда возможно есть потенциальная проблема с тем, что никогда не вызывается m_reportRender.clear()
ReportPages ReportEnginePrivate::renderToPages()
{
m_reportRender = ReportRender::Ptr(new ReportRender);
dataManager()->clearErrorsList();
dataManager()->connectAllDatabases();
dataManager()->setDesignTime(false);
connect(m_reportRender.data(),SIGNAL(pageRendered(int)),
this, SIGNAL(renderPageFinished(int)));
if (m_pages.count()){
emit renderStarted();
m_reportRender->setDatasources(dataManager());
ReportPages result = m_reportRender->renderPageToPages(m_pages.at(0));
emit renderFinished();
return result;
}else return ReportPages();
m_reportRender.clear();
}
Is there supposed to be a way to build without zint?
At the top of common.pri: CONFIG += zint
which means there's really no way to leave it out without editing LimeReport's qmake files.
Hi, every body, I am using Limereport and find it very usefull but was lacking of some useful functions so I created and added the following function:
In file: lrscriptenginemanager.cpp
QScriptValue currencyFormat(QScriptContext* pcontext, QScriptEngine* pengine){
QVariant value = pcontext->argument(0).toVariant();
QString CurrencySymbol = (pcontext->argumentCount()>1)?pcontext->argument(1).toString():"";
// Format it using USA locale
QString vTempStr=QLocale(QLocale::English, QLocale::UnitedStates).toCurrencyString(value.toDouble());
// Replace currency symbol if necesarry
if (CurrencySymbol!="") vTempStr.replace("$", CurrencySymbol);
QScriptValue res = pengine->newVariant(vTempStr);
return res;
}
And inside: ScriptEngineManager::ScriptEngineManager():m_model(0), m_dataManager(0)
addFunction("currencyFormat",currencyFormat,"NUMBER","currencyFormat(""+tr("Value")+"",""+tr("CurrencySymbol")+"")");
With this code you can easily convert plain numbers into nice formatted currency by using:
$S { currencyFormat(1000.25,"£") }
Beside allowing you to use SUM() with passed data fields!
I pass on the code so you can include it on the next release!
"QStyleOptionViewItemV4" is deprecated and should be replaced with the unversioned name. No change in function.
Потенциальная проблема.
Файл "lrpreviewreportwindow.cpp", строка 53, требуется перевод:
m_pagesNavigator->setPrefix("Page: ");
Hi,
I want to export data to a .txt file, I only need data in the report ,How can I do that?
Because DEST_LIBS, DEST_INCLUDE_DIR, and DEST_BINS are defined in common.pri
and it is included everywhere, there's no way to override the destination for the build.
Ideally I should be able to specify an INSTALL_DIR and it should create:
Объекты выделялись с CTRL, затем нажимал кнопку DELETE.
void CommandGroup::addCommand(CommandIf::Ptr command, bool execute)
{
if (execute && command->doIt())
m_commands.append(command);
else
m_commands.append(command);
}
LimeReport can easily go over a couple of Gb of memory intake when we do have many hundred of pages to generate. For 200 pages i was around 1.5Gb of memory and it often leads to a crash with Mingw 32 bits on Windows.
After a couple of days of investigations i noticed the QTextDocument component into the TextItem class was the responsible of the memory usage. I tried a workaround with the QStaticText and i was able to reduce the memory consumption by 5 ( 300Mb for 200 pages ) but the problems is it does not support all QTextDocument features and it does break "cloneUpperPart", "cloneBottomPart" and the " canBeSplitted ", the rest seems to work fine. Maybe the solution does reside into the implementation of a "SimpleTextItem" with more basics features ...
Большая таблица 10000х5 съедает много памяти, которую не возвращает при удалении ReportEngine
QVariant ReportModel::data(const QModelIndex &index, int role) const
{
return QVariant();
}
Баг нашёлся случайно, когда метод rowCount возвращал значение 10000, а в ReportModel::data проверялось 1000, иначе отдавался дефолтный QVariant.
If we call designReport() and destroy the report engine, then the designer window empty up (normal, report destroyed) but the window itself is not destroyed and still reference destroyed object (like QSettings).
This lead to crash.
Better destroy all windows created by the engine when it's deleted.
Also, it seems we can call many time designReport() on the same engine which each time instanciate a new designer.
I don't see any valuable reason for that, it should at most allowed one designer per engine.
Please use a QPointer for the designer window and reuse it.
My actual internal patches are:
diff --git a/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp b/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
--- a/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
+++ b/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
@@ -234,9 +234,15 @@ bool ReportDesignWidget::save()
return m_report->saveToFile();
}
else {
- m_report->emitSaveReport();
- if (m_report->isSaved()) return true;
- return m_report->saveToFile(QFileDialog::getSaveFileName(this,tr("Report file name"),"","Report files (*.lrxml);; All files (*)"));
+ if (m_report->isSaved()) {
+ m_report->emitSaveReport();
+ return true;
+ }
+ if (m_report->saveToFile(QFileDialog::getSaveFileName(this,tr("Report file name"),"","Report files (*.lrxml);; All files (*)"))) {
+ m_report->emitSaveReport();
+ return true;
+ }
+ return false;
}
}
diff --git a/3rdparty/LimeReport/limereport/lrreportengine.cpp b/3rdparty/LimeReport/limereport/lrreportengine.cpp
--- a/3rdparty/LimeReport/limereport/lrreportengine.cpp
+++ b/3rdparty/LimeReport/limereport/lrreportengine.cpp
@@ -67,6 +67,9 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
ReportEnginePrivate::~ReportEnginePrivate()
{
+ if (m_designerWindow) {
+ m_designerWindow->close();
+ }
if (m_activePreview){
m_activePreview->close();
}
@@ -384,24 +387,27 @@ void ReportEnginePrivate::cancelRender()
void ReportEnginePrivate::designReport()
{
- LimeReport::ReportDesignWindow* w = new LimeReport::ReportDesignWindow(this,QApplication::activeWindow(),settings());
- w->setAttribute(Qt::WA_DeleteOnClose,true);
- w->setWindowIcon(QIcon(":report/images/logo32"));
- w->setShowProgressDialog(m_showProgressDialog);
+ if (!m_designerWindow) {
+ m_designerWindow = new LimeReport::ReportDesignWindow(this,QApplication::activeWindow(),settings());
+ m_designerWindow->setAttribute(Qt::WA_DeleteOnClose,true);
+ m_designerWindow->setWindowIcon(QIcon(":report/images/logo32"));
+ m_designerWindow->setShowProgressDialog(m_showProgressDialog);
+ }
+
#if defined(Q_OS_MAC)
- //w->showModal();
+ //m_designerWindow->showModal();
#elif defined(Q_OS_UNIX)
- //w->showModal();
+ //m_designerWindow->showModal();
#endif
#ifdef Q_OS_WIN
- //w->setWindowFlags(Qt::Window|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint|Qt::WindowMinimizeButtonHint);
- w->setWindowModality(Qt::ApplicationModal);
- //w->showModal();
+ //m_designerWindow->setWindowFlags(Qt::Window|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint|Qt::WindowMinimizeButtonHint);
+ m_designerWindow->setWindowModality(Qt::ApplicationModal);
+ //m_designerWindow->showModal();
#endif
if (QApplication::activeWindow()==0){
- w->show();
+ m_designerWindow->show();
} else {
- w->showModal();
+ m_designerWindow->showModal();
}
}
diff --git a/3rdparty/LimeReport/limereport/lrreportengine_p.h b/3rdparty/LimeReport/limereport/lrreportengine_p.h
--- a/3rdparty/LimeReport/limereport/lrreportengine_p.h
+++ b/3rdparty/LimeReport/limereport/lrreportengine_p.h
@@ -46,6 +46,7 @@ namespace LimeReport{
class PageDesignIntf;
class PrintRange;
+class ReportDesignWindow;
//TODO: Add on render callback
@@ -153,6 +154,7 @@ private:
QMainWindow* m_activePreview;
QIcon m_previewWindowIcon;
QString m_previewWindowTitle;
+ QPointer<ReportDesignWindow> m_designerWindow;
};
}
Function for use default Printer and no QPrintDialog for batch procesing?:
connect(ui->tbPrint, SIGNAL(clicked(bool)), m_preview, SLOT(print()));
connect(ui->tbPrint, SIGNAL(clicked(bool)), m_preview, SLOT(printDirect()));
or
m_preview, SLOT(printTo(printer)));
When editing a report, even for small change (by example, just a width change) the saved file is then TOO MUCH different than the previous one while only a width changed.
The xml tags order is not 'stable' ie - it change place from save to save.
This could be easily fixed using a map instead of a hash for the names (if it's what is used), else consider grabbing the keys then sort them (qStableSort) before writing them.
This will a lot help users making diff against edited reports, it's actually a nightmare :)
Thanks,
Designer:
Hello!
Is it possible to build lime report with qt 4.6 ? When I tried , I got such error :
WBW&R, Grigory.
file: lrimageitem.cpp
need to use std::abs
if (shiftWidth > 0){
point.setX(point.x()+shiftWidth/2);
} else {
cutX = std::abs(shiftWidth/2); // << here
cutWidth += shiftWidth;
}
if (shiftHeight > 0){
point.setY(point.x()+shiftHeight/2);
} else {
cutY = std::abs(shiftHeight/2); //<< here
cutHeigth += shiftHeight;
}
Here is the fix:
diff --git a/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp b/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
index 1b590c3..6fe94c7 100644
--- a/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
+++ b/3rdparty/LimeReport/limereport/lrreportdesignwidget.cpp
@@ -227,7 +227,9 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
}
void ReportDesignWidget::saveToFile(const QString &fileName){
- m_report->saveToFile(fileName);
+ if (m_report->saveToFile(fileName)) {
+ m_report->emitSaveFinished();
+ }
}
bool ReportDesignWidget::save()
Actually i have 2 data bands and i can't move one to top / bottom.
It would require saving and manually editing the xml file, a bit boring.
Our windows slave do have issues building LimeReport on Windows/MinGW 4.8
The issues seems to comes from a file name in the qrc file: Control-Edit Box.png.
Not sure why it appear, the output only say: Error: not such file 'x/y/z/Control-Edit'.
We renamed the file here to replace space by _.
Could you make this change upstream please ?
thanks!
I ran into an issue when creating a callbackDataSource with createCallbackDataSource.
LimeReport::ICallbackDatasource* callbackDatasource = _report->dataManager()->createCallbackDatasouce( "standardData" );
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),this, SLOT(getDataStandardData(LimeReport::CallbackInfo,QVariant&)));
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)),this, SLOT(changePosStandardData(const LimeReport::CallbackInfo::ChangePosType&,bool&)));
During this call, the columnCount function is called. Since the signals and slots haven't been connected yet, the columnCount remains -1. When rendering a report, the datasource doesn't get refreshed at any point, so the data fields are never filled.
In my local copy of LimeReport, I added back the addCallbackDatasource
function and removed the lines for DataSource holder creation. With this, I was able to get the report to be generated properly, but I doubt that this is the best way to approach this problem. Is there a way to emit the datasourcesChanged
event that I'm missing?
So I've read the docs, watched the video, and read issue #21 .
I'm assuming that the version in the docs is out of date since the comments in #2 suggest we only need one signal/slot.
But I seem to be missing a piece of the puzzle... What do I need to put in the form using the front end in order to connect my columns in the slot with the actual form?
Here's what I'm doing:
connect(callbackDatasource, &LimeReport::ICallbackDatasource::getCallbackData, [=] ( const LimeReport::CallbackInfo &inInfo, QVariant &outVariant ) {
qDebug() << " getCallbackData" << outVariant << inInfo.columnName << inInfo.dataType;
const QStringList cColumns{ "Name", "Value" };
const int cColumnCount = cColumns.size();
const int cNumRows = 4;
switch (inInfo.dataType)
{
case LimeReport::CallbackInfo::IsEmpty:
outVariant = false;
break;
case LimeReport::CallbackInfo::HasNext:
outVariant = (inInfo.index != (cNumRows - 1));
break;
case LimeReport::CallbackInfo::ColumnHeaderData:
outVariant = cColumns.at( inInfo.index );
break;
case LimeReport::CallbackInfo::ColumnData:
outVariant = QString( inInfo.columnName + QStringLiteral( " " ) + QString::number( inInfo.index ) );
break;
case LimeReport::CallbackInfo::ColumnCount:
outVariant = cColumnCount;
break;
case LimeReport::CallbackInfo::RowCount:
outVariant = cNumRows;
break;
}
qDebug() << " ...returning" << outVariant;
});
...and it's never asking for data:
Debug: getCallbackData QVariant(Invalid) "" 4
Debug: ...returning QVariant(int, 2)
Debug: getCallbackData QVariant(Invalid) "" 2
Debug: ...returning QVariant(QString, "Name")
Debug: getCallbackData QVariant(Invalid) "" 2
Debug: ...returning QVariant(QString, "Value")
Debug: getCallbackData QVariant(int, 0) "" 5
Debug: ...returning QVariant(int, 4)
Debug: getCallbackData QVariant(Invalid) "" 5
Debug: ...returning QVariant(int, 4)
Debug: getCallbackData QVariant(int, 0) "" 5
Debug: ...returning QVariant(int, 4)
Debug: getCallbackData QVariant(Invalid) "" 5
Debug: ...returning QVariant(int, 4)
Presumably because I need to add fields to the form. I tried adding variables with the column names, but that didn't work.
How do I add the fields to my "DataBand"?
Thanks!
We can make slot interface same like to: ??
void setValue(int &recNo, QString ¶mName, QVariant ¶mValue, int reportPage)
{
if (paramName == "Name")
{
if (ui->tableWidget->item(recNo,0) == 0) return;
paramValue = ui->tableWidget->item(recNo,0)->text();
}
if (paramName == "Category") {..... blablabla
And connect:
QObject::connect(report, SIGNAL(setValue(int&, QString&, QVariant&, int)), this, SLOT(setValue(int&, QString&, QVariant&, int)));
QObject::connect(report, SIGNAL(setValueImage(int&, QString&, QImage&, int)), this, SLOT(setValueImage(int&, QString&, QImage&, int)));
For simple implementing lib?
Contruct report engi.
Load template.
conect values for template.
exec report embeded or preview or direct print.
Interest?
I've been looking at the available report tools and this one looks very promising!
How would I handle translation of reports? Making a separate copy of each report for each language seems impractical (though of course some would have to be done by hand - right-to-left scripts for example). Populating all text through variables and relying on QObject::tr() seems a bit painful, but I guess that might work.
Any suggestions? Am I missing something?
Would be cool if I could do it directly in the designer - select the language, populate the text for that language, then on the Qt side request a specific language when I load the report.
В аттаче пример. Библиотека собиралась под 4.8.6.
Ничего нажимать не нужно, после запуска вызывается превью отчёта и через 5 секунд закрывается главное окно.
PreviewReportWindow::closeEvent отрабатывает, из цикла сообщений выйти не успевает, падает.
void PreviewReportWindow::exec()
{
bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_DeleteOnClose,false);
setAttribute(Qt::WA_ShowModal,true);
show();
m_eventLoop.exec(); // <- вот тут оно падает
if (deleteOnClose) delete this;
}
Я понимаю, что пример экзотический, но у нас это случилось в реальном приложении, поэтому решил зарепортить. Конечно, можно убить ReportEngine до того, как закроется главное окно, но не уверен, что эта проблема не вылезет где-то ещё.
https://wiki.qt.io/New_Features_in_Qt_5.7
Deprecated Modules
The following modules are part of Qt 5.6 release, but deprecated and considered for removal in subsequent releases of Qt:
Qt Script
Вот почему хорошим кодстайлом является всегда ставить фигурные скобки, даже в однострочных выражениях.
I wanted to have two databands, one on the left and the other at the right of the report (kind of two columns but databands with different datasources).
To do it, I'd need a subreport or flexibles databand.
Is it possible with LimeReport?
LimeReport is great, but the LimeReport::ReportEngine is a bit too monolithic to be reused efficiently.
In fact the PrintPreview and Designer windows are not really useful because we can not instantiate them ourselves as it's tied to the ReportEnginePrivate thing.
Please allow those dialogs to be instantiated taking a simple ReportEngine in constructor, this way we can control where and how to instantiate those to suit our needs (modal, non modal, size , screen...).
Теряется расширение файла, при сохранении отчета. Проявляется при необходимости перезаписать файл.
Right now it show a text like 'Field header.field1 not found in TextItem6 !!!'
We would like to remove those texts.
We are hit by big performance issues when generating the report.
It took us ~8 seconds which is a lot.
Is there any special attention given to performance in lime report ?
Actually we do not have any programmatically way of changing the UI Preview window like:
We maintain a local patch for that and I don't like it.
Please add some sort of option hint to the previewReport() functions so we can customize appearance.
bool ReportDesignWidget::save()
{
if (!m_report->reportFileName().isEmpty()){
return m_report->saveToFile();
}
else {
if (m_report->isSaved()) {
m_report->emitSaveReport();
return true;
}
if (m_report->saveToFile(QFileDialog::getSaveFileName(this,tr("Report file name"),"","Report files (*.lrxml);; All files (*)"))) {
m_report->emitSaveReport();
return true;
}
return false;
}
}
Continuing issue #51 - when building now I get error
I couldn't find which permissions are absent. All files in "translations" folder has rwx permissions for owner, "translations" folder self also has rwx permissions. What permissions should I add ?
Windows 7, Qt 4.8.7 on MinGw32 4.8.2. Application "demo_r2" terminates after double click on DemoReport1_report_header_group_subdetail report. Just before fail, it writes to console "libpng warning: iCCP: known incorrect sRGB profile".
When launching report from report designer it works normally.
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
lastRenderedBand = m_patternPageItem->dataBandAt(i);
initDatasources();
renderDataBand(lastRenderedBand);
if (i<m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand);
}
When rendering new dataBand, it will reset all the datasources and that will cause my program broken. I wrote 3 datasources, the second datasource is the subdatasource of the first datasource. when the program runs to render the third datasource, it will init all the datasources, and it init the second datasource first, and my program should init the detailIterator to the begin of mainIterator's child list, which cause the error, because the mainIterator was not initial and it point to the end of the main list.
I think it maybe better for only initializing the current datasource of the data band.
Sorry for my poor english.
Создаём ReportEngine, передаём в него модель, вызываем previewReport. Если попытаться удалить ReportEngine, то приложение крашится. Проявляется в 1.2.1 и 1.3.9 (1.3.1 не пробовал), Qt 4.8.6.
На designReport не проявляется.
Возможно предполагается, что ReportEngine должен использоваться исключительно как синглтон. Но тогда нужен какой-либо признак, что сейчас есть открытый отчёт и функция "закрыть отчёт".
В одном конструкторе m_autoconnect инициализируется, в другом - нет.
Кстати, может давно пора добавить поддержку C++11 и инициализировать такие штуки про объявлении?
In the file "lrdatadesignintf.cpp" the function "MasterDetailProxyModel::fieldIndexByName" doesn't use the parameter it receives, instead it seems to compare the local "fieldName" variable to itself.
Here's the code:
int MasterDetailProxyModel::fieldIndexByName(QString fieldName) const {
for (int i = 0; i < sourceModel()->columnCount(); ++i) {
QString fieldName = sourceModel()->headerData(i, Qt::Horizontal, Qt::UserRole).isValid()
? sourceModel()->headerData(i, Qt::Horizontal, Qt::UserRole).toString()
: sourceModel()->headerData(i, Qt::Horizontal).toString();
if (fieldName.compare(fieldName, Qt::CaseInsensitive) == 0) {
return i;
}
}
return -1;
}
Есть ли возможность скрыть кнопку из вне библиотеки?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.