Qt4 build fixed

This commit is contained in:
Arin Alexander 2017-10-26 13:24:06 +04:00
parent 7ba2b1d5b3
commit 40bafebbbd
15 changed files with 95 additions and 16 deletions

View File

@ -59,7 +59,12 @@ win32 {
DESTDIR = $$DEST_DIR DESTDIR = $$DEST_DIR
RC_FILE += mainicon.rc 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, static_build){
contains(CONFIG,zint){ contains(CONFIG,zint){
LIBS += -L$${DEST_LIBS} -lQtZint LIBS += -L$${DEST_LIBS} -lQtZint

View File

@ -70,6 +70,11 @@ win32 {
LIBS += -llimereportd 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)
}
} }

View File

@ -156,7 +156,7 @@ namespace Const{
{ {
public: public:
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
Q_ENUM(VariableDataType) Q_ENUMS(VariableDataType)
private: private:
Enums(){} Enums(){}
Q_GADGET Q_GADGET

View File

@ -78,7 +78,12 @@ void LRVariableDialog::showEvent(QShowEvent *)
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex); QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){ if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){
ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString()); ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString());
#ifdef HAVE_QT5
ui->cbbType->setCurrentText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName))); 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)); ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName));
} }
} }

View File

@ -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); QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2);
qreal percent = angle/3.6; 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); qreal radAngle = qDegreesToRadians(angle/2+startAngle);
#endif
qreal radius = painter->fontMetrics().width("99,9%"); qreal radius = painter->fontMetrics().width("99,9%");
qreal border = chartRect.height()*0.02; qreal border = chartRect.height()*0.02;
qreal length = (chartRect.height())/2-(radius/2+border); qreal length = (chartRect.height())/2-(radius/2+border);

View File

@ -118,7 +118,12 @@ void ChartItemEditor::init()
ui->seriesTypeComboBox->addItem(enumerator.key(i)); ui->seriesTypeComboBox->addItem(enumerator.key(i));
} }
#ifdef HAVE_QT5
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField()); 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()){ if (!m_charItem->series().isEmpty()){
enableSeriesEditor(); enableSeriesEditor();
ui->tableWidget->selectRow(0); ui->tableWidget->selectRow(0);
@ -145,7 +150,12 @@ void ChartItemEditor::disableSeriesEditor()
ui->valuesFieldComboBox->setDisabled(true); ui->valuesFieldComboBox->setDisabled(true);
m_colorButton->setDisabled(true); m_colorButton->setDisabled(true);
m_colorIndicator->setDisabled(true); m_colorIndicator->setDisabled(true);
#ifdef HAVE_QT5
ui->valuesFieldComboBox->setCurrentText(""); ui->valuesFieldComboBox->setCurrentText("");
#endif
#ifdef HAVE_QT4
ui->valuesFieldComboBox->setEditText("");
#endif
ui->seriesTypeComboBox->setDisabled(true); ui->seriesTypeComboBox->setDisabled(true);
} }
@ -198,7 +208,12 @@ void ChartItemEditor::slotAddSeries()
ui->tableWidget->setRowCount(m_charItem->series().count()); ui->tableWidget->setRowCount(m_charItem->series().count());
ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name())); ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name()));
ui->tableWidget->selectRow(m_charItem->series().count()-1); ui->tableWidget->selectRow(m_charItem->series().count()-1);
#ifdef HAVE_QT5
ui->valuesFieldComboBox->setCurrentText(""); ui->valuesFieldComboBox->setCurrentText("");
#endif
#ifdef HAVE_QT4
ui->valuesFieldComboBox->setEditText("");
#endif
} }
void ChartItemEditor::slotDeleteSeries() void ChartItemEditor::slotDeleteSeries()
@ -220,11 +235,21 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged()
if (ui->tableWidget->selectionModel()->hasSelection()){ if (ui->tableWidget->selectionModel()->hasSelection()){
LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row()); LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
ui->seriesNameLineEdit->setText(series->name()); ui->seriesNameLineEdit->setText(series->name());
#ifdef HAVE_QT5
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn()); ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
#endif
#ifdef HAVE_QT4
ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn()));
#endif
m_colorIndicator->setColor(series->color()); m_colorIndicator->setColor(series->color());
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex); QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
#ifdef HAVE_QT5
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType())); ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
#endif
#ifdef HAVE_QT4
ui->seriesTypeComboBox->setCurrentIndex(ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
#endif
enableSeriesEditor(); enableSeriesEditor();
} }
} }

View File

@ -99,8 +99,13 @@ contains(CONFIG,build_translations){
TRANSLATIONS = $$prependAll(LANGUAGES, \"$$TRANSLATIONS_PATH/limereport_,.ts\") TRANSLATIONS = $$prependAll(LANGUAGES, \"$$TRANSLATIONS_PATH/limereport_,.ts\")
qtPrepareTool(LUPDATE, lupdate) 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 = TRANSLATIONS_FILES =
qtPrepareTool(LRELEASE, lrelease) qtPrepareTool(LRELEASE, lrelease)
for(tsfile, TRANSLATIONS) { for(tsfile, TRANSLATIONS) {

View File

@ -156,7 +156,7 @@ namespace Const{
{ {
public: public:
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
Q_ENUM(VariableDataType) Q_ENUMS(VariableDataType)
private: private:
Enums(){} Enums(){}
Q_GADGET Q_GADGET

View File

@ -58,11 +58,11 @@ ReportDesignWidget::ReportDesignWidget(ReportEngine *report, QMainWindow *mainWi
#endif #endif
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false) 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 #ifdef HAVE_QT4
m_tabWidget = new LimeReportTabWidget(this); m_tabWidget = new LimeReportTabWidget(this);
#endif
#ifdef HAVE_QT5
m_tabWidget = new QTabWidget(this);
#endif #endif
m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setTabPosition(QTabWidget::South);
m_tabWidget->setMovable(true); m_tabWidget->setMovable(true);

View File

@ -45,6 +45,7 @@
#ifdef HAVE_QT4 #ifdef HAVE_QT4
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class LimeReportTabWidget: public QTabWidget{ class LimeReportTabWidget: public QTabWidget{
Q_OBJECT
public: public:
explicit LimeReportTabWidget(QWidget *parent = 0):QTabWidget(parent){} explicit LimeReportTabWidget(QWidget *parent = 0):QTabWidget(parent){}
QTabBar* tabBar() const{ return QTabWidget::tabBar();} QTabBar* tabBar() const{ return QTabWidget::tabBar();}
@ -207,11 +208,11 @@ private:
DialogDesignerManager* m_dialogDesignerManager; DialogDesignerManager* m_dialogDesignerManager;
#endif #endif
QMainWindow *m_mainWindow; QMainWindow *m_mainWindow;
#ifdef HAVE_QT5
QTabWidget* m_tabWidget;
#endif
#ifdef HAVE_QT4 #ifdef HAVE_QT4
LimeReportTabWidget* m_tabWidget; LimeReportTabWidget* m_tabWidget;
#endif
#ifdef HAVE_QT5
QTabWidget* m_tabWidget;
#endif #endif
GraphicsViewZoomer* m_zoomer; GraphicsViewZoomer* m_zoomer;
QFont m_defaultFont; QFont m_defaultFont;

View File

@ -1003,8 +1003,14 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
if (band->isData()) m_renderedDataBandCount++; if (band->isData()) m_renderedDataBandCount++;
band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex)); band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex));
renameChildItems(band); 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(); emit m_lastDataBand->bandRegistred();
#endif
}
return true; return true;
} else return false; } else return false;
} }

View File

@ -303,8 +303,16 @@ private:
class ScriptFunctionsManager : public QObject{ class ScriptFunctionsManager : public QObject{
Q_OBJECT Q_OBJECT
public: public:
explicit ScriptFunctionsManager(QObject* parent = 0):QObject(parent){ m_wrappersFactory.insert("QComboBox",new ComboBoxWrapperCreator());} explicit ScriptFunctionsManager(QObject* parent = 0):QObject(parent){
~ScriptFunctionsManager(){ foreach(IWrapperCreator* wrapper, m_wrappersFactory.values()){ delete wrapper;} m_wrappersFactory.clear();} #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 calcGroupFunction(const QString& name, const QString& expressionID, const QString& bandName);
Q_INVOKABLE QVariant line(const QString& bandName); Q_INVOKABLE QVariant line(const QString& bandName);
Q_INVOKABLE QVariant numberFormat(QVariant value, const char &format, int precision, const QString &locale); 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);} static QColor createQColor(const QString& color){ return QColor(color);}
private: private:
ScriptEngineManager* m_scriptEngineManager; ScriptEngineManager* m_scriptEngineManager;
#ifdef USE_QJSENGINE
QMap<QString, IWrapperCreator*> m_wrappersFactory; QMap<QString, IWrapperCreator*> m_wrappersFactory;
#endif
}; };
class ScriptEngineManager : public QObject, public Singleton<ScriptEngineManager>, public IScriptEngineManager class ScriptEngineManager : public QObject, public Singleton<ScriptEngineManager>, public IScriptEngineManager
@ -484,7 +494,8 @@ public:
} }
#ifndef USE_QJSENGINE #ifndef USE_QJSENGINE
Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*); Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*)
Q_DECLARE_METATYPE(QComboBox*)
#endif #endif
#endif // LRSCRIPTENGINEMANAGER_H #endif // LRSCRIPTENGINEMANAGER_H

View File

@ -1,6 +1,9 @@
#include "lrscripteditor.h" #include "lrscripteditor.h"
#include "ui_lrscripteditor.h" #include "ui_lrscripteditor.h"
#ifdef USE_QJSENGINE
#include <QJSValueIterator> #include <QJSValueIterator>
#endif
#include "lrdatasourcemanager.h" #include "lrdatasourcemanager.h"
#include "lrscriptenginemanager.h" #include "lrscriptenginemanager.h"
@ -88,6 +91,7 @@ void ScriptEditor::initCompleter()
ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance(); ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
#ifdef USE_QJSENGINE
QJSValue globalObject = se.scriptEngine()->globalObject(); QJSValue globalObject = se.scriptEngine()->globalObject();
QJSValueIterator it(globalObject); QJSValueIterator it(globalObject);
while (it.hasNext()){ while (it.hasNext()){
@ -96,7 +100,7 @@ void ScriptEditor::initCompleter()
dataWords << it.name(); dataWords << it.name();
} }
} }
#endif
foreach(const QString &dsName,dm->dataSourceNames()){ foreach(const QString &dsName,dm->dataSourceNames()){
dataWords << dsName; dataWords << dsName;
foreach(const QString &field, dm->fieldNames(dsName)){ foreach(const QString &field, dm->fieldNames(dsName)){

View File

@ -12,7 +12,12 @@ LanguageSelectDialog::LanguageSelectDialog(QWidget *parent) :
for (int i = 2; i<QLocale::LastLanguage; ++i){ for (int i = 2; i<QLocale::LastLanguage; ++i){
ui->comboBox->addItem(QLocale::languageToString(static_cast<QLocale::Language>(i)),static_cast<QLocale::Language>(i)); ui->comboBox->addItem(QLocale::languageToString(static_cast<QLocale::Language>(i)),static_cast<QLocale::Language>(i));
} }
#ifdef HAVE_QT5
ui->comboBox->setCurrentText(""); ui->comboBox->setCurrentText("");
#endif
#ifdef HAVE_QT4
ui->comboBox->setEditText("");
#endif
} }
LanguageSelectDialog::~LanguageSelectDialog() LanguageSelectDialog::~LanguageSelectDialog()

View File

@ -20,4 +20,6 @@ private:
Ui::LanguageSelectDialog *ui; Ui::LanguageSelectDialog *ui;
}; };
Q_DECLARE_METATYPE(QLocale::Language)
#endif // LANGUAGESELECTDIALOG_H #endif // LANGUAGESELECTDIALOG_H