diff --git a/demo_r1/demo_r1.pro b/demo_r1/demo_r1.pro index 20c576f..9c4c76d 100644 --- a/demo_r1/demo_r1.pro +++ b/demo_r1/demo_r1.pro @@ -59,7 +59,12 @@ win32 { DESTDIR = $$DEST_DIR RC_FILE += mainicon.rc - QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$EXTRA_DIR\\*) $$shell_quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + greaterThan(QT_MAJOR_VERSION, 4) { + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$EXTRA_DIR\\*) $$shell_quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + } + lessThan(QT_MAJOR_VERSION, 5){ + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR\\*) $$quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + } !contains(CONFIG, static_build){ contains(CONFIG,zint){ LIBS += -L$${DEST_LIBS} -lQtZint diff --git a/demo_r2/demo_r2.pro b/demo_r2/demo_r2.pro index 224661d..a5961c0 100644 --- a/demo_r2/demo_r2.pro +++ b/demo_r2/demo_r2.pro @@ -70,6 +70,11 @@ win32 { LIBS += -llimereportd } - QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$EXTRA_DIR\\*) $$shell_quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + greaterThan(QT_MAJOR_VERSION, 4) { + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$EXTRA_DIR\\*) $$shell_quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + } + lessThan(QT_MAJOR_VERSION, 5){ + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR\\*) $$quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + } } diff --git a/include/lrglobal.h b/include/lrglobal.h index a553c58..74eeb00 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -156,7 +156,7 @@ namespace Const{ { public: enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; - Q_ENUM(VariableDataType) + Q_ENUMS(VariableDataType) private: Enums(){} Q_GADGET diff --git a/limereport/databrowser/lrvariabledialog.cpp b/limereport/databrowser/lrvariabledialog.cpp index d5c34d9..d039315 100644 --- a/limereport/databrowser/lrvariabledialog.cpp +++ b/limereport/databrowser/lrvariabledialog.cpp @@ -78,7 +78,12 @@ void LRVariableDialog::showEvent(QShowEvent *) QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex); if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){ ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString()); +#ifdef HAVE_QT5 ui->cbbType->setCurrentText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName))); +#endif +#ifdef HAVE_QT4 + ui->cbbType->setCurrentIndex(ui->cbbType->findText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName)))); +#endif ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName)); } } diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index 1a8a58b..62f9230 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -461,7 +461,12 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2); qreal percent = angle/3.6; +#ifdef HAVE_QT4 + qreal radAngle = (angle/2+startAngle)*(M_PI/180); +#endif +#ifdef HAVE_QT5 qreal radAngle = qDegreesToRadians(angle/2+startAngle); +#endif qreal radius = painter->fontMetrics().width("99,9%"); qreal border = chartRect.height()*0.02; qreal length = (chartRect.height())/2-(radius/2+border); diff --git a/limereport/items/lrchartitemeditor.cpp b/limereport/items/lrchartitemeditor.cpp index da58cbd..cb13541 100644 --- a/limereport/items/lrchartitemeditor.cpp +++ b/limereport/items/lrchartitemeditor.cpp @@ -118,7 +118,12 @@ void ChartItemEditor::init() ui->seriesTypeComboBox->addItem(enumerator.key(i)); } +#ifdef HAVE_QT5 ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField()); +#endif +#ifdef HAVE_QT4 + ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField())); +#endif if (!m_charItem->series().isEmpty()){ enableSeriesEditor(); ui->tableWidget->selectRow(0); @@ -145,7 +150,12 @@ void ChartItemEditor::disableSeriesEditor() ui->valuesFieldComboBox->setDisabled(true); m_colorButton->setDisabled(true); m_colorIndicator->setDisabled(true); +#ifdef HAVE_QT5 ui->valuesFieldComboBox->setCurrentText(""); +#endif +#ifdef HAVE_QT4 + ui->valuesFieldComboBox->setEditText(""); +#endif ui->seriesTypeComboBox->setDisabled(true); } @@ -198,7 +208,12 @@ void ChartItemEditor::slotAddSeries() ui->tableWidget->setRowCount(m_charItem->series().count()); ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name())); ui->tableWidget->selectRow(m_charItem->series().count()-1); +#ifdef HAVE_QT5 ui->valuesFieldComboBox->setCurrentText(""); +#endif +#ifdef HAVE_QT4 + ui->valuesFieldComboBox->setEditText(""); +#endif } void ChartItemEditor::slotDeleteSeries() @@ -220,11 +235,21 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged() if (ui->tableWidget->selectionModel()->hasSelection()){ LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row()); ui->seriesNameLineEdit->setText(series->name()); +#ifdef HAVE_QT5 ui->valuesFieldComboBox->setCurrentText(series->valuesColumn()); +#endif +#ifdef HAVE_QT4 + ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn())); +#endif m_colorIndicator->setColor(series->color()); static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex); +#ifdef HAVE_QT5 ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType())); +#endif +#ifdef HAVE_QT4 + ui->seriesTypeComboBox->setCurrentIndex(ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType()))); +#endif enableSeriesEditor(); } } diff --git a/limereport/limereport.pro b/limereport/limereport.pro index e98a9d1..815fc72 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -99,8 +99,13 @@ contains(CONFIG,build_translations){ TRANSLATIONS = $$prependAll(LANGUAGES, \"$$TRANSLATIONS_PATH/limereport_,.ts\") qtPrepareTool(LUPDATE, lupdate) - ts.commands = $$LUPDATE $$shell_quote($$PWD) -ts $$TRANSLATIONS +greaterThan(QT_MAJOR_VERSION, 4) { + ts.commands = $$LUPDATE $$shell_quote($$PWD) -ts $$TRANSLATIONS +} +lessThan(QT_MAJOR_VERSION, 5){ + ts.commands = $$LUPDATE $$quote($$PWD) -ts $$TRANSLATIONS +} TRANSLATIONS_FILES = qtPrepareTool(LRELEASE, lrelease) for(tsfile, TRANSLATIONS) { diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index a553c58..74eeb00 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -156,7 +156,7 @@ namespace Const{ { public: enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; - Q_ENUM(VariableDataType) + Q_ENUMS(VariableDataType) private: Enums(){} Q_GADGET diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 709ad3c..ff342b3 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -58,11 +58,11 @@ ReportDesignWidget::ReportDesignWidget(ReportEngine *report, QMainWindow *mainWi #endif m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false) { -#ifdef HAVE_QT5 - m_tabWidget = new QTabWidget(this); -#endif #ifdef HAVE_QT4 m_tabWidget = new LimeReportTabWidget(this); +#endif +#ifdef HAVE_QT5 + m_tabWidget = new QTabWidget(this); #endif m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setMovable(true); diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 25b9a74..81c13fd 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -45,6 +45,7 @@ #ifdef HAVE_QT4 QT_BEGIN_NAMESPACE class LimeReportTabWidget: public QTabWidget{ + Q_OBJECT public: explicit LimeReportTabWidget(QWidget *parent = 0):QTabWidget(parent){} QTabBar* tabBar() const{ return QTabWidget::tabBar();} @@ -207,11 +208,11 @@ private: DialogDesignerManager* m_dialogDesignerManager; #endif QMainWindow *m_mainWindow; -#ifdef HAVE_QT5 - QTabWidget* m_tabWidget; -#endif #ifdef HAVE_QT4 LimeReportTabWidget* m_tabWidget; +#endif +#ifdef HAVE_QT5 + QTabWidget* m_tabWidget; #endif GraphicsViewZoomer* m_zoomer; QFont m_defaultFont; diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index cd701c7..4e8be0f 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1003,8 +1003,14 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) if (band->isData()) m_renderedDataBandCount++; band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex)); renameChildItems(band); - if (m_lastDataBand) + if (m_lastDataBand){ +#ifdef HAVE_QT4 + m_lastDataBand->metaObject()->invokeMethod(m_lastDataBand,"bandRegistred"); +#endif +#ifdef HAVE_QT5 emit m_lastDataBand->bandRegistred(); +#endif + } return true; } else return false; } diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 3edd6dc..0c88af3 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -303,8 +303,16 @@ private: class ScriptFunctionsManager : public QObject{ Q_OBJECT public: - explicit ScriptFunctionsManager(QObject* parent = 0):QObject(parent){ m_wrappersFactory.insert("QComboBox",new ComboBoxWrapperCreator());} - ~ScriptFunctionsManager(){ foreach(IWrapperCreator* wrapper, m_wrappersFactory.values()){ delete wrapper;} m_wrappersFactory.clear();} + explicit ScriptFunctionsManager(QObject* parent = 0):QObject(parent){ +#ifdef USE_QJSENGINE + m_wrappersFactory.insert("QComboBox",new ComboBoxWrapperCreator()); +#endif + } + ~ScriptFunctionsManager(){ +#ifdef USE_QJSENGINE + foreach(IWrapperCreator* wrapper, m_wrappersFactory.values()){ delete wrapper;} m_wrappersFactory.clear(); +#endif + } Q_INVOKABLE QVariant calcGroupFunction(const QString& name, const QString& expressionID, const QString& bandName); Q_INVOKABLE QVariant line(const QString& bandName); Q_INVOKABLE QVariant numberFormat(QVariant value, const char &format, int precision, const QString &locale); @@ -337,7 +345,9 @@ public: static QColor createQColor(const QString& color){ return QColor(color);} private: ScriptEngineManager* m_scriptEngineManager; +#ifdef USE_QJSENGINE QMap m_wrappersFactory; +#endif }; class ScriptEngineManager : public QObject, public Singleton, public IScriptEngineManager @@ -484,7 +494,8 @@ public: } #ifndef USE_QJSENGINE -Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*); +Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*) +Q_DECLARE_METATYPE(QComboBox*) #endif #endif // LRSCRIPTENGINEMANAGER_H diff --git a/limereport/scripteditor/lrscripteditor.cpp b/limereport/scripteditor/lrscripteditor.cpp index abb254f..4db2fac 100644 --- a/limereport/scripteditor/lrscripteditor.cpp +++ b/limereport/scripteditor/lrscripteditor.cpp @@ -1,6 +1,9 @@ #include "lrscripteditor.h" #include "ui_lrscripteditor.h" + +#ifdef USE_QJSENGINE #include +#endif #include "lrdatasourcemanager.h" #include "lrscriptenginemanager.h" @@ -88,6 +91,7 @@ void ScriptEditor::initCompleter() ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance(); +#ifdef USE_QJSENGINE QJSValue globalObject = se.scriptEngine()->globalObject(); QJSValueIterator it(globalObject); while (it.hasNext()){ @@ -96,7 +100,7 @@ void ScriptEditor::initCompleter() dataWords << it.name(); } } - +#endif foreach(const QString &dsName,dm->dataSourceNames()){ dataWords << dsName; foreach(const QString &field, dm->fieldNames(dsName)){ diff --git a/limereport/translationeditor/languageselectdialog.cpp b/limereport/translationeditor/languageselectdialog.cpp index f52be35..64265c8 100644 --- a/limereport/translationeditor/languageselectdialog.cpp +++ b/limereport/translationeditor/languageselectdialog.cpp @@ -12,7 +12,12 @@ LanguageSelectDialog::LanguageSelectDialog(QWidget *parent) : for (int i = 2; icomboBox->addItem(QLocale::languageToString(static_cast(i)),static_cast(i)); } +#ifdef HAVE_QT5 ui->comboBox->setCurrentText(""); +#endif +#ifdef HAVE_QT4 + ui->comboBox->setEditText(""); +#endif } LanguageSelectDialog::~LanguageSelectDialog() diff --git a/limereport/translationeditor/languageselectdialog.h b/limereport/translationeditor/languageselectdialog.h index 3286527..0402327 100644 --- a/limereport/translationeditor/languageselectdialog.h +++ b/limereport/translationeditor/languageselectdialog.h @@ -20,4 +20,6 @@ private: Ui::LanguageSelectDialog *ui; }; +Q_DECLARE_METATYPE(QLocale::Language) + #endif // LANGUAGESELECTDIALOG_H