mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 12:12:59 +03:00
support of Qt6
This commit is contained in:
parent
1c81196db2
commit
8efb6792a3
@ -140,8 +140,8 @@ OBJECTS_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/obj
|
||||
RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
||||
|
||||
LIMEREPORT_VERSION_MAJOR = 1
|
||||
LIMEREPORT_VERSION_MINOR = 5
|
||||
LIMEREPORT_VERSION_RELEASE = 90
|
||||
LIMEREPORT_VERSION_MINOR = 6
|
||||
LIMEREPORT_VERSION_RELEASE = 0
|
||||
|
||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
||||
|
@ -104,10 +104,10 @@ namespace Const{
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
QString replaceHTMLSymbols(const QString &value);
|
||||
#if QT_VERSION < 0x060000
|
||||
QVector<QString> normalizeCaptures(const QRegExp ®);
|
||||
#else
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®);
|
||||
#else
|
||||
QVector<QString> normalizeCaptures(const QRegExp ®);
|
||||
#endif
|
||||
bool isColorDark(QColor color);
|
||||
|
||||
|
@ -17,9 +17,14 @@ SUBDIRS += \
|
||||
|
||||
if(equals(QT_MAJOR_VERSION, 5) : greaterThan(QT_MINOR_VERSION, 1)) | equals(QT_MAJOR_VERSION, 6) {
|
||||
SUBDIRS += console \
|
||||
lrdview
|
||||
lrdview
|
||||
|
||||
}
|
||||
|
||||
#if(equals(QT_MAJOR_VERSION, 5) : greaterThan(QT_MINOR_VERSION, 1)) {
|
||||
# SUBDIRS += lrdview
|
||||
#}
|
||||
|
||||
!CONFIG(embedded_designer) : !CONFIG(static_build) {
|
||||
SUBDIRS += designer_plugin
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void setPrintOnFirstPage(bool printOnFirstPage);
|
||||
bool printOnLastPage() const;
|
||||
void setPrintOnLastPage(bool printOnLastPage);
|
||||
bool isHeader() const{return true;}
|
||||
protected:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
QColor bandColor() const;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
bool printBeforePageHeader() const;
|
||||
void setPrintBeforePageHeader(bool printBeforePageHeader);
|
||||
bool isHeader() const {return true;}
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool m_printBeforePageHeader;
|
||||
|
@ -63,7 +63,11 @@ void FontEditorWidget::initEditor()
|
||||
m_fontSizeEditor = new QComboBox(this);
|
||||
m_fontSizeEditor->setModel(&m_fontSizeModel);
|
||||
m_fontSizeEditor->setEditable(true);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_fontSizeEditor,SIGNAL(currentTextChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
#else
|
||||
connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
#endif
|
||||
addWidget(m_fontSizeEditor);
|
||||
|
||||
addSeparator();
|
||||
|
@ -110,7 +110,7 @@ void HtmlContext::parseSymbs(QString text)
|
||||
text.remove(pos,rx.matchedLength());
|
||||
}
|
||||
|
||||
foreach(QString pattern,m_symbPatterns){
|
||||
foreach(QString pattern, m_symbPatterns){
|
||||
rx.setPattern(pattern);
|
||||
while (text.contains(rx)){
|
||||
int pos=rx.indexIn(text);
|
||||
@ -120,6 +120,13 @@ void HtmlContext::parseSymbs(QString text)
|
||||
}
|
||||
#else
|
||||
QRegularExpression rx("<[^<]*>");
|
||||
|
||||
while (text.contains(rx)){
|
||||
int pos=text.indexOf(rx); //rx.indexIn(text);
|
||||
if (rx.cap().compare("<br>",Qt::CaseInsensitive)==0)
|
||||
m_symbs.append(new Symb(rx.cap(),pos));
|
||||
text.remove(pos,rx.matchedLength());
|
||||
}
|
||||
// TODO: Qt6 port
|
||||
#endif
|
||||
}
|
||||
@ -191,43 +198,43 @@ bool HtmlContext::isVectorEqual(QVector<Tag *> source, QVector<Tag *> dest)
|
||||
return true;
|
||||
}
|
||||
|
||||
QString HtmlContext::extendTextByTags(QString text, int pos)
|
||||
{
|
||||
QString curText="";
|
||||
QVector<Tag*> curTags=tagsAt(pos);
|
||||
for(int i=0;i<curTags.count();i++){
|
||||
curText+='<'+curTags.at(i)->tagText()+'>';
|
||||
}
|
||||
//QString HtmlContext::extendTextByTags(QString text, int pos)
|
||||
//{
|
||||
// QString curText="";
|
||||
// QVector<Tag*> curTags=tagsAt(pos);
|
||||
// for(int i=0;i<curTags.count();i++){
|
||||
// curText+='<'+curTags.at(i)->tagText()+'>';
|
||||
// }
|
||||
|
||||
for(int i=0;i<text.length();i++,pos++){
|
||||
QVector<Tag*> tagsAtPos=tagsAt(pos);
|
||||
if (!HtmlContext::isVectorEqual(curTags,tagsAtPos)){
|
||||
QVector<TagDiff> diffs=HtmlContext::tagVectDiff(curTags,tagsAtPos);
|
||||
foreach(TagDiff diff,diffs){
|
||||
if (diff.direction==TagDiff::Inner){
|
||||
curText+='<'+diff.tag->tagText()+'>';
|
||||
curTags.append(diff.tag);
|
||||
}
|
||||
else{
|
||||
curText+="</"+HtmlContext::extractWord(diff.tag->tagText(),1)+'>';
|
||||
curTags.remove(curTags.indexOf(diff.tag));
|
||||
}
|
||||
}
|
||||
}
|
||||
Symb s=symbAt(pos);
|
||||
if (s.isValid()){
|
||||
if (s.isTag()) curText+=s.text()+text.at(i);
|
||||
else curText+=s.text();
|
||||
} else curText+=text.at(i);
|
||||
}
|
||||
// for(int i=0;i<text.length();i++,pos++){
|
||||
// QVector<Tag*> tagsAtPos=tagsAt(pos);
|
||||
// if (!HtmlContext::isVectorEqual(curTags,tagsAtPos)){
|
||||
// QVector<TagDiff> diffs=HtmlContext::tagVectDiff(curTags,tagsAtPos);
|
||||
// foreach(TagDiff diff,diffs){
|
||||
// if (diff.direction==TagDiff::Inner){
|
||||
// curText+='<'+diff.tag->tagText()+'>';
|
||||
// curTags.append(diff.tag);
|
||||
// }
|
||||
// else{
|
||||
// curText+="</"+HtmlContext::extractWord(diff.tag->tagText(),1)+'>';
|
||||
// curTags.remove(curTags.indexOf(diff.tag));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Symb s=symbAt(pos);
|
||||
// if (s.isValid()){
|
||||
// if (s.isTag()) curText+=s.text()+text.at(i);
|
||||
// else curText+=s.text();
|
||||
// } else curText+=text.at(i);
|
||||
// }
|
||||
|
||||
curTags=tagsAt(pos);
|
||||
for(int i=0;i<curTags.count();i++){
|
||||
curText+="</"+HtmlContext::extractWord(curTags.at(i)->tagText(),1)+'>';
|
||||
}
|
||||
// curTags=tagsAt(pos);
|
||||
// for(int i=0;i<curTags.count();i++){
|
||||
// curText+="</"+HtmlContext::extractWord(curTags.at(i)->tagText(),1)+'>';
|
||||
// }
|
||||
|
||||
return curText;
|
||||
}
|
||||
// return curText;
|
||||
//}
|
||||
|
||||
QVector<Tag *> HtmlContext::tagsAt(int pos)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
static QVector<TagDiff> tagVectDiff(QVector<Tag*> source, QVector<Tag*> dest);
|
||||
static bool isVectorEqual(QVector<Tag*> source, QVector<Tag*> dest);
|
||||
void fillTagVector(QString html);
|
||||
QString extendTextByTags(QString text, int pos);
|
||||
//QString extendTextByTags(QString text, int pos);
|
||||
QVector<Tag *> tagsAt(int pos);
|
||||
Symb symbAt(int pos);
|
||||
void clearTags();
|
||||
|
@ -360,10 +360,13 @@ void TextItem::updateLayout()
|
||||
|
||||
bool TextItem::isNeedExpandContent() const
|
||||
{
|
||||
bool result = false;
|
||||
#if QT_VERSION < 0x060000
|
||||
QRegExp rx("$*\\{[^{]*\\}");
|
||||
#else
|
||||
QRegularExpression rx("$*\\{[^{]*\\}");
|
||||
QRegularExpression rx("\\$*\\{[^{]*\\}");
|
||||
result = content().contains(rx) || isContentBackedUp();
|
||||
return result;
|
||||
#endif
|
||||
return content().contains(rx) || isContentBackedUp();
|
||||
}
|
||||
|
@ -88,9 +88,6 @@
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Esc</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -35,7 +35,7 @@ SOURCES += \
|
||||
$$REPORT_PATH/items/editors/lrfonteditorwidget.cpp \
|
||||
$$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.cpp \
|
||||
$$REPORT_PATH/items/editors/lritemsborderseditorwidget.cpp \
|
||||
$$REPORT_PATH/items/lrsimpletagparser.cpp \
|
||||
# $$REPORT_PATH/items/lrsimpletagparser.cpp \
|
||||
$$REPORT_PATH/items/lrimageitem.cpp \
|
||||
$$REPORT_PATH/items/lrimageitemeditor.cpp \
|
||||
$$REPORT_PATH/items/lrtextitemeditor.cpp \
|
||||
@ -121,7 +121,7 @@ HEADERS += \
|
||||
$$REPORT_PATH/items/lrshapeitem.h \
|
||||
$$REPORT_PATH/items/lrimageitem.h \
|
||||
$$REPORT_PATH/items/lrimageitemeditor.h \
|
||||
$$REPORT_PATH/items/lrsimpletagparser.h \
|
||||
# $$REPORT_PATH/items/lrsimpletagparser.h \
|
||||
$$REPORT_PATH/items/lrverticallayout.h \
|
||||
$$REPORT_PATH/items/lrlayoutmarker.h \
|
||||
$$REPORT_PATH/items/lrabstractlayout.h \
|
||||
|
@ -423,7 +423,28 @@ QString DataSourceManager::extractField(QString source)
|
||||
}
|
||||
|
||||
QString DataSourceManager::replaceVariables(QString value){
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
QRegularExpressionMatchIterator iter = rx.globalMatch(value);
|
||||
qsizetype pos = 0;
|
||||
QString result;
|
||||
while (iter.hasNext()) {
|
||||
QRegularExpressionMatch match = iter.next();
|
||||
QString var = match.captured(0);
|
||||
var.remove("$V{");
|
||||
var.remove("}");
|
||||
result += value.mid(pos, match.capturedStart(0));
|
||||
if (variable(var).isValid()){
|
||||
result += variable(var).toString();
|
||||
} else {
|
||||
result += QString(tr("Variable \"%1\" not found!").arg(var));
|
||||
}
|
||||
pos = match.capturedEnd(0);
|
||||
}
|
||||
result += value.mid(pos);
|
||||
return result;
|
||||
// TODO: Qt6 port - done
|
||||
#else
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
|
||||
if (value.contains(rx)){
|
||||
@ -440,17 +461,55 @@ QString DataSourceManager::replaceVariables(QString value){
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
#else
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
// TODO: Qt6 port
|
||||
return value;
|
||||
#endif
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
int curentAliasIndex = 0;
|
||||
if (query.contains(rx)){
|
||||
int pos = -1;
|
||||
QRegularExpressionMatch match = rx.match(query);
|
||||
while ((pos=match.capturedStart())!=-1){
|
||||
|
||||
QString var=match.captured(0);
|
||||
var.remove("$V{");
|
||||
var.remove("}");
|
||||
if (!match.captured(1).isEmpty()){
|
||||
if (aliasesToParam.contains(var)){
|
||||
curentAliasIndex++;
|
||||
aliasesToParam.insert(var+"_v_alias"+QString::number(curentAliasIndex),var);
|
||||
var += "_v_alias"+QString::number(curentAliasIndex);
|
||||
} else {
|
||||
aliasesToParam.insert(var,var);
|
||||
}
|
||||
query.replace(pos,match.captured(0).length(),":"+var);
|
||||
} else {
|
||||
QString varName = match.captured(2).trimmed();
|
||||
QString varParam = match.captured(3).trimmed();
|
||||
if (!varName.isEmpty()){
|
||||
if (!varParam.isEmpty() && varParam.compare("nobind") == 0 ){
|
||||
query.replace(pos,match.captured(0).length(), variable(varName).toString());
|
||||
} else {
|
||||
query.replace(pos,match.captured(0).length(),
|
||||
QString(tr("Unknown parameter \"%1\" for variable \"%2\" found!")
|
||||
.arg(varName)
|
||||
.arg(varParam))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
query.replace(pos,match.captured(0).length(),QString(tr("Variable \"%1\" not found!").arg(var)));
|
||||
}
|
||||
}
|
||||
match = rx.match(query);
|
||||
}
|
||||
}
|
||||
// TODO: Qt6 port - done
|
||||
#else
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
int curentAliasIndex = 0;
|
||||
if (query.contains(rx)){
|
||||
@ -488,17 +547,44 @@ QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString>
|
||||
}
|
||||
}
|
||||
}
|
||||
return query;
|
||||
#else
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
// TODO: Qt6 port
|
||||
#endif
|
||||
return QString();
|
||||
return query;
|
||||
}
|
||||
|
||||
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
|
||||
QRegularExpression rx(Const::FIELD_RX);
|
||||
int curentAliasIndex = 0;
|
||||
if (query.contains(rx)){
|
||||
int pos = -1;
|
||||
QRegularExpressionMatch match = rx.match(query);
|
||||
while ((pos=match.capturedStart())!=-1){
|
||||
|
||||
QString field=match.captured(0);
|
||||
field.remove("$D{");
|
||||
field.remove("}");
|
||||
|
||||
if (!aliasesToParam.contains(field)){
|
||||
if (field.contains("."))
|
||||
aliasesToParam.insert(field, field);
|
||||
else
|
||||
aliasesToParam.insert(field, masterDatasource+"."+field);
|
||||
} else {
|
||||
curentAliasIndex++;
|
||||
if (field.contains("."))
|
||||
aliasesToParam.insert(field+"_f_alias"+QString::number(curentAliasIndex), field);
|
||||
else
|
||||
aliasesToParam.insert(field+"_f_alias"+QString::number(curentAliasIndex), masterDatasource+"."+field);
|
||||
field+="_f_alias"+QString::number(curentAliasIndex);
|
||||
}
|
||||
query.replace(pos,match.capturedLength(),":"+extractField(field));
|
||||
match = rx.match(query);
|
||||
}
|
||||
}
|
||||
// TODO: Qt6 port - possible done
|
||||
#else
|
||||
QRegExp rx(Const::FIELD_RX);
|
||||
if (query.contains(rx)){
|
||||
int curentAliasIndex=0;
|
||||
@ -524,12 +610,9 @@ QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &a
|
||||
query.replace(pos,rx.cap(0).length(),":"+extractField(field));
|
||||
}
|
||||
}
|
||||
return query;
|
||||
#else
|
||||
QRegularExpression rx(Const::FIELD_RX);
|
||||
// TODO: Qt6 port
|
||||
return query;
|
||||
#endif
|
||||
return QString();
|
||||
return query;
|
||||
}
|
||||
|
||||
void DataSourceManager::setReportVariable(const QString &name, const QVariant &value)
|
||||
|
@ -67,10 +67,10 @@ QString replaceHTMLSymbols(const QString &value)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x060000
|
||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
|
||||
#else
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg){
|
||||
#else
|
||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
|
||||
#endif
|
||||
QVector<QString> result;
|
||||
foreach (QString cap, reg.capturedTexts()) {
|
||||
|
@ -104,10 +104,10 @@ namespace Const{
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
QString replaceHTMLSymbols(const QString &value);
|
||||
#if QT_VERSION < 0x060000
|
||||
QVector<QString> normalizeCaptures(const QRegExp ®);
|
||||
#else
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®);
|
||||
#else
|
||||
QVector<QString> normalizeCaptures(const QRegExp ®);
|
||||
#endif
|
||||
bool isColorDark(QColor color);
|
||||
|
||||
|
@ -119,7 +119,11 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
|
||||
|
||||
connect(ui->actionShowMessages, SIGNAL(triggered()), this, SLOT(slotShowErrors()));
|
||||
connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_scalePercent, SIGNAL(currentTextChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
|
||||
#else
|
||||
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
|
||||
#endif
|
||||
connect(m_previewReportWidget, SIGNAL(pageChanged(int)), this, SLOT(slotCurrentPageChanged(int)));
|
||||
connect(m_previewReportWidget, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
|
||||
this, SLOT(slotItemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
|
||||
|
@ -169,7 +169,7 @@ void ReportDesignWindow::createActions()
|
||||
m_editModeAction->setIcon(QIcon(":/report/images/editMode"));
|
||||
m_editModeAction->setCheckable(true);
|
||||
m_editModeAction->setChecked(true);
|
||||
m_editModeAction->setShortcut(QKeySequence(Qt::Key_Escape));
|
||||
//m_editModeAction->setShortcut(QKeySequence(Qt::Key_Escape));
|
||||
connect(m_editModeAction,SIGNAL(triggered()),this,SLOT(slotEditMode()));
|
||||
|
||||
m_undoAction = new QAction(tr("Undo"),this);
|
||||
@ -502,8 +502,11 @@ void ReportDesignWindow::createBandsButton()
|
||||
connect(m_newTearOffBand,SIGNAL(triggered()),m_bandsAddSignalsMap,SLOT(map()));
|
||||
m_bandsAddSignalsMap->setMapping(m_newTearOffBand,BandDesignIntf::TearOffBand);
|
||||
m_newBandButton->addAction(m_newTearOffBand);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_bandsAddSignalsMap,SIGNAL(mappedInt(int)),this,SLOT(slotNewBand(int)));
|
||||
#else
|
||||
connect(m_bandsAddSignalsMap,SIGNAL(mapped(int)),this,SLOT(slotNewBand(int)));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ReportDesignWindow::createMainMenu()
|
||||
@ -530,7 +533,11 @@ void ReportDesignWindow::createMainMenu()
|
||||
m_infoMenu->addAction(m_aboutAction);
|
||||
m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent Files"));
|
||||
m_recentFilesSignalMap = new QSignalMapper(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_recentFilesSignalMap,SIGNAL(mappedString(QString)),this,SLOT(slotLoadRecentFile(QString)));
|
||||
#else
|
||||
connect(m_recentFilesSignalMap,SIGNAL(mapped(QString)),this,SLOT(slotLoadRecentFile(QString)));
|
||||
#endif
|
||||
m_recentFilesMenu->setDisabled(m_recentFiles.isEmpty());
|
||||
}
|
||||
|
||||
@ -744,6 +751,11 @@ void ReportDesignWindow::setDocWidgetsVisibility(bool visible)
|
||||
hideDockWidgets(Qt::RightDockWidgetArea,!visible);
|
||||
}
|
||||
|
||||
void ReportDesignWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key()==Qt::Key_Escape){m_editModeAction->trigger();}
|
||||
}
|
||||
|
||||
void ReportDesignWindow::writeState()
|
||||
{
|
||||
settings()->beginGroup("DesignerWindow");
|
||||
@ -837,16 +849,16 @@ void ReportDesignWindow::restoreSetting()
|
||||
if (v.isValid()){
|
||||
restoreGeometry(v.toByteArray());
|
||||
} else {
|
||||
#if QT_VERSION < 0x060000
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth = desktop->screenGeometry().width();
|
||||
int screenHeight = desktop->screenGeometry().height();
|
||||
#else
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
|
||||
int screenWidth = screen->geometry().width();
|
||||
int screenHeight = screen->geometry().height();
|
||||
#else
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth = desktop->screenGeometry().width();
|
||||
int screenHeight = desktop->screenGeometry().height();
|
||||
#endif
|
||||
int x = screenWidth * 0.1;
|
||||
int y = screenHeight * 0.1;
|
||||
|
@ -138,6 +138,7 @@ protected:
|
||||
void hideDockWidgets(Qt::DockWidgetArea area, bool value);
|
||||
bool isDockAreaVisible(Qt::DockWidgetArea area);
|
||||
void setDocWidgetsVisibility(bool visible);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
private:
|
||||
void initReportEditor(ReportEnginePrivate* report);
|
||||
|
@ -196,14 +196,19 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt
|
||||
QString content = contentItem->content();
|
||||
QVector<QString> functions;
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
||||
if(content.indexOf(rx)>=0){
|
||||
functions.append(functionName);
|
||||
}
|
||||
// TODO: Qt6 port - done
|
||||
#else
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
if (rx.indexIn(content)>=0){
|
||||
functions.append(functionName);
|
||||
}
|
||||
#else
|
||||
// TODO: Qt6 port
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (functions.size()>0)
|
||||
@ -363,13 +368,18 @@ void ReportRender::clearPageMap()
|
||||
bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){
|
||||
QString content = item->content();
|
||||
foreach(QString functionName, datasources->groupFunctionNames()){
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
||||
if(content.indexOf(rx)>=0){
|
||||
return true;
|
||||
}
|
||||
// TODO: Qt6 port - done
|
||||
#else
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
if (rx.indexIn(content)>=0){
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
// TODO: Qt6 port
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
@ -390,7 +400,78 @@ bool ReportRender::containsGroupFunctions(BaseDesignIntf *container){
|
||||
}
|
||||
|
||||
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
|
||||
if ( contentItem && contentItem->content().contains(QRegularExpression("\\$S\\s*\\{.*\\}"))){
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
||||
QRegularExpression rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName));
|
||||
rxName.setPatternOptions(rx.InvertedGreedinessOption);
|
||||
|
||||
QRegularExpressionMatch match = rx.match(contentItem->content());
|
||||
if (match.hasMatch()){
|
||||
|
||||
QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content());
|
||||
while(iter.hasNext()){
|
||||
match = iter.next();
|
||||
QVector<QString> captures = normalizeCaptures(match);
|
||||
if (captures.size() >= 3){
|
||||
int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX;
|
||||
BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex));
|
||||
if (dataBand){
|
||||
GroupFunction* gf = datasources()->addGroupFunction(
|
||||
functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName()
|
||||
);
|
||||
if (gf){
|
||||
connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)),
|
||||
gf, SLOT(slotBandRendered(BandDesignIntf*)));
|
||||
connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)),
|
||||
gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*)));
|
||||
}
|
||||
} else {
|
||||
GroupFunction* gf = datasources()->addGroupFunction(
|
||||
functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex)
|
||||
);
|
||||
gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// int pos = 0;
|
||||
// while ( (pos = match.capturedStart()) != -1){
|
||||
// QVector<QString> captures = normalizeCaptures(match);
|
||||
// if (captures.size() >= 3){
|
||||
// int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX;
|
||||
// BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex));
|
||||
// if (dataBand){
|
||||
// GroupFunction* gf = datasources()->addGroupFunction(
|
||||
// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName()
|
||||
// );
|
||||
// if (gf){
|
||||
// connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)),
|
||||
// gf, SLOT(slotBandRendered(BandDesignIntf*)));
|
||||
// connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)),
|
||||
// gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*)));
|
||||
// }
|
||||
// } else {
|
||||
// GroupFunction* gf = datasources()->addGroupFunction(
|
||||
// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex)
|
||||
// );
|
||||
// gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex)));
|
||||
// }
|
||||
// }
|
||||
// match = rx.match(contentItem->content(), pos + match.capturedLength());
|
||||
// }
|
||||
} else if (contentItem->content().indexOf(rxName)>=0){
|
||||
match = rxName.match(contentItem->content());
|
||||
GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), "");
|
||||
gf->setInvalid(tr("Wrong using function %1").arg(functionName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Qt6 port - possible done
|
||||
#else
|
||||
if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
@ -424,9 +505,7 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt
|
||||
gf->setInvalid(tr("Wrong using function %1").arg(functionName));
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO: Qt6 port
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -450,7 +529,35 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
|
||||
if (m_groupfunctionItems.contains(contentItem->patternName())){
|
||||
QString content = contentItem->content();
|
||||
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
|
||||
#if QT_VERSION < 0x060000
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
|
||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
||||
QRegularExpressionMatch match = rx.match(content);
|
||||
|
||||
if (match.capturedStart() != -1){
|
||||
int pos = 0;
|
||||
while ( (pos = match.capturedStart()) != -1 ){
|
||||
QVector<QString> captures = normalizeCaptures(match);
|
||||
if (captures.size() >= 3){
|
||||
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
|
||||
if (captures.size()<5){
|
||||
content.replace(captures.at(0), QString("%1(%2,%3)")
|
||||
.arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
|
||||
} else {
|
||||
content.replace(captures.at(0), QString("%1(%2,%3,%4)").arg(
|
||||
functionName,
|
||||
'"'+expressionIndex+'"',
|
||||
'"'+band->objectName()+'"',
|
||||
captures.at(4)
|
||||
));
|
||||
}
|
||||
}
|
||||
match = rx.match(content, pos + match.capturedLength());
|
||||
}
|
||||
}
|
||||
// TODO: Qt6 port - possible done
|
||||
#else
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
if (rx.indexIn(content)>=0){
|
||||
@ -470,11 +577,9 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
|
||||
));
|
||||
}
|
||||
}
|
||||
pos += rx.matchedLength();
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO: Qt6 port
|
||||
|
||||
#endif
|
||||
}
|
||||
contentItem->setContent(content);
|
||||
@ -747,11 +852,13 @@ void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage)
|
||||
void ReportRender::renderReportHeader(PageItemDesignIntf *patternPage, PageRenderStage stage)
|
||||
{
|
||||
BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::ReportHeader);
|
||||
BandDesignIntf* resBand = 0;
|
||||
if (band){
|
||||
if (band->property("printBeforePageHeader").toBool() && stage == BeforePageHeader )
|
||||
renderBand(band, 0, StartNewPageAsNeeded);
|
||||
resBand = renderBand(band, 0, StartNewPageAsNeeded);
|
||||
if (!band->property("printBeforePageHeader").toBool() && stage == AfterPageHeader )
|
||||
renderBand(band, 0, StartNewPageAsNeeded);
|
||||
resBand = renderBand(band, 0, StartNewPageAsNeeded);
|
||||
if (resBand && containsGroupFunctions(band)) m_recalcBands.append(resBand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,7 @@ void CodeEditor::keyPressEvent(QKeyEvent *e)
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Escape:
|
||||
m_compleater->popup()->close();
|
||||
case Qt::Key_Tab:
|
||||
case Qt::Key_Backtab:
|
||||
case Qt::Key_Right:
|
||||
|
@ -197,7 +197,8 @@ QVariant XmlFontSerializator::loadValue()
|
||||
//#if QT_VERSION>0x040800
|
||||
// font.setStyleName(node()->attribute("stylename"));
|
||||
//#endif
|
||||
font.setWeight(static_cast<QFont::Weight>(node()->attribute("weight").toInt()));
|
||||
if (node()->attribute("weight").toInt() > 0)
|
||||
font.setWeight(static_cast<QFont::Weight>(node()->attribute("weight").toInt()));
|
||||
if (!node()->attribute("bold").isEmpty())
|
||||
font.setBold(node()->attribute("bold").toInt());
|
||||
font.setItalic(node()->attribute("italic").toInt());
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include <private/qzipreader_p.h>
|
||||
#include <QDebug>
|
||||
#include <QtCore/qabstractanimation.h>
|
||||
#if QT_VERSION < 0x060000
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include "XmlModel.h"
|
||||
#include "SettingDialog.h"
|
||||
#include "lrreportengine.h"
|
||||
@ -15,11 +17,22 @@
|
||||
//#endif
|
||||
|
||||
void centerWindow(QWidget* widget, double widthFactor, double heightFactor) {
|
||||
#if QT_VERSION < 0x060000
|
||||
QDesktopWidget desk;
|
||||
int ww = desk.width() * widthFactor;
|
||||
int wh = desk.height() * heightFactor;
|
||||
widget->resize(ww, wh);
|
||||
widget->move((desk.width() - ww) / 2, (desk.height() - wh) / 2);
|
||||
widget->resize(ww, wh);
|
||||
#else
|
||||
QScreen* desk = QGuiApplication::primaryScreen();
|
||||
int ww = desk->geometry().width() * widthFactor;
|
||||
int wh = desk->geometry().height() * heightFactor;
|
||||
|
||||
widget->resize(ww, wh);
|
||||
widget->move((desk->geometry().width() - ww) / 2, (desk->geometry().height() - wh) / 2);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
|
Loading…
Reference in New Issue
Block a user